[PR #11888] fix(provider): strip properties/required from non-object types in Gemini schema #13973

Closed
opened 2026-02-16 18:18:47 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/11888

State: closed
Merged: Yes


Summary

Gemini API rejects tool schemas where properties or required fields are present on non-object types. This commonly occurs with MCP tools (e.g., Notion MCP) that define these fields incorrectly.

Fixes #11889

Problem

When using MCP servers like Notion, the tool schemas may have properties or required on non-object types, causing:

Bad Request: {
  "error": {
    "code": 400,
    "message": "GenerateContentRequest.tools[0].function_declarations[80].parameters.properties[data].properties: only allowed for OBJECT type",
    "status": "INVALID_ARGUMENT"
  }
}

Solution

Extend sanitizeGemini in transform.ts to remove properties and required from any schema node where type is not "object".

Changes

  • packages/opencode/src/provider/transform.ts: Added 6 lines to strip invalid properties

Related Issues

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11888 **State:** closed **Merged:** Yes --- ## Summary Gemini API rejects tool schemas where `properties` or `required` fields are present on non-object types. This commonly occurs with MCP tools (e.g., Notion MCP) that define these fields incorrectly. Fixes #11889 ## Problem When using MCP servers like Notion, the tool schemas may have `properties` or `required` on non-object types, causing: ``` Bad Request: { "error": { "code": 400, "message": "GenerateContentRequest.tools[0].function_declarations[80].parameters.properties[data].properties: only allowed for OBJECT type", "status": "INVALID_ARGUMENT" } } ``` ## Solution Extend `sanitizeGemini` in `transform.ts` to remove `properties` and `required` from any schema node where `type` is not `"object"`. ## Changes - `packages/opencode/src/provider/transform.ts`: Added 6 lines to strip invalid properties ## Related Issues - #11889 - Similar to #3140, #8036
yindo added the pull-request label 2026-02-16 18:18:47 -05:00
yindo closed this issue 2026-02-16 18:18:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13973