API 400: thinking blocks mutated after advisor tool / Plan agent (Opus 4.7 extended thinking)

Resolved 💬 3 comments Opened Apr 24, 2026 by bfgpollara Closed Apr 27, 2026

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.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗