[BUG] Session becomes completely unrecoverable due to thinking block API error
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report
- [x] I am using the latest version of Claude Code
Bug Description
During an extended Claude Code session, an API error occurs that makes the session completely unrecoverable. The error is related to thinking blocks being modified. Once this error occurs:
- Cannot continue the conversation (any input triggers the error)
/compactfails with the same error/clear- untested but context loss is unacceptable- The only option is to abandon the session and lose all context
This is a critical bug because it causes complete loss of work-in-progress with no recovery path.
Error Message
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.49.content.1: `thinking` or `redacted_thinking` blocks in the latest assistant message cannot be modified. These blocks must remain as they were in the original response."},"request_id":"req_011CVeW1YWWvLQ7fem8ut3YA"}
Environment
- Claude Code Version: 2.0.55
- Platform: macOS (Mac Mini M4 Pro, 64GB RAM)
- macOS Version: 15.6.1 (Build 24G90)
- Terminal: VS Code integrated terminal
- Node Version: v22.16.0
Steps to Reproduce
- Use Claude Code for an extended session (in this case, 49+ messages based on error)
- At some point during normal usage, the error occurs
- Any subsequent input (including
/compact) triggers the same error - Session is completely stuck with no way to recover context
Expected Behavior
- Thinking blocks should be managed internally without corruption
- If corruption occurs,
/compactshould be able to recover by summarizing and starting fresh - At minimum, there should be a way to export/save context before being forced to abandon the session
Actual Behavior
Session becomes completely unusable. User is forced to lose all conversation context and start over.
Impact
- Severity: High
- Complete loss of conversation context
- Loss of work-in-progress
- No recovery mechanism available
- Forces user to restart and manually reconstruct context
Related Issues
This appears related to #11323 which describes a similar thinking block error after Ctrl+C interruption, though in this case no interruption was involved.
Additional Context
- Error occurred during normal usage, no Ctrl+C or interruption
- The session was working normally until this error appeared
- Multiple installation paths detected (npm-local and npm-global) but this is likely unrelated
Suggested Fix
- Ensure thinking blocks are never corrupted during normal session flow
- Add a recovery mechanism (e.g.,
/compact --forceor/recover) that can salvage context even when message structure is invalid - Add ability to export conversation context before clearing
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/10199
- https://github.com/anthropics/claude-code/issues/12130
- https://github.com/anthropics/claude-code/issues/12525
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.11.content.7: thinking or redacted_thinking blocks in the latest assistant message cannot be modified. These blocks must remain as they were in the original response."},"request_id":"req_011CVeZdvHJiCjKEhhjYmCvv"}
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
I am experiencing the same problem https://github.com/anthropics/claude-code/issues/19460#issuecomment-3771849168
Also experiencing this.
saw the same thing in #25062
Workaround confirmed working — claude-code-thinking-blocks-fix by @miteshashar recovered my bricked session. This looks like the same root cause as #12311.
Long session (~6,600 lines, heavy subagent use) hit the "thinking blocks cannot be modified" error and became completely unresponsive — no message, /compact, /debug, or even /feedback worked.
I asked Claude Code about it in a new session and it found the community repair tool, diagnosed the issue, and applied the fix — all within the conversation. Diagnosis found 12 corruption points from streaming interleaving of parallel subagent responses. Needed two passes of the targeted fix to fully clean up (first pass left one residual from a merged thinking block). Session resumed successfully.
claude-session-fix-thinking diagnose SESSION_ID # 12 corruption points
claude-session-fix-thinking fix SESSION_ID # 11 fixed, 1 residual
claude-session-fix-thinking fix SESSION_ID # residual cleaned
claude-session-fix-thinking diagnose SESSION_ID # clean
claude --resume SESSION_ID # working
For anyone hitting this: try the targeted fix first — it preserves thinking blocks where possible and creates backups automatically. Run diagnose after to verify clean, and do a second pass if needed. The nuke option (strips all thinking blocks) is available as a fallback.
Glad it worked for you to recover your session, @adam0white. I'd been planning to check out the issues and post this on the relevant one. Superb that you beat me to it!
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.