Skip to content

Critical: Conversation compaction fails for conversations started under previous Claude Code versions #12946

Closed as duplicate

Description

@joshcreter

Summary

Claude Code 2.0.57 cannot compact conversations that were started under previous versions, resulting in a 400 API error. This effectively freezes ongoing work in those conversations with no recovery path.

Error Message

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

Impact

Severity: Critical (P1)

  • Conversations at 0% context cannot proceed without compaction
  • Compaction fails, making these conversations permanently unusable
  • All accumulated context and work-in-progress is lost
  • No user-side workaround exists (this is an API validation error)

Environment

  • Claude Code version: 2.0.57
  • Previous version: Unknown (conversation started before upgrade)
  • Platform: macOS (Darwin 24.5.0)

Root Cause Hypothesis

The compaction process modifies message structure in a way that changes thinking blocks from previous assistant turns. The current API enforces that thinking/redacted_thinking blocks must remain byte-identical to original responses, causing validation failure.

Expected Behavior

Conversations started under previous Claude Code versions should remain functional after upgrade, including compaction. This is a basic backward compatibility expectation for production software.

Suggested Fixes

  1. Migration: Automatically migrate old conversation format on upgrade
  2. Compaction handling: Modify compaction to preserve thinking blocks exactly as stored
  3. Graceful degradation: If compaction fails, offer user options (export context, start fresh with summary) rather than hard failure

User Impact Statement

"Claude Code is not experimental software at this point. As a product owner, I would expect a clean transition from local file formats and/or API stability. Imagine if Microsoft Word didn't open previous documents!"

This breaks the fundamental contract of being able to continue previous work sessions.

Activity

  1. joshcreter commented on Dec 4, 2025

    @joshcreter
    Author

    Update: Issue Persists in 2.0.57

    Just encountered this again:

    > /compact
      ⎿ Error: Error during compaction: Error: API Error: 400
        {"type":"error","error":{"type":"invalid_request_error","message":"messages.3.content.101: `thinking` or `redacted_thinking`
        blocks in the latest assistant message cannot be modified. These blocks must remain as they were in the original
        response."},"request_id":"req_011CVnLgBPDzFuBq6FDWW27H"}
    

    Related Issues

    This appears to be part of a broader pattern affecting many users:

    Issue Title Comments Status
    #7530 [BUG] Error during compaction 92 Open (assigned, oncall)
    #10199 [BUG] API Error 400 - Thinking Block Modification Error 24 Open
    #12225 [BUG] API Error 400: Thinking Block Modification Error (Not a Duplicate) 19 Open
    #12973 Compaction fails with 400 error when thinking blocks present 2 Open
    #13086 [Bug] Cannot modify thinking blocks during message compaction 1 Open
    #12311 Auto-compact fails with Opus 4.5 extended thinking blocks 5 Open

    Impact Escalation

    This is now a production blocker. Conversations that hit context limits become completely unusable with no recovery path. The only workaround is:

    1. Manually /export the conversation
    2. Rewind (esc twice) to earlier state
    3. Lose all accumulated context and work

    This defeats the purpose of long-running agentic sessions.

    Note on Claimed Fixes

    In #7530, @sid374 mentioned fixes were shipped post-2.0.40. However, users continue reporting this in 2.0.55 and now 2.0.57. The fix appears incomplete or the root cause may be different for conversations that span version upgrades.

  2. joshcreter commented on Dec 4, 2025

    @joshcreter
    Author

    Correction: Workarounds Do NOT Work

    The workarounds suggested in #7530 are not viable in practice:

    1. /export fails - When the conversation is in this broken state, export also fails
    2. Rewinding context fails - The esc rewind mechanism also fails when thinking blocks are corrupted

    This means there is NO recovery path once a conversation hits this state. All accumulated context, work-in-progress, and session history is permanently lost.

    This is not an edge case inconvenience - this is data loss affecting production workflows.

  3. chenyanv commented on Dec 5, 2025

    @chenyanv

    I got the same error when I tried to click /compact, with the Sonnet 4.5 model. When all the context is used up, the agent gets stuck on "prompt is too long" and becomes completely unresponsive.

  4. willyjie23 commented on Dec 7, 2025

    @willyjie23

    same
    Image

  5. mnadler commented on Dec 8, 2025

    @mnadler

    Same issue for me on MacOS.

    Claude Code claims to have used internal thinking blocks (I didn't use ultrathink)

    /compact 
      ⎿ Error: Error during compaction: Error: API Error: 400 
        {"type":"error","error":{"type":"invalid_request_error","message":"me
        ssages.7.content.144: `thinking` or `redacted_thinking` blocks in the
         latest assistant message cannot be modified. These blocks must 
        remain as they were in the original 
        response."},"request_id":"req_011CVtGiUXiWBhpnjpfrJ2M5"}
    

    From Claude Code Agent

    This error happens because I use internal thinking blocks (even
      though they're not visible to you) and the API won't allow those to
       be modified during compaction.
    
  6. davidjpnelson commented on Dec 9, 2025

    @davidjpnelson

    Bumping;

    Error: Error during compaction: Error: API Error: 400 
    {
      "type":"error",
      "error": {
        "type":"invalid_request_error",
        "message":"messages.45.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."},
      "request_id":"req_011CVwLyz8qE1ti3pD4z1QZU"
    }
    
  7. dicksontsai commented on Dec 9, 2025

    @dicksontsai
    Collaborator

    Closing as duplicate of #12311 (earliest compact-related thinking block issue with most activity). Please follow that issue for updates.

  8. github-actions commented on Dec 17, 2025

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  9. locked as resolved and limited conversation to collaborators on Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions