Skip to content

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

Closed

Description

@adeperio

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.

Activity

  1. github-actions commented on Aug 19, 2025

    @github-actions
    Contributor

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

    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.

  2. rekram1-node commented on Aug 19, 2025

    @rekram1-node
    Contributor

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

  3. self-assigned this
    on Aug 20, 2025
  4. adeperio commented on Aug 20, 2025

    @adeperio
    Author

    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

  5. adeperio commented on Aug 20, 2025

    @adeperio
    Author

    Hi @rekram1-node

    It's the browser-use MCP causing issues.

  6. rekram1-node commented on Aug 20, 2025

    @rekram1-node
    Contributor

    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?

  7. adeperio commented on Aug 20, 2025

    @adeperio
    Author

    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?

  8. rekram1-node commented on Aug 20, 2025

    @rekram1-node
    Contributor

    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

  9. rekram1-node commented on Aug 20, 2025

    @rekram1-node
    Contributor

    ppl in claude code reporting similar thing w/ different mcp: anthropics/claude-code#586

  10. adeperio commented on Aug 20, 2025

    @adeperio
    Author
  11. rekram1-node commented on Aug 20, 2025

    @rekram1-node
    Contributor

    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

  12. rekram1-node commented on Aug 20, 2025

    @rekram1-node
    Contributor

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

  13. adeperio commented on Aug 21, 2025

    @adeperio
    Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions