fix(agent): robust context compression summary fallback#4243
Closed
lumethegreat wants to merge 1 commit into
Closed
fix(agent): robust context compression summary fallback#4243lumethegreat wants to merge 1 commit into
lumethegreat wants to merge 1 commit into
Conversation
Retry summary generation on failure using provider=main + main model to avoid silent compaction failures when auxiliary model routing is misconfigured (e.g. google/* on Codex). Also insert an explicit warning summary marker when summarization fails so users understand continuity may degrade.
This was referenced Apr 2, 2026
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.
What changed
This PR makes context compaction (conversation compression) more robust when summary generation fails due to misconfigured auxiliary model routing.
Retry summary generation using the main provider/model
google/*model routed to a Codex endpoint), the compressor retries with:provider="main"model=self.model(the main conversation model)Never fail silently when compaction cannot produce a summary
None, we insert an explicit compaction warning summary marker (with the standard compaction prefix), explaining that earlier turns may have been dropped without a summary and how to fix configuration.Why
We observed failures where context compression attempted to use an unsupported summarization model for the active endpoint (e.g.
google/gemini-3-flash-previewon a Codex ChatGPT account). The summary call failed, a session split occurred due to “compression”, and continuity degraded (inconsistent answers / lost context).This PR both:
User impact / behavior
compression.summary_*andauxiliary.compression.provider=main).How to reproduce (example)
compression.summary_model: google/gemini-3-flash-previewwhile using a Codex endpoint).How this fixes it
provider=main+ the main model, avoiding the incompatible auxiliary route.Tests
provider=main)NoneCommand run locally:
PYTHONPATH="$PWD" pytest -q tests/agent/test_context_compressor.pyFiles changed
agent/context_compressor.pytests/agent/test_context_compressor.py