fix(anthropic): strip all thinking blocks from historical messages#88941
fix(anthropic): strip all thinking blocks from historical messages#88941bladin wants to merge 1 commit into
Conversation
Strip ALL thinking blocks from historical assistant messages to avoid "Invalid signature in thinking block" errors when Anthropic thinking signatures expire. Anthropic thinking signatures are time-limited and single-use. Replaying them causes API errors that brick sessions until manual reset. The current-turn thinking block is preserved by the stream handler, not by transcript replay. Fixes openclaw#88932
|
Codex review: needs real behavior proof before merge. Reviewed June 1, 2026, 2:06 AM ET / 06:06 UTC. Summary PR surface: Source -10, Tests -11. Total -21 across 2 files. Reproducibility: no. high-confidence live reproduction was established. Source inspection shows current main can replay same-model signed thinking blocks, and the linked report describes Anthropic invalid-signature failures, but this review did not run a live Anthropic replay and current recovery may already retry some failures. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Keep the shared transform replay semantics intact, then implement an Anthropic-scoped replay policy, recovery, or converter repair with regression tests proving other providers still preserve their signed reasoning context. Do we have a high-confidence way to reproduce the issue? No high-confidence live reproduction was established. Source inspection shows current main can replay same-model signed thinking blocks, and the linked report describes Anthropic invalid-signature failures, but this review did not run a live Anthropic replay and current recovery may already retry some failures. Is this the best way to solve the issue? No, this is not the best fix as written. The repair should stay Anthropic-scoped instead of changing transformMessages for every provider that depends on signed reasoning replay. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 44cad6f8a48e. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source -10, Tests -11. Total -21 across 2 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Closing as superseded by current The linked issue #88932 is already closed because current Verification I ran on current node scripts/run-vitest.mjs src/agents/embedded-agent-helpers.isbillingerrormessage.test.ts src/agents/embedded-agent-runner.sanitize-session-history.test.ts -- --reporter=verbose -t "invalid signature|replay invalid|thinking signatures"Result: passed 2 Vitest shards; 1 classifier test and 9 sanitizer/replay tests passed. Thanks @bladin for jumping on the report quickly; the current-main fix is the safer shape here. |
Summary
Fixes #88932 — Anthropic thinking blocks with expired signatures cause crash loop on replay.
Anthropic thinking signatures are time-limited and single-use. When historical thinking blocks with expired signatures are replayed to the Anthropic Messages API, the API rejects them with
Invalid signature in thinking blockerrors, causing sessions to brick until manual reset.Changes
Why this fix
The previous logic preserved thinking blocks with signatures for same-model replay. However, Anthropic signatures expire and become invalid, causing API errors. There is no valid reason to replay thinking blocks from earlier turns — they are intermediate reasoning state, not user-visible content.
Risk checklist
Tests and validation
Real behavior proof
This fix prevents the following error cascade described in #88932:
messages.X.content.Y: Invalid signature in thinking blockAfter this fix, thinking blocks are stripped before provider conversion, preventing the error entirely.