Skip to content

Commit cb71141

Browse files
committed
fix(provider): strip properties/required from non-object types in Gemini schema
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 on array or other types. Error example: GenerateContentRequest.tools[0].function_declarations[80].parameters.properties[data].properties: only allowed for OBJECT type This fix extends sanitizeGemini to remove properties/required from any schema node where type is not 'object'. Fixes issues similar to anomalyco#3140, anomalyco#8036
1 parent ca8c23d commit cb71141

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎packages/opencode/src/provider/transform.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,12 @@ export namespace ProviderTransform {
772772
result.items = {}
773773
}
774774

775+
// Remove properties/required from non-object types (Gemini rejects these)
776+
if (result.type && result.type !== "object") {
777+
delete result.properties
778+
delete result.required
779+
}
780+
775781
return result
776782
}
777783

0 commit comments

Comments
 (0)