Back to browse
GitHub Repository

Fix Claude Code 'thinking blocks cannot be modified' API errors caused by streaming interleaving corruption in session JSONL files

16 starsPython

Recover bricked Claude Code sessions with "thinking blocks" error

by miteshashar·Feb 14, 2026·1 point·0 comments

AI Analysis

●●SolidNiche GemSolve My Problem
The Take

The repo does one painful thing well: it inspects SESSION_ID.jsonl, pinpoints where streaming/interleaving corrupted 'thinking' blocks, and offers diagnose, fix (with auto-backup), and nuke fallbacks. It's pragmatic and ruthless — small CLI commands, clear recovery workflow, and rescue-first guidance — but it's narrowly targeted to Claude Code users and won't matter to most people.

Target Audience

Developers and power users of Claude Code / Anthropic Claude who run long-lived sessions and need to recover corrupted session histories

Post Description

I built a small open-source CLI to recover Claude Code sessions that get stuck on this error:

messages.N.content.M: thinking or redacted_thinking blocks in the latest assistant message cannot be modified

When this happens, `--resume` can keep failing and the session feels bricked.

The tool provides:

* diagnose SESSION_ID to find likely corruption points in session JSONL

* fix SESSION_ID for targeted repair (auto-backup before write)

* nuke SESSION_ID as fallback (strip all thinking/redacted_thinking blocks, also auto-backup)

Quick usage:

* claude-session-fix-thinking diagnose SESSION_ID

* claude-session-fix-thinking fix SESSION_ID

* claude --resume SESSION_ID

Repo: https://github.com/miteshashar/claude-code-thinking-blocks-f...

If you every got stuck due to this, you can use this script to resume your session.

Similar Projects