openclaw - 💡(How to fix) Fix Feature Request: 推理模型多轮 Tool Call 的 reasoning_content 回传策略声明

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

"error": {

Fix Action

Fix / Workaround

  • 所有 reasoning: true 的 OpenAI-compatible 自定义 provider 模型
  • 仅在 tool call 多轮场景中触发(单轮请求不受影响)
  • 当前 workaround 是将模型 reasoning 设为 false,但牺牲了 CoT 推理能力

随着支持 reasoning 的模型越来越多,OpenClaw 应该提供一个声明式的回传策略配置,而不是依赖用户逐个发现、手动 workaround。

Code Example

{
  "error": {
    "code": "400",
    "message": "Param Incorrect",
    "param": "The reasoning_content in the thinking mode must be passed back to the API."
  }
}

---

2轮请求 = [user, assistant(tool_calls), tool(result)] + tools
           ↑ 缺少上一轮 assistant 的 reasoning_content

---

2轮请求 = [user, assistant(content="", tool_calls, reasoning_content="..."), tool(result)] + tools

---

models:
  providers:
    mimo:
      models:
        - id: "mimo-v2.5-pro"
          reasoning: true
          reasoningEchoPolicy: "include_in_assistant"  # 多轮 tool call 时回传 reasoning_content
RAW_BUFFERClick to expand / collapse

Feature Request: 推理模型多轮 Tool Call 的 reasoning_content 回传策略

问题概述

支持 reasoning/thinking 的模型(如 MiMo v2.5-Pro)在多轮 tool call 场景中要求:第 N 轮请求必须回传第 N-1 轮响应中的 reasoning_content 字段

OpenClaw 当前的多轮 tool call 流程只保留 tool_calls 和 tool result 消息,不携带上一轮的 reasoning_content,导致 MiMo API 直接拒绝:

{
  "error": {
    "code": "400",
    "message": "Param Incorrect",
    "param": "The reasoning_content in the thinking mode must be passed back to the API."
  }
}

复现步骤

  1. 配置 OpenClaw 使用 mimo-v2.5-proreasoning: true
  2. 触发一个需要 tool call 的任务
  3. 第 1 轮(user → assistant tool_calls)正常
  4. 第 2 轮(assistant tool_calls + tool result → assistant response)失败,fallback 到下一候选模型

根因分析

MiMo v2.5 系列的推理模式(默认开启,即使不传 enable_thinking)在 tool call 场景中有一个非标准要求:必须回传上一轮的 reasoning_content

OpenClaw 当前的消息构建逻辑:

第2轮请求 = [user, assistant(tool_calls), tool(result)] + tools
           ↑ 缺少上一轮 assistant 的 reasoning_content

正确格式应为:

第2轮请求 = [user, assistant(content="", tool_calls, reasoning_content="..."), tool(result)] + tools

影响范围

  • 所有 reasoning: true 的 OpenAI-compatible 自定义 provider 模型
  • 仅在 tool call 多轮场景中触发(单轮请求不受影响)
  • 当前 workaround 是将模型 reasoning 设为 false,但牺牲了 CoT 推理能力

建议方案

方案 A(推荐):模型配置声明 reasoningEchoPolicy

在模型配置中新增一个声明式字段,让 OpenClaw 自动处理不同模型的推理回传策略:

models:
  providers:
    mimo:
      models:
        - id: "mimo-v2.5-pro"
          reasoning: true
          reasoningEchoPolicy: "include_in_assistant"  # 多轮 tool call 时回传 reasoning_content

策略枚举值:

策略值行为适用模型
none(默认)不回传,当前行为OpenAI GPT-4o, Claude, Gemini
include_in_assistant拼回 assistant 消息MiMo v2.5, DeepSeek(某些场景)
as_system_prefix作为 system prompt 前缀未来可能的其他模型

方案 B:thinkingFormat 隐式推导

compat.thinkingFormat: "deepseek" 时,OpenClaw 已经识别出 DeepSeek 格式,可以隐式地在 tool call 多轮中回传 reasoning_content。这样用户不需要额外配置。

但问题是 DeepSeek 原生 API 不要求回传,所以这个隐含规则只适用于非 DeepSeek 域名但使用 DeepSeek 格式的模型(如 MiMo),逻辑上不够清晰。

为什么这是一个通用需求而非单一模型问题

推理类模型的协议尚未完全统一:

模型reasoning 字段多轮 tool call 回传要求
OpenAI o-seriesreasoning_effort不需要
DeepSeekenable_thinking不需要(原生 DeepSeek 域名)
MiMo v2.5默认开启需要
Qwen3 (thinking)enable_thinking待验证

随着支持 reasoning 的模型越来越多,OpenClaw 应该提供一个声明式的回传策略配置,而不是依赖用户逐个发现、手动 workaround。

技术细节

OpenClaw 源码中消息构建的关键位置:

  • transport-stream-DINDUbV2.js — 请求体构建
  • openai-transport-stream-BWwvx0MZ.js — delta 解析,已有 reasoning_content 处理逻辑(kind: "thinking"
  • stream-DKDJJ-CW.jsenable_thinking + preserve_thinking 注入

需要在 tool call 多轮场景中,将上一轮响应的 reasoning_content 合并到 assistant 消息中发送。

环境

  • OpenClaw: 2026.5.12 (f066dd2)
  • Provider: mimo (openai-completions API)
  • Model: mimo-v2.5-pro
  • 场景: tool call 多轮对话

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Feature Request: 推理模型多轮 Tool Call 的 reasoning_content 回传策略声明