Skip to content

Compaction fails: thinking/redacted_thinking blocks in latest assistant message cannot be modified #41738

Closed as not planned

Description

@nathan-cook-ai

Summary

Compacting a session that uses an extended-thinking model fails with a Claude API validation error. The compaction request is rejected before it can run, so the session can no longer be compacted.

Error

undefined: The model returned the following errors: messages.49.content.13: `thinking` or `redacted_thinking` blocks in the latest assistant message cannot be modified. These blocks must remain as they were in the original response.

(The message/content indices vary per session.)

What I think is happening

When extended thinking is enabled, assistant messages contain thinking / redacted_thinking content blocks that Anthropic signs. On resend they must be byte-for-byte identical to the original response — they cannot be edited, truncated, reordered, or dropped.

Compaction rewrites/summarizes the conversation history and appears to mutate or partially copy a thinking block in an existing assistant message (rather than passing it through verbatim). The API then rejects the request with the error above.

Steps to reproduce

  1. Use a Claude model with extended thinking / reasoning enabled.
  2. Have a conversation long enough that at least one assistant turn contains a thinking block.
  3. Trigger compaction.
  4. Compaction fails with the error above and cannot complete.

Expected

Compaction should preserve thinking / redacted_thinking blocks verbatim (or drop whole assistant turns cleanly) so the resulting request passes Claude's validation.

Environment

  • OpenCode version: 1.18.4
  • Model: Claude (extended thinking / reasoning enabled)
  • Platform: Linux

Workarounds observed

  • Starting a fresh session avoids the corrupted history.
  • Disabling extended thinking for the model lets compaction proceed (no signed blocks in history).

Activity

  1. github-actions commented on Aug 11, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions