Repository navigation
feat(context): carry the prior summary forward instead of re-summarizing it - #64
Merged
Merged
Conversation
…ing it Each compression pass summarized the whole old block, including the summary the previous pass wrote. Detail eroded a little at a time: a fact stated in the first message survived three passes and was gone by the fourth. Split the prior summary off, summarize only the turns that arrived since, and prepend the earlier summary verbatim. Same for the emergency collapse tier.
…summary # Conflicts: # README.md # README_CN.md # article/00-index.md # article/00-index_EN.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
Compression now carries the earlier summary forward instead of summarizing it again.
Every pass used to hand the whole old block to the summarizer, including the summary the previous pass had written. Each round therefore compressed a compression. Detail eroded a little at a time, and nothing looked wrong at any single step.
Measured on a seeded session with a fact in the first message (
the deploy key lives in /etc/app/deploy.key), a summarizer that keeps what it is given, and four rounds of continued conversation:The fact survives three compressions and is gone on the fourth. On a long task that is exactly the early decision the rest of the work leans on.
How it works
_split_prior_summaryrecognizes the two markers this manager writes, lifts the prior summary out, and drops the acknowledgement turn that follows it._summarize_oldand_hard_collapsesummarize only the turns that arrived since, then prepend the earlier summary verbatim. If nothing new aged out, layer 2 returnsFalserather than paying for a model call that would rewrite the same text.The kept-tail boundary still goes through
_safe_split, so atoolresult is never severed from thetool_callsthat produced it.Tests
tests/test_context_rolling_summary.py, three cases:Red-green verified twice: with
context.pyreverted all three fail; restored, all three pass.test_live_smoke.pyneeds a real provider key and was not run.Docs
Both READMEs describe the new behavior in the compression paragraph. The engine LoC badge and prose move 1483 → 1511 and the package totals 2989 → 3020 / 2442 → 2470, which is what
test_readme_line_counts_are_currentandtest_doc_python_line_references_are_currentpin;context.pyreferences inarticle/move 220 → 251. Those two guards were failing before this change touched the docs and pass now.Note on formatting:
ruff format --checkreports pre-existing drift incontext.pythat predates this branch (the same warning fires on the unmodified file). CI runsruff check, notruff format, so I left the unrelated reformatting out of this diff.