opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Gemini 3 models fail with "Invalid JSON payload received. Unknown name 'parameters'" error

Open lvsao opened this issue 2 weeks ago • 1 comments

OpenCode GitHub Issue Report

Issue Title

Gemini 3 models fail with "Invalid JSON payload received. Unknown name 'parameters'" error when using antigravity-auth plugin

Issue Description

When using google/antigravity-gemini-3-flash or google/antigravity-gemini-3-pro models, OpenCode fails with a 400 error due to invalid tool schema format for Gemini API.

Error Message

Invalid JSON payload received. Unknown name "parameters" at 'request.tools[0]': Cannot find field.
Status: 400
Requested Model: antigravity-gemini-3-flash
Effective Model: gemini-3-flash
Endpoint: https://daily-cloudcode-pa.sandbox.googleapis.com/v1internal:streamGenerateContent?alt=sse

Tool Debug Payload (Problematic)

The tool schema being sent to Gemini contains an incorrectly formatted structure:

[{
  "functionDeclarations": [...],
  "parameters": {
    "type": "OBJECT",
    "properties": {
      "_placeholder": {
        "type": "BOOLEAN",
        "description": "Placeholder. Always pass true."
      }
    },
    "required": ["_placeholder"]
  }
}]

Expected Behavior

Tool schemas should be formatted according to Gemini API specifications, with:

  1. Proper type: "object" (lowercase)
  2. No _placeholder parameters
  3. No unsupported JSON Schema fields like $schema
  4. String-only enum values

Environment

  • OpenCode Version: v1.1.23 (latest)
  • Plugin: [email protected]
  • OS: Windows
  • Model: google/antigravity-gemini-3-flash (all variants fail)
  • Project: J:\apps\max-Translator\max-ai-omni-translator

Related Issues

  • OpenCode #3140: "AI_APICallError: GenerateContentRequest.tools[0].function_declarations[32].parameters. required[0]: property is not defined"
  • OpenCode #4512: "sanitize tools for Gemini 3 compatibility" (fixed in PR #4538 but issue persists)
  • OpenCode #4665: "OpenCode plus Zen Gemini 3 Pro model causes errors"
  • Qwen Code #1186: "API Error 400 with Gemini model: Invalid JSON payload received. Unknown name '$schema'"

Reproduction Steps

  1. Install opencode-antigravity-auth@beta plugin
  2. Configure google/antigravity-gemini-3-flash model
  3. Run: opencode run "Hello" --model=google/antigravity-gemini-3-flash
  4. Observe 400 error with "Unknown name 'parameters'" message

Workaround

Claude models (antigravity-claude-sonnet-4-5-thinking) work correctly with the same configuration.

Suggested Fix

Implement proper tool schema sanitization for Gemini API:

  1. Remove $schema field from tool parameter schemas
  2. Convert non-string enum values to strings
  3. Ensure type field uses lowercase values
  4. Remove placeholder parameters like _placeholder
  5. Validate schema against Gemini's expected format

See OpenCode PR #4538 for previous attempts at fixing similar issues.

lvsao avatar Jan 16 '26 10:01 lvsao

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

  • #3140: AI_APICallError with Gemini API tool schema validation (similar 'parameters' and 'required' property issues)
  • #8036: Schema validation error with Google/Gemini models (enum values not being strings - same root cause)
  • #365: Google provider tool call schema mismatches with Gemini models (same error pattern with function_declarations)
  • #4512: sanitize tools for Gemini 3 compatibility (Gemini enum validation failures - related root cause)
  • #4665: OpenCode plus Zen Gemini 3 Pro model causes errors (Gemini tool schema validation - same issue pattern)
  • #2082: JSON schema validation errors affecting Gemini and other providers (related tool schema issue)

These issues all relate to tool schema formatting problems when interfacing with Gemini API. The root cause appears to be improper sanitization of tool schemas before sending to the Gemini API (missing required fields, incorrect enum types, unsupported fields like $schema, etc.).

Feel free to ignore if your specific case differs.

github-actions[bot] avatar Jan 16 '26 10:01 github-actions[bot]

believe this is a bug in ur plugin

rekram1-node avatar Jan 16 '26 16:01 rekram1-node

I'm encountering the same issue

Using with github-copilot vendor: Image

Using with google/antigravity

opencode run --model google/antigravity-gemini-3-pro-high "hi" Error: Invalid JSON payload received. Unknown name "parameters" at 'request.tools[0]': Cannot find field.

[Debug Info] Requested Model: antigravity-gemini-3-pro-high Effective Model: gemini-3-pro-high Project: *********** Endpoint: https://daily-cloudcode-pa.sandbox.googleapis.com/v1internal:streamGenerateContent?alt=sse Status: 400 Request ID: N/A Tool Debug Missing: 1 Tool Debug Summary: idx=0, hasCustom=true, customSchema=true, hasFunction=false, functionSchema=false

noises1990 avatar Jan 16 '26 19:01 noises1990