Repository navigation
Description
Description
When using OpenCode with Claude models that have extended thinking enabled (e.g., claude-opus-4 via Amazon Bedrock), the API returns the following error after several conversation turns:
undefined: The model returned the following errors:
messages.3.content.7: `thinking` or `redacted_thinking` blocks in the latest assistant message
cannot be modified. These blocks must remain as they were in the original response.
This indicates that when OpenCode sends conversation history back to the Claude API, the thinking or redacted_thinking content blocks in assistant messages are being altered from their original form. The Claude API requires these blocks to be passed back byte-for-byte identical to how they were received.
Root Cause Hypothesis
Somewhere in the message serialization/deserialization pipeline (likely during session persistence, message compaction, or history truncation), the thinking blocks are being modified — possibly through:
- Message compaction/summarization stripping or truncating thinking blocks
- Database storage/retrieval altering the content (e.g., encoding changes, whitespace normalization)
- Content block filtering inadvertently modifying thinking blocks (note: v1.2.26 added "Filter empty content blocks for Bedrock provider" — similar pipeline)
Workaround
Starting a new session avoids the error since there are no prior thinking blocks in history.
Plugins
Custom skills/agents via .opencode/ config (not related to the issue — reproducible with default config)
OpenCode version
v1.2.20 (checked release notes through v1.2.27 — no related fix found)
Steps to reproduce
- Configure OpenCode with a Claude model that has extended thinking enabled (e.g.,
claude-opus-4via Amazon Bedrock withthinking_mode: auto) - Have a multi-turn conversation (3+ turns) where the model uses extended thinking
- The error occurs when the conversation history containing thinking blocks is sent back to the API
Note: This is intermittent — it depends on whether the model produces thinking blocks and how the history is managed across turns.
Screenshot and/or share link
Error message:
undefined: The model returned the following errors:
messages.3.content.7: `thinking` or `redacted_thinking` blocks in the latest assistant message
cannot be modified. These blocks must remain as they were in the original response.
Operating System
macOS (Apple Silicon)
Terminal
iTerm2 / Ghostty
Activity
github-actions commentedon Mar 18, 2026
This issue might be a duplicate of existing issues. Please check:
thinking/redacted_thinkingblocks in assistant messages cannot be modified after multi-turn conversations, same root cause in message history handlingIf your issue is the same as #13286, please add a reaction or comment there instead so the discussion stays focused.