claude-session-recover A developer created a Python script called `claude-session-recover` to fix Claude Code sessions stuck in an unrecoverable loop caused by a server-side API validation error. The tool removes `thinking` and `redacted_thinking` blocks from session transcripts on disk, eliminating the signature mismatch that prevents the stateless API from accepting further requests. The fix preserves all text, tool calls, and tool results while repairing the parentUuid chain to maintain rewind functionality, though the developer notes this is a client-side stopgap for a server-side issue that began appearing around May 28, 2026. | /usr/bin/env python3 | | | """Recover a Claude Code session stuck in a loop on this API 400 error: | | | " thinking or redacted thinking blocks in the latest assistant message | | | cannot be modified. These blocks must remain as they were in the original | | | response." | | | Thinking blocks carry a server-issued signature that the stateless API | | | re-validates on every request. When a transcript ends up with those blocks in a | | | context the signature no longer matches e.g. duplicated/merged turns after a | | | rewind or compaction , every resend is rejected and the session is wedged — no | | | prompt, /compact, or rewind gets you out. | | | This script fixes the transcript on disk. It's the persistent equivalent of | | | "turn thinking off": it removes every thinking / redacted thinking block, so | | | there are no signatures left to validate. You keep ALL text, tool calls, and | | | tool results — you only lose the model's prior private reasoning, so the next | | | turn reasons fresh. Empty assistant entries are dropped and the parentUuid chain | | | is repaired so /rewind still works. Every other line is passed through | | | byte-for-byte. Pure Python 3 stdlib — no pip installs. | | | NOTE: this is a client-side stopgap. The underlying cause appears to be | | | server-side a wave of these started 2026-05-28; see claude-code issue 10199 . | | | It recovers a stuck session but does not prevent recurrence. | | | ---------------------------------------------------------------------------- | | | USAGE | | | ---------------------------------------------------------------------------- | | | 1. Find your session file. It lives at | | | ~/.claude/projects/