AI_APICallError: tools.19.custom.input_schema: JSON schema is invalid. #1386

Closed
opened 2026-02-16 17:30:45 -05:00 by yindo · 12 comments
Owner

Originally created by @adeperio on GitHub (Aug 19, 2025).

Originally assigned to: @rekram1-node on GitHub.

I've upgraded to version 0.5.7 and I'm currently getting the following error with Sonnet 4 and GPT 5 ( I haven't tested any other models yet)

AI_APICallError: tools.19.custom.input_schema: JSON schema is invalid. It must match JSON Schema draft 2020-12 (https://json-
schema.org/draft/2020-12). Learn more about tool use at https://docs.anthropic.com/en/docs/tool-use.

I'm getting this error on simple coding prompts.

Originally created by @adeperio on GitHub (Aug 19, 2025). Originally assigned to: @rekram1-node on GitHub. I've upgraded to version 0.5.7 and I'm currently getting the following error with Sonnet 4 and GPT 5 ( I haven't tested any other models yet) AI_APICallError: tools.19.custom.input_schema: JSON schema is invalid. It must match JSON Schema draft 2020-12 (https://json- schema.org/draft/2020-12). Learn more about tool use at https://docs.anthropic.com/en/docs/tool-use. I'm getting this error on simple coding prompts.
yindo closed this issue 2026-02-16 17:30:45 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 19, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #1987: GPT-5 tool calling issues where the agent fails to create files properly due to tool execution problems
  • #1984: GPT-5 model parameter compatibility issues with specific model configurations
  • #1814: GPT-5 error related to invalid tools array being too long (238 tools vs 128 max), suggesting tool schema validation problems
  • #2040: Schema validation errors with "response did not match schema" for agent creation, indicating broader JSON schema validation issues

The common thread appears to be JSON schema validation failures when using GPT-5/Sonnet 4 models with OpenCode's tool system. These issues suggest the tool schemas being sent to these models may not be compatible with their JSON Schema draft 2020-12 requirements.

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Aug 19, 2025): This issue might be a duplicate of existing issues. Please check: - #1987: GPT-5 tool calling issues where the agent fails to create files properly due to tool execution problems - #1984: GPT-5 model parameter compatibility issues with specific model configurations - #1814: GPT-5 error related to invalid tools array being too long (238 tools vs 128 max), suggesting tool schema validation problems - #2040: Schema validation errors with "response did not match schema" for agent creation, indicating broader JSON schema validation issues The common thread appears to be JSON schema validation failures when using GPT-5/Sonnet 4 models with OpenCode's tool system. These issues suggest the tool schemas being sent to these models may not be compatible with their JSON Schema draft 2020-12 requirements. Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Aug 19, 2025):

@adeperio what mcp servers are you using? This looks like an mcp server

@rekram1-node commented on GitHub (Aug 19, 2025): @adeperio what mcp servers are you using? This looks like an mcp server
Author
Owner

@adeperio commented on GitHub (Aug 19, 2025):

Hi @rekram1-node here are my MCPs (sitting at the global level)

{
  2   "$schema": "https://opencode.ai/config.json",
  3   "instructions": ["CLAUDE.md"],
  4   "autoupdate": true,
  5   "mcp": {
  6     "browser-use": {
  7         "type": "local",
  8         "command": ["uvx", "browser-use[cli]", "--mcp"],
  9         "enabled": true,
 10         "environment": {
 11             "OPENAI_API_KEY":"my_key",
 12             "BROWSER_USE_HEADLESS": "false"
 13         }
 14     },
 15     "playwright": {
 16       "type": "local",
 17       "command": [
 18         "npx",
 19         "@playwright/mcp@latest",
 20         "--headless",
 21         "--viewport-size=1280,800",
 22         "--output-dir={env:HOME}/.config/opencode/playwright-mcp",
 23         "--caps=pdf"
 24       ],
 25       "enabled": true
 26     },
 27     "shadcn-ui": {
 28       "type": "local",
 29       "command": ["npx", "-y", "@jpisnice/shadcn-ui-mcp-server"],
 30       "enabled": true
 31     },
 32     "context7": {
 33       "type": "local",
 34       "command": ["npx", "-y", "@upstash/context7-mcp"],
 35       "enabled": true
 36     },
 37     "firecrawl": {
 38       "type": "local",
 39       "command": ["npx", "-y", "firecrawl-mcp"],
 40       "enabled": true,
 41       "environment": {
 42         "FIRECRAWL_API_KEY": "my_key"
 43       }
 44     },
 45     "sequential-thinking": {
 46       "type": "local",
 47       "command": ["npx", "-y", "@modelcontextprotocol/server-sequential-thinking"],
 48       "enabled": true
 49     },
            "exa": {
 51       "type": "local",
 52       "command": ["npx", "-y", "exa-mcp-server"],
 53       "enabled": true,
 54       "environment": {
 55         "EXA_API_KEY": "my_key"
 56       }
 57     }

I'll try isolate the MCP and report back

@adeperio commented on GitHub (Aug 19, 2025): Hi @rekram1-node here are my MCPs (sitting at the global level) ``` { 2 "$schema": "https://opencode.ai/config.json", 3 "instructions": ["CLAUDE.md"], 4 "autoupdate": true, 5 "mcp": { 6 "browser-use": { 7 "type": "local", 8 "command": ["uvx", "browser-use[cli]", "--mcp"], 9 "enabled": true, 10 "environment": { 11 "OPENAI_API_KEY":"my_key", 12 "BROWSER_USE_HEADLESS": "false" 13 } 14 }, 15 "playwright": { 16 "type": "local", 17 "command": [ 18 "npx", 19 "@playwright/mcp@latest", 20 "--headless", 21 "--viewport-size=1280,800", 22 "--output-dir={env:HOME}/.config/opencode/playwright-mcp", 23 "--caps=pdf" 24 ], 25 "enabled": true 26 }, 27 "shadcn-ui": { 28 "type": "local", 29 "command": ["npx", "-y", "@jpisnice/shadcn-ui-mcp-server"], 30 "enabled": true 31 }, 32 "context7": { 33 "type": "local", 34 "command": ["npx", "-y", "@upstash/context7-mcp"], 35 "enabled": true 36 }, 37 "firecrawl": { 38 "type": "local", 39 "command": ["npx", "-y", "firecrawl-mcp"], 40 "enabled": true, 41 "environment": { 42 "FIRECRAWL_API_KEY": "my_key" 43 } 44 }, 45 "sequential-thinking": { 46 "type": "local", 47 "command": ["npx", "-y", "@modelcontextprotocol/server-sequential-thinking"], 48 "enabled": true 49 }, "exa": { 51 "type": "local", 52 "command": ["npx", "-y", "exa-mcp-server"], 53 "enabled": true, 54 "environment": { 55 "EXA_API_KEY": "my_key" 56 } 57 } ``` I'll try isolate the MCP and report back
Author
Owner

@adeperio commented on GitHub (Aug 20, 2025):

Hi @rekram1-node

It's the browser-use MCP causing issues.

@adeperio commented on GitHub (Aug 20, 2025): Hi @rekram1-node It's the browser-use MCP causing issues.
Author
Owner

@rekram1-node commented on GitHub (Aug 20, 2025):

Yeah idk if there is anything to do on our end, it may make sense to sanitize mcp tools in some cases but if the entire schema isn't valid for your provider that sounds kinda painful for us to solve for...

What do you think?

@rekram1-node commented on GitHub (Aug 20, 2025): Yeah idk if there is anything to do on our end, it may make sense to sanitize mcp tools in some cases but if the entire schema isn't valid for your provider that sounds kinda painful for us to solve for... What do you think?
Author
Owner

@adeperio commented on GitHub (Aug 20, 2025):

Yep I agree with that. I wouldn't think developers would expect that either.

Maybe it would be useful to have more detail in the error message? I'm fine to debug which MCP server is causing the issue in my config. But maybe if the AI_APICallError could return some info about the tool that caused the error, and if it was an MCP server, which MCP it was?

@adeperio commented on GitHub (Aug 20, 2025): Yep I agree with that. I wouldn't think developers would expect that either. Maybe it would be useful to have more detail in the error message? I'm fine to debug which MCP server is causing the issue in my config. But maybe if the AI_APICallError could return some info about the tool that caused the error, and if it was an MCP server, which MCP it was?
Author
Owner

@rekram1-node commented on GitHub (Aug 20, 2025):

hm that part is harder because that error is coming from the provider, we dont know which one they disnt like unless they tell us, this is provider specific

@rekram1-node commented on GitHub (Aug 20, 2025): hm that part is harder because that error is coming from the provider, we dont know which one they disnt like unless they tell us, this is provider specific
Author
Owner

@rekram1-node commented on GitHub (Aug 20, 2025):

ppl in claude code reporting similar thing w/ different mcp: https://github.com/anthropics/claude-code/issues/586

@rekram1-node commented on GitHub (Aug 20, 2025): ppl in claude code reporting similar thing w/ different mcp: https://github.com/anthropics/claude-code/issues/586
Author
Owner

@adeperio commented on GitHub (Aug 20, 2025):

Ahh ok yea if tricky to do, then probably ok to leave.
Good to be aware of it.

The experience for me is that when I saw the error, I wasn’t sure if it was
an MCP causing it, or some other tool call. Which made it difficult to
understand what was going on.

Happy to close though if there are higher priorities

Tony

On Thu, 21 Aug 2025 at 2:06 am, Aiden Cline @.***>
wrote:

rekram1-node left a comment (sst/opencode#2082)
https://github.com/sst/opencode/issues/2082#issuecomment-3207013813

ppl in claude code reporting similar thing w/ different mcp:
anthropics/claude-code#586
https://github.com/anthropics/claude-code/issues/586


Reply to this email directly, view it on GitHub
https://github.com/sst/opencode/issues/2082#issuecomment-3207013813, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AAKD2XXOPACEPVZCXDXLK533OSMJ5AVCNFSM6AAAAACEJXVJ4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEMBXGAYTGOBRGM
.
You are receiving this because you were mentioned.Message ID:
@.***>

@adeperio commented on GitHub (Aug 20, 2025): Ahh ok yea if tricky to do, then probably ok to leave. Good to be aware of it. The experience for me is that when I saw the error, I wasn’t sure if it was an MCP causing it, or some other tool call. Which made it difficult to understand what was going on. Happy to close though if there are higher priorities Tony On Thu, 21 Aug 2025 at 2:06 am, Aiden Cline ***@***.***> wrote: > *rekram1-node* left a comment (sst/opencode#2082) > <https://github.com/sst/opencode/issues/2082#issuecomment-3207013813> > > ppl in claude code reporting similar thing w/ different mcp: > anthropics/claude-code#586 > <https://github.com/anthropics/claude-code/issues/586> > > — > Reply to this email directly, view it on GitHub > <https://github.com/sst/opencode/issues/2082#issuecomment-3207013813>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/AAKD2XXOPACEPVZCXDXLK533OSMJ5AVCNFSM6AAAAACEJXVJ4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEMBXGAYTGOBRGM> > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> >
Author
Owner

@rekram1-node commented on GitHub (Aug 20, 2025):

yeah we could try to parse response out for every provider and show a better err message but idk seems like more work to keep up with

@rekram1-node commented on GitHub (Aug 20, 2025): yeah we could try to parse response out for every provider and show a better err message but idk seems like more work to keep up with
Author
Owner

@rekram1-node commented on GitHub (Aug 20, 2025):

i think it is best we close this for now and will readdress better later if needed

@rekram1-node commented on GitHub (Aug 20, 2025): i think it is best we close this for now and will readdress better later if needed
Author
Owner

@adeperio commented on GitHub (Aug 20, 2025):

Thanks @rekram1-node yep for sure. Thanks for your comments!

@adeperio commented on GitHub (Aug 20, 2025): Thanks @rekram1-node yep for sure. Thanks for your comments!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1386