AI_APICallError: GenerateContentRequest.tools[0].function_declarations[32].parameters. required[0]: property is not defined with Gemini API #2077

Closed
opened 2026-02-16 17:34:03 -05:00 by yindo · 4 comments
Owner

Originally created by @soyruiz on GitHub (Oct 13, 2025).

Originally assigned to: @rekram1-node on GitHub.

Related to: #2275, #2241, #3077

Bug Description

Getting AI_APICallError when using Gemini API in Opencode with
function declarations validation error.

Error Details

AI_APICallError:
GenerateContentRequest.tools[0].function_declarations[32].parameters.
required[0]:
property is not defined

Additional Context

This appears to be related to previous Gemini API issues:

  • #2275: URL construction bug (fixed)
  • #2241: Function call turn order error (fixed)
  • #3077: Tool use vs thinking block conflict (fixed)

The error suggests a schema validation issue where a function
declaration has a required parameter but the property name is not
properly defined in the parameters.required array.

Thanks :)

Originally created by @soyruiz on GitHub (Oct 13, 2025). Originally assigned to: @rekram1-node on GitHub. Related to: #2275, #2241, #3077 ## Bug Description Getting AI_APICallError when using Gemini API in Opencode with function declarations validation error. ## Error Details AI_APICallError: GenerateContentRequest.tools[0].function_declarations[32].parameters. required[0]: property is not defined ## Additional Context This appears to be related to previous Gemini API issues: - #2275: URL construction bug (fixed) - #2241: Function call turn order error (fixed) - #3077: Tool use vs thinking block conflict (fixed) The error suggests a schema validation issue where a function declaration has a required parameter but the property name is not properly defined in the parameters.required array. Thanks :)
yindo closed this issue 2026-02-16 17:34:03 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 13, 2025):

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

  • #365: [bug] google provider not running due to tool call schema mismatches - Both issues report the same type of Gemini API error with function_declarations schema validation failing, specifically around 'parameters.required' properties not being defined

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

@github-actions[bot] commented on GitHub (Oct 13, 2025): This issue might be a duplicate of existing issues. Please check: - #365: [bug] google provider not running due to tool call schema mismatches - Both issues report the same type of Gemini API error with function_declarations schema validation failing, specifically around 'parameters.required' properties not being defined Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Oct 13, 2025):

Yeah this is due to mcp server tools, we can sanitize them but they aren't compatible with gemini api out of the box

@rekram1-node commented on GitHub (Oct 13, 2025): Yeah this is due to mcp server tools, we can sanitize them but they aren't compatible with gemini api out of the box
Author
Owner

@rekram1-node commented on GitHub (Dec 1, 2025):

This should fix it: https://github.com/sst/opencode/commit/0331931f562239abf3adaebfb18539adf6665359

in next release

@rekram1-node commented on GitHub (Dec 1, 2025): This should fix it: https://github.com/sst/opencode/commit/0331931f562239abf3adaebfb18539adf6665359 in next release
Author
Owner

@jeffscottward commented on GitHub (Dec 18, 2025):

I am still getting this error.
I am trying to use Docker MCP toolkit as an aggregation for all my MCPs to stop it from eating the context window.
My current open code version is 1.0.167
@rekram1-node should this be reopened?

Specifically, my error says exactly this:

* GenerateContentRequest.tools[0].function_declarations[21].parameters.required[1]: property is not defined* 

Since I think I'm already at the latest version, and that this shouldn't be an issue, I asked AI, and it said this.


If you're already on a version that includes commit 0331931, then the issue is likely one of these scenarios:

Possible Explanations

  1. The Fix Doesn't Cover All MCP Servers
    The commit may have fixed specific servers mentioned in issue #3140, but the Docker MCP Gateway itself might be generating malformed schemas for other MCP servers (like the ones you're using). The fix in 0331931 may have been targeted at OpenCode's built-in tool declarations, not the MCP Gateway's schema translation layer.

  2. Docker MCP Gateway Issue (Not OpenCode)
    The problem might actually be in Docker Desktop's MCP Gateway itself, not OpenCode. The Gateway is responsible for translating MCP server schemas into a format that AI models can consume. If Docker's Gateway has bugs in how it generates Gemini-compatible schemas, OpenCode can't fix that—Docker would need to release an update to their MCP Toolkit.​

  3. Specific MCP Servers Have Invalid Schemas
    The MCP servers you enabled (GitHub, Neon, Next.js, etc.) might have invalid tool declarations in their own source code. When the Gateway passes these through to OpenCode and then to Gemini, the validation fails. This would require fixes from the individual MCP server maintainers.

What You Can Check
To determine where the issue actually is:

  1. Check Your OpenCode Version
    Run this command to see exactly which version you're on:

bash
opencode --version
The fix from commit 0331931 should be in version 1.0.137 or later (based on the Chocolatey package dated December 17, 2025).​

  1. Check Docker MCP Toolkit Version
    The issue might be in Docker's MCP Gateway, not OpenCode. Check your Docker Desktop version:

Open Docker Desktop

Go to Settings → General

Look for "MCP Toolkit" or check the Docker version

  1. Test Without Docker MCP Gateway
    Temporarily remove the MCP_DOCKER configuration from your OpenCode config to see if errors persist with other tools. If errors disappear, it confirms the Gateway is the problem.

  2. Check Which Specific Tools Are Failing
    The error indices (13, 63, 103, 114) point to specific tools. You can inspect the actual schema being sent to Gemini by enabling debug logging in OpenCode or checking the Gateway's output directly.

Most Likely Scenario
Given that you're on the latest OpenCode version and the issue persists, this is almost certainly a Docker MCP Gateway bug, not an OpenCode bug. The Gateway is translating MCP server schemas incorrectly for Gemini's strict validation requirements.

Your current workaround (disabling problematic MCP servers) is the right approach until Docker releases an updated MCP Toolkit that properly formats function declarations for Gemini's API. Other AI models like Claude are more lenient with schema validation, which is why this specifically affects Gemini users.​

@jeffscottward commented on GitHub (Dec 18, 2025): I am still getting this error. I am trying to use `Docker MCP toolkit` as an aggregation for all my MCPs to stop it from eating the context window. My current open code version is `1.0.167` @rekram1-node should this be reopened? Specifically, my error says exactly this: ```js * GenerateContentRequest.tools[0].function_declarations[21].parameters.required[1]: property is not defined* ``` Since I think I'm already at the latest version, and that this shouldn't be an issue, I asked AI, and it said this. --------------- If you're already on a version that includes commit 0331931, then the issue is likely one of these scenarios: Possible Explanations 1. The Fix Doesn't Cover All MCP Servers The commit may have fixed specific servers mentioned in issue #3140, but the Docker MCP Gateway itself might be generating malformed schemas for other MCP servers (like the ones you're using). The fix in 0331931 may have been targeted at OpenCode's built-in tool declarations, not the MCP Gateway's schema translation layer. 2. Docker MCP Gateway Issue (Not OpenCode) The problem might actually be in Docker Desktop's MCP Gateway itself, not OpenCode. The Gateway is responsible for translating MCP server schemas into a format that AI models can consume. If Docker's Gateway has bugs in how it generates Gemini-compatible schemas, OpenCode can't fix that—Docker would need to release an update to their MCP Toolkit.​ 3. Specific MCP Servers Have Invalid Schemas The MCP servers you enabled (GitHub, Neon, Next.js, etc.) might have invalid tool declarations in their own source code. When the Gateway passes these through to OpenCode and then to Gemini, the validation fails. This would require fixes from the individual MCP server maintainers. What You Can Check To determine where the issue actually is: 1. Check Your OpenCode Version Run this command to see exactly which version you're on: bash opencode --version The fix from commit 0331931 should be in version 1.0.137 or later (based on the Chocolatey package dated December 17, 2025).​ 2. Check Docker MCP Toolkit Version The issue might be in Docker's MCP Gateway, not OpenCode. Check your Docker Desktop version: Open Docker Desktop Go to Settings → General Look for "MCP Toolkit" or check the Docker version 3. Test Without Docker MCP Gateway Temporarily remove the MCP_DOCKER configuration from your OpenCode config to see if errors persist with other tools. If errors disappear, it confirms the Gateway is the problem. 4. Check Which Specific Tools Are Failing The error indices (13, 63, 103, 114) point to specific tools. You can inspect the actual schema being sent to Gemini by enabling debug logging in OpenCode or checking the Gateway's output directly. Most Likely Scenario Given that you're on the latest OpenCode version and the issue persists, this is almost certainly a Docker MCP Gateway bug, not an OpenCode bug. The Gateway is translating MCP server schemas incorrectly for Gemini's strict validation requirements. Your current workaround (disabling problematic MCP servers) is the right approach until Docker releases an updated MCP Toolkit that properly formats function declarations for Gemini's API. Other AI models like Claude are more lenient with schema validation, which is why this specifically affects Gemini users.​
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2077