fix(voice): cancel parked preemptive generation before pausing the activity - #6865
Open
uuzzrm wants to merge 1 commit into
Open
fix(voice): cancel parked preemptive generation before pausing the activity#6865uuzzrm wants to merge 1 commit into
uuzzrm wants to merge 1 commit into
Conversation
…tivity A preemptive reply started while the user was talking can end up parked in _preemptive_generation when the turn is discarded because an uninterruptible message is playing. pause() waits for all outstanding speech work, so an awaited AgentTask (whose handoff takes the pause path) would hang until the session closed. Drop the parked generation in both places: - on the turn-discard path in _user_turn_completed_task, since the speculative reply can never be scheduled, and - in pause(), matching drain()/aclose()/interrupt(), so a handoff can never wait on a generation nobody scheduled. Adds a regression test covering both guards.
Contributor
Author
|
Reopening this - the deadlock in #6858 is still reproducible on the latest agent (we hit it again today on a handoff where the caller spoke during an uninterruptible reply). The branch was synced with main and the focused test suite passes locally; re-running CI on the current head now. |
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.
Fixes #6858
What changed
When the caller's turn ends while an uninterruptible message is playing,
_user_turn_completed_taskdiscards the turn and returns early. If aspeculative reply had already been started (preemptive generation), it
stayed parked in
_preemptive_generation- never scheduled, nevercancelled.
Awaiting an
AgentTasktakes the pause path, andpause()waits for alloutstanding speech work. With the parked reply still in
_speech_tasks,that wait never completes, so the handoff hangs until the session is
closed (or the caller hangs up).
drain(),aclose()andinterrupt()all cancel the parked generationbefore waiting;
pause()was the only one that didn't.Changes
_user_turn_completed_task: cancel the speculative reply when the turnis discarded, since it can never be scheduled.
pause(): cancel any parked preemptive generation before waiting forthe speech tasks to drain, matching the other teardown paths.
Tests
tests/test_preemptive_pause_deadlock.pywith two cases:pause()completes in the presence of a parked generation instead ofhanging.
pytest tests/test_preemptive_pause_deadlock.py- 2 passed.ruff checkandruff format --checkare clean.