Function call is missing a thought_signature 报错 (cc-switch)
Quick fix
升级 cc-switch 到最新版本。此问题源于 Gemini API 要求工具调用必须包含 thought_signature,旧版本转发时未自动添加该字段。
Symptom
Section titled “Symptom”CC Switch local proxy failed while handling Codex endpoint /responses. Provider: Gemini Native; model: gemini-3.5-flash; upstream_status: HTTP 400; cause: [{"error":{"code":400,"message":"Function call is missing a thought_signature in functionCall parts. This is required for tools to work correctly, and missing thought_signature may lead to degraded model performance. Additional data, function call `default_api:get_goal` , position 3. Please refer to https://ai.google.dev/gemini-api/docs/thought-signatures for more details.","status":"INVALID_ARGUMENT"}}]Google 更新了 Gemini API(特别是在引入推理模型后),要求 functionCall(函数调用)数据结构中必须包含名为 thought_signature 的字段。当 Codex 或 Claude Code 通过 cc-switch 本地代理调用 Gemini 模型并触发工具使用时,旧版本的 cc-switch 在协议转换过程中没有自动添加或正确转发该字段,导致 Gemini API 返回 HTTP 400 错误。此外,早期版本还存在 prompt_cache_key 字段泄露给 Gemini 上游导致 400 错误的问题,该问题已在 v3.14.0 中修复。
升级 cc-switch 到最新版本(v3.14.0 或更高版本)。该版本修复了 prompt_cache_key 泄露问题,并改善了 Gemini 原生接口的转发能力。
如果使用的是 Gemini Native API,确保在 Provider 配置中正确选择 Gemini 格式,而非仅使用 OpenAI 兼容层。早期版本对 Gemini 原生格式的 function calling 支持不完善。
检查是否开启了本地路由(Needs Local Routing)并正确配置了 base_url。对于 Gemini OpenAI 兼容层,base_url 应为 https://generativelanguage.googleapis.com/v1beta/openai/。
cc-switch provider 配置示例 base_url: "https://generativelanguage.googleapis.com/v1beta/openai/"
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”本页汇总自 7 个真实 issue
- #1786使用New API的中转api代理claude code时提示tool_calls[0]
- #2206Google ai studio配置claude code报错 prompt_cache_key和404,已开启整流器
- #4112谷歌api接入Codex,思考的时候会报错
- #4286希望可以尽快适配gemini3.5
- #4457Gemini模型function calling会报错
- #5415当 Codex 应用通过 cc-switch 调用 Gemini API 的工具时缺少 thought_signature 导致 HTTP 400 错误
- #84274.0.14版本Gemini 4 Argon的官方API在codex中接入时仍然存在问题
- 为什么一思考(使用推理模型)就报错?
- Google 在引入推理模型后,要求 functionCall 必须包含 thought_signature 字段。旧版本 cc-switch 在转发请求时未添加该字段,导致 Gemini API 拒绝请求。
- 如何配置 Gemini 才能避免这个错误?
- 首先确保升级到 cc-switch v3.14.0 或更高版本。如果使用的是 Gemini Native API,确认 provider 类型选择正确。如果使用的是 OpenAI 兼容层,确保 base_url 配置为 https://generativelanguage.googleapis.com/v1beta/openai/ 并启用本地路由。
- 这个错误和 New API 中转站的 tool_calls[0] id cannot be empty 是同一个问题吗?
- 不是。虽然都表现为 invalid_argument,但 tool_calls[0] id 错误是中转站(如 New API)的消息格式校验问题,而 thought_signature 错误是 Gemini 官方 API 对函数调用结构的特定要求。
这是一个非官方社区 wiki,与 cc-switch 作者及项目本身无隶属关系。内容整理自项目公开的 GitHub issues。本站不分发任何软件。