Skip to content

fix(google): send a bare turnComplete when a reply request carries no turns - #7323

Open
rosetta-livekit-bot[bot] wants to merge 1 commit into
mainfrom
lummoxes-mestizo-thirsty
Open

rosetta-livekit-bot[bot] wants to merge 1 commit into
mainfrom
lummoxes-mestizo-thirsty

Conversation

@rosetta-livekit-bot

@rosetta-livekit-bot rosetta-livekit-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

What

Port livekit/agents-js#2506 so Gemini Live reply requests with no turns omit the turns argument and send only turn_complete=True. The Google SDK rejects an empty turns array, which previously killed the send task before models such as gemini-3.8-live could reply. Non-empty turns and explicit turn_complete=False continue to pass through unchanged.

Source: livekit/agents-js#2506

Source diff coverage
  • .changeset/gemini-live-empty-turns.md: not applicable. The target does not use changesets, and its contribution policy leaves package manifest and changelog updates to maintainers.
  • plugins/google/src/realtime/realtime_api.ts: adapted to livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/realtime_api.py. The TypeScript parameter normalizer is implemented with Python SDK argument names, omitting turns when absent or empty and defaulting turn_complete to True.
  • plugins/google/src/realtime/realtime_api.test.ts: adapted to tests/test_plugin_google_realtime.py. Both source helper tests are ported with Python Content objects and snake_case SDK arguments; no additional tests were added.

Verification

  • uv run pytest tests/test_plugin_google_realtime.py --unit (28 passed)
  • uv run pytest --plugin google (76 passed; one unrelated existing Gemini TTS leaked-task teardown error)
  • make unit-tests / uv run pytest --unit (3,007 passed before a pre-existing pytest concurrency harness failure: RuntimeError: Event loop is closed in tests/concurrency.py; reproduced in isolation)
  • make check
  • uv build --package livekit-plugins-google

Runtime cue-cli validation could not be performed because this environment has no GOOGLE_API_KEY or Google application credentials. LiveKit transport credentials and cue-cli are available, but a Gemini Live session cannot be created without provider credentials. The SDK boundary behavior is covered by the two tests ported from the source PR.


Ported from livekit/agents-js#2506

Original PR description

What

generateReply() on models that take no placeholder user turn (gemini-3.8-live, gemini-3.8-live-extended-thinking, gemini-3.1-flash-live-preview, since #2503) queues a content event with turns: []. @google/genai's Session.sendClientContent rejects an empty turns array (tContents throws "contents are required", surfaced as Failed to parse client content "turns"), which kills the send task and restarts the session, so the reply is never produced.

This sends a bare { turnComplete: true } when there are no turns, which is the Live API's own way of requesting a reply, and passes non-empty turns through unchanged.

How verified

  • Reproduced on gemini-3.8-live with the agents-js 1.9.0 release: every generateReply() logged Error in send task: Error: Failed to parse client content "turns", type: 'object' followed by Connecting to Gemini Realtime API...; with this change the same agent opens the conversation and answers generateReply({ userInput }) turns (opening, typed text, image via updateChatCtx, injection during a pending tool call).
  • pnpm vitest run plugins/google/src/realtime/realtime_api.test.ts (12 passed, two new cases for the helper).
  • pnpm exec prettier --check on the two files; eslint reports only the three pre-existing no-explicit-any warnings.

Includes a patch changeset for @livekit/agents-plugin-google.

@rosetta-livekit-bot
rosetta-livekit-bot Bot requested a review from a team as a code owner September 17, 2026 16:04

@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 bugs or issues to report.

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.

0 participants