Uh oh!
There was an error while loading. Please reload this page.
fix(opencode): use api.npm to detect Anthropic SDK for cache control - #14643
fix(opencode): use api.npm to detect Anthropic SDK for cache control#14643llc1123 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in cache control detection for models using the Anthropic SDK. The applyCaching function previously used model.providerID === "anthropic" to determine whether to apply message-level cache control, which failed for non-Claude models (like kimi-k2.5) that use @ai-sdk/anthropic but have a different providerID. The fix changes the detection to use model.api.npm instead, correctly identifying Anthropic SDK usage regardless of the model's providerID.
Changes:
- Updated
applyCachingto detect Anthropic SDK viamodel.api.npm(checking for@ai-sdk/anthropicor@ai-sdk/google-vertex/anthropic) - Added test case validating that non-Claude models using
@ai-sdk/anthropiccorrectly receive message-level cache control
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/opencode/src/provider/transform.ts | Fixed Anthropic SDK detection in applyCaching function to use model.api.npm instead of model.providerID |
| packages/opencode/test/provider/transform.test.ts | Added test case for kimi-k2.5 model using Anthropic SDK to verify message-level cache control |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR. |
Issue for this PR
Closes#14642
Type of change
What does this PR do?
The
applyCachingfunction incorrectly usedmodel.providerID === "anthropic"to detect Anthropic SDK models. This fails for non-Claude models (e.g. kimi-k2.5) that use@ai-sdk/anthropicbut have a differentproviderID.Changed detection to use
model.api.npm:How did you verify your code works?
bun turbo typecheck)Screenshots / recordings
N/A — no UI changes.
Checklist