fix(provider): infer type 'object' for schemas with properties but missing type in Gemini sanitization#13150
Open
ChickenBreast-ky wants to merge 1 commit intoanomalyco:devfrom
Conversation
…ssing type in Gemini sanitization Follow-up to anomalyco#11888. sanitizeGemini strips properties/required from non-object types, but misses the case where type is entirely undefined. MCP tools like Notion define schemas with properties/required but no type field, causing Gemini API 400 errors. This fix infers type 'object' when properties or required exist but type is missing, per JSON Schema's implicit object semantics. Fixes anomalyco#13148
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
Contributor
Author
|
CI note: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #11888.
sanitizeGeministripsproperties/requiredfrom non-object types, but misses the case wheretypeis entirely undefined (undefined).Fixes #13148
Problem
The current check:
When
typeisundefined,result.type && ...short-circuits tofalse, soproperties/requiredare not removed. MCP tools like Notion MCP define schemas wheretypeis omitted butproperties/requiredare present (valid per JSON Schema spec as implicit objects):{ "data": { "description": "The data required for updating a page", "properties": { "page_id": { "type": "string" } }, "required": ["page_id"] } }This causes:
Solution
Infer
type: "object"whenpropertiesorrequiredexist buttypeis missing, before the existing non-object stripping logic:Changes
packages/opencode/src/provider/transform.ts: Added 4 lines to infer missing typepackages/opencode/test/provider/transform.test.ts: Added 2 test cases for missing type inferenceRelated Issues