openclaw - 💡(How to fix) Fix [Bug]: embedded agent (memory flush) fails when session history contains DeepSeek thinking-mode messages [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#74880Fetched 2026-05-01 05:40:24
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
2
Timeline (top)
closed ×1commented ×1

When a session contains messages from DeepSeek in thinking mode (which produce reasoning_content fields), any subsequent embedded agent run (e.g. memory flush before compaction) that inherits the session history will fail with a 400 error from DeepSeek:

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

The fallback model (claude-sonnet) then also fails with:

400 消息内容不能为空

This causes memory flush to silently fail — important context from the session is never written to memory files.

Error Message

When a session contains messages from DeepSeek in thinking mode (which produce reasoning_content fields), any subsequent embedded agent run (e.g. memory flush before compaction) that inherits the session history will fail with a 400 error from DeepSeek: High — memory flush silently fails every time a DeepSeek thinking-mode session triggers compaction. Long-running sessions lose all memory consolidation. The failure is silent from the user's perspective (no error shown in chat).

Root Cause

The embedded agent inherits the full session history including reasoning_content fields, then calls DeepSeek without passing those fields back, causing a 400 rejection. The fallback to sonnet also fails because the message body is left empty after stripping the reasoning content.

Fix Action

Workaround

Use a non-thinking model as the default (e.g. sonnet). New sessions without DeepSeek thinking history are not affected.

Code Example

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

---

400 消息内容不能为空

---

Embedded agent failed before reply: All models failed (2): 
  deepseek/deepseek-v4-flash: 400 The `reasoning_content` in the thinking mode must be passed back to the API. (format) 
  openai/claude-sonnet-4-6: 400 消息内容不能为空 (format) 
  LLM request failed: provider rejected the request schema or tool payload.
RAW_BUFFERClick to expand / collapse

Bug: embedded agent (memory flush) fails when session history contains DeepSeek thinking-mode messages

Bug type

Regression / Integration bug

Summary

When a session contains messages from DeepSeek in thinking mode (which produce reasoning_content fields), any subsequent embedded agent run (e.g. memory flush before compaction) that inherits the session history will fail with a 400 error from DeepSeek:

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

The fallback model (claude-sonnet) then also fails with:

400 消息内容不能为空

This causes memory flush to silently fail — important context from the session is never written to memory files.

Steps to reproduce

  1. Start a session with DeepSeek thinking mode enabled (e.g. thinkingDefault: low with a DeepSeek model)
  2. Have a multi-turn conversation that produces reasoning_content in the assistant messages
  3. Wait for or trigger a memory flush (compaction or session end)
  4. Observe embedded agent failure in logs

Expected behavior

The embedded agent should either:

  • Strip reasoning_content from inherited session history before sending to DeepSeek (since it's a background task, not a continuation of the thinking chain), OR
  • Use a non-thinking model for embedded agent runs regardless of the parent session's model

Actual behavior

The embedded agent inherits the full session history including reasoning_content fields, then calls DeepSeek without passing those fields back, causing a 400 rejection. The fallback to sonnet also fails because the message body is left empty after stripping the reasoning content.

Log evidence

Embedded agent failed before reply: All models failed (2): 
  deepseek/deepseek-v4-flash: 400 The `reasoning_content` in the thinking mode must be passed back to the API. (format) 
  openai/claude-sonnet-4-6: 400 消息内容不能为空 (format) 
  LLM request failed: provider rejected the request schema or tool payload.

OpenClaw version

2026.4.25 (aa36ee6)

Operating system

macOS (arm64)

Install method

npm global

Model

deepseek/deepseek-v4-flash (thinking mode)

Impact and severity

High — memory flush silently fails every time a DeepSeek thinking-mode session triggers compaction. Long-running sessions lose all memory consolidation. The failure is silent from the user's perspective (no error shown in chat).

Workaround

Use a non-thinking model as the default (e.g. sonnet). New sessions without DeepSeek thinking history are not affected.

Additional information

DeepSeek's API requires that reasoning_content from a previous assistant turn be passed back in the next request when using thinking mode. This is a DeepSeek API constraint, not a bug in DeepSeek. The fix should be in OpenClaw's embedded agent message history builder: either strip reasoning_content fields when constructing the history for background/embedded runs, or ensure they are properly forwarded.

extent analysis

TL;DR

Modify the embedded agent's message history builder to either strip reasoning_content fields or properly forward them when using DeepSeek in thinking mode.

Guidance

  • Identify the code responsible for constructing the session history for embedded agent runs and modify it to exclude reasoning_content fields when using DeepSeek in thinking mode.
  • Alternatively, update the embedded agent to properly pass reasoning_content fields back to the DeepSeek API when using thinking mode.
  • Verify the fix by reproducing the issue with the modified code and checking for successful memory flush operations.
  • Consider adding a fallback mechanism to use a non-thinking model for embedded agent runs if the primary model fails due to reasoning_content issues.

Example

# Pseudo-code example of stripping reasoning_content fields
def build_session_history(session):
    history = []
    for message in session.messages:
        if 'reasoning_content' in message and message.model == 'deepseek':
            del message['reasoning_content']
        history.append(message)
    return history

Notes

The fix requires modifying the OpenClaw codebase to accommodate DeepSeek's API constraints. The exact implementation details may vary depending on the OpenClaw code structure and architecture.

Recommendation

Apply a workaround by using a non-thinking model as the default, as this will prevent the issue from occurring in new sessions without DeepSeek thinking history. However, a permanent fix should involve modifying the embedded agent's message history builder to properly handle reasoning_content fields.

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

The embedded agent should either:

  • Strip reasoning_content from inherited session history before sending to DeepSeek (since it's a background task, not a continuation of the thinking chain), OR
  • Use a non-thinking model for embedded agent runs regardless of the parent session's model

Still need to ship something?

×6

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

Back to top recommendations

TRENDING