fix: budget-exhausted conversations now get a summary instead of empty response - #8935
Merged
Merged
Conversation
…y response The post-loop grace call mechanism was broken: it injected a user message and set _budget_grace_call=True, but could never re-enter the while loop (already exited). Worse, the flag blocked the fallback _handle_max_iterations from running, so final_response stayed None. Users saw empty/no response when the agent hit max iterations. Fix: remove the dead grace block and let _handle_max_iterations handle it directly — it already injects a summary request and makes one extra toolless API call.
This was referenced Apr 13, 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.
When the agent hits max iterations or budget exhaustion, users see an empty/no response. This is a long-standing bug affecting both CLI and gateway.
Root cause: The post-loop grace call mechanism at line 10156 was dead code. It:
_budget_grace_call = True_handle_max_iterationsfrom running (condition:not self._budget_grace_call)final_response = None→ empty response to userFix: Remove the broken grace block. Let
_handle_max_iterationshandle budget exhaustion directly — it already injects a summary request and makes one extra toolless API call.Change: 5 insertions, 19 deletions. Net simpler.