Repository navigation
Conversation
Claude 适配器在 Anthropic 响应转 OpenAI 格式时丢弃了 thinking 块的
signature,并在构建 Claude 请求时忽略 reasoning_content,导致需要回传
完整 thinking 块(文本 + signature)的上游(如 DeepSeek Anthropic 渠道)
在多轮对话时报 HTTP 400 "thinking must be passed back"。
三处修复:
- 流式响应:signature_delta 编码为 {"_sig":"<sig>"} 写入 reasoning_content,
不再用换行符替换丢弃
- 非流式响应:thinking 文本末尾追加同样的 signature 标记
- 请求路径:assistant 消息的 reasoning_content 还原为完整的
{type:"thinking", thinking, signature} 块后再发送上游
无 thinking 的普通对话不受影响,新逻辑仅在 reasoning_content 非空时触发。
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughThe conversion paths now preserve assistant reasoning content and Claude signatures. Claude signatures use JSON ChangesReasoning preservation
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This is a localized request-conversion fix with no actionable merge-blocking risk remaining; the standalone relaykit build should be completed as a normal validation step. Sequence Diagram(s)sequenceDiagram
participant ClaudeResponse
participant OpenAIChatResponse
participant OpenAIAssistantMessage
participant ClaudeRequest
ClaudeResponse->>OpenAIChatResponse: append JSON _sig marker
OpenAIChatResponse->>OpenAIAssistantMessage: preserve reasoning content
OpenAIAssistantMessage->>ClaudeRequest: create thinking block with signature
ClaudeRequest->>ClaudeRequest: place thinking before text or tool use
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
51fdfc5 to
2b6f1df
Compare
Claude 适配器在 Anthropic 响应转 OpenAI 格式时丢弃了 thinking 块的 signature,并在构建 Claude 请求时忽略 reasoning_content,导致需要回传 完整 thinking 块(文本 + signature)的上游(如 DeepSeek Anthropic 渠道) 在多轮对话时报 HTTP 400 "thinking must be passed back"。
三处修复:
无 thinking 的普通对话不受影响,新逻辑仅在 reasoning_content 非空时触发。
Important
我们公司的模型网关也基于new-api搭建,在使用过程中发现的这个bug,具体触发场景是网关配置了anthropic渠道的deepseek模型,用户本地使用codex + ccswitch采用openai的格式请求网关,会发生偶发的“ HTTP 400; cause: The request is invalid: The content[].thinking in the thinking mode must be passed back to the API.. Please check the request body, required fields, and request format.”这种报错。
经过排查发现原因其实很简单,deepSeek 要求开启 thinking 模式后,上轮产生的 thinking 内容块(含加密签名)必须在下轮请求中原样传回。但网关在 claude↔openAI 格式转换时, 响应路径丢弃了签名 , 请求路径忽略了 reasoning_content ,导致 thinking 块在多轮对话中永久丢失,上游返回 400。
📝 变更描述 / Description
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
(请在此粘贴截图、关键日志或测试报告,以证明变更生效)

修改前:
报错:CC Switch local proxy failed while handling Codex endpoint /responses. Provider: deepseek v4; model: deepseek-v4-pro[1m]; upstream_status: HTTP 400; cause: The request is invalid: The content[].thinking in the thinking mode must be passed back to the API.. Please check the request body, required fields, and request format.
修改后测试:

运行正常
Summary by CodeRabbit
New Features
Bug Fixes