#20747: feat(copilot): support Claude models with correct context windows (1M for Opus 4.6)
commands
agents
size: S
Cluster:
AI Provider Enhancements
## Summary
GitHub Copilot now serves Claude models (Opus 4.6, Sonnet 4.6/4.5, Haiku 4.5), but OpenClaw had no awareness of them. Copilot uses its own model naming convention that differs from Anthropic's official API names:
- Copilot uses dot-notation: `claude-opus-4.6`, `claude-sonnet-4.6`
- Copilot exposes a `-1m` suffix variant for extended context: `claude-opus-4.6-1m`
- Anthropic's official names (e.g. `claude-opus-4-20250514`) are **not** accepted by Copilot
### Before this PR
- All Copilot models used a hardcoded `contextWindow: 128_000` instead of 200K
- The `-1m` variant (~936K empirically) was completely unknown
- Claude models were missing from model selection UIs
- Forward-compat resolution skipped the `github-copilot` provider entirely
### Changes (4 files)
1. **`github-copilot-models.ts`** — Add Claude models to the default Copilot model list with per-model context windows (200K standard, 936K for the verified `claude-opus-4-6-1m` variant) and correct `reasoning` flags. Both dot-notation (Copilot native) and dash-notation (OpenClaw internal) are handled.
2. **`model-forward-compat.ts`** — Add forward-compat resolution for `github-copilot` and `copilot-proxy` providers. For `-1m` variants, **clone the base model from the registry** (e.g. `claude-opus-4.6` → `claude-opus-4.6-1m`) inheriting `api`, `baseUrl`, and `headers`, then override only `contextWindow`. This is critical because Copilot's Claude models use `api: "anthropic-messages"` with a Copilot-specific `baseUrl` and auth headers — constructing a model with `api: "openai-responses"` would send requests to the wrong endpoint and 401.
3. **`live-model-filter.ts`** — Recognize `github-copilot` and `copilot-proxy` providers in `isModernModelRef()`, and add dot-notation variants to `ANTHROPIC_PREFIXES` so `-1m` suffixed models are also matched.
4. **`list.registry.ts`** — Inherit auth availability for Copilot `-1m` forward-compat models from their base models, so `models list` correctly shows `Auth: yes` instead of `Auth: no`.
### Context on 1M window
- `claude-opus-4.6-1m` is a **Copilot-specific model name** not documented publicly but confirmed working via API testing.
- Copilot enforces ~936K tokens empirically rather than the full 1M.
- The `anthropic-beta: context-1m-2025-08-07` header is only for direct Anthropic API calls — Copilot handles this internally via the model name suffix.
## Test plan
- [x] `npx vitest run src/agents/model-forward-compat.test.ts` — 3 tests pass
- [x] `npx vitest run src/providers/` — 7 files, 26 tests pass
- [x] `npx vitest run src/agents/pi-embedded-runner/model` — 19 tests pass
- [x] `npx vitest run src/agents/ src/providers/ src/commands/models` — 86 files, 488 tests pass
- [x] Manually tested on live OpenClaw gateway (v2026.2.17) with `github-copilot/claude-opus-4.6-1m`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added support for GitHub Copilot's Claude models (Opus 4.6, Sonnet 4.6/4.5, Haiku 4.5) with correct context windows. Copilot uses dot-notation (`claude-opus-4.6`) and exposes `-1m` suffix variants for extended context (~936K). The forward-compat resolver clones base models from the registry to preserve critical transport config (`api: "anthropic-messages"`, Copilot baseUrl, auth headers) rather than constructing new models, which would cause 401 errors.
**Key changes:**
- Added Claude models to default Copilot list with per-model context windows (200K standard, 936K for `-1m`)
- Implemented forward-compat resolution for `github-copilot` and `copilot-proxy` providers
- Updated model filtering to recognize Copilot providers and normalize dot-notation
- Inherited auth availability for `-1m` variants from base models in `models list`
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The implementation is well-architected and follows existing patterns in the codebase. The critical insight of cloning base models from the registry (rather than constructing new ones) correctly preserves transport configuration. All tests pass according to the PR description. The changes are additive and don't break existing functionality.
- No files require special attention
<sub>Last reviewed commit: 8fd9c96</sub>
<!-- 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
#20095: fix(model-forward-compat): extend claude-sonnet-4.6 forward-compat ...
by SeeYangZhi · 2026-02-18
85.2%
#11447: feat(providers): add Claude models to GitHub Copilot provider
by yylonly · 2026-02-07
82.3%
#2806: [AI-Assisted] Fix: Repair tool_use/tool_result pairing for Claude o...
by Arthur742Ramos · 2026-01-27
81.3%
#17015: fix: correct Claude 4.5 context limits in model registry
by Limitless2023 · 2026-02-15
80.6%
#12220: fix: forward-compat models now respect user-configured contextWindow
by Batuhan4 · 2026-02-09
80.2%
#10831: fix(agents): set Opus 4.6 context window to 1M in forward-compat fa...
by slawt · 2026-02-07
79.6%
#18697: fix: include forward-compat models in model catalog for allowlist val…
by dmitry-orabey · 2026-02-17
79.0%
#20947: feat: expand Copilot model catalog with anthropic-messages API
by austenstone · 2026-02-19
78.9%
#13119: fix: add forward-compat for google-antigravity claude-opus-4-6 models
by sdb001 · 2026-02-10
78.5%
#23250: feat: add Sonnet 4.6 forward compat for google-antigravity
by Oceanswave · 2026-02-22
76.8%