anomalyco / anomalyco/opencode

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

Open
#43,494 1 comment 1 reaction 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 19, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.