[PR #13457] feat: enable 1M context window for Anthropic Claude models #14678

Closed
opened 2026-02-16 18:19:27 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13457

State: closed
Merged: No


Summary

  • Add optional 1m variant for Claude Opus 4.6 that enables the 1M token context window
  • Users can select this variant in the model selector (e.g., claude-opus-4-6[1m]) to opt-in to extended context
  • Default context remains at 200K to avoid higher session costs

Details

This PR makes the 1M context window opt-in rather than automatic. The context-1m-2025-08-07 header is sent to enable the feature on Anthropic's side, but the actual context limit is only increased when the user explicitly selects the [1m] variant.

Why optional?

The 1M context window uses higher token pricing (context_over_200k tier) and delays compaction. Making it opt-in lets users choose when they need the extended context vs. when they prefer lower costs with automatic compaction at 200K.

Changes

  • transform.ts: Add 1m variant for Opus 4.6 with contextLimit: 1_000_000
  • transform.ts: Add contextLimit() helper to resolve effective limit from variant
  • compaction.ts: Update isOverflow() to use variant-aware context limit
  • processor.ts / prompt.ts: Pass variant to overflow checks

Usage

# Default (200K context, lower cost)
/model anthropic/claude-opus-4-6

# Extended context (1M, higher cost)  
/model anthropic/claude-opus-4-6[1m]

Note to reviewers: This supersedes the approach in #12342 which enabled 1M by default. The optional variant approach gives users control over the cost/context tradeoff.

Closes #13455

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13457 **State:** closed **Merged:** No --- ## Summary - Add optional `1m` variant for Claude Opus 4.6 that enables the 1M token context window - Users can select this variant in the model selector (e.g., `claude-opus-4-6[1m]`) to opt-in to extended context - Default context remains at 200K to avoid higher session costs ## Details This PR makes the 1M context window **opt-in** rather than automatic. The `context-1m-2025-08-07` header is sent to enable the feature on Anthropic's side, but the actual context limit is only increased when the user explicitly selects the `[1m]` variant. ### Why optional? The 1M context window uses higher token pricing (`context_over_200k` tier) and delays compaction. Making it opt-in lets users choose when they need the extended context vs. when they prefer lower costs with automatic compaction at 200K. ### Changes - **transform.ts**: Add `1m` variant for Opus 4.6 with `contextLimit: 1_000_000` - **transform.ts**: Add `contextLimit()` helper to resolve effective limit from variant - **compaction.ts**: Update `isOverflow()` to use variant-aware context limit - **processor.ts** / **prompt.ts**: Pass variant to overflow checks ### Usage ```bash # Default (200K context, lower cost) /model anthropic/claude-opus-4-6 # Extended context (1M, higher cost) /model anthropic/claude-opus-4-6[1m] ``` --- **Note to reviewers**: This supersedes the approach in #12342 which enabled 1M by default. The optional variant approach gives users control over the cost/context tradeoff. Closes #13455
yindo added the pull-request label 2026-02-16 18:19:27 -05:00
yindo closed this issue 2026-02-16 18:19:27 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14678