fix(tool): convert tuple-style items to prefixItems for JSON Schema 2020-12 compliance - #39335
Open
argszero wants to merge 1 commit into
Open
fix(tool): convert tuple-style items to prefixItems for JSON Schema 2020-12 compliance#39335argszero wants to merge 1 commit into
argszero wants to merge 1 commit into
Conversation
…020-12 compliance Effect's Schema.toJsonSchemaDocument() can produce items as an array (tuple format valid in Draft 4/7 but not 2020-12), causing strict validators (e.g., Xiaomi MiMo models) to reject tool schemas. Changes in normalize(): 1. Convert items-as-array to prefixItems + items:false (2020-12 tuple syntax) 2. Filter boolean exclusiveMinimum/exclusiveMaximum (Draft 4 legacy) Fixes anomalyco#39118 (ReadMediaFile tool pages parameter rejections) Also prevents the same root cause for any Effect-sourced schema (e.g., anomalyco#34687 GLM-5.2 structural_tag tool)
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.
Issue for this PR
Closes #39118
Type of change
What does this PR do?
Fixes JSON Schema 2020-12 compliance for tuple-style
itemsin tool schemas. Effect'sSchema.toJsonSchemaDocumentcan produceitemsas an array (Draft 4/7 tuple format), but 2020-12 requiresitemsto be a single schema or boolean. Providers like Xiaomi Token Plan / MiMo that validate strictly against 2020-12 reject arrays initems.The fix converts tuple-style
items(array) toprefixItemswithitems: falsein thenormalizefunction. It also strips booleanexclusiveMinimum/exclusiveMaximumvalues (invalid in 2020-12 — only numeric values are allowed).This is a general fix applied during schema normalization, so it covers all tools, not just
ReadMediaFile.How did you verify your code works?
bun typecheckpasses inpackages/opencodeitemsare converted toprefixItems+items: falseexclusiveMinimum/exclusiveMaximumare stripped from outputChecklist