400 'thinking blocks in the latest assistant message cannot be modified' with extended thinking + experimental agent-teams (bridge-session)
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=1in~/.claude/settings.json- Extended thinking enabled
What happens
The error is generated at request-build time, not on disk. I verified this directly:
- Stripped every
thinking/redacted_thinkingblock from the affected session JSONL (transcript then contained 0 thinking blocks; the file parses cleanly). - Resumed the session on Opus 4.8.
- 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
- Set
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1, extended thinking on, model Opus 4.8. - Run a session that uses agent teams enough to accumulate
bridge-sessionboundaries (spawning teammates / SendMessage across turns). - Continue the session through a few thinking turns.
- Observe the
400 ... thinking blocks in the latest assistant message cannot be modifiedand 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.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗