Skip to content

Gemini schema sanitizer doesn't strip contentEncoding from MCP tool schemas #15408

Closed as not planned

Description

@RaviTharuma

Bug Description

When using Gemini-based agents (e.g. oh-my-opencode Junior Sisyphus) with MCP servers that define contentEncoding in their tool schemas, the Gemini API rejects the request with a 400 error.

The existing schema sanitizer (introduced in v1.0.137 via #3140) strips properties/required from non-object types, but does not strip contentEncoding or contentMediaType — both valid JSON Schema keywords that Gemini's function calling API doesn't support.

Error

Bad Request: {
  "error": {
    "code": 400,
    "message": "Invalid JSON payload received. Unknown name \"contentEncoding\" at 'request.tools[0].function_declarations[87].parameters.properties[4].value.items.properties[2].value': Cannot find field.\nInvalid JSON payload received. Unknown name \"contentEncoding\" at 'request.tools[0].function_declarations[88].parameters.properties[4].value.items.properties[2].value': Cannot find field.\nInvalid JSON payload received. Unknown name \"contentEncoding\" at 'request.tools[0].function_declarations[89].parameters.properties[4].value.items.properties[2].value': Cannot find field.",
    "status": "INVALID_ARGUMENT"
  }
}

Reproduction

  1. Configure an MCP server that uses contentEncoding in tool schemas (e.g. chrome-devtools-mcp — tools like take_screenshot, take_snapshot, upload_file use contentEncoding: "base64")
  2. Start a session with a Gemini model
  3. The API call fails with the above error

Expected Behavior

The Gemini schema sanitizer should strip unsupported JSON Schema keywords before sending function declarations. At minimum:

  • contentEncoding
  • contentMediaType

Environment

  • opencode v1.2.15
  • MCP server: chrome-devtools-mcp (mcpm)
  • Gemini model via oh-my-opencode Junior Sisyphus agent

Related

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 27, 2026
  2. Br1an67 commented on Mar 1, 2026

    @Br1an67

    I'd like to work on this. The fix adds contentEncoding and contentMediaType stripping to the existing sanitizeGemini function in transform.ts.

    PR: #15593

  3. assigned and unassigned on Apr 26, 2026
  4. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. github-actions commented on Jul 3, 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

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions