fix(voice): clear the stale user turn when resuming a false interruption - #7067
Open
saime428 wants to merge 1 commit into
Open
fix(voice): clear the stale user turn when resuming a false interruption#7067saime428 wants to merge 1 commit into
saime428 wants to merge 1 commit into
Conversation
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 #7063
When a false interruption is confirmed and the paused agent speech resumes,
_on_false_interruptionnever discards the recognition turn that triggered the pause. For a VAD-only turn (nothing committed by STT) that means_speech_start_timesurvives the resume. AudioRecognition only sets that anchor while it is None, so the next real utterance inherits the old one, and the committed ChatMessage ends up with astarted_speaking_atfrom before the agent even resumed speaking. Sorting a transcript by timestamp then puts the user line in the wrong place. The issue saw a 12 second offset in production.The change calls
_clear_user_turn()at the top of the resume branch, before agent speech restarts. That is the same discard path the publicclear_user_turn()API uses, so the dropped turn's transcript buffer, timing anchors and turn tracker all go together. Two cases that might look risky are fine: the resume callback cannot fire while the user is talking, because a new START_OF_SPEECH cancels the false-interruption timer, and a committed turn cancels the timer on its own path before the callback ever runs.Added
test_resume_discards_the_stale_recognition_turnto the existing false-interruption suite. It fails on main and passes here.Tested with
uv run pytest tests/test_false_interruption_resume.py --unit(10 passed) and the fulluv run pytest --unitgate (1901 passed, no new failures compared to main).make checkis clean apart from a pre-existing mypy complaint about the missing boto3 stub in the aws plugin.