Skip to content

fix(tool): convert tuple-style items to prefixItems for JSON Schema 2020-12 compliance - #39335

Open
argszero wants to merge 1 commit into
anomalyco:devfrom
argszero:json-schema-prefix-items
Open

fix(tool): convert tuple-style items to prefixItems for JSON Schema 2020-12 compliance#39335
argszero wants to merge 1 commit into
anomalyco:devfrom
argszero:json-schema-prefix-items

Conversation

@argszero

Copy link
Copy Markdown

Issue for this PR

Closes #39118

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Fixes JSON Schema 2020-12 compliance for tuple-style items in tool schemas. Effect's Schema.toJsonSchemaDocument can produce items as an array (Draft 4/7 tuple format), but 2020-12 requires items to be a single schema or boolean. Providers like Xiaomi Token Plan / MiMo that validate strictly against 2020-12 reject arrays in items.

The fix converts tuple-style items (array) to prefixItems with items: false in the normalize function. It also strips boolean exclusiveMinimum/exclusiveMaximum values (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 typecheck passes in packages/opencode
  • Manual inspection of generated JSON Schema output confirms arrays in items are converted to prefixItems + items: false
  • Boolean exclusiveMinimum/exclusiveMaximum are stripped from output

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: ReadMediaFile tool pages parameter uses tuple-style items which is rejected by strict JSON Schema validators

1 participant