fix(google): preserve non-blocking realtime generation#6526
Open
usluio wants to merge 1 commit into
Open
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.
Summary
NON_BLOCKINGfunction call arrivesWhy
Gemini 2.5 asynchronous function calling allows the model to continue the active conversation while a non-blocking tool executes. The Google realtime plugin currently calls
_mark_current_generation_done()for every tool call, which closes the audio and text streams before trailing output in the same turn can be delivered.This change only defers finalization for declarations configured with
Behavior.NON_BLOCKING. The generation still closes on Gemini's existinggeneration_completeandturn_completeevents. Blocking calls retain the current behavior.This is intentionally narrower than #6285, which addresses blocking/tool-terminated turns such as Gemini 3.1 with an audio-drain timeout.
Related: #5742
Tests
uv run --python 3.12 pytest tests/test_plugin_google_realtime.py --unit -quv run --python 3.12 ruff check livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/realtime_api.py tests/test_plugin_google_realtime.pyuv run --python 3.12 ruff format --check livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/realtime_api.py tests/test_plugin_google_realtime.pyuv run --python 3.12 mypy --untyped-calls-exclude=smithy_aws_core -p livekit.plugins.googleFull repository type checking is currently blocked locally by a missing
boto3stub in the AWS experimental plugin.