Description
When using an Anthropic model with extended thinking enabled, the following error appears mid-conversation:
The model returned the following errors: messages.N.content.1: thinking or redacted_thinking blocks in the latest assistant message cannot be modified.
Root cause is in packages/opencode/src/session/message-v2.ts. When reconstructing conversation history, reasoning parts strip providerMetadata when the message was produced by a different model:
...(differentModel ? {} : { providerMetadata: part.metadata }),
This is correct for text and tool parts — it prevents provider-specific data (e.g. OpenAI itemId) from leaking into other providers. But Anthropic's thinking blocks carry a cryptographic signature inside providerMetadata. Anthropic verifies this signature on every subsequent turn. If it is missing, the block is considered modified and the request is rejected.
The fix is to always preserve providerMetadata for reasoning parts regardless of the differentModel flag.
Steps to reproduce
- Enable extended thinking on a Claude 3.7+ model
- Have a conversation long enough to accumulate thinking blocks in history, or switch models mid-session and switch back to Anthropic
- Continue the conversation — the error fires on any turn that replays a thinking block without its signature
OpenCode version: 1.4.6
OS: WSL
Terminal: Alacritty
Plugins
No response
OpenCode version
1.4.6
Steps to reproduce
- Enable extended thinking on a Claude 3.7+ model
- Have a conversation long enough to accumulate thinking blocks in history, or switch models mid-session and switch back to Anthropic
- Continue the conversation — the error fires on any turn that replays a thinking block without its signature
Screenshot and/or share link
No response
Operating System
Win 11 (WSL)
Terminal
Alacritty
Description
When using an Anthropic model with extended thinking enabled, the following error appears mid-conversation:
The model returned the following errors:
messages.N.content.1: thinking or redacted_thinking blocks in the latest assistant message cannot be modified.Root cause is in
packages/opencode/src/session/message-v2.ts. When reconstructing conversation history, reasoning parts stripproviderMetadatawhen the message was produced by a different model:This is correct for text and tool parts — it prevents provider-specific data (e.g. OpenAI itemId) from leaking into other providers. But Anthropic's thinking blocks carry a cryptographic signature inside providerMetadata. Anthropic verifies this signature on every subsequent turn. If it is missing, the block is considered modified and the request is rejected.
The fix is to always preserve providerMetadata for reasoning parts regardless of the differentModel flag.
Steps to reproduce
OpenCode version: 1.4.6
OS: WSL
Terminal: Alacritty
Plugins
No response
OpenCode version
1.4.6
Steps to reproduce
Screenshot and/or share link
No response
Operating System
Win 11 (WSL)
Terminal
Alacritty