Skip to content

toGeminiToolSchema

function toGeminiToolSchema(node): Record<string, unknown>;

Defined in: core/src/schema.ts:226

A JSON Schema for Gemini’s parametersJsonSchema and responseJsonSchema, which take standard JSON Schema. It is sent as written except for the four shapes the API refuses. Measured on gemini-3.8-flash on 2026-10-21, in a tool and as a response schema alike; every other keyword tried ($ref, $defs, oneOf, allOf, not, if, const, numeric enum, type: [..., "null"], patternProperties, additionalProperties, arrays without items) came back accepted:

  • required names a property that is not declared, at any depth: 400 “requires unspecified property”. The names with no property are dropped.
  • Draft-04 exclusiveMinimum: true (or false): 400 “must be a number”. It becomes the number form, exclusiveMinimum: <minimum>, and minimum goes.
  • A tuple, items: [a, b]: 400 “must be a boolean or an object”. It becomes prefixItems, and additionalItems becomes items, as in 2020-12.
  • A recursive $ref that is not behind an optional property or an array that may be empty: 400 “ref loops are only supported if …”. The self-reference becomes {}.

This replaced a sanitizer written for the older parameters field, which accepts a small OpenAPI subset. Kept on parametersJsonSchema, it turned a numeric enum into a string enum (the model then sent "2" for 2), forced string items onto an array of anything, and dropped every $ref, while still sending the 400s above.

Parameter Type
node unknown

Record<string, unknown>