Skip to content

[codex chat 桥] 思考模型多轮工具调用: 工具轮 content=null 与 reasoning 缓存 miss 导致上游 400 #458

Description

@tangjunyi1

环境

  • cc-switch-cli v5.10.4(Linux x64 musl)
  • codex-cli 0.153.4
  • 供应商:第三方 OpenAI 兼容网关(自建聚合网关,Chat Completions 端点),思考型 deepseek 模型,apiFormat = "openai_chat" 走本地代理接管做 Responses→Chat 转换
  • meta:codexChatReasoning = { supportsThinking: true, supportsEffort: true, thinkingParam: "thinking", effortParam: "reasoning_effort", effortValueMode: "passthrough", outputFormat: "auto" }

现象

多轮工具调用对话(连续 2~5 次工具调用,尤其是「assistant 先输出一段文字再发 tool_calls」的轮次)触发上游 400,两种错误交替出现:

  1. The \reasoning_content` in the thinking mode must be passed back to the API.`
  2. Failed to deserialize the JSON body into the target type: messages[N]: content should be a string or a list

单轮/两轮纯文本对话正常;v5.9.2→v5.10.4 升级后 2 轮工具调用可过,5 轮仍必挂(模型行为有随机性,输出文字+工具调用混合轮时更容易触发)。

抓包证据

在桥与上游之间加捕获层,记录桥实际发出的请求体。稳定的轮次结构如下(content 已脱敏,只看形状):

[ 3] assistant content=str(39)      reasoning=str(367)   -
[ 4] assistant content=None         reasoning=str(367)   tool_calls(1)
[ 6] assistant content=None         reasoning=str(9)     tool_calls(1)

可以看到两个问题:

复现

  1. 配一个思考型模型的 openai_chat 供应商(严格校验 reasoning_content 回传 + 拒收 content:null 的网关,或官方 deepseek interleaved thinking)
  2. codex exec "依次执行 5 条 shell 命令,每条命令前先用一句话说明你要做什么,最后把 5 个输出合并成一行回复"(强制「文字+工具调用」混合轮)

期望

  • 工具调用轮 content"" 而不是 null
  • 思考模式下 assistant 轮的 reasoning 缓存 miss 时兜底发占位符(上游仅校验存在性时不影响语义)

感谢!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions