Skip to content

fix(google): keep declared property order in Gemini Live tool schemas - #2537

Open
CodeWithMoin wants to merge 1 commit into
livekit:mainfrom
CodeWithMoin:fix/google-property-ordering
Open

CodeWithMoin wants to merge 1 commit into
livekit:mainfrom
CodeWithMoin:fix/google-property-ordering

Conversation

@CodeWithMoin

Copy link
Copy Markdown

Description

Fixes #2529. Gemini Live was generating tool arguments in alphabetical order, not the order the tool declares them. So a reasoning field meant to come first got written after answer, the field it's supposed to inform.

The Live path (useParametersJsonSchema: false) converts parameters to Gemini's OpenAPI Schema, and that schema never carried propertyOrdering. Gemini sorts properties alphabetically without it. We now emit it from each object's own key order, nested objects included.

The text API already sends parametersJsonSchema (#2516) and is untouched.

Changes Made

  • plugins/google/src/utils.ts: convertJSONSchemaToOpenAPISchema sets propertyOrdering whenever an object has properties. It recurses, so nested objects get it too.
  • plugins/google/src/utils.test.ts: new test for a { reasoning, answer, detail: { why, confidence } } tool on the Live path, checking top-level and nested order and that non-object fields get no ordering. The existing Live API assertion now includes propertyOrdering.
  • .changeset/gemini-live-property-ordering.md: patch for @livekit/agents-plugin-google.

Pre-Review Checklist

  • Build passes: All builds (lint, typecheck, tests) pass locally
  • AI-generated code reviewed: Removed unnecessary comments and ensured code quality
  • Changes explained: All changes are properly documented and justified above
  • Scope appropriate: All changes relate to the PR title, or explanations provided for why they're included
  • Video demo: n/a, schema-only change with no UI surface

Testing

  • Automated tests added/updated (if applicable)
  • All tests pass
  • Make sure both restaurant_agent.ts and realtime_agent.ts work properly (for major changes): not a major change
pnpm build:plugins
npx vitest run plugins/google        # 7 files passed, 1 skipped; 71 tests passed, 2 skipped
npx tsc --noEmit -p plugins/google   # clean
eslint plugins/google/src/utils.ts plugins/google/src/utils.test.ts   # clean
prettier --check (changed files + changeset)                          # clean

Without the fix, the new test and the updated Live API test both fail. With it, all pass.

Additional Notes

Google docs on this: https://ai.google.dev/gemini-api/docs/structured-output#property-ordering

The Live API path converts tool parameters to Gemini's OpenAPI Schema,
which never carried propertyOrdering, so Gemini generated tool arguments
alphabetically. A field meant to be written first (reasoning) could come
after the field it should inform (answer).

Emit propertyOrdering from each object schema's own key order, nested
objects included. The text API already sends parametersJsonSchema and is
unchanged.

Fixes livekit#2529
@CodeWithMoin
CodeWithMoin requested a review from a team as a code owner September 19, 2026 12:22
@changeset-bot

changeset-bot Bot commented Sep 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: deffd30

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 39 packages
Name Type
@livekit/agents-plugin-google Patch
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-anthropic Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-azure Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-krisp Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-meta Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-protoface Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant

CLAassistant commented Sep 19, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@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.

google plugin: tool schemas never send Gemini propertyOrdering, so arguments generate alphabetically

2 participants