-
Notifications
You must be signed in to change notification settings - Fork 334
fix(voice): stop dropping turns whose playback starts after audio forwarding completes (combines #1910 + #1960) #1966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
aede2a9
fix(voice): stop dropping turns whose playback starts after audio for…
toubatbrian 43def48
fix(voice): gate interrupted-commit playback evidence on captured seg…
toubatbrian 4de626d
fix(test): handle race rejection in paused-gate test for throws-check
toubatbrian 33cdbcc
Merge main and close interrupted playback races
toubatbrian 2247ec5
chore: keep merged example unchanged
toubatbrian 0891342
fix(voice): avoid stalled interrupted speech queues
toubatbrian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| '@livekit/agents': patch | ||
| --- | ||
|
|
||
| fix(voice): stop dropping agent turns whose playback starts after audio forwarding completes (#1909, #1960; port of livekit/agents#5039). | ||
|
|
||
| `forwardAudio` used to reject `firstFrameFut` (and detach its `PLAYBACK_STARTED` listener) in its `finally` block whenever no frame had played by the time forwarding finished. Two real scenarios hit this window: a speech paused in the thinking state by a brief user sound, whose buffered first frame only plays after the false interruption clears (#1909), and DataStream avatar outputs with `waitPlaybackStart: true`, which deliver `lk.playback_started` ~1s after frames were captured (#1960). In both cases the late playback-started event found nothing listening, the reply was classified "skipped", and the turn was silently removed from the chat context while the agent never entered the `speaking` state. | ||
|
|
||
| The `PLAYBACK_STARTED` listener now lives in `performAudioForwarding` so it outlives the forwarding task, and `forwardAudio` no longer settles the future; the reply tasks (including the `say()` path) settle it once the playout window ends, which also detaches the listener. A reported non-zero playback position on interruption is additionally honored as evidence of partial playback — but only when the segment actually captured a frame into the output (tracked via the output's segment count, which is also what makes the reported position fresh rather than stale) — covering avatars whose playback-started RPC races the interruption itself. |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 The say() path lacks the new partial-playback-position heuristic
The
ttsTaskmethod (used bysession.say()) atagents/src/voice/agent_activity.ts:2551-2558handles interruption by aborting and clearing the buffer, but unlike the pipeline (forwardSegmentat line 2925-2928) and realtime (processOneMessageat line 3493-3496) paths, it does NOT checkstartedForwardingAtorplaybackPosition > 0as a fallback for detecting partial playback whenfirstFrameFuthasn't resolved. This means thesay()path still relies solely onfirstFrameFutresolving (via the late PLAYBACK_STARTED listener) to enter the 'speaking' state and record metrics. For avatar outputs where the playback-started RPC races with interruption,say()may still miss the speaking-state transition. This is a pre-existing gap that the PR's new heuristic doesn't cover for this path, though thesay()path always commits to chat context regardless (line 2560-2583), so the dropped-turn symptom doesn't apply here.Was this helpful? React with 👍 or 👎 to provide feedback.