[Bug]: Google GenAI provider fails with extra_forbidden for tool parameters containing $schema
What version of Kimi Code CLI is running?
1.2
Which open platform/subscription were you using?
google_genai
Which model were you using?
gemini-3-pro-preview
What platform is your computer?
Linux
What issue are you seeing?
When using Exa MCP (https://mcp.exa.ai/mcp) or other tools that provide standard JSON Schema parameters, a validation error occurs during the tool calling phase:
Unexpected error: 1 validation error for FunctionDeclaration
parameters.$schema
Extra inputs are not permitted [type=extra_forbidden, input_value='http://json-schema.org/draft-07/schema#', input_type=str]
For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
This error is caused by the google-genai SDK's Pydantic model enforcing strict validation on the FunctionDeclaration parameters field, rejecting the $schema metadata field.
What steps can reproduce the bug?
- Configure the
google_genaiprovider. - Add Exa MCP:
kimi mcp add exa https://mcp.exa.ai/mcp. - Execute any command triggering a search (e.g.,
Search for latest AI news using exa). - The error occurs.
Minimal Reproduction Code (using uv):
uv run --no-project --python 3.12 --with google-genai --with pydantic python -c "
from google.genai.types import FunctionDeclaration
try:
FunctionDeclaration(
name='test',
description='test',
parameters={'$schema': 'http://json-schema.org/draft-07/schema#', 'type': 'object'}
)
except Exception as e:
print(e)
"
What is the expected behavior?
Tool calls should proceed successfully. The provider should strip unsupported JSON Schema keywords (like $schema) from the parameters before passing them to the google-genai SDK.
I'll try to fix it.
The tool_to_google_genai() function passes tool.parameters directly to FunctionDeclaration, and the google-genai SDK's Pydantic model rejects $schema and similar JSON Schema metadata fields. Fix: strip unsupported keys ($schema, $id, $ref, $comment, definitions, $defs) before passing to the SDK.