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! |
|
Hi! Thank you for taking the time to contribute to this project—we really appreciate it. 🙏 We are currently working on re-platforming the core of our VS Code and JetBrains extensions to be based on our new Kilo CLI, with a complete rebuild based on OpenCode as our new foundation, and the moment has come to promote this repository to become the main repository. To do that, we moved the code from this repository to the kilocode repository. This unfortunately means we cannot merge this branch here anymore. Please add https://github.com/Kilo-Org/kilocode.git as a remote, and push your branch there and create a new PR in https://github.com/Kilo-Org/kilocode . We unfortunately cannot do this for you as then the PR would not be in your name anymore. If you need any help, feel free to ask on our Discord in #kilo-dev-contributors Sorry for the inconvenience and thank you for contributing to Kilo! |
|
@JoaoHenriqueBarbosa since OpenCode removed the SDK support now anyway because of blocked accounts, we probably don't want to follow up on this anyway. |
|
@marius-kilocode no problem! Anyway I feel happy to be considered and for your answers, thank you! |
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 Kilo-Org/kilocode#6300
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.