Skip to content

[Bug]Gemini 模型工具声明阶段报 400 错误:Unknown name "examples" at function_declarations #7572

@konodiodaaaaa1

Description

@konodiodaaaaa1

What happened / 发生了什么

在使用 openai_chat_completion 提供商(通过中转 API)调用 Gemini 模型(如 gemini-3.1-pro-preview)时,如果启用的插件在注册工具时带有 examples 字段(例如 claude_code、hapi_coding 等插件),大模型会直接抛出 400 错误并拒绝响应。
之前的 PR #7386#7134 完美修复了 Gemini 工具返回阶段的格式校验问题,但遗漏了在工具声明阶段 (Function Declarations) 的校验。
由于 OpenAI 和 DeepSeek 的接口比较宽容,会自动忽略多余的 examples 字段,但 Gemini 的 OpenAPI Schema 校验极度严格,遇到不认识的字段直接拒收。目前 AstrBot 官方生态内的插件普遍带有 examples,导致配置 Gemini 后大面积无法使用工具。

Reproduce / 如何复现?

配置大模型为 gemini-3.1-pro-preview(走 OpenAI 格式转接)。开启并配置任意注册工具时带有 examples 字段的插件(如 claude_code)。框架向 API 提交携带该工具的 payload,立刻触发 400 报错崩溃。

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

Astrbot版本:4.23.1
部署方式:Windows Launcher
提供商:OpenAl Compatible

OS

Windows

Logs / 报错日志

[13:30:21.036] [Core] [WARN] [v4.23.1] [runners.tool_loop_agent_runner:350]: Chat Model jeniya/gemini-3-flash-preview request error: Error code: 429 - {'error': {'message': 'Invalid JSON payload received. Unknown name "examples" at 'tools[0].function_declarations[38]..properties[0].value': Cannot find field.\nInvalid JSON payload received. Unknown name "examples" at 'tools[0].function_declarations[39]..properties[0].value': Cannot find field.\nInvalid JSON payload received. Unknown name "examples" at 'tools[0].function_declarations[40]..properties[0].value': Cannot find field.\nInvalid JSON payload received. Unknown name "examples" at 'tools[0].function_declarations[40]..properties[1].value': Cannot find field.\nInvalid JSON payload received. Unknown name "examples" at 'tools[0].function_declarations[41]..properties[0].value': Cannot find field.\nInvalid JSON payload received. Unknown name "examples" at 'tools[0].function_declarations[42]..properties[0].value': Cannot find field.\nInvalid JSON payload received. Unknown name "examples" at 'tools[0].function_declarations[44]..properties[0].value': Cannot find field.\nInvalid JSON payload received. Unknown name "examples" at 'tools[0].function_declarations[47]..properties[0].value': Cannot find field. (request id: 20260415133004251996465A32XL8KX)', 'type': 'upstream_error', 'param': '', 'code': '400'}}

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • Yes!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:providerThe bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions