-
-
Notifications
You must be signed in to change notification settings - Fork 69.6k
Bug: persisted WhatsApp Anthropic sessions can fail on replay due to thinking blocks #44387
Description
Summary
Persisted WhatsApp sessions can become unusable with Anthropic models when earlier stored assistant messages contain thinking / redacted_thinking content blocks. Later turns fail immediately with Anthropic rejecting the replayed message history.
In my case this affected a normal WhatsApp DM conversation. The chat had worked earlier, then later turns started failing immediately with a provider error instead of a real reply.
Error
messages.3.content.1: `thinking` or `redacted_thinking` blocks in the latest assistant message cannot be modified. These blocks must remain as they were in the original response.
Environment
- OpenClaw: 2026.3.11
- Provider/model:
anthropic/claude-opus-4-6 - Channel: WhatsApp
- Runtime: Linux
Observed behaviour
- WhatsApp inbound delivery still worked
- The message reached the agent session
- The turn then failed immediately with the Anthropic invalid request error above
- The failure reproduced on multiple later turns in the same WhatsApp session
Relevant finding
The stored session transcript for the affected WhatsApp conversation contained earlier assistant messages with Anthropic thinking blocks.
Later replay of that session appears to send history back to Anthropic in a form that is not byte-identical to the originally returned thinking blocks, and Anthropic rejects the request.
Local recovery that worked
I backed up the affected session transcript and removed only the stored thinking / redacted_thinking blocks from prior assistant messages in that one session, leaving visible text/tool history intact.
After that, WhatsApp replies resumed working normally.
Why this seems like an OpenClaw bug
OpenClaw persists session history and later replays it. If Anthropic requires thinking blocks to remain exactly unchanged, then one of these likely needs to happen during persistence/replay:
- preserve thinking blocks byte-for-byte exactly as originally returned, or
- omit them from persisted replay history, or
- store them separately and never reconstruct them into assistant content unless exact preservation is guaranteed
Impact
A previously working persisted chat session can later become unusable until the transcript is manually repaired.
Suggested follow-up
- Add a regression test for persisted Anthropic sessions containing
thinkingblocks - Verify replay logic for compacted and non-compacted sessions
- Consider sanitising stored assistant content before replay if exact preservation is not guaranteed