Skip to content

fix(google): preserve non-blocking realtime generation#6526

Open
usluio wants to merge 1 commit into
livekit:mainfrom
usluio:fix/google-realtime-nonblocking-generation
Open

fix(google): preserve non-blocking realtime generation#6526
usluio wants to merge 1 commit into
livekit:mainfrom
usluio:fix/google-realtime-nonblocking-generation

Conversation

@usluio

@usluio usluio commented Jul 23, 2026

Copy link
Copy Markdown

Summary

  • keep Gemini realtime output streams open when a NON_BLOCKING function call arrives
  • continue using the existing immediate finalization behavior for blocking function calls
  • add regression coverage for both blocking and non-blocking tool behavior

Why

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 existing generation_complete and turn_complete events. 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 -q
  • uv run --python 3.12 ruff check livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/realtime_api.py tests/test_plugin_google_realtime.py
  • uv run --python 3.12 ruff format --check livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/realtime_api.py tests/test_plugin_google_realtime.py
  • uv run --python 3.12 mypy --untyped-calls-exclude=smithy_aws_core -p livekit.plugins.google

Full repository type checking is currently blocked locally by a missing boto3 stub in the AWS experimental plugin.

@usluio
usluio requested a review from a team as a code owner July 23, 2026 17:37

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant