fix(provider): sanitize tool schemas for strict validators#13738
fix(provider): sanitize tool schemas for strict validators#13738sametakofficial wants to merge 1 commit intoanomalyco:devfrom
Conversation
Strip non-standard keywords ($schema, ref) and ensure all properties are in required when additionalProperties is false.
|
The following comment was made by an LLM, it may be inaccurate: Based on my search results, I found two potentially related PRs that appear to be addressing similar schema sanitization issues:
These PRs seem to be part of a broader effort to sanitize tool schemas across different providers. They may be related work or even duplicative approaches to the same problem. I recommend checking if PR #13619 and #13666 are already merged or if they cover the same scope as PR #13738. |
|
Can u provide means to reproduce issue? You said before they 400, what tools were you passing? |
|
No custom tools — this happens with a completely clean config. I set up a fresh The endpoint rejects opencode's built-in {
"type": "object",
"properties": {
"question": { "type": "string" },
"header": { "type": "string" },
"options": { "type": "array", ... },
"multiple": { "type": "boolean" }
},
"required": ["question", "header", "options"],
"additionalProperties": false,
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
The Re: #13619 and #13666 — those are provider-specific fixes (Claude API and Gemini). This one runs in |
Fixes #13737
Related: #11413, #8184, #13618
Tool schemas have two issues that cause 400s on strict validators (Codex, Vertex AI, SGLang): optional properties missing from
requiredwhenadditionalProperties: falseis set, and non-standard keywords ($schema,ref) from Zod meta.Added a recursive
sanitize()step inProviderTransform.schema()that strips the bad keywords and ensures all properties are inrequiredwhenadditionalPropertiesis false. Runs before provider-specific transforms.Tested against Codex and Vertex AI endpoints — both previously 400, now work. 6 new unit tests, all 104 existing tests pass.