fix(compaction): mark end of context summary in role=user fallback (salvage #17121) - #20169
Merged
Conversation
When the head ends with assistant/tool and the tail starts with assistant, the summary is inserted as a standalone role="user" message. The body's verbatim "## Active Task" quote then gets read as fresh user input by weak/local models (#11475, #14521). The merge-into-tail path already appends an explicit end-of-summary marker for this reason. Mirror it on the standalone path so both insertion routes give the model the same "summary above, not new input" signal.
This was referenced May 16, 2026
This was referenced Jun 9, 2026
13 tasks
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.
Salvages @wmagev's PR #17121 onto current main (trivial test-file conflict with newer sanitizer test resolved — both tests now land).
What it does
When compaction's standalone-summary path picks role="user" (head ends with assistant/tool), the body's verbatim
## Active Taskquote gets read as fresh user input by weak/local models (#11475, #14521). The merge-into-tail path already appends an--- END OF CONTEXT SUMMARY ---marker; this mirrors it on the standalone path so both routes give the same signal.Changes
agent/context_compressor.py— append end-of-summary marker whensummary_role == 'user'and we're not merging into tail.tests/agent/test_context_compressor.py— newtest_user_role_summary_carries_end_marker.scripts/release.py— AUTHOR_MAP entry for wmagev.Validation
tests/agent/test_context_compressor.py— 68 passed locally.Closes #17121 via salvage.