Skip to content

[BUG]: Error switching from thinking model to non-thinking model mid-session #11571

@okossa

Description

@okossa

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

  1. Start a conversation with Claude Opus (or any model with extended thinking)
  2. Get a response that includes thinking/reasoning blocks
  3. Switch to GPT 5.2 or Claude Sonnet (without thinking enabled) mid-session using Ctrl+M
  4. 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions