claude-code - 💡(How to fix) Fix /compact fails with 'thinking or redacted_thinking blocks cannot be modified' error when context is too long

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…

When a conversation reaches the context limit and the user runs /compact, compaction fails with the following error:

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

This leaves the user completely stuck — the conversation is too long to continue, but /compact also fails, so there's no way to recover the session.

Error Message

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

Actual Behavior

Compaction fails because the last assistant message contains thinking or redacted_thinking blocks, which the API does not allow to be modified during compaction.

Code Example

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

Bug Report

Description

When a conversation reaches the context limit and the user runs /compact, compaction fails with the following error:

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

This leaves the user completely stuck — the conversation is too long to continue, but /compact also fails, so there's no way to recover the session.

Steps to Reproduce

  1. Have a long conversation that reaches the context limit
  2. See the "Conversation is too long" error banner
  3. Run /compact
  4. Compaction fails with the error above

Expected Behavior

/compact should successfully summarize and compress the conversation history, allowing the session to continue.

Actual Behavior

Compaction fails because the last assistant message contains thinking or redacted_thinking blocks, which the API does not allow to be modified during compaction.

Impact

User is completely unable to recover the session — cannot compact, cannot continue, only option is to start a new chat and lose all context.

Suggested Fix

Before compaction, strip or handle thinking/redacted_thinking blocks from the latest assistant message so the API call doesn't fail.

Environment

  • Claude Code CLI
  • Reported by user via FleetView session

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

claude-code - 💡(How to fix) Fix /compact fails with 'thinking or redacted_thinking blocks cannot be modified' error when context is too long