fix(provider): scope Anthropic context-1m beta header to 1M models#605
fix(provider): scope Anthropic context-1m beta header to 1M models#605Olusammytee wants to merge 1 commit intoKilo-Org:devfrom
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
| } | ||
|
|
||
| headers["anthropic-beta"] = parts.join(",") | ||
| const sdk = createAnthropic({ |
There was a problem hiding this comment.
CRITICAL: This creates a brand-new createAnthropic() SDK using only the raw provider.options, discarding the pre-built sdk parameter (renamed _sdk on line 110). Every other getModel implementation in this file (openai, github-copilot, azure, amazon-bedrock, etc.) uses the passed sdk parameter.
The sdk passed to getModel is built by getSDK() which enriches provider.options with apiKey, baseURL, model-specific headers, and a custom fetch wrapper (with timeout logic, OpenAI ID stripping, etc.). By creating a new SDK here, all of those are lost.
This means Anthropic 1M-context models will likely fail or behave incorrectly because the new SDK won't have the API key, base URL, or timeout handling.
Consider modifying the headers on the existing sdk or restructuring so the beta header is applied at the getSDK level based on the model ID, rather than creating a separate SDK instance.
| .filter(Boolean) | ||
| .filter((item) => item !== longContextBeta) | ||
|
|
||
| if (modelID.toLowerCase().includes("1m")) { |
There was a problem hiding this comment.
WARNING: The check modelID.toLowerCase().includes("1m") is fragile. It would match any model ID containing "1m" anywhere (e.g., a hypothetical model like claude-21march or claude-v1mini). Consider a more specific pattern like checking for -1m- or a suffix match to reduce false positives.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)CRITICAL
WARNING
Files Reviewed (1 files)
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the context-1m-2025-08-07 Anthropic beta header was being sent unconditionally for all Anthropic API requests, causing errors for users on plans without long context access (like Claude Max plan) when using standard 200K context models.
Changes:
- Removed
context-1m-2025-08-07from the default Anthropic beta headers - Added a custom
getModel()function that conditionally includes the 1M context beta header only for models with "1m" in their ID - Preserved all other Anthropic beta headers (claude-code, interleaved-thinking, fine-grained-tool-streaming)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Fixes #482