You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Google Gemini models (both via @ai-sdk/google API key and antigravity OAuth), MCP tools with anyOf/const patterns in their JSON Schema cause Gemini API to reject the request with errors like:
GenerateContentRequest.tools[0].function_declarations[32].parameters.properties[format].any_of[0].enum: only allowed for STRING type
Root Cause
ProviderTransform.schema() in packages/opencode/src/provider/transform.ts has a sanitizeGemini function (line 772) that converts integer enums to string enums, but does not flatten anyOf/const patterns that Gemini API rejects.
In sanitizeGemini, add handling for anyOf/oneOf arrays of const values:
// Flatten anyOf/oneOf with const values into enumfor(constkeywordof['anyOf','any_of','oneOf','one_of']){if(Array.isArray(result[keyword])){constconstants=result[keyword].filter((item: any)=>item&&typeofitem==='object'&&'const'initem)if(constants.length===result[keyword].length&&constants.length>0){result.type='string'result.enum=constants.map((item: any)=>String(item.const))deleteresult[keyword]}}}
Environment
OpenCode version: 1.1.53
Provider: @ai-sdk/google (both API key and antigravity plugin)
MCP server: Obsidian Local REST API
OS: macOS (Apple Silicon)
Workaround
Currently the only workaround is to disable the problematic MCP server's tools using permissions, but this affects all providers — not just Gemini.
Activity
fix(google): sanitize unsupported JSON Schema keywords for Gemini API
github-actions commentedon Apr 12, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.