What happens
@livekit/agents-plugin-google builds each tool's Gemini Schema from its JSON schema in dist/utils.js, copying a fixed set of keys (type, description, required, properties, items, enum, …). It never emits propertyOrdering.
The Gemini API orders an object's properties alphabetically unless the schema carries propertyOrdering, so a tool's arguments are generated in alphabetical order rather than the order the schema declares.
Why it matters
Gemini writes a tool call's arguments as JSON, one field at a time, so a field can only be conditioned on the fields already written. When a tool has a field that is meant to be worked out first and a field that depends on it, alphabetical order can invert them.
A minimal example — a tool declared as:
{
reasoning: z.string(), // meant to be written first
answer: z.enum(['a', 'b']),
}
is generated as answer first, then reasoning, because answer sorts before reasoning. The field intended to inform the decision is produced after it.
Expected
Tool declarations carry propertyOrdering taken from each object schema's own property order, nested objects included, so Gemini generates the fields in the order the tool declares them.
Notes
- Google's docs: property ordering — "properties listed in
propertyOrdering are generated first, in the specified order".
@google/genai passes the field through on the Live setup path (the Schema type carries propertyOrdering, and unknown keys survive processJsonSchema), so no SDK change is needed.
- We currently patch the plugin locally: set
propertyOrdering from the property key order of every object schema that has properties, applied recursively. Confirmed present in the declarations sent to a Gemini 3.8 Live session.
- Happy to open a PR for that if it's wanted.
Version
@livekit/agents 1.9.0, @livekit/agents-plugin-google 1.9.0, Node 24, Gemini Live (realtime).
What happens
@livekit/agents-plugin-googlebuilds each tool's GeminiSchemafrom its JSON schema indist/utils.js, copying a fixed set of keys (type,description,required,properties,items,enum, …). It never emitspropertyOrdering.The Gemini API orders an object's properties alphabetically unless the schema carries
propertyOrdering, so a tool's arguments are generated in alphabetical order rather than the order the schema declares.Why it matters
Gemini writes a tool call's arguments as JSON, one field at a time, so a field can only be conditioned on the fields already written. When a tool has a field that is meant to be worked out first and a field that depends on it, alphabetical order can invert them.
A minimal example — a tool declared as:
is generated as
answerfirst, thenreasoning, becauseanswersorts beforereasoning. The field intended to inform the decision is produced after it.Expected
Tool declarations carry
propertyOrderingtaken from each object schema's own property order, nested objects included, so Gemini generates the fields in the order the tool declares them.Notes
propertyOrderingare generated first, in the specified order".@google/genaipasses the field through on the Live setup path (theSchematype carriespropertyOrdering, and unknown keys surviveprocessJsonSchema), so no SDK change is needed.propertyOrderingfrom the property key order of every object schema that hasproperties, applied recursively. Confirmed present in the declarations sent to a Gemini 3.8 Live session.Version
@livekit/agents1.9.0,@livekit/agents-plugin-google1.9.0, Node 24, Gemini Live (realtime).