fix(compressor): decay head protection across compression cycles#12092
Open
truenorth-lj wants to merge 1 commit into
Open
fix(compressor): decay head protection across compression cycles#12092truenorth-lj wants to merge 1 commit into
truenorth-lj wants to merge 1 commit into
Conversation
After the first compression, reduce head protection from protect_first_n to 1 (system message only). Previously, the first N messages were preserved verbatim across every compression cycle, causing "fossilized" messages that survived indefinitely even after being summarized. The system message (index 0) is always preserved. User/assistant messages in positions 1..protect_first_n are only protected during the first compression — subsequent compressions include them in the summarization window since their content is already captured in the summary. Closes NousResearch#11996 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 tasks
Collaborator
Contributor
Author
|
Thanks for flagging @alt-glitch. After reading #9199, I think these are complementary rather than competing — they fix two different sub-cases of HEAD fossilization:
Concretely, even after #9199 lands, a long session with a system prompt and Happy to rebase on top of #9199 once it lands, or fold both fixes into a single PR if a maintainer prefers. |
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
protect_first_nto 1 (system message only) so old user/assistant messages become eligible for summarization instead of surviving every compression cycle indefinitelyChanges
agent/context_compressor.pycompress(), compute_effective_headbased oncompression_count— fullprotect_first_non first compression, decays to 1 on subsequent compressions_min_for_compressto use the effective head counttests/agent/test_context_compressor.pyTestHeadProtectionDecayclass with 5 tests:test_first_compression_preserves_full_head— verifies original behavior on first compressiontest_second_compression_decays_head_protection— verifies fossilized messages are included in compression windowtest_system_message_always_preserved— verifies system prompt survives all compressionstest_protect_first_1_no_decay— edge case when protect_first_n=1test_multiple_compressions_dont_fossilize— end-to-end 2-cycle simulationTest plan
Closes #11996
🤖 Generated with Claude Code