-
-
Notifications
You must be signed in to change notification settings - Fork 69.4k
Bug: thinking/redacted_thinking blocks corrupted during context compaction (safeguard mode) #20039
Description
Description
When extended thinking (thinking=low or higher) is enabled and a session grows long enough to trigger context compaction (compaction.mode: safeguard), OpenClaw appears to modify or strip thinking/redacted_thinking blocks from the conversation history.
This causes subsequent API calls to fail with:
LLM request rejected: messages.N.content.N: `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 session then becomes permanently broken — every new message triggers the same error in a loop.
Steps to Reproduce
- Enable thinking mode (
/reasoningor setthinking: lowin config) - Have a long conversation in a channel/thread session
- Wait until context compaction triggers (safeguard mode)
- Send another message — the error appears
- Every subsequent message in the same session produces the same error
Expected Behavior
Context compaction should either:
- Preserve
thinking/redacted_thinkingblocks intact, OR - Remove the entire assistant turn (both thinking blocks AND text blocks together), never partially
Actual Behavior
Thinking blocks are stripped or modified during compaction, corrupting the conversation history. The session cannot recover — requires /new to reset.
Environment
- OpenClaw version: 2026.2.9
- Model:
anthropic/claude-sonnet-4-5 - Thinking:
low - Compaction mode:
safeguard - Channel: Discord (thread session)
Workaround
Use /new to reset the session. The session cannot self-recover.
Notes
Per Anthropic's API docs, thinking and redacted_thinking blocks must be passed back exactly as returned in multi-turn conversations. Any modification — including removal of thinking blocks while keeping text blocks — is rejected by the API.