Skip to content

fix(voice): prevent dropped run_input acks in remote sessions - #6665

Open
samanyugoyal2010 wants to merge 7 commits into
livekit:mainfrom
samanyugoyal2010:cursor/fix-sim-run-input-timeout-990a
Open

fix(voice): prevent dropped run_input acks in remote sessions#6665
samanyugoyal2010 wants to merge 7 commits into
livekit:mainfrom
samanyugoyal2010:cursor/fix-sim-run-input-timeout-990a

Conversation

@samanyugoyal2010

Copy link
Copy Markdown

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

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.
@samanyugoyal2010
samanyugoyal2010 requested a review from a team as a code owner August 2, 2026 09:41
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.
devin-ai-integration[bot]

This comment was marked as resolved.

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.
devin-ai-integration[bot]

This comment was marked as resolved.

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.
devin-ai-integration[bot]

This comment was marked as resolved.

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.
devin-ai-integration[bot]

This comment was marked as resolved.

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@CLAassistant

CLAassistant commented Aug 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@samanyugoyal2010

Copy link
Copy Markdown
Author

@chenghao-mou please merge

@cursor
cursor Bot force-pushed the cursor/fix-sim-run-input-timeout-990a branch from 9f124ef to 7a959d1 Compare August 2, 2026 11:09
devin-ai-integration[bot]

This comment was marked as resolved.

…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>
@samanyugoyal2010

Copy link
Copy Markdown
Author

@devin-ai-aintegration[bot] can this PR be merged

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.

2 participants