claude-code - 💡(How to fix) Fix [BUG] /compact fails with 400 error when last assistant turn contains thinking blocks

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

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

Error: Error during compaction: API Error: 400 messages.181.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.

Fix Action

Fix / Workaround

Workaround

Code Example

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

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

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

When a conversation grows long enough to trigger compaction (either via /compact or auto-compact), the operation fails with a 400 API error if the most recent assistant message contains thinking or redacted_thinking blocks. The conversation is then stuck — too long to continue, but impossible to compact.

Actual behavior

Compaction fails completely. The session is stuck — the conversation is too long to continue and /compact cannot recover it. The only escape is /clear (losing all context) or starting a new conversation.

Workaround

Run /compact manually early, while the conversation still has room, before auto-compact triggers at the edge. Starting a new conversation and pasting in context also works.

Environment

Claude Code version: (check claude --version) Model: any model with extended thinking enabled Platform: (your OS)

What Should Happen?

Expected behavior

/compact should handle conversations that end with thinking blocks. It should either:

Exclude the last assistant turn's thinking blocks from the summary payload (keeping only the text blocks for context), or Omit the last assistant message from the replay entirely and let the summary stand alone

Error Messages/Logs

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

Error: Error during compaction: API Error: 400 messages.181.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.

Steps to Reproduce

To reproduce

Use a model with extended thinking enabled (e.g. Opus fast mode) Have a long multi-turn conversation until it approaches the context limit Run /compact (or wait for auto-compact to trigger) Observe the 400 error — compaction fails and the session is unrecoverable

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

opus 4.7 1m

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other

Additional Information

using claude for vscode extension access in cursor

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