Fix auto compression for tool-heavy sessions#36626
Open
franksong2702 wants to merge 1 commit into
Open
Conversation
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
Long single-turn, tool-heavy sessions could repeatedly auto-compress without materially reducing context. Completed tool results in the protected tail could remain large, internal context-compaction markers could be treated like real user anchors, and repeated no-op compression could continue until the provider rejected the oversized context.
This PR makes auto compression fail explicitly when it is exhausted and demotes completed tool results to concise evidence summaries, including completed tool results at the current tail before the next LLM call.
Changes
toolresult bodies to concise evidence summaries even when they sit in the current protected tail.compression_exhausted.Verification
python -m pytest tests/test_auto_compression_tool_heavy_tail.py tests/run_agent/test_1630_context_overflow_loop.py tests/run_agent/test_compression_trigger_excludes_reasoning.py tests/test_ctx_halving_fix.py tests/run_agent/test_compression_persistence.py tests/run_agent/test_compressor_fallback_update.py tests/run_agent/test_compression_boundary.py -qgit diff --checkRelated
Risks / Follow-ups
mainby one commit; no rebase was performed before publishing to avoid changing the already-validated branch state.role=toolmessages; running tools have no result row to summarize.Model Used
AI-assisted implementation with OpenAI GPT-5 Codex in a local coding workflow. The assistant inspected repository code, wrote regression tests, implemented the fix, and ran the verification commands above.