claude-code - 💡(How to fix) Fix API 400: thinking blocks mutated after advisor tool / Plan agent (Opus 4.7 extended thinking) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52676Fetched 2026-04-24 10:42:43
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×5commented ×1

Claude Code gets wedged into an unrecoverable 400 invalid_request_error after invoking tools/agents that use Opus 4.7 extended thinking (the advisor tool, and separately when passing plans to the Plan agent from the web/plan mode). The error indicates a thinking / redacted_thinking block in a prior assistant message has been modified between turns. Because the corrupted message is baked into the session history, every subsequent user prompt fails with the same error on the same message index — the session becomes unusable until /compact or /clear.

Error Message

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.25.content.31: `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_011CaMr8CRqANnScPay5pjK6"}

Additional request IDs from the same wedged session (same error, consecutive retries):

  • req_011CaMqywrGCmzCJpBvskQie
  • req_011CaMr529s8n6UoHRn4x4Nf
  • req_011CaMr8CRqANnScPay5pjK6

Root Cause

Claude Code gets wedged into an unrecoverable 400 invalid_request_error after invoking tools/agents that use Opus 4.7 extended thinking (the advisor tool, and separately when passing plans to the Plan agent from the web/plan mode). The error indicates a thinking / redacted_thinking block in a prior assistant message has been modified between turns. Because the corrupted message is baked into the session history, every subsequent user prompt fails with the same error on the same message index — the session becomes unusable until /compact or /clear.

Code Example

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.25.content.31: `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_011CaMr8CRqANnScPay5pjK6"}
RAW_BUFFERClick to expand / collapse

Summary

Claude Code gets wedged into an unrecoverable 400 invalid_request_error after invoking tools/agents that use Opus 4.7 extended thinking (the advisor tool, and separately when passing plans to the Plan agent from the web/plan mode). The error indicates a thinking / redacted_thinking block in a prior assistant message has been modified between turns. Because the corrupted message is baked into the session history, every subsequent user prompt fails with the same error on the same message index — the session becomes unusable until /compact or /clear.

Error

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.25.content.31: `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_011CaMr8CRqANnScPay5pjK6"}

Additional request IDs from the same wedged session (same error, consecutive retries):

  • req_011CaMqywrGCmzCJpBvskQie
  • req_011CaMr529s8n6UoHRn4x4Nf
  • req_011CaMr8CRqANnScPay5pjK6

Repro (two paths observed)

Path A — advisor tool mid-session:

  1. Running on Opus 4.7 (claude-opus-4-7[1m]) in an interactive session.
  2. Model calls the advisor tool (which itself uses Opus 4.7 with extended thinking and returns thinking blocks in the assistant message).
  3. Model continues with the next tool call (in my case a Bash grep).
  4. The tool result comes back and the next API request fails with the 400 above.
  5. Retrying the user prompt produces the identical error — the bad assistant message is permanent in history.

Path B — Plan agent / passing plans on the web:

  • Same error class has occurred when passing a plan to the Plan agent from plan mode in the web UI. Don't have the request IDs for that occurrence, but the failure mode is identical (thinking block mutation complaint, session unrecoverable without /compact).

Expected

Tools/agents that return extended-thinking content should have those thinking / redacted_thinking blocks (with their signature fields) passed back to the API verbatim on subsequent turns. They should not be re-serialized, reordered, stripped of signature, or otherwise mutated by the client.

Actual

Something in the advisor/Plan integration is modifying the thinking block between when it's received and when it's sent back in the next request, triggering API rejection. Once this happens the session can't continue — only /compact or /clear recovers.

Environment

  • Claude Code: 2.1.119
  • Model: Opus 4.7 (1M context) — claude-opus-4-7[1m]
  • macOS: 15.7.4
  • Shell: zsh

Impact

Medium-high for anyone using the advisor tool or Plan agent on Opus 4.7. Work-in-progress context is effectively lost — /compact recovers the session but drops thinking blocks from history, and /clear loses everything. Filing so the advisor/Plan pipeline can be audited for thinking-block passthrough.

extent analysis

TL;DR

The issue can likely be fixed by ensuring that thinking and redacted_thinking blocks are passed back to the API verbatim without any modifications.

Guidance

  • Verify that the advisor tool and Plan agent are not modifying the thinking or redacted_thinking blocks in any way, including re-serialization, reordering, or stripping of signature fields.
  • Check the integration code between the advisor tool, Plan agent, and the API to ensure that these blocks are passed through unchanged.
  • Test the advisor tool and Plan agent separately to isolate where the modification is occurring.
  • Consider adding logging or debugging statements to track the thinking and redacted_thinking blocks as they are received and sent back to the API.

Example

No code snippet is provided as the issue does not include specific code details.

Notes

The issue seems to be related to the modification of thinking and redacted_thinking blocks between turns, which is not allowed by the API. The advisor tool and Plan agent need to be audited to ensure they are passing these blocks through correctly.

Recommendation

Apply a workaround to ensure that thinking and redacted_thinking blocks are passed back to the API verbatim, as modifying these blocks is not allowed and causes the session to become unrecoverable.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix API 400: thinking blocks mutated after advisor tool / Plan agent (Opus 4.7 extended thinking) [1 comments, 2 participants]