← 返回 Skills 市场
17329971

DeepSeek V4 Reasoning Bug

作者 17329971 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
95
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install deepseek-v4-reasoning-bug
功能描述
排查 DeepSeek V4-Pro 在 tool-call 模式下因 reasoning_content 字段缺失导致的 API 400 错误。适用场景:(1) DeepSeek V4-Pro 使用 thinking/reasoning 模式时遇到 400 error, (2) 报错内容为 'The reaso...
使用说明 (SKILL.md)

DeepSeek V4-Pro reasoning_content Bug

使用方式

当报错文本中出现 The reasoning_content in the thinking mode must be passed back to the API.,优先把本技能当作 协议兼容性 / 消息回放问题 来排查,而不是先怀疑网络、余额或普通鉴权。

问题描述

V4-Pro 启用 thinking(推理)模式时,在多轮对话 + tool call 场景下,DeepSeek API 要求客户端的后续请求必须回传前一轮响应中的 reasoning_content 字段,否则返回 HTTP 400。

The reasoning_content in the thinking mode must be passed back to the API.

触发条件

场景 结果
单轮对话(无工具) ✅ 正常
单轮对话(有工具定义) ✅ 正常
多轮对话(无工具调用) ✅ 正常
多轮对话 + 工具调用 (tool call) 400 报错
多轮对话 + 作为工具(tool)角色 400 报错

核心触发条件: Tool call 产生的 tool 角色消息之后,下一轮对话必须包含上一轮的 reasoning_content,否则报错。

DeepSeek 的约束要求

  • reasoning_content 字段必须存在(值可以是空字符串 ""
  • reasoning_content 完全缺失 → 400
  • reasoning_content 合并到 content 字段中 → 400(DeepSeek 只看字段名,不看内容位置)
  • reasoning_content: ""(空字符串)→ ✅ 200 成功

因此最小修复方案是: 在回传给 DeepSeek 的 assistant 消息中,无条件添加 reasoning_content: "" 字段作为 fallback。

影响范围

  • 任何使用 DeepSeek V4-Pro + thinking 模式的客户端都可能遇到
  • OpenClaw 中:convertMessages 函数会过滤掉内容为空的 thinking block,导致 reasoning_content 字段完全缺失
  • 不影响 V4-Flash(reasoning: false,不产生 reasoning_content
  • 不影响单轮对话场景

排查方法

1. 确认是否是此 bug

检查 API 响应 body 中是否包含:

{
  "error": {
    "message": "The reasoning_content in the thinking mode must be passed back to the API."
  }
}

2. 确认触发场景

查看请求历史,确认是否有 assistant + tool_calls 消息后跟了 tool 角色消息。

3. 临时 workaround

如果必须在当前版本使用 V4-Pro + thinking,可以:

  • 每次请求中手动向 assistant 消息添加 reasoning_content: ""
  • 或在消息处理管线中拦截 assistant 消息,无条件注入空 reasoning_content

4. 检查客户端版本

检查所使用的 DeepSeek SDK / 客户端版本是否已有修复。

临时决策建议

  • 如果当前客户端未修复:不要把 V4-Pro thinking + tool-call 当作稳定主力链路
  • 如果必须继续使用:优先采用“无条件补 reasoning_content: ""”的最小 fallback
  • 如果是纯单轮或无工具场景:可继续验证,但不要把该结果外推到多轮 tool-call 场景

官方修复状态

PR 作者 描述 状态
#71105 lsdsjy DeepSeek 官方 provider 插件 + reasoning_content 回传修复 Review 中
#71146 snowzlm replay DeepSeek reasoning_content on tool-turn history Review 中

两个 PR 于 2026-04-24 提交。修复方案都涉及在 tool-turn 历史消息中回传 reasoning_content 字段。

复现方法

import requests

# 1. 首次请求(带 thinking + tool calls)
response = requests.post("https://api.deepseek.com/v1/chat/completions", json={
    "model": "deepseek-v4-pro",
    "reasoning": {"effort": "low"},
    "messages": [
        {"role": "user", "content": "查询一下天气"}
    ],
    "tools": [{"type": "function", "function": {"name": "get_weather", ...}}]
})

# 2. 模拟 tool call 结果
data = response.json()
assistant_msg = data["choices"][0]["message"]

# 3. 下次请求不传 reasoning_content → 会 400
bad_request = requests.post("https://api.deepseek.com/v1/chat/completions", json={
    "model": "deepseek-v4-pro",
    "reasoning": {"effort": "low"},
    "messages": [
        {"role": "user", "content": "查询一下天气"},
        {
            "role": "assistant",
            "content": assistant_msg["content"],
            "tool_calls": assistant_msg["tool_calls"],
            # ❌ reasoning_content 缺失
        },
        {"role": "tool", "content": "晴,25°C", "tool_call_id": ...}
    ]
})
# → HTTP 400 ❌
安全使用建议
This skill appears coherent and focused: it documents a client-side compatibility bug and a minimal workaround (add reasoning_content: "" to assistant messages). Before using the workaround in production, test it in a staging environment and confirm it doesn't change expected behavior for your clients or downstream tooling. Keep your DeepSeek API keys and other secrets separate (the guide contains example requests but does not manage credentials). Prefer applying the upstream fixes referenced in the PRs when they land instead of relying on a long-term manual injection. If you need higher assurance, inspect your convertMessages/message pipeline code to ensure the injection is limited to the specific assistant/tool-turn case and won't inadvertently expose or persist sensitive content.
功能分析
Type: OpenClaw Skill Name: deepseek-v4-reasoning-bug Version: 1.0.0 The skill bundle is a diagnostic guide for troubleshooting a specific API error (HTTP 400) related to DeepSeek V4-Pro's 'reasoning_content' field during tool calls. It contains documentation and a standard Python reproduction script (SKILL.md) that uses the requests library to demonstrate the protocol requirement, with no evidence of malicious intent, data exfiltration, or harmful instructions.
能力评估
Purpose & Capability
Name/description describe diagnosing and working around DeepSeek V4-Pro reasoning_content behavior. The SKILL.md only requires inspecting API responses and modifying client message handling to include reasoning_content, which aligns with the stated purpose. No unrelated credentials, binaries, or system-wide access are requested.
Instruction Scope
Runtime instructions focus on: identifying the specific 400 error message, confirming the multi-turn+tool-call scenario, applying a minimal workaround (inject reasoning_content: ""), checking client/SDK versions, and following referenced PRs. The guide does not instruct reading arbitrary system files, exfiltrating data, or contacting unexpected remote endpoints beyond the DeepSeek API used in the examples.
Install Mechanism
There is no install spec and no code files; the skill is instruction-only so nothing is written to disk or downloaded during install.
Credentials
The skill declares no environment variables, secrets, or config paths. Example code shows calls to api.deepseek.com but the SKILL.md does not request API keys or other unrelated credentials.
Persistence & Privilege
Skill is not always-enabled and does not request persistent or elevated platform privileges. It advises modifying client message handling (which is a normal, local change) and does not attempt to modify other skills or global agent settings.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install deepseek-v4-reasoning-bug
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /deepseek-v4-reasoning-bug 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial publish: document the reasoning_content 400 bug, trigger conditions, workaround, and OpenClaw PR tracking.
元数据
Slug deepseek-v4-reasoning-bug
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

DeepSeek V4 Reasoning Bug 是什么?

排查 DeepSeek V4-Pro 在 tool-call 模式下因 reasoning_content 字段缺失导致的 API 400 错误。适用场景:(1) DeepSeek V4-Pro 使用 thinking/reasoning 模式时遇到 400 error, (2) 报错内容为 'The reaso... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 95 次。

如何安装 DeepSeek V4 Reasoning Bug?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install deepseek-v4-reasoning-bug」即可一键安装,无需额外配置。

DeepSeek V4 Reasoning Bug 是免费的吗?

是的,DeepSeek V4 Reasoning Bug 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

DeepSeek V4 Reasoning Bug 支持哪些平台?

DeepSeek V4 Reasoning Bug 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 DeepSeek V4 Reasoning Bug?

由 17329971(@17329971)开发并维护,当前版本 v1.0.0。

💬 留言讨论