anomalyco / anomalyco/opencode
Gemini tool schema fails when a tool input is a nullable array
@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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.