Skip to content

Gateway crash corrupts session history: thinking blocks become unrecoverable #25194

@kaykas

Description

@kaykas

Bug Report

Summary

When the OpenClaw gateway crashes while a session has thinking mode enabled (thinking=low or higher), the session becomes permanently unrecoverable. Every subsequent message returns:

LLM request rejected: messages.17.content.57: thinking or redacted_thinking blocks in the latest assistant message cannot be modified. These blocks must remain as they were in the original response.

The only fix is /reset to discard the entire session history.

Steps to Reproduce

  1. Have a session with thinking mode enabled (default: thinking=low on claude-sonnet-4-6)
  2. Exchange several messages so thinking blocks accumulate in session history
  3. Crash the gateway (e.g. via an invalid config value, unhandled exception, etc.)
  4. Gateway restarts and reconstructs sessions from stored history
  5. Send any message in the affected session

Expected Behavior

Session history is reconstructed with thinking blocks preserved exactly as-is (required by Anthropic API). Session continues normally.

Actual Behavior

Thinking blocks are dropped or modified during session reconstruction after crash. Every subsequent API call is rejected by Anthropic with the error above. Session is permanently broken until /reset.

Why This Matters

  • A crash that isn't the user's fault (or is, as in my case — a bad config value) should not permanently destroy an active session
  • The error message gives no indication that /reset is the fix — users will retry, get the same error, and be stuck in a loop
  • This is a reliability/safety issue: any unclean gateway shutdown can silently corrupt sessions

Suggested Fixes

  1. During session reconstruction: Preserve thinking blocks byte-for-byte from stored history. Do not strip or summarize them.
  2. Or: detect the error and auto-recover: If an API call returns this specific error, offer to strip history back to before the last thinking block (with user confirmation) or auto-/reset
  3. Immediate UX fix: When this error occurs, reply to the user with a human-readable explanation and /reset suggestion instead of forwarding the raw API error

Environment

  • OpenClaw version: pinned at 076df941a3265067802e0951a4233cfb7e8597ea
  • Model: anthropic/claude-sonnet-4-6
  • Channel: Telegram
  • Thinking mode: low (default)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions