[PR #7035] fix(session): strip reasoning blocks for Claude Code compatibility #12215

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

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

State: closed
Merged: No


Summary

Strip reasoning blocks from message history when converting to model format, enabling seamless switching between reasoning and non-reasoning models.

Problem

When using a reasoning model (e.g., Claude with extended thinking) and then switching to Claude Code, the session fails with an "Invalid signature" error. This happens because Claude Code's API doesn't recognize the reasoning blocks that were added by the previous model.

Solution

Filter out reasoning type parts from messages in convertToModelMessages() before sending to the model API. This ensures compatibility regardless of which models were used earlier in the session.

Changes

  • packages/opencode/src/session/message-v2.ts - Filter reasoning parts in message conversion

Testing

  • Verified typecheck passes
  • Manual testing: Start session with reasoning model, switch to Claude Code, continue conversation without errors
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7035 **State:** closed **Merged:** No --- ## Summary Strip reasoning blocks from message history when converting to model format, enabling seamless switching between reasoning and non-reasoning models. ## Problem When using a reasoning model (e.g., Claude with extended thinking) and then switching to Claude Code, the session fails with an "Invalid signature" error. This happens because Claude Code's API doesn't recognize the reasoning blocks that were added by the previous model. ## Solution Filter out `reasoning` type parts from messages in `convertToModelMessages()` before sending to the model API. This ensures compatibility regardless of which models were used earlier in the session. ## Changes - `packages/opencode/src/session/message-v2.ts` - Filter reasoning parts in message conversion ## Testing - Verified typecheck passes - Manual testing: Start session with reasoning model, switch to Claude Code, continue conversation without errors
yindo added the pull-request label 2026-02-16 18:17:08 -05:00
yindo closed this issue 2026-02-16 18:17:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12215