Skip to content

Gemini API rejects JSON Schema containing $ref references #12295

@high726

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

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