fix: only send context-1m beta header for models with >200K context#483
fix: only send context-1m beta header for models with >200K context#483JoaoHenriqueBarbosa wants to merge 5 commits intoKilo-Org:devfrom
Conversation
The `context-1m-2025-08-07` anthropic-beta header was unconditionally sent for all Anthropic API requests. This causes "extra usage is required for long context requests" errors for users on plans that don't include the long context beta (e.g. Claude Max plan). Now the header is only appended when the model's context limit exceeds 200K tokens, which indicates it is a 1M context model that actually needs the beta. Fixes anthropics/claude-code#23700
|
The The |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge OverviewThis PR moves the Key observations:
Files Reviewed (1 file)
|
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
…ext-1m-beta-header
|
Hey @chrarnoldus @markijbema @catrielmuller @marius-kilocode, could you take a look at this PR when you get a chance? Thanks! |
Context
The
context-1m-2025-08-07anthropic-beta header is unconditionally sent in all Anthropic API requests. This causes"extra usage is required for long context requests"errors for users on plans that don't include the long context beta (e.g. Claude Max plan), even when using standard 200K context models.Fixes #482
Related: anthropics/claude-code#23700, anthropics/claude-code#23472
Implementation
Two changes in
packages/opencode/src/provider/provider.ts:Removed
context-1m-2025-08-07from the defaultanthropic-betaheader inCUSTOM_LOADERS.anthropic()(line 106) — this header was being sent for every Anthropic API call regardless of the model's context window.Added conditional logic in
getSDK()to append thecontext-1m-2025-08-07header only whenmodel.limit.context > 200_000. This way, standard 200K models work normally on all plans, while 1M context models still get the beta header they need.The check correctly differentiates:
context: 200000) → nocontext-1mheadercontext: 1000000) →context-1mheader appendedNo new dependencies, no refactoring, minimal diff.
Changed Files
packages/opencode/src/provider/provider.ts— Removedcontext-1m-2025-08-07from default headers, added conditional append ingetSDK()How to Test
"extra usage is required for long context requests"errorcontext-1mheader should still be sent (verified via debug logs or network inspection)Get in Touch
Available here on GitHub.