anomalyco / anomalyco/opencode

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

Open
#39,118 2 comments 0 reactions 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Jul 27, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
Avg merge
7h 2m
Merged PRs (30d)
384

Description

Description

Bug: ReadMediaFile tool pages parameter uses tuple-style items which is rejected by strict JSON Schema validators
Description
The built-in ReadMediaFile tool defines a pages parameter whose JSON Schema uses tuple-style items:

"pages": {
"items": [
{"type": "integer", "exclusiveMinimum": 0, "maximum": 9007199254740991},
{"type": "integer", "exclusiveMinimum": 0, "maximum": 9007199254740991}
]
}
This format is valid in JSON Schema draft-07/draft-2019-09 (tuple validation), but JSON Schema 2020-12 changed items to accept only a single schema object or boolean, removing tuple validation.

Some API providers (e.g., Xiaomi Token Plan / MiMo models) validate tool schemas against JSON Schema 2020-12 and reject this format:

prefill failed: Tool 45 function has invalid 'parameters' schema: [{'type': 'integer', 'exclusiveMinimum': 0, 'maximum': 9007199254740991}, {'type': 'integer', 'exclusiveMinimum': 0, 'maximum': 9007199254740991}] is not of type 'object', 'boolean'

Failed validating 'type' in metaschema['allOf'][1]['properties']['properties']['additionalProperties']['$dynamicRef']['allOf'][1]['properties']['items']['$dynamicRef']['allOf'][0]:
Steps to Reproduce
Configure opencode to use a provider with strict JSON Schema 2020-12 validation (e.g., Xiaomi Token Plan with MiMo model)
Start a session
The API call fails immediately with the schema validation error
Expected Behavior
The tool schema should use JSON Schema 2020-12 compatible format. For a tuple/array of two integers, the fix would be:

"pages": {
"type": "array",
"items": {"type": "integer", "exclusiveMinimum": 0, "maximum": 9007199254740991},
"minItems": 2,
"maxItems": 2
}
Or use prefixItems (2020-12 syntax):

"pages": {
"type": "array",
"prefixItems": [
{"type": "integer", "exclusiveMinimum": 0, "maximum": 9007199254740991},
{"type": "integer", "exclusiveMinimum": 0, "maximum": 9007199254740991}
],
"minItems": 2,
"maxItems": 2
}
Environment
opencode version: 1.18.7
OS: Windows_NT 10.0.26200 x64
Plugin: oh-my-openagent
Provider: xiaomi-token-plan-sgp / mimo-v2.5-pro
Additional Context
This affects any provider that strictly validates tool schemas against JSON Schema 2020-12. Providers with more lenient validation (e.g., DeepSeek, OpenAI) accept the tuple format without issue, which is why this bug may not have been widely reported.

issue-bug-report.md
issue-bug-report.pdf

Plugins

oh-my-openagent

OpenCode version

1.18.7

Steps to reproduce
  1. Configure opencode with a provider that validates tool schemas strictly against JSON Schema 2020-12 (e.g.,
    xiaomi-token-plan-sgp with mimo-v2.5-pro model)
    2. Start a new session in opencode TUI
    3. The API call fails immediately before any user interaction with: prefill failed: Tool 45 function has invalid 'parameters' schema
Screenshot and/or share link

No response

Operating System

Windows 11 (Windows_NT 10.0.26200 x64)

Terminal

Windows Terminal

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.