Compaction fails with 400 when conversation contains thinking/redacted_thinking blocks

Resolved 💬 3 comments Opened Feb 18, 2026 by JaneAdora Closed Feb 22, 2026

Description

Both automatic context compaction and the /compact command fail with HTTP 400 when the conversation history contains thinking or redacted_thinking blocks (extended thinking output). This makes it impossible to continue or compact long sessions that used extended thinking.

Error

400: {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.10: \`thinking\` or \`redacted_thinking\` blocks in the latest assistant message cannot be modified. These blocks must remain as they were in the original response."}}

Full error chain logged as:

Error in API request: 400 ...
Error: API Error: 400 ...
Error during compaction: Error: API Error: 400 ...

Steps to Reproduce

  1. Start a session with extended thinking active
  2. Have a conversation long enough to approach context limits (or manually run \/compact\)
  3. Compaction is triggered (automatically or via \/compact\)
  4. Compaction agent attempts to pass conversation history to API
  5. API rejects with 400 because thinking blocks cannot be modified

Expected Behavior

Compaction should strip or preserve thinking/redacted_thinking blocks correctly before sending to the API. The API requires these blocks to pass through verbatim — the compaction process should either preserve them as-is or remove them entirely before summarizing.

Actual Behavior

The compaction fork crashes, the error propagates as "Error during compaction", and the session becomes unusable — too long to continue, but unable to compact.

Impact

Session is unrecoverable. The user is stuck in a catch-22: context too long to continue, /compact fails with the same error. The only option is to abandon the session.

Environment

  • Claude Code version: 2.1.45.760 (from debug log)
  • Session ID: 2778146d-8896-4b3c-8199-b78b04323316
  • Platform: Linux

Suggested Fix

Before sending the conversation to the compaction API, strip or properly handle thinking/redacted_thinking content blocks so they don't violate the API constraint.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗