Repository navigation
Description
Problem
When running with thinking=adaptive (or any thinking mode) against Anthropic models, extended thinking blocks with cryptographically signed replay signatures accumulate in the session transcript. These signatures are time-limited and single-use.
The current transcript hygiene strips thinking blocks with missing, empty, or blank signatures:
Thinking blocks with missing, empty, or blank replay signatures are stripped before provider conversion.
However, it does not strip thinking blocks where the signature is present but expired/invalid. When these are replayed to the Anthropic Messages API, the API rejects the entire request:
messages.9.content.6: Invalid signature in thinking block
This causes a cascade:
- Every subsequent LLM call fails because the full history is replayed
- The corrupted transcript is persisted to disk
- Container restarts reload the same bad transcript → crash loop
- No automatic recovery without manual session reset
Expected Behavior
Historical thinking blocks should be stripped from replay regardless of signature state. The Anthropic API uses signatures for single-use replay within the same conversation turn; there is no valid reason to replay thinking blocks from earlier turns. All type: "thinking" blocks in historical assistant messages should be removed before provider conversion.
Actual Behavior
Thinking blocks with expired but non-empty signatures pass through transcript hygiene and are sent to the Anthropic API, which rejects them.
Reproduction
- Run an agent with
thinking=adaptiveon Anthropic Claude - Have a long-running session (10+ turns with thinking responses)
- Wait for signatures to expire (or restart the container after some time)
- Next LLM call fails with
Invalid signature in thinking block - All subsequent calls fail — session is bricked
Impact
- Two production outages in our setup: 1.5h and 8h downtime
- Only recoverable via manual session transcript deletion
- Affects any long-running session using thinking mode with Anthropic
Suggested Fix
In the Anthropic provider adapter's transcript hygiene, change the stripping condition from "missing/empty/blank signature" to "all thinking blocks in historical turns":
// Before: only strips missing/blank
content.filter(b => !(b.type === 'thinking' && (!b.signature || b.signature.trim() === '')))
// After: strip ALL thinking blocks from historical assistant messages
content.filter(b => b.type !== 'thinking')The current-turn thinking block (if any) should still be preserved for tool-call continuations within the same turn, per existing logic.
Environment
- OpenClaw: 2026.5.27
- Model: anthropic/claude-opus-4-6
- Thinking mode: adaptive
Workaround
Manual session reset to delete all transcript files and restart the gateway.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 1, 2026
Thanks for the context here. I did a careful shell check against current
main, and this is already implemented.Current main now detects the reported Anthropic invalid-signature thinking-block rejection and retries the provider call with thinking blocks stripped, so the session no longer hard-loops; the proof is current-main-only and is not in v2026.5.28.
So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Keep the current main preserve-then-recover implementation and ship it in the next release; reopen only if a current-main build still loops after replay-invalid recovery.
Do we have a high-confidence way to reproduce the issue?
Source-reproducible: v2026.5.28 lacks the replay-invalid thinking-signature classifier, while current main has classifier and recovery tests for the exact error shape. I did not run a live Anthropic session in this read-only review.
Is this the best way to solve the issue?
Yes. Current main preserves signed thinking where Anthropic requires it for tool-use/current-turn continuity, then recovers opaque invalid-signature rejections by retrying once without thinking blocks, which is narrower than removing all Claude 4.6+ historical thinking up front.
Security review:
Security review: Non-PR issue review; the report is an availability/session-state bug rather than a security-boundary issue.
AGENTS.md: found and applied where relevant.
What I checked:
AGENTS.md:1, 630f0d6938cd)src/agents/embedded-agent-helpers/errors.ts:366, 630f0d6938cd)src/agents/embedded-agent-runner/thinking.ts:532, 630f0d6938cd)src/agents/embedded-agent-runner/run/attempt.ts:2613, 630f0d6938cd)Invalid signature in thinking blockpayload as replay_invalid and cover pre-content stream-error retry without thinking blocks. (src/agents/embedded-agent-helpers.isbillingerrormessage.test.ts:1566, 630f0d6938cd)Likely related people:
src/agents/embedded-agent-helpers/errors.ts,src/agents/embedded-agent-runner/thinking.ts,src/agents/embedded-agent-runner/run/attempt.ts)src/agents/pi-embedded-runner/replay-history.ts,src/agents/session-transcript-repair.ts,src/agents/pi-embedded-runner/run/attempt.tool-call-normalization.ts)src/agents/transcript-policy.ts,src/agents/pi-embedded-runner/run/attempt.ts)src/agents/pi-embedded-runner/thinking.ts,src/agents/pi-embedded-runner/proxy-stream-wrappers.ts)Codex review notes: model gpt-5.5, reasoning high; reviewed against 630f0d6938cd; fix evidence: commit 76fa1b99c310, main fix timestamp 2026-06-01T05:17:27+02:00.