fix(compression): skip auto-lower when context_length is user-configured - #58418
Conversation
auxiliary.compression.context_length in config.yaml declares an input budget for the summarizer, not a capability limit. The auto-lower logic unconditionally set threshold_tokens = aux_context when it was below the session threshold, causing near-useless compression loops on long sessions (6+ rounds in 15 minutes, ~1.3M input tokens burned on ineffective summarization). Skip auto-lower when _aux_compression_context_length_config is set, indicating the value came from explicit user config. Auto-lower still engages when the aux model's detected context is genuinely below the threshold (no config override). Fixes NousResearch#58407
…aces Per maintainer feedback on the interface-ideas thread: a context-engine plugin already owns the full compression policy (should_compress / compress / preflight on the ContextEngine ABC), and a ProviderProfile already owns its model catalog (models_url / fetch_models / fallback_models). Call both out explicitly — the queued PRs that patch core for these (NousResearch#58418, NousResearch#58444, NousResearch#58453) suggest contributors don't find the existing surface, which is the failure mode this guide exists to fix. Also adds both rows to the PR-shape → seam mapping table. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FWMcB7RPSYUpsXDfBgwjzM
|
Thanks — the bug is confirmed real (#58407's every-turn compression loop traced exactly as you described, and the 1.3M-token burn is a serious defect), and your diagnosis of the mechanism was correct. Closing on fix direction rather than quality: the auto-lower you're skipping is the overflow guard for the summarizer — it exists so compression's own request fits inside the aux model's window. The resolution needs a semantics decision, not a provenance gate — tracked in #58745 (candidate designs: cap/chunk the summarizer input, warn-and-refuse, or splitting capability from budget), alongside the related #57102/#53235. Your report and analysis are credited there; if the design lands on a direction you'd like to implement, a fresh PR against that decision would be very welcome. Your other PRs from today (#58431, #58378, #58397) were all merged with your authorship preserved — thanks for the strong batch. |
…aces Per maintainer feedback on the interface-ideas thread: a context-engine plugin already owns the full compression policy (should_compress / compress / preflight on the ContextEngine ABC), and a ProviderProfile already owns its model catalog (models_url / fetch_models / fallback_models). Call both out explicitly — the queued PRs that patch core for these (NousResearch#58418, NousResearch#58444, NousResearch#58453) suggest contributors don't find the existing surface, which is the failure mode this guide exists to fix. Also adds both rows to the PR-shape → seam mapping table. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FWMcB7RPSYUpsXDfBgwjzM
What does this PR do?
Fixes
auxiliary.compression.context_lengthin config.yaml having an unintended side effect: it triggers the auto-lower mechanism, reducing the session's compression threshold to the config value — causing near-useless compression loops on long-running sessions.Root cause: In
check_compression_model_feasibility(), whenaux_context < threshold, the auto-lower unconditionally setsthreshold_tokens = aux_context. But whenaux_contextcomes from the user's explicitauxiliary.compression.context_lengthconfig, it represents an input budget for the summarizer, not a capability limit of the compression model. A flash model can process 400K+ tokens just fine — the user set 128K to limit how much history to feed it, not to declare it can't handle more.Fix: Skip auto-lower when
_aux_compression_context_length_configis set (indicating the value came from user config). The auto-lower still engages when the aux model's detected context is genuinely below the threshold (no config override).Related Issue
Fixes #58407
Type of Change
Changes Made
agent/conversation_compression.py: Incheck_compression_model_feasibility(), skip the auto-lower whenaux_contextoriginates from explicit user config (_aux_compression_context_length_config is not None). Added 7 lines (1 logic + 6 comment).tests/run_agent/test_compression_config_auto_lower.py: Added 2 regression tests — one verifying auto-lower is skipped when config is set, one verifying it still engages without config.How to Test
auxiliary.compression.context_length: 128000in config.yaml with a main model context of 800K+ andcompression.threshold: 0.50context_lengthconfig — auto-lower should re-engage when the aux model's detected context is below thresholdpython -m pytest tests/run_agent/test_compression_config_auto_lower.py -xvs— should passpython -m pytest tests/run_agent/test_compression_feasibility.py -xvs— all existing tests should still passChecklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping
cli-config.yaml.example— or N/ACONTRIBUTING.mdorAGENTS.md— or N/A