claude-code - 💡(How to fix) Fix 400 'thinking blocks in the latest assistant message cannot be modified' with extended thinking + experimental agent-teams (bridge-session)

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…

With extended thinking enabled (Opus 4.8) and the experimental agent-teams feature on (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1), the API rejects every send in an affected session with:

API Error: 400 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.

The session becomes hard-stuck: every retry re-sends the same poisoned latest turn and 400s again. Switching the model to one that does not emit thinking blocks (e.g. Sonnet 4.6) lets the session continue, which is what masks the root cause.

Error Message

API Error: 400 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.

Root Cause

The session becomes hard-stuck: every retry re-sends the same poisoned latest turn and 400s again. Switching the model to one that does not emit thinking blocks (e.g. Sonnet 4.6) lets the session continue, which is what masks the root cause.

Fix Action

Workaround

  • Disable CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS, or
  • Run extended-thinking models in sessions that are not teams-bridged, or
  • Temporarily switch to a non-thinking model to get unstuck, then strip thinking blocks from the JSONL before resuming on a thinking model.

Code Example

API Error: 400 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.
RAW_BUFFERClick to expand / collapse

Summary

With extended thinking enabled (Opus 4.8) and the experimental agent-teams feature on (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1), the API rejects every send in an affected session with:

API Error: 400 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.

The session becomes hard-stuck: every retry re-sends the same poisoned latest turn and 400s again. Switching the model to one that does not emit thinking blocks (e.g. Sonnet 4.6) lets the session continue, which is what masks the root cause.

Environment

  • Claude Code version: 2.1.154
  • Model: claude-opus-4-8 (also reproduced on the 1M-context variant claude-opus-4-8[1m])
  • OS: Windows 11 Pro (26200)
  • CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 in ~/.claude/settings.json
  • Extended thinking enabled

What happens

The error is generated at request-build time, not on disk. I verified this directly:

  1. Stripped every thinking/redacted_thinking block from the affected session JSONL (transcript then contained 0 thinking blocks; the file parses cleanly).
  2. Resumed the session on Opus 4.8.
  3. The harness generated 12 new thinking blocks during the next turns and 400'd again with the same error.

So a transcript cleaner is only a band-aid — the modification recurs every time extended thinking emits a block in an affected session.

Correlation with agent-teams bridging

The affected session is saturated with session-bridging: a 22,500-line transcript contained 1,541 bridge-session records, with bridge boundaries appearing immediately before each poisoned assistant turn. Each bridge reconstructs the message array, which appears to mutate the latest assistant turn's thinking block (or change the set of sibling blocks in that turn), invalidating the signature the API validates against.

  • Disabling extended thinking → no error (no thinking blocks to mutate).
  • Disabling CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS → expected to resolve (the bridging that reconstructs the turn no longer runs). (Filing this report at the same time as switching the flag off to confirm.)
  • Sonnet 4.6 (no extended thinking) → never reproduces.

Ruled out

  • No user hook rewrites the transcript. The only configured hooks (a memory-compiler's SessionStart/PreCompact/SessionEnd) read the transcript and write to separate files; they never modify the session JSONL.
  • The empty-text-block repair script (issue #54421) is not wired as a hook here.

Steps to reproduce

  1. Set CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1, extended thinking on, model Opus 4.8.
  2. Run a session that uses agent teams enough to accumulate bridge-session boundaries (spawning teammates / SendMessage across turns).
  3. Continue the session through a few thinking turns.
  4. Observe the 400 ... thinking blocks in the latest assistant message cannot be modified and the session getting stuck.

Expected

Session bridging (and any other request-build step) must preserve thinking/redacted_thinking blocks in the latest assistant message byte-for-byte, or omit them per the API's rules for prior turns — never emit a modified copy.

Workaround

  • Disable CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS, or
  • Run extended-thinking models in sessions that are not teams-bridged, or
  • Temporarily switch to a non-thinking model to get unstuck, then strip thinking blocks from the JSONL before resuming on a thinking model.

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