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
- 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).
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
(The message/content indices vary per session.)
What I think is happening
When extended thinking is enabled, assistant messages contain
thinking/redacted_thinkingcontent 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
thinkingblock in an existing assistant message (rather than passing it through verbatim). The API then rejects the request with the error above.Steps to reproduce
thinkingblock.Expected
Compaction should preserve
thinking/redacted_thinkingblocks verbatim (or drop whole assistant turns cleanly) so the resulting request passes Claude's validation.Environment
Workarounds observed