#10831: fix(agents): set Opus 4.6 context window to 1M in forward-compat fallback
agents
stale
Cluster:
Context Window and Model Updates
## Problem
The `resolveAnthropicOpus46ForwardCompatModel` function (added in #10720 / commit 0daf416) clones Opus 4.5's model definition as a forward-compat fallback for Opus 4.6. However, it inherits Opus 4.5's 200K context window.
Opus 4.6 supports a **1M token context window** and **128K max output tokens**. Users relying on the forward-compat path (when pi-ai's built-in catalog hasn't been updated yet) silently get 200K instead of 1M.
## Fix
- Add `ANTHROPIC_OPUS_46_CONTEXT_WINDOW` (1,000,000) and `ANTHROPIC_OPUS_46_MAX_TOKENS` (128,000) constants
- Override the cloned template's `contextWindow` and `maxTokens` in the forward-compat fallback path
- Update existing test to verify correct context window and max tokens values
- Add test for dot notation variant (`claude-opus-4.6`)
## Notes
- Does **not** change `DEFAULT_CONTEXT_TOKENS` (200K) since that's a cross-provider fallback
- Scoped only to the Opus 4.6 forward-compat path
- Matches Anthropic's published specs for Opus 4.6
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
- Updates the Anthropic Opus 4.6 forward-compat model resolver to override cloned Opus 4.5 limits with Opus 4.6’s published `contextWindow` (1,000,000) and `maxTokens` (128,000).
- Adds constants for Opus 4.6 limits and applies them when cloning a 4.5 template in `resolveAnthropicOpus46ForwardCompatModel`.
- Extends unit tests to assert the new limits and covers both dash (`claude-opus-4-6`) and dot (`claude-opus-4.6`) notation IDs.
- Change is localized to the pi-embedded-runner model resolution path; other provider fallbacks remain unchanged.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- The change is a small, targeted override of two numeric fields in a narrow forward-compat code path, and tests were updated/added to validate both ID variants and the new limits. No other model resolution behavior is modified.
- No files require special attention
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#12220: fix: forward-compat models now respect user-configured contextWindow
by Batuhan4 · 2026-02-09
90.6%
#17015: fix: correct Claude 4.5 context limits in model registry
by Limitless2023 · 2026-02-15
81.4%
#16891: fix(models): generic opus-4-6 forward-compat for all providers
by battman21 · 2026-02-15
80.4%
#20747: feat(copilot): support Claude models with correct context windows (...
by yuf1011 · 2026-02-19
79.6%
#13119: fix: add forward-compat for google-antigravity claude-opus-4-6 models
by sdb001 · 2026-02-10
78.9%
#6053: fix: use 400K context window instead of 200K if the model allows (g...
by icedac · 2026-02-01
78.4%
#19533: fix: allow forward-compat models in buildAllowedModelSet
by Anthony-g-dev · 2026-02-17
78.4%
#23250: feat: add Sonnet 4.6 forward compat for google-antigravity
by Oceanswave · 2026-02-22
78.1%
#17414: fix(sessions): refresh contextTokens when model override changes
by michaelbship · 2026-02-15
77.7%
#20095: fix(model-forward-compat): extend claude-sonnet-4.6 forward-compat ...
by SeeYangZhi · 2026-02-18
77.6%