Context Compression Improvements
Tracking issue for seven independent improvements to agent/context_compressor.py that improve information retention, efficiency, and robustness during context compression.
PRs — Information Quality (merged from original batch)
PRs — Robustness & Efficiency (new batch)
Benchmark Summary
Smart tool collapse (PR #9661):
| Metric |
Before |
After |
| Space savings |
99.3% |
98.9% |
| Key facts preserved (tool name, file path, command, exit code) |
0/24 |
24/24 |
User message preservation (PR #9665):
| Metric |
Before |
After |
| User preferences surviving compression |
0/6 |
6/6 |
Anti-thrashing (PR #9674): Prevents infinite compression loops that burn LLM summary calls with <10% savings each.
Dedup (PR #9677): 5 reads of the same 10KB file → 50KB in context → deduped to 10KB + 4 stubs.
Hardening (PR #9678): Summary model now gets 1.3x budget instead of 2x (cost saving). Transient errors cool down for 60s instead of 600s.
Independence
All 7 PRs are independent — each can be merged separately. They touch different methods within context_compressor.py:
Related issues addressed
Context Compression Improvements
Tracking issue for seven independent improvements to
agent/context_compressor.pythat improve information retention, efficiency, and robustness during context compression.PRs — Information Quality (merged from original batch)
[terminal] ran \npm test` -> exit 0, 47 lines`)[tool: name]tags, and Active State sectionPRs — Robustness & Efficiency (new batch)
should_compress_preflight()to avoid paying for a full API call when already over the limitBenchmark Summary
Smart tool collapse (PR #9661):
User message preservation (PR #9665):
Anti-thrashing (PR #9674): Prevents infinite compression loops that burn LLM summary calls with <10% savings each.
Dedup (PR #9677): 5 reads of the same 10KB file → 50KB in context → deduped to 10KB + 4 stubs.
Hardening (PR #9678): Summary model now gets 1.3x budget instead of 2x (cost saving). Transient errors cool down for 60s instead of 600s.
Independence
All 7 PRs are independent — each can be merged separately. They touch different methods within
context_compressor.py:_prune_old_tool_results()+ new_summarize_tool_result()_generate_summary()prompt template_extract_user_messages()+compress()Phase 3bshould_compress()+compress()savings tracking +on_session_reset()should_compress_preflight()override_prune_old_tool_results()dedup + arg pruning passes_generate_summary()max_tokens,_prune_old_tool_results()multimodal,compress()note, failure cooldownRelated issues addressed