Skip to content

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

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

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