Skip to content

fix(opencode): support interleaved reasoning_content for anthropic protocol non-Claude models#14641

Draft
llc1123 wants to merge 2 commits intoanomalyco:devfrom
llc1123:fix/anthropic-interleaved-reasoning-via-sdk
Draft

fix(opencode): support interleaved reasoning_content for anthropic protocol non-Claude models#14641
llc1123 wants to merge 2 commits intoanomalyco:devfrom
llc1123:fix/anthropic-interleaved-reasoning-via-sdk

Conversation

@llc1123
Copy link

@llc1123 llc1123 commented Feb 22, 2026

Issue for this PR

Closes #14638

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When non-Claude models (e.g. kimi-k2.5) are used via the Anthropic SDK with interleaved reasoning enabled, reasoning content from previous assistant turns is silently dropped because the Anthropic SDK has no mechanism to pass arbitrary message-level fields (like reasoning_content) through to the HTTP body.

This PR makes the interleaved reasoning path for Anthropic SDK models use providerOptions.anthropic — the same pattern the openai-compatible provider already uses with providerOptions.openaiCompatible.

Dependencies

Blocked by: vercel/ai#12760 — Adds support for spreading providerOptions.anthropic onto assistant messages in @ai-sdk/anthropic.

This PR is not ready for review until the upstream change lands and is released.

How did you verify your code works?

  • Typecheck passes (bun turbo typecheck)
  • 108 tests pass (including 5 new tests for this feature)
  • Tested with kimi-k2.5 via Anthropic SDK: reasoning content round-trips correctly across turns

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found:

Since PR #14641 (current PR) and PR #14637 share the exact same title and appear to address the same issue, you should check if one is a duplicate of the other and consider closing one while consolidating efforts on the other.

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.

Interleaved reasoning_content lost for non-Claude models on Anthropic SDK

1 participant