Skip to content

Gemini: all requests fail due to anyOf schema in github_create_pull_request_review tool #14509

Closed as not planned

Description

@IamCooller

Bug Report

Description

When using Gemini as the AI provider in OpenCode, every request fails with the following error:

Unable to submit request because `github_create_pull_request_review` functionDeclaration
`parameters.comments` schema specified other fields alongside any_of.
When using any_of, it must be the only field set.
Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling

Root Cause

Gemini API validates all tool schemas before processing any request.
The github_create_pull_request_review tool from @modelcontextprotocol/server-github
defines the comments parameter with anyOf combined with other fields (e.g. type, description, items).

Gemini strictly requires that when anyOf is used, it must be the only field in the schema object. No sibling fields allowed.

Impact

  • ANY request to Gemini fails — not just GitHub-related ones
  • The error appears even for simple questions like "hello"
  • Makes Gemini completely unusable when the GitHub MCP server is enabled

Workaround

Disable the GitHub MCP server in opencode.json:

"github": {
  "enabled": false
}

Expected Fix

OpenCode should sanitize tool schemas before sending them to Gemini. When a schema uses anyOf, strip all sibling fields:

// Before (breaks Gemini):
{ type: 'array', anyOf: [...], description: '...' }

// After (Gemini-compatible):
{ anyOf: [...] }

Reference: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling

Environment

  • OpenCode with Gemini provider (via opencode-gemini-auth plugin)
  • GitHub MCP: @modelcontextprotocol/server-github
  • Platform: macOS

Activity

  1. github-actions commented on Feb 21, 2026

    @github-actions
    Contributor

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

    If your issue is distinct from the above (e.g. specifically about sibling fields alongside anyOf rather than anyOf/const flattening), please clarify the difference so this can be tracked separately.

  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 21, 2026
  3. kuyavinny commented on Feb 22, 2026

    @kuyavinny

    Same issue affects built-in edit tool — not MCP-specific

    I'm encountering the identical error with OpenCode's built-in edit tool, not an MCP tool:

    Error: Bad Request: {
      "error": {
        "code": 400,
        "message": "Unable to submit request because edit functionDeclaration parameters.edits schema specified other fields alongside any_of. When using any_of, it must be the only field set.",
        "status": "INVALID_ARGUMENT"
      }
    }

    This makes all Google/Gemini models completely unusable via the Antigravity auth plugin, since the edit tool is registered for every session.
    This confirms the issue isn't limited to MCP tools — it also affects core built-in tools. The schema sanitization fix would need to handle all tools, not just MCP-sourced ones.

  4. added a commit that references this issue on Feb 22, 2026
    3ef78a3
  5. OmerFarukOruc commented on Feb 22, 2026

    @OmerFarukOruc

    Additional findings: built-in edit tool schema causes failure, not MCP tools

    Disabling MCP servers does not fix this. The failing tool is OpenCode's own built-in edit tool (function_declarations[5]), not a GitHub or any other MCP tool.

    Error

    GenerateContentRequest.tools[0].function_declarations[5].parameters.properties[edits].items.properties: only allowed for OBJECT type
    GenerateContentRequest.tools[0].function_declarations[5].parameters.properties[edits].items.required: only allowed for OBJECT type
    

    Root cause

    The edit tool's edits parameter is an array whose items define properties and required fields, but without type: "object". Gemini's API strictly requires type: "object" to be set before allowing properties/required on any schema node.

    Since Gemini validates all tool schemas upfront, this causes every request to fail — including simple "hello" messages.

    Fix needed

    The Gemini schema sanitizer needs to handle array items — when items contain properties/required, add type: "object" if missing. PRs #13666 and #12911 are on the right track but need to cover the items case as well.

  6. shyuuuuni commented on Feb 23, 2026

    @shyuuuuni

    I have same issue. Is there a solution? I'm using gemini as my main model.

    Bad Request: [{
      "error": {
        "code": 400,
        "message": "Unable to submit request because `edit` functionDeclaration `parameters.edits` schema specified other fields alongside any_of. When using any_of, it must be the only field set. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling",
        "errors": [
          {
            "message": "Unable to submit request because `edit` functionDeclaration `parameters.edits` schema specified other fields alongside any_of. When using any_of, it must be the only field set. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling",
            "domain": "global",
            "reason": "badRequest"
          }
        ],
        "status": "INVALID_ARGUMENT"
      }
    }
    ]
    
  7. RovshanMuradov commented on Feb 23, 2026

    @RovshanMuradov
    Contributor

    I have same issue. Is there a solution? I'm using gemini as my main model.

    Bad Request: [{
      "error": {
        "code": 400,
        "message": "Unable to submit request because `edit` functionDeclaration `parameters.edits` schema specified other fields alongside any_of. When using any_of, it must be the only field set. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling",
        "errors": [
          {
            "message": "Unable to submit request because `edit` functionDeclaration `parameters.edits` schema specified other fields alongside any_of. When using any_of, it must be the only field set. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling",
            "domain": "global",
            "reason": "badRequest"
          }
        ],
        "status": "INVALID_ARGUMENT"
      }
    }
    ]
    

    set this plugin with that pr and it will fix, until then we have to wait when Dax fixes it jenslys/opencode-gemini-auth#58

  8. kuyavinny commented on Feb 24, 2026

    @kuyavinny

    I have PR #14659. It worked for me, but it needs more testing. It strips all sibling fields before submitting to the AI.

  9. github-actions commented on Apr 26, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions