Function call is missing a thought_signature - Gemini
Quick fix
升级或修补 cc-switch 的 forwarder/session 逻辑,让 Codex 工具调用请求携带 thought_signature
Symptom
Section titled “Symptom”CC Switch local proxy failed while handling Codex endpoint /responses. Provider: Google; model: models/gemini-3.1-flash-lite; 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:mcp__node_repl__js` , position 37. Please refer to https://ai.google.dev/gemini-api/docs/thought-signatures for more details.","status":"INVALID_ARGUMENT"}}]该问题的核心是 Gemini API 对 functionCall 数据结构提出了新的要求:在涉及工具调用时必须包含 thought_signature 字段。多个 issue 中用户看到的都是同一类 HTTP 400 INVALID_ARGUMENT 报错,只是模型名、function call 名称和 position 不同。例如 Codex 调用 Gemini 时,一旦触发工具调用,cc-switch 本地代理转发给 Gemini 的请求缺少 thought_signature,就会被上游拒绝。
另有部分相关报错属于同一 invalid_argument 大类但机制不同:#2206 是早期版本把 Claude 的 prompt_cache_key 泄漏到 Google AI Studio / Gemini 请求中,导致 Unknown name "prompt_cache_key" 的 400 错误,维护者确认已在 v3.14.0 修复;#1786 则是 New API 中转 Claude Code 时 tool_calls[0] id cannot be empty,也属于 invalid_argument,但和 thought_signature 不是同一根因。本页修复主要针对 Gemini thought_signature 缺失导致的工具调用失败。
如果你使用的是 v3.14.0 之前的版本,先升级 cc-switch,避免 prompt_cache_key 泄漏到 Google AI Studio / Gemini 请求中。
对于 Gemini thought_signature 问题,升级到包含修复的 cc-switch 版本;issue 中用户确认在 v3.20 通过更新 session 与 forwarder 相关逻辑后可用。
如果暂时无法升级,可参考 issue 中用户提供的补丁思路,修改 cc-switch 的代理转发逻辑,使 Codex 的 /responses 工具调用在转发到 Gemini API 时补充 thought_signature。
cc-switch\src-tauri\src\proxy\forwarder.rs # 按 issue #5415 中用户提供的 v3.20 补丁思路更新 forwarder/session 逻辑在 Codex 中重新触发一次工具调用,确认不再出现 Function call is missing a thought_signature 的 HTTP 400 错误。
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”本页汇总自 5 个真实 issue
- 这个错误是 Google API 的问题还是 cc-switch 的问题?
- 从 issue 看,直接原因是 cc-switch 转发 Codex 工具调用到 Gemini 时没有带上 Gemini 新要求的 thought_signature 字段,因此上游返回 HTTP 400。
- 没有调用工具时为什么正常?
- 多个 issue 中提到,没有触发工具调用时请求不涉及 functionCall,因此不会缺少 thought_signature;一旦 Codex 调用工具就会报错。
- prompt_cache_key 报错和 thought_signature 是同一个问题吗?
- 不是同一个根因,但都属于 invalid_argument 类错误。prompt_cache_key 是早期版本把 Claude 字段泄漏给 Google API,维护者说已在 v3.14.0 修复;thought_signature 是 Gemini 工具调用新增字段未适配。
- issue 里提到哪个版本可能可用?
- 有用户在 issue #5415 中表示按 v3.20 修改 session 和 forwarder 两个文件后可以工作,但输入中没有维护者明确确认这是正式修复版本。
这是一个非官方社区 wiki,与 cc-switch 作者及项目本身无隶属关系。内容整理自项目公开的 GitHub issues。本站不分发任何软件。