Skip to content

fix(google): keep tool argument defaults in the Gemini schema - #7190

Open
Darshak03 wants to merge 1 commit into
livekit:mainfrom
Darshak03:fix/gemini-schema-keep-default
Open

fix(google): keep tool argument defaults in the Gemini schema#7190
Darshak03 wants to merge 1 commit into
livekit:mainfrom
Darshak03:fix/gemini-schema-keep-default

Conversation

@Darshak03

Copy link
Copy Markdown

_GeminiJsonSchema._simplify dropped default from every property of a tool's JSON Schema:

schema.pop("title", None)
schema.pop("default", None)   # removed
schema.pop("additionalProperties", None)

google.genai.types.Schema has a default field, so unlike title or $schema this is not compatibility stripping — it removes information Gemini accepts and uses. For an argument the caller pre-filled, that default is the model's only record of the value: with it gone the model omits the argument, and a tool that needs it (an MCP server expecting automationId / version, say) rejects the call with an invalid-arguments error.

Both paths through _GeminiJsonSchema are affected — the chat() LLM path, and the realtime path, which is routed through simplify() for raw-schema function tools because Gemini Live does not accept parameters_json_schema (#5560, googleapis/python-genai#1147).

Tests: test_default_is_kept asserts the defaults survive and round-trips the result through types.Schema, so the kept value is proven acceptable to the genai type. Two existing expectations are updated to keep the defaults they previously asserted were stripped.

A nullable field (Location | None = None) now keeps "default": None. That is left as-is rather than filtered: it is the schema as declared, and it serializes away.

schema.pop("default", None) has been there since #1588 and looks carried over from the pydantic-ai implementation this class is based on, alongside the keywords Gemini genuinely rejects.

Fixes #7189

_GeminiJsonSchema._simplify dropped `default` from every property. types.Schema
supports the field, so unlike `title` or `$schema` this removed information Gemini
accepts and uses: for a pre-filled argument the default is the model's only record
of the value, so the model omitted the argument and the tool rejected the call.

Fixes livekit#7189
@Darshak03
Darshak03 requested a review from a team as a code owner September 9, 2026 16:13

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

Gemini tool schemas drop argument defaults, so pre-filled arguments are never sent

1 participant