fix(agent): focus automatic compression on recent user turns (salvages #38155)#44687
Merged
Conversation
…_topic The parameter was reserved-but-unused (del'd immediately); YAGNI. Test call site updated.
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unsupported-operator |
3 |
unresolved-attribute |
1 |
First entries
tests/agent/test_compress_focus.py:145: [unresolved-attribute] unresolved-attribute: Attribute `startswith` is not defined on `None` in union `Unknown | None`
tests/agent/test_compress_focus.py:147: [unsupported-operator] unsupported-operator: Operator `in` is not supported between objects of type `Literal["- third"]` and `Unknown | None`
tests/agent/test_compress_focus.py:146: [unsupported-operator] unsupported-operator: Operator `in` is not supported between objects of type `Literal["- second"]` and `Unknown | None`
tests/agent/test_compress_focus.py:148: [unsupported-operator] unsupported-operator: Operator `in` is not supported between objects of type `Literal["- fourth"]` and `Unknown | None`
✅ Fixed issues: none
Unchanged: 5648 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
This was referenced Jun 12, 2026
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.
Summary
Automatic compaction now derives a focus topic from the last 3 real user turns, so iterative summaries stop keeping completed topics alive and overriding the active one.
Root cause (#9631): the iterative-update prompt says "PRESERVE all existing information", so dead topics accrete across compactions with no recency weighting — only manual
/compress <topic>ever set a focus; automatic compaction passedfocus_topic=None.Closes #9631.
Changes
agent/context_compressor.py:_derive_auto_focus_topic()— last ≤3 real user turns (skips persisted handoff summaries), redacted, 260 chars/turn, 700 chars total; used bycompress()whenever no explicit focus is given — from fix(agent): focus automatic compression on recent user turns #38155 by @konsisumeragent/context_compressor.py: focus-prompt wording no longer claims "the user has requested" when the focus is auto-derivedtail_startparameter (YAGNI)Validation
_is_context_summary_contentpytest test_compress_focus.py + compressor suitesAttribution
Salvages #38155 by @konsisumer — cherry-picked with authorship preserved; rebase-merge to keep per-commit credit. Rebased onto the #44454 prompt consolidation.
Infographic