fix(agents): clear pending auto tool reply future on timeout#5725
Merged
Conversation
Previously, the timeout branch of _wait_for_auto_tool_reply only logged and returned, leaving self._pending_auto_tool_reply_fut still pointing at the stale future. A subsequent tool execution would then skip the wait setup (the guard checks `is None`), so RunResult would not be held open for the next realtime auto reply. Move the cleanup into a finally block so timeout and other exits clear the field. The success path (cleared in _on_generation_created) is preserved by the `is auto_reply_fut` guard.
chenghao-mou
approved these changes
May 13, 2026
theomonnom
approved these changes
May 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.
Summary
The timeout branch of
_wait_for_auto_tool_reply(inauto_tool_reply_generationsetup, added in #5702) leavesself._pending_auto_tool_reply_futset to the stale future. A subsequent tool execution then short-circuits the wait-setup guard (is None), soRunResultis not held open for the next realtime auto reply.Move the cleanup into a
finallyblock. The success path is already cleared in_on_generation_created; theis auto_reply_futguard keeps the finally a no-op there.Reproducing
A realtime model with
auto_tool_reply_generation=Truewhose first auto-reply takes >5s — the run completes after the warning, then the next tool turn returns fromsess.run(...)before the auto-reply.