Skip to content

Gemini 3.1 Pro API returns 400 error due to tool schema incompatibility #19276

@yufan001

Description

@yufan001

Description

When using Gemini 3.1 Pro (via google/gemini-3.1-pro-preview or google/antigravity-gemini-3.1-pro), all requests fail with a 400 error due to tool schema incompatibility.

Error Details

Status: 400
Tool Debug Missing: 1
Tool Debug Summary: idx=0, hasCustom=true, customSchema=true, hasFunction=false, functionSchema=false

The problematic tool is question (idx=0). The schema for the question tool's nested properties doesn't meet Gemini's strict JSON Schema validation requirements.

Root Cause

Gemini API has stricter JSON Schema validation than other providers. The question tool's schema has nested objects that may be missing required type fields or have structural issues that Gemini rejects.

Related issues:

Environment

  • OpenCode version: 1.3.2
  • Model: google/gemini-3.1-pro-preview, google/antigravity-gemini-3.1-pro
  • Platform: macOS (darwin)

Workaround

Use other models that don't have this schema validation issue:

  • bailian-coding-plan/glm-5
  • nvidia/glm5
  • nvidia/minimax-m2.1

Expected Behavior

Gemini 3.1 Pro should work without schema errors.

Actual Behavior

All requests to Gemini 3.1 Pro fail with 400 Bad Request.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions