[FEATURE]: Enable 1M context window for Anthropic Claude models #9243

Closed
opened 2026-02-16 18:11:59 -05:00 by yindo · 2 comments
Owner

Originally created by @mguttmann on GitHub (Feb 13, 2026).

Originally assigned to: @thdxr on GitHub.

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

  1. 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.

  2. 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
Originally created by @mguttmann on GitHub (Feb 13, 2026). Originally assigned to: @thdxr on GitHub. ## 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 1. **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. 2. **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
yindo added the needs:compliance label 2026-02-16 18:11:59 -05:00
yindo closed this issue 2026-02-16 18:11:59 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 13, 2026):

This issue doesn't fully meet our contributing guidelines.

What needs to be fixed:

  • The issue title should start with [FEATURE]: as specified in the Feature Request template. Current title: "feat: Enable 1M context window for Anthropic Claude models" should be "[FEATURE]: Enable 1M context window for Anthropic Claude models"

Please edit this issue to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions[bot] commented on GitHub (Feb 13, 2026): <!-- issue-compliance --> This issue doesn't fully meet our [contributing guidelines](.github/ISSUE_TEMPLATE/feature-request.yml). **What needs to be fixed:** - The issue title should start with `[FEATURE]:` as specified in the Feature Request template. Current title: "feat: Enable 1M context window for Anthropic Claude models" should be "[FEATURE]: Enable 1M context window for Anthropic Claude models" Please edit this issue to address the above within **2 hours**, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know.
Author
Owner

@mguttmann commented on GitHub (Feb 13, 2026):

Closing - the context-1m beta is not available for all Anthropic subscriptions. Sending this header causes errors for users without access to the feature.

@mguttmann commented on GitHub (Feb 13, 2026): Closing - the context-1m beta is not available for all Anthropic subscriptions. Sending this header causes errors for users without access to the feature.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9243