Skip to content

fix(context): keep _partition in bounds when nothing is kept - #12

Merged
zhanghanduo merged 1 commit into
mainfrom
refactor/context-management-phase2
Sep 1, 2026
Merged

zhanghanduo merged 1 commit into
mainfrom
refactor/context-management-phase2

Conversation

@zhanghanduo

Copy link
Copy Markdown
Collaborator

keep_recent=0 — how a caller asks for the whole history to be summarised — made split_idx == len(rest), which is neither the forward nor the backward case of the orphan guard added in e4908c8: the forward walk has nothing to scan, and the else branch indexed rest[len(rest)].

The kept window is empty there, so no orphan tool result is possible and both walks are meaningless. Leave the split alone instead.

Callers that summarise a finished session (SessionHistoryCompactor._summarize and apodex's explicit compaction) wrap compact() in try/except, so the IndexError surfaced as "no summary available" and the whole rollup was lost silently.

``keep_recent=0`` — how a caller asks for the whole history to be summarised —
made ``split_idx == len(rest)``, which is neither the forward nor the backward
case of the orphan guard added in e4908c8: the forward walk has nothing to scan,
and the ``else`` branch indexed ``rest[len(rest)]``.

The kept window is empty there, so no orphan tool result is possible and both
walks are meaningless. Leave the split alone instead.

Callers that summarise a finished session (``SessionHistoryCompactor._summarize``
and apodex's explicit compaction) wrap ``compact()`` in ``try/except``, so the
IndexError surfaced as "no summary available" and the whole rollup was lost
silently.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@zhanghanduo
zhanghanduo merged commit 4f76cbb into main Sep 1, 2026
1 check passed
@zhanghanduo
zhanghanduo deleted the refactor/context-management-phase2 branch September 1, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant