-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Closed
01luyicheng/opencode
#5Description
Description
When switching from a model with extended thinking (e.g., Claude Opus with thinking enabled) to a model without thinking support (e.g., GPT 5.2, Claude Sonnet without thinking) mid-session, an error occurs:
messages.1.content.0.thinking: each thinking block must contain thinking
Root Cause
The reasoning parts from the previous model's responses are stored in the message history. When switching to a model that doesn't support interleaved reasoning (capabilities.interleaved === false), these parts are still sent to the API, causing validation errors.
Steps to Reproduce
- Start a conversation with Claude Opus (or any model with extended thinking)
- Get a response that includes thinking/reasoning blocks
- Switch to GPT 5.2 or Claude Sonnet (without thinking enabled) mid-session using Ctrl+M
- Send a new message
Expected Behavior
Switching models mid-session should work seamlessly. OpenCode should strip reasoning parts from message history when the target model doesn't support them.
Actual Behavior
API error about invalid thinking blocks.
Environment
- OpenCode version: 0.0.0-dev
- OS: macOS
- Provider: Anthropic / OpenAI
Related Issues
- Invalid
signatureinthinkingblock when switching Claude models (Copilot provider) #11546 (similar but for Claude-to-Claude switching with signature issues)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels