[BUG] API Error 400 - Thinking Block Modification Error
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
The Claude Code session became completely unresponsive with repeated API 400 errors. Every subsequent user input triggered the same error, making recovery impossible.
Symptom: Session entered an error loop where the conversation history reached a corrupted state:
- A previous assistant response contained thinking blocks
- The system attempted to modify or replay that message's thinking blocks
- The API correctly rejected this (thinking blocks are immutable once sent)
- The error persisted because the corrupted state remained in conversation history
Error Pattern: The error occurred at messages.71.content.8 (71st message, 8th content block), indicating:
- Deep conversation history (71 messages)
- Specific content block contained thinking blocks that couldn't be modified
- Every subsequent user input triggered the same error
Contributing Factors:
- Long session: Nearly 15k lines of transcript suggests extended conversation
- Complex workflow: Multiple tool calls, file reads, git operations
- Repeated questions: Same question asked multiple times may have confused state
- Message editing attempt: The system may have tried to edit/retry previous responses
Impact:
- Session Status: Completely unrecoverable
- User Action: Had to save transcript and start new session
- Work Status: Context lost mid-conversation about a technical topic
- Data Loss: Any uncommitted mental state/context
What Was Lost:
- Active conversation context and unresolved questions
- Current working state and recent discussion topics
- Mental model of the problem being discussed
What Should Happen?
Expected Behavior:
- Claude Code should handle long conversations gracefully without entering unrecoverable error states
- If thinking blocks cannot be modified (as per API constraint), the system should detect this condition before submitting the request
- When errors occur, the system should offer graceful degradation options
Ideal Recovery Flow:
- Detect when conversation state is approaching problematic conditions
- Offer to summarize current state
- Save context to file automatically
- Start fresh session with context restored
- Or provide mechanism to "rewind" conversation history to before corrupted state
Preventive Measures That Should Exist:
- Conversation state validation to detect when thinking blocks are being modified
- Message history pruning or summarization for very long conversations
- Threshold warnings when conversation history reaches risky size (>10k lines)
- Checkpoint mechanism to enable rollback to stable state
Error Messages/Logs
### Primary Error Message
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.71.content.8: `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_011CUQZ6ttKtJbU8JQRYyizo"}
### Error Repetition Pattern
Line 14957: User asks question → API Error 400
Line 14961: User asks same question → API Error 400 (same request)
Line 14965: User asks same question → API Error 400 (same request)
Line 14969: User references the error itself → API Error 400
Line 14974: User asks to update memory files → API Error 400
### Technical Details
**API Endpoint**: Anthropic Claude API (claude.code integration)
**Error Type**: `invalid_request_error`
**Error Message Pattern**:
messages.{N}.content.{M}: `thinking` or `redacted_thinking` blocks in the latest
assistant message cannot be modified. These blocks must remain as they were in
the original response.
Where:
- `{N}` = Message index in conversation history (71 in this case)
- `{M}` = Content block index within that message (8 in this case)
**Request IDs**:
- req_011CUQZ6ttKtJbU8JQRYyizo
- req_011CUQZ8XPZgRdbaXt8GJrxy
- req_011CUQZ9SAKKbLfL1g7ieqU8
- req_011CUQZAR1eH1AotrvNzGhx8
**Transcript Available**: Yes (763.4KB, 14,976 lines)
Steps to Reproduce
Context Leading to Error
- User and assistant engaged in extended session about a technical topic (~14,976 lines)
- Conversation involved multiple rounds of investigation and explanation
- Assistant provided detailed technical explanations
- User asked follow-up question requesting clarification
- Same question was asked 3 times in succession (possibly due to user not seeing response)
- ERROR STATE TRIGGERED
Reproduction Steps
- Start Claude Code session
- Engage in extended conversation with multiple tool calls, file reads, and complex workflows
- Reach approximately 71 messages deep in conversation history
- Have assistant generate response with thinking blocks
- Ask follow-up question that may trigger message retry or state replay
- Observe API Error 400 with thinking block modification error
- Attempt to continue session → error repeats for all subsequent inputs
Conditions That May Trigger
- Very long sessions (>10k lines of transcript)
- Conversation history at ~71 messages or deeper
- Assistant responses containing thinking blocks
- Rapid repeated questions (asked 3 times in succession in this case)
- Complex multi-turn workflows with many tool calls
Warning Signs
- Session approaching 10k+ lines of transcript
- Repeated API errors occurring
- Same question triggering errors multiple times
- Any API 400 error mentioning thinking blocks
Recovery Actions Taken
- User saved full transcript to local file
- User started new Claude Code session
- User asked new session to review the transcript
- User requested this bug report be filed
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
2.0.25 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
IntelliJ IDEA terminal
Additional Information
No response
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/2171
- https://github.com/anthropics/claude-code/issues/1702
- https://github.com/anthropics/claude-code/issues/2608
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
not a duplicate -- all the false positives listed above have different error messages
Experiencing a similar issue with CC throwing 400's.
Claude Code Version: 2.0.25 Login method: Claude Max Account Model: Sonnet 4.5 (default) OS: GNU Guix TERM: xterm-256color (via ssh)
how do you get the API response codes from the CLI ?
It just logged them. I did nothing special.
It just logged them. I did nothing special.
Can you please elaborate ? I am also facing a similar issue but not sure if it is the same in vs code terminal. I wanted to verify if it is the 400 response as you have mentioned. It would be nice if you can share how you log the claude-code's API calls. Please & thank you
I lost the logs
I'm getting a similar error after attempting to /resume a Claude Code terminal session:
⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.19: The final block in an assistant
message cannot be `thinking`."},"request_id":"req_011CV4VkJfmm9mTv9eWV9381"}
It's displayed the first time I send a message since /resume. Disabling thinking (pressing tab) resolved it.
@zubin how do you get the API calls logged ?
@zubin how do you get the API calls logged ?
I didn't do anything log-related. Just tried /resume and that text was printed.
I am getting this also. As a workaround, instead of a long prompt, I am writing my prompt to a .md file and then instructing claude-code to read and implement the instructions in the .md.
experiencing similar issue too, here is the log
{"message":"400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.1.content.0: Invalid `signature` in `thinking` block\"},\"request_id\":\"req_vrtx_011CVMkoUR3ukzE5uNm6Nuip\"}","status":400,"request_id":"req_vrtx_011CVMkoUR3ukzE5uNm6Nuip","modelId":"claude-sonnet-4-5@20250929","providerId":"vertex","details":{"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.0: Invalid `signature` in `thinking` block"},"request_id":"req_vrtx_011CVMkoUR3ukzE5uNm6Nuip"}}
Request ID: req_vrtx_011CVMkoUR3ukzE5uNm6Nuip
This started happening to me a few hours ago when using /resume in Claude Code cli. Functions without issue in other cases.
similar issue.
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.9.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_011CVQSt71zTgpRrWfMKDwaZ"}
claude code 2.0.50 , Max user, ubuntu(wsl)
rewinding 2 or 3 messages usually solves this issue for me.
similar issue. 2.0.50 (Claude Code), Pro User, Mac os
⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.9.content.24: 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_011CVQp9vC1ZRNZGKGyJHSCm"}
same problem, turning thinking off does not fix the problem
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.7.content.5: `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_011CVRLyHHZxZ7edDKMNR7K9"}
I just got this for the first time.
- I first rewound two messages prior to the error first appearing (i.e., to the latest conversation state that previously did not result in the error on the next message), but this did not resolve the error
- I next tried disabling thinking: messages sent with thinking disabled did not produce the error in that state
- Re-enabling thinking and sending a message produced the error again
- I then rewound by an additional message (undoing a step that resulted in a large number of auto accepted edits, though I didn't revert the code), and in this state did not get the error even with thinking enabled
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.21.content.116:
thinkingorredacted_thinkingblocks in the latest assistant message cannot be modified. These blocks must remain as they were in the original response."},"request_id":"req_011CVRbhLRdv1LZsPvyyGksL"}
+1, lost all progress, gotta copy to restart, any best recovery method?
compaction via /compact seemed to fix it for me
Same here, but compacting does not fix the issue either (nor does disable thinking, or going back to the previous message).
Same Once it is happened, I can't use /compact and request any prompt more
Workaround that worked for me:
I encountered the same error and was able to resolve it by manually removing thinking blocks from the conversation JSONL file.
Steps:
- Close Claude Code completely
- Find the conversation file:
ls -la ~/.claude/projects/
# Look for the largest/most recent .jsonl file in your project folder
- Backup and fix the file:
import json
filepath = "/path/to/your/session.jsonl"
with open(filepath, 'r') as f:
lines = f.readlines()
with open(filepath, 'w') as f:
for line in lines:
if not line.strip():
continue
data = json.loads(line)
if 'message' in data and 'content' in data['message']:
if isinstance(data['message']['content'], list):
data['message']['content'] = [
c for c in data['message']['content']
if c.get('type') not in ('thinking', 'redacted_thinking')
]
f.write(json.dumps(data) + '\n')
- Restart Claude Code
This is a temporary workaround until an official fix is released. Hope this helps others facing the same issue!
@nahyeongjin1 Sounds good! Thanks for sharing!! I'll try it next time it comes up.
@nahyeongjin1 this workaround worked perfectly for me, thank you 🙏🏽