Skip to content

Gemini API rejects JSON Schema containing $ref references #12295

Closed

Description

@high726

Problem

Gemini API rejects schemas containing $ref alongside other fields, causing errors like:

$ref 'QuestionOption' was set alongside unsupported fields. 
If a schema node has $ref set, then only description and default can be set alongside it

This happens when MCP tools use JSON Schema with $ref references to $defs/definitions.

Expected Behavior

OpenCode should expand $ref references before sending schemas to Gemini API.

Related Issues

Related PRs

Activity

  1. github-actions commented on Feb 5, 2026

    @github-actions
    Contributor

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

    Additionally, #11968 is a related PR that applies schema transformation to MCP tools - you may want to verify if extending that fix to handle $ref expansion would solve this issue.

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

  2. github-actions commented on Apr 7, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 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

zenRelates to Zen

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions