openclaw - ✅(Solved) Fix DeepSeek thinking mode + tool calls = HTTP 400: reasoning_content not preserved [2 pull requests, 1 comments, 2 participants]

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…
GitHub stats
openclaw/openclaw#71407Fetched 2026-04-26 05:13:10
View on GitHub
Comments
1
Participants
2
Timeline
9
Reactions
0
Participants
Timeline (top)
cross-referenced ×4closed ×1commented ×1mentioned ×1

Error Message

❌ Error Message

Root Cause

🔍 Root Cause

Fix Action

Fixed

PR fix notes

PR #71445: fix: disable validateAnthropicTurns for strict OpenAI-compatible transports

Description (problem / solution / changelog)

Summary

Fixes #71407 — DeepSeek thinking mode + tool calls = HTTP 400.

DeepSeek API requires reasoning_content to be passed back in all subsequent requests during tool-call loops. The validateAnthropicTurns policy flag was enabled for all strict OpenAI-compatible providers (openai-completions modelApi), which includes DeepSeek, Cerebras, xAI, Mistral, and others. When enabled, stripDanglingAnthropicToolUses drops thinking blocks from assistant messages when tool calls lack matching tool results — which strips the reasoning_content that DeepSeek needs.

The fix: Remove isStrictOpenAiCompatible from the validateAnthropicTurns condition in buildUnownedProviderTransportReplayFallback. This flag is only meaningful for Anthropic-family transports (anthropic-messages, bedrock-converse-stream) where the dangling-tool-use API rule applies. OpenAI-compatible providers handle dangling tool calls through their own transform layers (transformTransportMessages, pi-ai transformMessages).

Changes:

  • src/agents/transcript-policy.ts:119: restrict validateAnthropicTurns to isAnthropic only (was isAnthropic || isStrictOpenAiCompatible)
  • src/agents/transcript-policy.test.ts: update two test expectations for the unowned fallback path

Test plan

  • transcript-policy.test.ts — all 29 tests pass
  • pi-embedded-helpers.validate-turns.test.ts — all 31 tests pass
  • Provider-owned policies (MiniMax, Bedrock, etc.) unaffected — verified in test matrix
  • DeepSeek tool-call + reasoning round-trips should no longer produce HTTP 400

🤖 Generated with Claude Code

Changed files

  • src/agents/transcript-policy.test.ts (modified, +2/-2)
  • src/agents/transcript-policy.ts (modified, +1/-1)

PR #71447: fix: restrict validateAnthropicTurns to Anthropic transports only

Description (problem / solution / changelog)

Summary

Fixes #71407

DeepSeek API requires reasoning_content to be passed back in subsequent requests during tool-call loops. The validateAnthropicTurns flag was enabled for all strict OpenAI-compatible providers, which includes DeepSeek. When enabled, stripDanglingAnthropicToolUses drops thinking blocks from assistant messages when tool calls lack matching tool results, stripping the reasoning_content that DeepSeek needs.

This change removes isStrictOpenAiCompatible from the validateAnthropicTurns condition so the flag only applies to Anthropic-family transports (anthropic-messages, bedrock-converse-stream). OpenAI-compatible providers handle dangling tool calls through their own transform layers.

Changes

  • src/agents/transcript-policy.ts: restrict validateAnthropicTurns to isAnthropic only
  • src/agents/transcript-policy.test.ts: update test expectations for the unowned fallback path

Test plan

  • transcript-policy.test.ts — 29 tests pass
  • validate-turns.test.ts — 31 tests pass
  • Provider-owned policies (MiniMax, Bedrock, etc.) unaffected

Changed files

  • src/agents/transcript-policy.test.ts (modified, +2/-2)
  • src/agents/transcript-policy.ts (modified, +1/-1)

Code Example

1. Configure deepseek-v4-pro with reasoning: true
2. Start a conversation that triggers tool calls
   (file read/write, exec, web_fetch, etc.)
3. First tool call → works fine
4. Next request → 💥 HTTP 400

---

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

---

What OpenClaw does:
   messages → API (missing reasoning_content)

What it should do:
   messages.append(response.choices[0].message)
   → carries content + reasoning_content + tool_calls

---

Thinking ON + Tool calls → 💀 Session freezes entirely
Thinking OFF / No tools     → ✅ Works fine
RAW_BUFFERClick to expand / collapse

🐛 DeepSeek thinking mode + tool calls = HTTP 400: reasoning_content not preserved


📋 Environment

ItemValue
OpenClaw2026.4.15 ~ 2026.4.23 (confirmed unfixed)
Modeldeepseek-v4-pro
Configreasoning: true (thinking mode enabled)
APIOpenAI-compatible → https://api.deepseek.com

🔁 Steps to Reproduce

1. Configure deepseek-v4-pro with reasoning: true
2. Start a conversation that triggers tool calls
   (file read/write, exec, web_fetch, etc.)
3. First tool call → works fine
4. Next request → 💥 HTTP 400

❌ Error Message

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

🔍 Root Cause

Per DeepSeek Official Docs:

Scenarioreasoning_content handling
No tool callsIgnored, no need to pass back
With tool callsMust be passed back in ALL subsequent requests

Current behavior — OpenClaw drops reasoning_content during tool call loops:

❌ What OpenClaw does:
   messages → API (missing reasoning_content)

✅ What it should do:
   messages.append(response.choices[0].message)
   → carries content + reasoning_content + tool_calls

📊 Impact

Thinking ON + Tool calls → 💀 Session freezes entirely
Thinking OFF / No tools     → ✅ Works fine

📎 References


extent analysis

TL;DR

To fix the issue, ensure that reasoning_content is passed back to the API in all subsequent requests when using tool calls with thinking mode enabled.

Guidance

  • Review the OpenClaw configuration to verify that reasoning_content is being properly handled during tool call loops.
  • Check the API requests to confirm that reasoning_content is being included in the payload of subsequent requests.
  • Modify the OpenClaw code to append reasoning_content to the messages before sending them to the API, as described in the DeepSeek Official Docs.
  • Test the updated configuration with tool calls to ensure that the reasoning_content is being preserved and the session no longer freezes.

Example

messages.append(response.choices[0].message)
# Ensure reasoning_content is included in the message
message['reasoning_content'] = previous_response['reasoning_content']

Notes

The fix may require updates to the OpenClaw code to properly handle reasoning_content during tool call loops. The issue is specific to versions 2026.4.15 through 2026.4.23 of OpenClaw.

Recommendation

Apply workaround: Modify the OpenClaw code to preserve reasoning_content during tool call loops, as this is a confirmed issue in the affected versions.

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 - ✅(Solved) Fix DeepSeek thinking mode + tool calls = HTTP 400: reasoning_content not preserved [2 pull requests, 1 comments, 2 participants]