claude-code - 💡(How to fix) Fix Opus 4.8: thinking blocks broken by context compaction — 400 error on every turn after first compaction

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…

Once Claude Code compacts conversation context in a session using Opus 4.8, every subsequent turn fails with a 400 API error. The session becomes permanently broken and the only recovery is to start a new conversation.

Error Message

API Error: 400 messages.1.content.24: `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

Opus 4.8 uses extended thinking, which produces thinking / redacted_thinking blocks in assistant messages. The Anthropic API requires these blocks be preserved verbatim in conversation history on subsequent requests. The Claude Code context compaction/summarization step modifies or removes these blocks, violating that constraint and causing the 400 error.

Fix Action

Workaround

Switch to Sonnet 4.6, which does not use extended thinking and is not affected.

Code Example

API Error: 400 messages.1.content.24: `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

Once Claude Code compacts conversation context in a session using Opus 4.8, every subsequent turn fails with a 400 API error. The session becomes permanently broken and the only recovery is to start a new conversation.

Error message

API Error: 400 messages.1.content.24: `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

Opus 4.8 uses extended thinking, which produces thinking / redacted_thinking blocks in assistant messages. The Anthropic API requires these blocks be preserved verbatim in conversation history on subsequent requests. The Claude Code context compaction/summarization step modifies or removes these blocks, violating that constraint and causing the 400 error.

Steps to reproduce

  1. Start a session with model set to Opus 4.8 (1M context)
  2. Have a long enough conversation to trigger context compaction
  3. Send any follow-up message
  4. Observe the 400 error — the session is now permanently broken

Environment

  • Claude Code version: 2.1.154
  • Model: claude-opus-4-8 (1M context)
  • Platform: Linux

Expected behavior

Context compaction should preserve thinking / redacted_thinking blocks verbatim, or exclude them from summarization entirely.

Workaround

Switch to Sonnet 4.6, which does not use extended thinking and is not affected.

Impact

Opus 4.8 is unusable for any non-trivial session length. This is a regression introduced with the 4.8 release — the harness was not updated alongside the new model to handle thinking blocks correctly.

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…

FAQ

Expected behavior

Context compaction should preserve thinking / redacted_thinking blocks verbatim, or exclude them from summarization entirely.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING