Problem
OpenCode currently sets the context window limit for claude-opus-4-6 (and other Claude models) to 200,000 tokens, matching the default Anthropic API limit. However, Anthropic supports a 1,000,000 token context window when the context-1m-2025-08-07 beta header is sent.
The OpenCode console/zen proxy already sends this header (in packages/console/app/src/routes/zen/util/provider/anthropic.ts), but the core opencode package does not — meaning users running OpenCode locally with their own API key are limited to 200K context.
Proposed Solution
-
Add context-1m-2025-08-07 to the anthropic-beta header in the Anthropic provider configuration (packages/opencode/src/provider/provider.ts), so the 1M context API feature is activated for all Anthropic requests.
-
Update the context window limit for models that support 1M context (currently claude-opus-4-6 and Claude Sonnet models) from 200,000 to 1,000,000 in the model data pipeline.
This enables OpenCode to hold much larger codebases in memory during sessions, which is transformative for large-scale refactors and migrations.
References
- Anthropic docs: Extended context window beta
- The console/zen proxy already implements this:
packages/console/app/src/routes/zen/util/provider/anthropic.ts line 37
context_over_200k pricing is already supported in the cost calculation logic
Problem
OpenCode currently sets the context window limit for
claude-opus-4-6(and other Claude models) to 200,000 tokens, matching the default Anthropic API limit. However, Anthropic supports a 1,000,000 token context window when thecontext-1m-2025-08-07beta header is sent.The OpenCode console/zen proxy already sends this header (in
packages/console/app/src/routes/zen/util/provider/anthropic.ts), but the coreopencodepackage does not — meaning users running OpenCode locally with their own API key are limited to 200K context.Proposed Solution
Add
context-1m-2025-08-07to theanthropic-betaheader in the Anthropic provider configuration (packages/opencode/src/provider/provider.ts), so the 1M context API feature is activated for all Anthropic requests.Update the context window limit for models that support 1M context (currently
claude-opus-4-6and Claude Sonnet models) from 200,000 to 1,000,000 in the model data pipeline.This enables OpenCode to hold much larger codebases in memory during sessions, which is transformative for large-scale refactors and migrations.
References
packages/console/app/src/routes/zen/util/provider/anthropic.tsline 37context_over_200kpricing is already supported in the cost calculation logic