Repository navigation
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
Reacted by Jordan Love, Chris Weis, Christian Roy, Johanna Hawkins, GY, 나형진(Hyeongjin Na), Maurice Faber, Zain Rizvi, elHege, Neural Syndicate and 55 more
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
Activity
github-actions commentedon Oct 23, 2025
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
WamBamBoozle commentedon Oct 23, 2025
not a duplicate -- all the false positives listed above have different error messages
chops commentedon Oct 23, 2025
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)
bhaskarEEN commentedon Nov 3, 2025
how do you get the API response codes from the CLI ?
WamBamBoozle commentedon Nov 3, 2025
It just logged them. I did nothing special.
bhaskarEEN commentedon Nov 3, 2025
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
WamBamBoozle commentedon Nov 4, 2025
I lost the logs
zubin commentedon Nov 12, 2025
I'm getting a similar error after attempting to
/resumea Claude Code terminal session:It's displayed the first time I send a message since
/resume. Disabling thinking (pressing tab) resolved it.bhaskarEEN commentedon Nov 13, 2025
@zubin how do you get the API calls logged ?
zubin commentedon Nov 17, 2025
I didn't do anything log-related. Just tried
/resumeand that text was printed.80 remaining items
ryanleedavies commentedon May 28, 2026
Still reproducing this on a much newer Code version, and with a notably different
trigger pattern than OP's. Adding evidence in case it helps narrow it.
Environment
2.1.154(cc_version=2.1.154.230,cc_entrypoint=cli)v22.14.0claude-opus-4-8[1m]What's different from OP
OP reproduced on a long session (~14,976 lines,
messages.71.content.8) andhypothesized repeated questions / message-edit retries as contributing factors.
I'm reproducing on short, clean sessions — error indices
messages.1.content.24,messages.1.content.8, andmessages.3.content.8across three separate failures.So conversation depth and repeated questions aren't required; the bug fires on a
first-or-second assistant turn that contains interleaved thinking plus a multi-tool
Bash burst.
Reliable reproduction (~30 seconds, fresh session)
claude --debugfrom a directory with a few git repos as immediate children.~/path/to/src, then after Iapprove, run a few
git/lsbash calls to do it."issuing additional probe Bash calls (
pwd,echo hello,/bin/echo,true,isolated
git rev-parse,env -i /bin/bash,printf 'PROBE_OK') — appears tobe self-diagnostics after detecting something wrong in tool output.
/v1/messagesrequest 400s.Controls I ran first that all pass on the same install:
short single-tool plan-mode flows work in practice)
The failure requires plan-mode-exit transition + multi-tool turn + interleaved thinking.
Workaround for users hitting this: run multi-step commands in normal mode (Tab to
toggle out of plan mode).
Server-side identifiers for this failure
request_id:req_011CbVTRgxcdKgkdc5GRMurDx-client-request-id:f3f45405-61b8-4fc1-9e82-0a5698cbfd502026-05-28T18:40:45.196Z(request) →…45.441Z(400)attempt 1/11 … 11/11) 400 identically with the samerequest_id.What
--debugshows right before the failureTwo code paths look implicated.
(1) Dynamic tool loading re-walks message history before each main-loop dispatch.
Immediately before the 400:
If that walker is re-serializing assistant content blocks in place, it would
invalidate signed thinking blocks.
(2) Auto-mode classifier firing six times concurrently against the same conversation.
Between 18:40:00 and 18:40:28 (i.e. during the live turn):
transcriptEntriesandmessagesstay constant at4and14, buttools=fluctuates across consecutive classifier preparations:
3455, 3157, 3200, 2921, 2987, 2978. The tool inventory being serialized is mutating mid-turn while themain loop is also active — that's consistent with shared mutable state between
the main loop and the auto-permission classifier path.
Stack trace
Ruled out from my side
sessions (
/clearandclaudefrom a fresh shell), not resumed.~/.claudestate — full integrity check after a hard powercycle the same morning: all top-level JSON parses, all per-project
sessions-index.jsonparse,history.jsonllast line parses, all newestsession transcripts parse.
the thinking-block layer per the hooks reference ("cannot block the message or
change what is stored in the transcript or sent to Claude").
2.1.154is current at the time of repro.Happy to share the full ~970-line
--debuglog and the prior session transcriptsif useful.
robertfw commentedon May 28, 2026
I'm seeing this on Opus 4.8 version 2.1.145
I spotted complaints from the agent about tool calls returning no results, and I also saw this before one instance of this happening:
and then a little after...
edit: in another session, just prior to getting the error:
robertfw commentedon May 29, 2026
Another observation - I can go for a while with everything going fine, and then I'll see all of my agents start getting blank or corrupted tool call results, and shortly after they'll hit the issue.
I've had some luck using the following script to un-block sessions, but it doesn't stop the problem. Just helps avoid losing work.
https://gist.github.com/robertfw/993dbe8643c4fbdf12005dff2eca1f90
chid commentedon May 29, 2026
Thanks @robertfw - I've just tried that and it works well! Did they also just recently reset quotas?
ijstokes commentedon May 29, 2026
Another reproducible trigger on 2.1.154: a heredoc inside a parallel Bash batch → orphaned
tool_useblocks → permanent 400Adding a concrete, deterministic trigger that fits the "blank/cancelled tool results shortly before the 400" pattern several others have reported in this thread. We hit it across multiple autonomous agents; sharing the mechanism, a redacted trace, and the agent-side mitigation that stopped it for us.
Environment
2.1.154, macOS (Darwin, arm64)/loopauto-resumeHow it happens (trigger)
A single turn emitted several Bash calls in parallel. One was a multi-line command containing a heredoc (
<<'EOF' … EOF). The heredoc terminator got split off and ran as its own command (EOF→command not found, exit 127). That error cancelled the sibling parallel calls, leaving theirtool_useblocks with no matchingtool_result— in an assistant turn that also contained signedthinkingblocks.(The same batch also had an unquoted URL containing
?ref=<sha>→ a zshno matches foundglob failure. A second way these batches die, same root cause: hand-built shell strings with metacharacters.)Why it wedges
On the next request, the prior assistant turn's
thinkingblocks must be re-sent verbatim. With the batch partially cancelled and the turn in a modified state, the resend is rejected:The API rule itself is intentional — the problem is that the harness gets into an unsendable state and cannot get out: the corrupted turn stays in history, so every subsequent request — including each
/loopwakeup — replays it and 400s identically. Unrecoverable.Redacted trace
(identifiers genericised:
<repo>,<path>,<sha>,<dir>)How to recover
No in-session recovery — the poisoned turn is fixed in history. We abandon the session and start a fresh one. (Others in this thread have posted transcript-surgery scripts that strip/repair the offending block as a partial workaround.)
How we mitigated (agent-side, until a fix lands)
Because the trigger is deterministic, we codified three rules for our agents:
cat <<EOF,echo >)./loop/ auto-resume must start a fresh session on an unrecoverable 400 rather than replay the transcript.(1) and (2) remove the trigger; (3) stops a transient failure from becoming permanent. Happy to add more detail if useful.
rondoallaturka commentedon May 29, 2026
Same error reproduces on a fresh single-turn session under remote control (not deep history)
Hit
API Error 400: messages.1.content.14: thinking or redacted_thinking blocks in the latest assistant message cannot be modified— but the conditions are different from the original report, and I think they localize the bug:/clear, with a single user request. Not a long/deep session.alwaysThinkingEnabled: true)./clearand re-running reproduce it identically; a fresh request hits the same 400 at message 1.Working hypothesis: the assistant turn gets re-serialized across the remote-control relay between phone and Mac, re-encoding a thinking block so it no longer matches its signature → API rejects it. That would explain why it fails on turn 1 and why the local v2.1.156 fix doesn't cover it (different code path).
Workaround that avoids it: setting
alwaysThinkingEnabled: false(no thinking blocks for the relay to touch).Environment: macOS, Claude Code CLI v2.1.156, remote control via mobile app.
evnchn commentedon May 29, 2026
No bug triggered when resort to Opus 4.7:
claude --dangerously-skip-permissions --model claude-opus-4-7dotsinspace commentedon May 30, 2026
is it on 4.8 only ? any fix guys
moszoro commentedon May 30, 2026
Switching to 4.7 helps
chid commentedon May 30, 2026
I’m not sure this is consistently tied to heredoc usage. I’ve also noticed the issue with 4.7 in sessions that don’t use heredocs.I put together a quick script that worked for me to identify affected sessions: https://gist.github.com/chid/aa4169a086ccea78545611c1e0963251After identifying them, I used the fix above to strip the affected session data #10199 (comment). It then successfully resumed.
feat(missions): switch models on the fly + bump claudecode CLI to 2.1…
robertfw commentedon May 30, 2026
No, I've seen this on 4.7 as well.
Today I just saw this:
I run multiple agents and keep an eye on all (well most) of them one one screen, and I'll see this start to occur across all of them at the same time.
I think this has to do with the increased measures of hiding thinking text from the agent (to prevent distillation/training by other LLMs), and it's either being overzealous or being applied wrong, or the harness/agent doesn't know how to deal with the hidden responses.
tanguc commentedon May 31, 2026
still on opus 4.8
samkazmi110 commentedon Jun 26, 2026
burning my tokens and giving me error in the end "opus 4.8 Thinking Effort = Max" any timeline when this will be fixed?
note: thinking effort = High is working. it is only "Max" throwing an error for me
fix(gateway): ToolSearch 历史 signed thinking 预过滤 (#63792/#10199) (#1087)