What happened?
When using the Gemini model (specifically gemini-2.5-pro as shown in the terminal), I encountered a crash with an API Error 400. The error message specifically states Invalid JSON payload received. Unknown name "$schema", indicating that the $schema field in the tool parameters is being rejected by the API.
It appears that when MCP tools (which use parametersJsonSchema) are processed, the schema is passed directly to the API without sanitization. The Gemini API does not support the $schema property in the function declaration parameters.
Terminal Output:
✕ [API Error: 400 400: Invalid JSON payload received. Unknown name "$schema" at 'tools[0].function_declarations[0].parameters': Cannot find field. Invalid JSON payload received. Unknown name "$schema" at 'tools[0].function_declarations[10].parameters': Cannot find field. Invalid JSON payload received. Unknown name "$schema" at 'tools[0].function_declarations[11].parameters': Cannot find field.]
Relevant Code Location:
In packages/core/src/core/openaiContentGenerator/converter.ts
What did you expect to happen?
The application should automatically sanitize tool parameters before sending them to the Gemini API. Specifically, it should remove the $schema property from the JSON schema, as it is not a valid field for the tool definition in the Gemini API's expected format. This would prevent the 400 error and allow tool usage to proceed normally.
Client information
Client Information
Run qwen to enter the interactive CLI, then run the /about command.
$ qwen /about
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ 关于 Qwen Code │
│ │
│ CLI 版本 0.4.1 │
│ Git 提交 628094ec │
│ 模型 gemini-2.5-pro │
│ 沙箱 no sandbox │
│ 操作系统平台 darwin │
│ 操作系统架构 arm64 │
│ 操作系统版本 25.1.0 │
│ Node.js 版本 v20.19.3 │
│ NPM 版本 10.8.2 │
│ 会话 ID fd9d960f-dc16-4d71-8da5-b4954884efbf │
│ 认证方式 openai │
│ 基础 URL https │
│ 内存使用 227.9 MB │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Login information
No response
Anything else we need to know?
No response
What happened?
When using the Gemini model (specifically gemini-2.5-pro as shown in the terminal), I encountered a crash with an API Error 400. The error message specifically states Invalid JSON payload received. Unknown name "$schema", indicating that the $schema field in the tool parameters is being rejected by the API.
It appears that when MCP tools (which use parametersJsonSchema) are processed, the schema is passed directly to the API without sanitization. The Gemini API does not support the $schema property in the function declaration parameters.
Terminal Output:
✕ [API Error: 400 400: Invalid JSON payload received. Unknown name "$schema" at 'tools[0].function_declarations[0].parameters': Cannot find field. Invalid JSON payload received. Unknown name "$schema" at 'tools[0].function_declarations[10].parameters': Cannot find field. Invalid JSON payload received. Unknown name "$schema" at 'tools[0].function_declarations[11].parameters': Cannot find field.]Relevant Code Location:
In packages/core/src/core/openaiContentGenerator/converter.ts
What did you expect to happen?
The application should automatically sanitize tool parameters before sending them to the Gemini API. Specifically, it should remove the $schema property from the JSON schema, as it is not a valid field for the tool definition in the Gemini API's expected format. This would prevent the 400 error and allow tool usage to proceed normally.
Client information
Client Information
Run
qwento enter the interactive CLI, then run the/aboutcommand.Login information
No response
Anything else we need to know?
No response