agents icon indicating copy to clipboard operation
agents copied to clipboard

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

Open Darshak03 opened this issue 2 months ago • 1 comments

Bug Description

_GeminiJsonSchema._simplify (livekit-plugins/livekit-plugins-google/livekit/plugins/google/utils.py) drops the default keyword from every property of a tool's JSON Schema:

def _simplify(self, schema: dict[str, Any], refs_stack: tuple[str, ...]) -> None:
    schema.pop("title", None)
    schema.pop("default", None)          # <-- here
    schema.pop("additionalProperties", None)

google.genai.types.Schema has a default field, so this is not a compatibility stripping like title or $schema — it removes information Gemini accepts and uses.

For a tool argument that carries a pre-filled value, that default is the model's only record of what to send. With it stripped the argument is simply absent from the schema the model sees, so the model omits it, and a tool that requires the value (an MCP server expecting automationId / version, for example) rejects the call with an invalid-arguments error.

This affects both paths that go through _GeminiJsonSchema: 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).

Expected Behavior

A default declared on a tool argument survives into the schema sent to Gemini, so the model can fill the argument with the pre-set value.

Reproduction Steps

1. Install livekit-plugins-google and run:

   from pydantic import BaseModel
   from google.genai import types
   from livekit.plugins.google import utils

   class Params(BaseModel):
       automation_id: str = "auto-42"
       name: str

   print(utils._GeminiJsonSchema(Params.model_json_schema()).simplify())

2. Observe:
   {'properties': {'automation_id': {'type': <Type.STRING>},
                   'name': {'type': <Type.STRING>}},
    'required': ['name'], 'type': <Type.OBJECT>}

   The pre-filled "auto-42" is gone.
   Expected: {'automation_id': {'default': 'auto-42', 'type': <Type.STRING>}, ...}

3. With a real tool, the model then calls it without automation_id and the tool
   errors on the missing argument.

Operating System

macOS

Models Used

Gemini (both chat() and realtime; the realtime path reaches simplify() via the raw-schema branch added in #5560)

Package Versions

livekit-agents==1.8.0
livekit-plugins-google==1.8.0
google-genai==2.20.0

Session/Room/Call IDs

No response

Proposed Solution

# livekit/plugins/google/utils.py
def _simplify(self, schema: dict[str, Any], refs_stack: tuple[str, ...]) -> None:
    schema.pop("title", None)
    # `default` is kept: types.Schema supports it, and it is the model's only
    # record of a pre-filled argument value.
    schema.pop("additionalProperties", None)

Additional Context

schema.pop("default", None) has been there since #1588 and looks like it was carried over from the pydantic-ai implementation this class is based on, alongside the keywords Gemini genuinely rejects, rather than being a deliberate decision about default.

Darshak03 avatar Sep 09 '26 16:09 Darshak03

Hi, I'm Himanshu, looking for a first contribution. I saw #7190 already handles the schema change. Would checking defaults such as false, 0, and an empty string in nested tool schemas be a useful testing follow-up, including the chat/realtime schema paths? Happy to follow your guidance on a remaining gap rather than duplicate the PR.

himanshumehta10 avatar Oct 24 '26 03:10 himanshumehta10