Skip to content

Conversation

@usvimal
Copy link
Contributor

@usvimal usvimal commented Jan 3, 2026

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

…odels

When switching from a model like minimax to Claude/Opus, the session
contains thinking blocks with signatures that Anthropic's API rejects
with 'Invalid signature in thinking block' error.

This fix:
- Filters out thinking blocks with signatures when targeting Claude
- Converts reasoning parts to text wrapped in <thinking> tags to
  preserve the content while making it compatible
@coleleavitt
Copy link
Contributor

can validate this is still an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants