-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Open
Labels
area:apiarea:corebugSomething isn't workingSomething isn't workinghas reproHas detailed reproduction stepsHas detailed reproduction stepsoncallplatform:macosIssue specifically occurs on macOSIssue specifically occurs on macOS
Description
Preflight Checklist
- I have searched existing issues and this hasn't been reported yet
- This is a single bug report (please file separate reports for different bugs)
- 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:apiarea:corebugSomething isn't workingSomething isn't workinghas reproHas detailed reproduction stepsHas detailed reproduction stepsoncallplatform:macosIssue specifically occurs on macOSIssue specifically occurs on macOS