feat: return reasoning_content with tool_calls for DeepSeek models#2543
Conversation
|
Claude finished @farion1231's task in 1m 9s —— View job Review: PR #2543
LGTM — no blocking issues. Small, well-scoped change that extends the existing Moonshot/Kimi
The substring-match approach ( Note on the unchecked clippy box in the PR description: |
|
Codex Review: Didn't find any major issues. 🎉 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
farion1231
left a comment
There was a problem hiding this comment.
非常感谢您的贡献,请查看一下有以下问题吗:
PR #2543 方向正确,但目前只解决了请求侧识别 DeepSeek 并尝试回传 reasoning_content。
真正修复 #2282 还需要补响应侧转换,否则真实的 DeepSeek reasoning_content 会在返回给 Claude Code 时丢失。
需要修改 streaming.rs::Delta:为 reasoning 增加 #[serde(alias = "reasoning_content")],兼容 DeepSeek 流式返回字段。
需要修改 openai_to_anthropic:把非流式响应里的 message.reasoning_content 映射为 Anthropic thinking block。
当前代码在拿不到真实 thinking 时会回传占位 "tool call",这不满足 DeepSeek tool call 场景“必须完整传回 reasoning_content”的要求,仍可能导致 400,或造成 thinking 丢失、答案质量下降、调试困难
确实有问题,我修改一下 |
|
@farion1231 修改好了
|
…arion1231#2543) * feat: return reasoning_content with tool_calls for DeepSeek models * fix: correct reasoning_content handling for DeepSeek tool_calls * test: cover DeepSeek reasoning content round trip --------- Co-authored-by: Jason <[email protected]>
…arion1231#2543) * feat: return reasoning_content with tool_calls for DeepSeek models * fix: correct reasoning_content handling for DeepSeek tool_calls * test: cover DeepSeek reasoning content round trip --------- Co-authored-by: Jason <[email protected]>
…arion1231#2543) * feat: return reasoning_content with tool_calls for DeepSeek models * fix: correct reasoning_content handling for DeepSeek tool_calls * test: cover DeepSeek reasoning content round trip --------- Co-authored-by: Jason <[email protected]>
…arion1231#2543) * feat: return reasoning_content with tool_calls for DeepSeek models * fix: correct reasoning_content handling for DeepSeek tool_calls * test: cover DeepSeek reasoning content round trip --------- Co-authored-by: Jason <[email protected]>
Preserve reasoning_content alongside tool_calls for DeepSeek/Moonshot/Kimi models. When an assistant message contains both thinking content and tool_calls, extract thinking into the reasoning_content field at the message level — required by these providers to avoid upstream errors. Reference: farion1231/cc-switch#2543

Summary / 概述
Add DeepSeek to the OpenAI Chat reasoning_content compatibility path so DeepSeek tool call requests preserve reasoning_content alongside tool_calls, matching the existing Moonshot/Kimi behavior.
为 DeepSeek 接入 OpenAI Chat 的
reasoning_content兼容逻辑,使 DeepSeek 在工具调用场景下与现有 Moonshot/Kimi 行为一致,在tool_calls同级回传reasoning_content。Related Issue / 关联 Issue
Fixes #2282 #2277 #2531
Screenshots / 截图
Checklist / 检查清单
pnpm typecheckpasses / 通过 TypeScript 类型检查pnpm format:checkpasses / 通过代码格式检查cargo clippypasses (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)cargo clippy 因为其他文件而不通过