claude-code - 💡(How to fix) Fix [Bug] Anthropic API Error: thinking blocks corrupted during context compaction with extended thinking enabled

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…

Error Message

Recurring 400 error mid-conversation with extended thinking enabled: API Error: 400 messages.3.content.1: thinking or redacted_thinking blocks First turn succeeds; the error appears on a later turn when a prior assistant message containing a thinking block is

Fix Action

Fix / Workaround

Bug Description Title: 400 "thinking blocks cannot be modified" mid-conversation with no user-side trigger

Description:

Recurring 400 error mid-conversation with extended thinking enabled:

API Error: 400 messages.3.content.1: thinking or redacted_thinking blocks in the latest assistant message cannot be modified. These blocks must remain as they were in the original response.

First turn succeeds; the error appears on a later turn when a prior assistant message containing a thinking block is replayed. messages.3.content.1 points to a thinking block that was altered before being re-sent.

Important: This happens during normal use with no user-side trigger — I did not interrupt a streaming response, did not queue/type a message while the assistant was responding, did not switch models, and did not use /rewind or edit any previous message. This points to internal history handling (likely context compaction or message replay) corrupting the thinking block rather than a user action.

Environment:

  • Claude Code: 2.1.154 (native install, latest available)
  • Platform: macOS (Darwin 25.5.0), arm64
  • Shell: zsh
  • Model: Opus 4.8 (1M context), effortLevel: high
  • Hooks: one PreToolUse hook (matcher Bash) → rtk hook claude (ruled out — Bash-only, never touches messages)

Workaround: /clear restores the session.

Code Example

[]
RAW_BUFFERClick to expand / collapse

Bug Description Title: 400 "thinking blocks cannot be modified" mid-conversation with no user-side trigger

Description:

Recurring 400 error mid-conversation with extended thinking enabled:

API Error: 400 messages.3.content.1: thinking or redacted_thinking blocks in the latest assistant message cannot be modified. These blocks must remain as they were in the original response.

First turn succeeds; the error appears on a later turn when a prior assistant message containing a thinking block is replayed. messages.3.content.1 points to a thinking block that was altered before being re-sent.

Important: This happens during normal use with no user-side trigger — I did not interrupt a streaming response, did not queue/type a message while the assistant was responding, did not switch models, and did not use /rewind or edit any previous message. This points to internal history handling (likely context compaction or message replay) corrupting the thinking block rather than a user action.

Environment:

  • Claude Code: 2.1.154 (native install, latest available)
  • Platform: macOS (Darwin 25.5.0), arm64
  • Shell: zsh
  • Model: Opus 4.8 (1M context), effortLevel: high
  • Hooks: one PreToolUse hook (matcher Bash) → rtk hook claude (ruled out — Bash-only, never touches messages)

Workaround: /clear restores the session.

Environment Info

  • Platform: darwin
  • Terminal: Apple_Terminal
  • Version: 2.1.154
  • Feedback ID: 835f774d-11b2-4799-a94d-671158993161

Errors

[]

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