Repository navigation
fix(agent): guide recovery from oversized tool results - #4925
Merged
Merged
Conversation
chengyongru
marked this pull request as draft
July 14, 2026 10:33
chengyongru
marked this pull request as ready for review
July 15, 2026 02:18
chengyongru
force-pushed
the
fix/context-budget-reprompt
branch
from
July 15, 2026 03:37
d6a6486 to
01723f5
Compare
7 tasks
chengyongru
force-pushed
the
fix/context-budget-reprompt
branch
2 times, most recently
from
July 18, 2026 16:57
9de2fe9 to
87e47df
Compare
Use the existing in-flight context governor to replace tool output that cannot fit the next model request with a bounded, actionable instruction. The model can retry with narrower arguments, use another tool, or explain the context limit without a second recovery state machine.
chengyongru
force-pushed
the
fix/context-budget-reprompt
branch
from
July 18, 2026 17:02
87e47df to
701467d
Compare
This was referenced Jul 19, 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.
Summary
Fixes #2343.
Behavior
After a tool call completes, the next normal agent iteration already runs
ContextGovernor.prepare_for_model()before making a provider request. If the estimated prompt exceeds the configured input budget,compact_inflight_overflow()replaces oversized in-flight tool results in the model-facing copy.The replacement now tells the model that:
Tools remain available on the next ordinary model call. The context governor continues to leave persisted session history untouched and keeps the compacted model-facing result stable for the rest of the turn.
Deliberate boundaries
stop_reason, cross-turn state, configuration, or checkpoint behavior.Tests
python -m pytest tests/agent/test_runner_governance.py -q— 28 passed.python -m pytest tests/agent/test_runner_core.py tests/agent/test_runner_governance.py tests/agent/test_loop_runner_integration.py -q— 59 passed.read_fileresult was replaced before the next provider request; the model then issued a narroweroffset/limitcall and completed normally.git diff --checkpass.