fix(google): close realtime output streams on generation_complete#6431
Merged
Conversation
Gemini delays turn_complete until it estimates client-side playback has finished, so ending the response on turn_complete made AudioSegmentEnd and the finalized transcript arrive seconds after the last audio chunk. Close the audio and text streams on generation_complete instead, matching OpenAI. Finalization still waits for turn_complete; late audio/text is dropped with a warning. Fixes #6421
Contributor
|
I tested this, it's working great now. |
theomonnom
approved these changes
Jul 17, 2026
ronanmcnulty
pushed a commit
to GreyhoundRecyclingIreland/agents
that referenced
this pull request
Jul 23, 2026
Routine + handled on our deployment: post-completion re-emissions are dropped by design (livekit#6431/livekit#6481) and the worker's capture wrap folds the text into the stored transcript before this handler runs. The WARNING paged Rollbar on essentially every Gemini call (cai items livekit#1543/livekit#1544, livekit#1606/livekit#1607).
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.
Gemini's realtime API delays
turn_completeuntil it estimates client-side playback has finished, so ending the response onturn_completemadeAudioSegmentEnd(and the finalized transcript) arrive several seconds after the last audio chunk. This closes the audio and text streams ongeneration_completeinstead, matching the OpenAI realtime behavior. Full finalization (input transcription, metrics) still waits forturn_complete, and any audio/text received aftergeneration_completeis dropped with a warning.Fixes #6421 and #5821 (comment)