opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix: strip incompatible thinking blocks when switching to Anthropic models

Open usvimal opened this issue 2 weeks ago • 1 comments

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

usvimal avatar Jan 03 '26 11:01 usvimal