Skip to content

Gemini tool schema fails when a tool input is a nullable array #43494

Description

@Role1776

Bug

When a tool input is declared as a nullable array (type: ["null", "array"]), @ai-sdk/google's convertJSONSchemaToOpenAPISchema splits it into anyOf: [{ type: "array" }] but leaves a sibling items field dangling at the parent level.

Gemini rejects the resulting function declaration because items sits outside the array branch, producing a schema error for any tool whose input is a nullable array.

Impact

Any opencode tool whose input schema contains type: ["null", "array"] fails against Google Gemini (@ai-sdk/google / @ai-sdk/google-vertex).

Suggested fix

Before sending the request, fold the sibling items into the array-typed branches of any union (anyOf/oneOf/allOf) so the generated function declaration carries items inside the array branch. See packages/opencode/src/session/llm/request.ts.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions