fix(voice): prevent dropped run_input acks in remote sessions - #6665
Open
samanyugoyal2010 wants to merge 7 commits into
Open
fix(voice): prevent dropped run_input acks in remote sessions#6665samanyugoyal2010 wants to merge 7 commits into
samanyugoyal2010 wants to merge 7 commits into
Conversation
Serialize SessionHost outbound events and responses through a single writer so concurrent transport writes and shutdown cancellation cannot drop a completed run_input acknowledgement after conversation events were already delivered (spurious "Agent did not respond within 60.0s"). Also harden RemoteSession pending-request handling (register-before-send, finally cleanup, late/unknown response warnings, clear close errors) and make room/TCP transports fail loudly on send errors.
Prefer a run_input ack that lands on the timeout boundary over a false timeout, recreate the SessionHost outbound channel on restart, and avoid setting CancelledError on writer completion futures. Add regression coverage for these edge cases.
On 3.10, asyncio.TimeoutError is distinct from builtin TimeoutError, so bare except TimeoutError around wait_for never fired. Match wait_for_ready and catch both at SessionHost.aclose drain sites and RemoteSession._send_request, and update the new remote-session tests accordingly.
After send_message started raising instead of silently dropping, early pings could fail immediately when the room/peer was not ready yet. Retry those errors (with a short sleep) until the deadline, then raise TimeoutError chaining the last cause.
Use one shared drain deadline (3s total, under the worker's 10s process shutdown budget) for in-flight handlers and the outbound writer. Close the outbound channel when the writer exits so later sends fail fast instead of hanging on unresolved futures.
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
|
@chenghao-mou please merge |
cursor
Bot
force-pushed
the
cursor/fix-sim-run-input-timeout-990a
branch
from
August 2, 2026 11:09
9f124ef to
7a959d1
Compare
…close Await the outbound writer with asyncio.wait so a Task cancelled inside _writer_loop (CancelledError from transport.send_message) cannot make aclose itself raise and abort AgentSession cleanup before RoomIO closes. Co-authored-by: samanyugoyal2010 <samanyugoyal2010@users.noreply.github.com>
Author
|
@devin-ai-aintegration[bot] can this PR be merged |
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.
Serialize SessionHost outbound events and responses through a single writer so concurrent transport writes and shutdown cancellation cannot drop a completed run_input acknowledgement after conversation events were already delivered (spurious "Agent did not respond within 60.0s").
Also harden RemoteSession pending-request handling (register-before-send, finally cleanup, late/unknown response warnings, clear close errors) and make room/TCP transports fail loudly on send errors.
addresses #6661