[PR #6748] fix: strip incompatible thinking blocks when switching to Anthropic models #12083

Open
opened 2026-02-16 18:17:01 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6748

State: open
Merged: No


Problem

When switching from a model like minimax to Claude/Opus mid-session, the API returns:

messages.9.content.0: Invalid 'signature' in 'thinking' block

This happens because the session contains cached messages with thinking blocks that have signatures from the previous model (minimax), which Anthropic's API rejects.

Solution

In normalizeMessages(), when the target model is Claude:

  1. Filter out thinking blocks that have signatures (from other providers)
  2. Convert reasoning parts to text wrapped in <thinking> tags to preserve content

Testing

  1. Start a session with minimax or another model that generates thinking blocks
  2. Switch to Claude Opus mid-session
  3. Should no longer get the 'Invalid signature' error
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6748 **State:** open **Merged:** No --- ## Problem When switching from a model like minimax to Claude/Opus mid-session, the API returns: ``` messages.9.content.0: Invalid 'signature' in 'thinking' block ``` This happens because the session contains cached messages with thinking blocks that have signatures from the previous model (minimax), which Anthropic's API rejects. ## Solution In `normalizeMessages()`, when the target model is Claude: 1. Filter out `thinking` blocks that have signatures (from other providers) 2. Convert `reasoning` parts to text wrapped in `<thinking>` tags to preserve content ## Testing 1. Start a session with minimax or another model that generates thinking blocks 2. Switch to Claude Opus mid-session 3. Should no longer get the 'Invalid signature' error
yindo added the pull-request label 2026-02-16 18:17:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12083