fix: improve context compression quality — higher limits, tool tracking, degradation warning#4153
Closed
SHL0MS wants to merge 1 commit into
Closed
fix: improve context compression quality — higher limits, tool tracking, degradation warning#4153SHL0MS wants to merge 1 commit into
SHL0MS wants to merge 1 commit into
Conversation
…ng, degradation warning Three targeted improvements to the compression system: 1. Increase serializer truncation limits (3000→6000 chars for content, 500→1500 for tool args). The summarizer LLM was working from heavily truncated data — 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). After compression, the agent retains its tool definitions but loses conversational context of HOW tools were used effectively. This section preserves working 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.' The compression_count was tracked but never surfaced to the user. Ref NousResearch#499
Collaborator
Author
|
Superseded by PR from fix/compression-quality-v2 branch (rebased cleanly on latest main). |
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 input:
A 200-line code edit or a full test output was being cut to 3000 chars before the summarizer ever ran. The summary was working from incomplete data. The budget here is the summary model's context window, not the main model's — there's room.
2. Add "Tools & Patterns" section to compression prompts
Both the first-pass and iterative compression prompts now include:
After compression, the agent retains tool definitions (from
self.tools) but loses conversational context of HOW those tools were used effectively. This section preserves working invocations, preferred flags, and tool-specific discoveries.3. Degradation warning on repeated compressions
After the 2nd compression, the user sees:
compression_countwas already tracked (context_compressor.py:145) but never surfaced. Multiple compressions silently compound quality loss — "summaries of summaries" lose information with each pass.Changes
24 lines changed, 9 added across
agent/context_compressor.pyandrun_agent.py.Ref #499