anomalyco / anomalyco/opencode

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

Open
#41,738 1 comment 0 reactions 1 assignee View on GitHub

@nexxeln is already working on this.

Since Aug 11, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

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).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.