← Back to PRs

#20747: feat(copilot): support Claude models with correct context windows (1M for Opus 4.6)

by yuf1011 open 2026-02-19 08:16 View on GitHub →
commands agents size: S
## 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