Skip to content

fix(agents): clear pending auto tool reply future on timeout#5725

Merged
u9g merged 1 commit into
mainfrom
fix/auto-tool-reply-timeout-leak
May 13, 2026
Merged

fix(agents): clear pending auto tool reply future on timeout#5725
u9g merged 1 commit into
mainfrom
fix/auto-tool-reply-timeout-leak

Conversation

@u9g
Copy link
Copy Markdown
Contributor

@u9g u9g commented May 13, 2026

Summary

The timeout branch of _wait_for_auto_tool_reply (in auto_tool_reply_generation setup, added in #5702) leaves self._pending_auto_tool_reply_fut set to the stale future. A subsequent tool execution then short-circuits the wait-setup guard (is None), so RunResult is not held open for the next realtime auto reply.

Move the cleanup into a finally block. The success path is already cleared in _on_generation_created; the is auto_reply_fut guard keeps the finally a no-op there.

Reproducing

A realtime model with auto_tool_reply_generation=True whose first auto-reply takes >5s — the run completes after the warning, then the next tool turn returns from sess.run(...) before the auto-reply.

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 chenghao-mou requested a review from a team May 13, 2026 10:56
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@u9g u9g merged commit 3c488cf into main May 13, 2026
27 checks passed
@u9g u9g deleted the fix/auto-tool-reply-timeout-leak branch May 13, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants