You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Compaction fails: thinking/redacted_thinking blocks in latest assistant message cannot be modified #41738
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
Use a Claude model with extended thinking / reasoning enabled.
Have a conversation long enough that at least one assistant turn contains a thinking block.
Trigger compaction.
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).
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.
Activity
github-actions commentedon Aug 11, 2026
This issue might be a duplicate of existing issues. Please check:
thinkingblock to the Anthropic API, resulting in a permanent 400 retry loopthinkingblocks (Anthropic extended thinking) #31188: Same error message and behavior — compaction always fails when session containsthinkingblocks from extended thinking models (also includes a detailed root cause analysis and proposed fix incompaction.ts/message-v2.ts)thdxr commentedon Oct 11, 2026
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 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊