fix: improve context compression quality — higher limits, tool tracking, degradation warning#4156
Closed
SHL0MS wants to merge 1 commit into
Closed
fix: improve context compression quality — higher limits, tool tracking, degradation warning#4156SHL0MS wants to merge 1 commit into
SHL0MS wants to merge 1 commit into
Conversation
353dd6e to
6f08887
Compare
…king, degradation warning Three targeted improvements to the compression system: 1. Replace hardcoded truncation limits with named class constants (_CONTENT_MAX=6000, _CONTENT_HEAD=4000, _CONTENT_TAIL=1500, _TOOL_ARGS_MAX=1500, _TOOL_ARGS_HEAD=1200). Previous limits (3000/500) heavily truncated the summarizer's input — a 200-line edit got cut to 3000 chars before the summarizer ever saw it. 2. Add '## Tools & Patterns' section to both compression prompt templates (first-pass and iterative). Preserves working tool invocations, preferred flags, and tool-specific discoveries across compaction boundaries. 3. Warn users on 2nd+ compression: 'Session compressed N times — accuracy may degrade. Consider /new to start fresh.' Ref NousResearch#499
6f08887 to
3b53b0d
Compare
Contributor
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
Three targeted improvements to the compression system that address the most impactful remaining quality issues documented in #499.
1. Increase serializer truncation limits
The summarizer LLM was working from heavily truncated data. The budget is the summary model's context window, not the main model's.
2. Add "Tools & Patterns" section to compression prompts
Both templates now include:
Preserves HOW tools were used effectively across compaction boundaries.
3. Degradation warning on repeated compressions
After 2nd compression:
compression_countwas tracked but never surfaced.Changes
24 insertions, 9 deletions across
agent/context_compressor.pyandrun_agent.py. Clean diff on latest main.Ref #499 (supersedes #4153 which had merge conflicts)