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

Closed
opened 2026-02-16 18:09:24 -05:00 by yindo · 3 comments
Owner

Originally created by @okossa on GitHub (Feb 1, 2026).

Originally assigned to: @rekram1-node on GitHub.

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

  • #11546 (similar but for Claude-to-Claude switching with signature issues)
Originally created by @okossa on GitHub (Feb 1, 2026). Originally assigned to: @rekram1-node on GitHub. ## 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 - #11546 (similar but for Claude-to-Claude switching with signature issues)
yindo closed this issue 2026-02-16 18:09:24 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 1, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #11546: Invalid signature in thinking block when switching Claude models (Copilot provider) - very similar issue with Claude model switching
  • #5577: DeepSeek V3.2: reasoning_content not cleared from message history on new turns - related to reasoning blocks persisting in message history
  • #8185: Does OpenCode send back all previous reasoning blocks to Claude - discusses if reasoning blocks are properly handled in message history
  • #6418: Error: Invalid signature in thinking block - general thinking block validation error

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Feb 1, 2026): This issue might be a duplicate of existing issues. Please check: - #11546: Invalid `signature` in `thinking` block when switching Claude models (Copilot provider) - very similar issue with Claude model switching - #5577: DeepSeek V3.2: reasoning_content not cleared from message history on new turns - related to reasoning blocks persisting in message history - #8185: Does OpenCode send back all previous reasoning blocks to Claude - discusses if reasoning blocks are properly handled in message history - #6418: Error: Invalid `signature` in `thinking` block - general thinking block validation error Feel free to ignore if none of these address your specific case.
Author
Owner

@wildcatDownstairs commented on GitHub (Feb 2, 2026):

I also got this problem
Image

@wildcatDownstairs commented on GitHub (Feb 2, 2026): I also got this problem <img width="1116" height="368" alt="Image" src="https://github.com/user-attachments/assets/1f7f3a73-f508-4946-b391-c0064fb28df2" />
Author
Owner

@rekram1-node commented on GitHub (Feb 2, 2026):

Fixed in next release, copilot specific issue

@rekram1-node commented on GitHub (Feb 2, 2026): Fixed in next release, copilot specific issue
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8199