openclaw - ✅(Solved) Fix [Bug]: DeepSeek thinking sessions fail on follow-up turns with missing reasoning_content and trigger fallback [1 pull requests, 2 comments, 3 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#70931Fetched 2026-04-24 10:37:43
View on GitHub
Comments
2
Participants
3
Timeline
5
Reactions
7
Author
Timeline (top)
commented ×2subscribed ×2cross-referenced ×1

When using deepseek/deepseek-v4-pro with thinking enabled, the first turn can succeed, but a later turn in the same session fails with:

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

OpenClaw then classifies this as a format error and falls back to another model (for example openai-codex/gpt-5.4).

This does not appear to be an API key or provider enablement problem. The DeepSeek provider is configured and the session starts on DeepSeek successfully. The failure happens on a later request, which suggests OpenClaw is not preserving or replaying the required reasoning_content across turns when DeepSeek thinking is enabled.

Error Message

OpenClaw then classifies this as a format error and falls back to another model (for example openai-codex/gpt-5.4). 7. Observe that OpenClaw marks the failure as a format error and falls back to another configured model.

Root Cause

A later turn in the same session fails because the DeepSeek API reports missing reasoning_content, and the session falls back to another model.

Fix Action

Fixed

PR fix notes

PR #70963: feat(deepseek): add deepseek-v4-pro and deepseek-v4-flash to model catalog [AI-assisted]

Description (problem / solution / changelog)

Summary

Adds the two current-generation DeepSeek models to the bundled DeepSeek provider catalog:

  • deepseek-v4-pro — reasoning model, 1M context window, 384K max output
  • deepseek-v4-flash — reasoning model, 1M context window, 384K max output

DeepSeek's /models endpoint now returns only these two IDs. The legacy deepseek-chat and deepseek-reasoner entries are kept (backwards compatibility — legacy aliases still resolve on the upstream API), but without this change users cannot select V4 through openclaw (it falls back to openai/deepseek-v4-pro, which is not what users want).

Changes

ModelActionreasoningcontextWindowmaxTokenscost (input / output per 1M)
deepseek-v4-proAddtrue1,000,000384,000$1.74 / $3.48
deepseek-v4-flashAddtrue1,000,000384,000$0.14 / $0.28

Pricing source: https://api-docs.deepseek.com/quick_start/pricing

Files changed:

  • extensions/deepseek/models.ts — add V4 pricing constants and catalog entries
  • extensions/deepseek/index.test.ts — extend static-catalog assertion with V4 ids and attribute checks

Validation

Live API

/models endpoint confirms the two IDs:

{"object":"list","data":[
  {"id":"deepseek-v4-flash","object":"model","owned_by":"deepseek"},
  {"id":"deepseek-v4-pro","object":"model","owned_by":"deepseek"}
]}

deepseek-v4-pro — live request/response (returns reasoning_content, confirming reasoning: true):

Request:  {"model":"deepseek-v4-pro","messages":[{"role":"user","content":"What is 2+2? Answer in one word."}],"max_tokens":50}
Response: {"role":"assistant","content":"","reasoning_content":"We are asked: \"What is 2+2?\" ... the answer is \"four\"..."}
usage:    {"prompt_tokens":16,"completion_tokens":50,"completion_tokens_details":{"reasoning_tokens":50}}
system_fingerprint: "fp_9954b31ca7_prod0820_fp8_kvcache_20260402"

deepseek-v4-flash — live request/response:

Request:  {"model":"deepseek-v4-flash","messages":[{"role":"user","content":"What is 2+2? Answer in one word."}],"max_tokens":50}
Response: {"role":"assistant","content":"Four","reasoning_content":"We need to answer \"What is 2+2?\" ... The answer is obviously four..."}
usage:    {"prompt_tokens":16,"completion_tokens":33,"completion_tokens_details":{"reasoning_tokens":31}}
system_fingerprint: "fp_058df29938_prod0820_fp8_kvcache_20260402"

Local checks

$ pnpm test extensions/deepseek
Test Files  1 passed (1)
Tests  3 passed (3)

$ pnpm format:check extensions/deepseek
All matched files use the correct format.

$ node_modules/.bin/oxlint extensions/deepseek --tsconfig tsconfig.oxlint.extensions.json
Found 0 warnings and 0 errors.

$ pnpm tsgo:extensions / pnpm tsgo:extensions:test
both pass (37s / 123s)

pnpm check:changed full run also passes the typecheck and conflict-marker gates; the tree-wide oxlint step OOMs on my WSL2 dev box (7.6GB RAM) but is unrelated to this diff.

Known follow-ups (not part of this PR)

  • Multi-turn sessions: these V4 models enforce DeepSeek's new "thinking mode" contract, which requires reasoning_content to be replayed in subsequent assistant turns. openclaw's current openai-completions replay path drops that field, so multi-turn sessions fail with 400 The \reasoning_content` in the thinking mode must be passed back to the API`. That is tracked in #70931 and needs a separate PR (likely in the transcript → completions message transform for reasoning-capable openai-completions providers). Single-turn requests work against the newly-catalogued models.
  • tieredPricing: DeepSeek's pricing page does not currently show context-length tiers for V4; leaving tieredPricing unset. If V4 gains tiered input rates this should be revisited.

AI-assisted disclosure

  • Mark as AI-assisted: yes, Claude Opus 4.7
  • Degree of testing: fully tested — local unit tests pass, live API requests/responses captured above, pricing verified against official docs
  • Prompts / session logs: happy to share on request
  • Confirm understanding of code: yes
  • `codex review --base origin/main` — not available in my environment; will address any review-bot comments on this PR

Test plan

  • pnpm test extensions/deepseek — passes
  • pnpm format:check extensions/deepseek — passes
  • oxlint extensions/deepseek — 0 errors
  • pnpm tsgo:extensions — passes
  • pnpm tsgo:extensions:test — passes
  • Live /models listing + per-model chat completion requests — captured above

Changed files

  • extensions/deepseek/index.test.ts (modified, +10/-0)
  • extensions/deepseek/models.ts (modified, +38/-0)

Code Example

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

---

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

---

🧠 Model: deepseek/deepseek-v4-pro · 🔑 api-key (deepseek:default)
↪️ Fallback: openai-codex/gpt-5.4 ... (format (+1 more attempts))
⚙️ Runtime: direct · Think: high

---

errorMessage: 400 The `reasoning_content` in the thinking mode must be passed back to the API.
RAW_BUFFERClick to expand / collapse

Bug type

Regression / provider compatibility bug

Beta release blocker

No

Summary

When using deepseek/deepseek-v4-pro with thinking enabled, the first turn can succeed, but a later turn in the same session fails with:

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

OpenClaw then classifies this as a format error and falls back to another model (for example openai-codex/gpt-5.4).

This does not appear to be an API key or provider enablement problem. The DeepSeek provider is configured and the session starts on DeepSeek successfully. The failure happens on a later request, which suggests OpenClaw is not preserving or replaying the required reasoning_content across turns when DeepSeek thinking is enabled.

Steps to reproduce

  1. Configure a session to use deepseek/deepseek-v4-pro.
  2. Keep thinking enabled (Think: high in session status).
  3. Start a fresh session.
  4. Send a first message that completes successfully.
  5. Send a follow-up message in the same session.
  6. Observe that the request may fail with:
400 The `reasoning_content` in the thinking mode must be passed back to the API.
  1. Observe that OpenClaw marks the failure as a format error and falls back to another configured model.

Expected behavior

DeepSeek thinking sessions should continue across turns without losing the provider-required reasoning payload. OpenClaw should not trigger fallback for a normal follow-up turn.

Actual behavior

A later turn in the same session fails because the DeepSeek API reports missing reasoning_content, and the session falls back to another model.

OpenClaw version

2026.4.21

Operating system

Ubuntu 24.04 / Linux 6.8.0-107-generic

Install method

npm global

Model

deepseek/deepseek-v4-pro

Provider / routing chain

openclaw -> deepseek (openai-completions) -> deepseek-v4-pro

Additional provider/model setup details

  • Provider: deepseek
  • API mode: openai-completions
  • Thinking enabled
  • Observed fallback target: openai-codex/gpt-5.4

Logs, screenshots, and evidence

Session status showed:

🧠 Model: deepseek/deepseek-v4-pro · 🔑 api-key (deepseek:default)
↪️ Fallback: openai-codex/gpt-5.4 ... (format (+1 more attempts))
⚙️ Runtime: direct · Think: high

Captured session transcript showed the DeepSeek turn failing with:

errorMessage: 400 The `reasoning_content` in the thinking mode must be passed back to the API.

This happened at least twice in the same session:

  • once immediately after a tool-use turn near session startup
  • once again on a later normal user follow-up in the same session

Impact and severity

  • DeepSeek thinking sessions become unreliable across multiple turns
  • Requests silently fall back to another model, which can hide the root cause
  • Users may incorrectly assume their DeepSeek provider/API key is misconfigured

Additional information

Likely cause: OpenClaw is not persisting or replaying DeepSeek-required reasoning_content on follow-up requests in thinking mode, possibly in transcript transform / message serialization / replay logic for openai-completions reasoning turns.

extent analysis

TL;DR

OpenClaw needs to persist and replay the reasoning_content for DeepSeek thinking mode across turns to prevent the 400 error and fallback to another model.

Guidance

  • Verify that OpenClaw's session management correctly stores and retrieves the reasoning_content for each turn when using deepseek/deepseek-v4-pro with thinking enabled.
  • Check the transcript transform, message serialization, and replay logic for openai-completions reasoning turns to ensure reasoning_content is properly handled.
  • Review the OpenClaw configuration and session settings to confirm that thinking mode is correctly enabled and the reasoning_content is being passed as required.
  • Test the session with multiple turns to reproduce the issue and observe if the reasoning_content is being lost or not replayed correctly.

Example

No code snippet is provided as the issue seems to be related to the internal logic of OpenClaw's session management and transcript handling.

Notes

The issue appears to be specific to the deepseek/deepseek-v4-pro model with thinking enabled, and the problem may not occur with other models or configurations.

Recommendation

Apply a workaround to modify the OpenClaw session management logic to correctly persist and replay the reasoning_content for DeepSeek thinking mode, as this seems to be the root cause of the issue.

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…

FAQ

Expected behavior

DeepSeek thinking sessions should continue across turns without losing the provider-required reasoning payload. OpenClaw should not trigger fallback for a normal follow-up turn.

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 [Bug]: DeepSeek thinking sessions fail on follow-up turns with missing reasoning_content and trigger fallback [1 pull requests, 2 comments, 3 participants]