feat: add Claude Opus 4.6 support with known-model fallbacks#9834
feat: add Claude Opus 4.6 support with known-model fallbacks#9834tinybluedev wants to merge 1 commit intoopenclaw:mainfrom
Conversation
- Update DEFAULT_MODEL to claude-opus-4-6 (1M context window) - Update opus alias to anthropic/claude-opus-4-6 - Add opus-4.6 shorthand to normalizeAnthropicModelId - Add KNOWN_MODEL_FALLBACKS in model-catalog.ts to inject models when the upstream pi-ai catalog hasn't been updated yet - Add ANTHROPIC_MODEL_FALLBACKS in resolveModel() to prevent 'Unknown model' crashes when pi-ai is behind on new releases This ensures OpenClaw can immediately support newly released Anthropic models without waiting for upstream pi-ai package updates. The fallback mechanism is reusable for future model releases.
| // Fallback: check known Anthropic models when upstream catalog is behind. | ||
| // This prevents crashes when a new model is released but pi-ai hasn't | ||
| // been updated yet. | ||
| if (normalizeProviderId(provider) === "anthropic") { |
There was a problem hiding this comment.
Fallback never triggers
In resolveModel(), the ANTHROPIC_MODEL_FALLBACKS check is unreachable for unknown Anthropic models because the earlier if (providerCfg || modelId.startsWith("mock-")) branch will always run when an Anthropic provider config exists (which it typically does). That branch returns a generic openai-responses model, so a user configuring anthropic/claude-opus-4-6 will still resolve to the wrong API/model instead of your Anthropic fallback.
This means the crash may be avoided, but the resolved model will be incorrect (wrong api, baseUrl, pricing, etc.) in the common case where cfg.models.providers.anthropic is set.
Also appears at src/agents/pi-embedded-runner/model.ts:119-134 (generic providerCfg fallback preceding the Anthropic fallback).
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/pi-embedded-runner/model.ts
Line: 136:139
Comment:
**Fallback never triggers**
In `resolveModel()`, the `ANTHROPIC_MODEL_FALLBACKS` check is unreachable for *unknown* Anthropic models because the earlier `if (providerCfg || modelId.startsWith("mock-"))` branch will always run when an Anthropic provider config exists (which it typically does). That branch returns a generic `openai-responses` model, so a user configuring `anthropic/claude-opus-4-6` will still resolve to the wrong API/model instead of your Anthropic fallback.
This means the crash may be avoided, but the resolved model will be incorrect (wrong `api`, `baseUrl`, pricing, etc.) in the common case where `cfg.models.providers.anthropic` is set.
Also appears at `src/agents/pi-embedded-runner/model.ts:119-134` (generic providerCfg fallback preceding the Anthropic fallback).
How can I resolve this? If you propose a fix, please make it concise.
Additional Comments (2)
Prompt To Fix With AIThis is a comment left during a code review.
Path: src/agents/pi-embedded-runner/model.ts
Line: 119:122
Comment:
**Incorrect provider config lookup**
`providerCfg` is fetched via `providers[provider]`, but elsewhere in this function you normalize provider IDs (and configs may be keyed by normalized IDs). If a caller passes an unnormalized provider string (e.g. different casing/alias), `providers[provider]` will be `undefined` even when the provider is configured, and you’ll fall through to `Unknown model` (or other fallbacks) incorrectly. Use the same normalized key you computed (`normalizedProvider`) when looking up `providerCfg` to keep behavior consistent.
How can I resolve this? If you propose a fix, please make it concise.
When Prompt To Fix With AIThis is a comment left during a code review.
Path: src/agents/model-catalog.ts
Line: 114:117
Comment:
**Cache isn’t really reset**
When `models.length === 0`, the code sets `modelCatalogPromise = null` inside the async initializer, but still returns the already-created promise to the caller. This means callers will still receive a cached empty result for that invocation (and potentially continue using it) despite the comment implying it won’t be cached. If the intent is “don’t cache empties”, you need to avoid returning an empty `modelCatalogPromise` in the first place (or re-run load before returning).
How can I resolve this? If you propose a fix, please make it concise. |
There was a problem hiding this comment.
Pull request overview
This PR adds support for Claude Opus 4.6 (released February 5, 2026) with a 1 million token context window and implements a future-proof fallback mechanism to prevent crashes when new Anthropic models are released before the upstream pi-ai package catalog is updated.
Changes:
- Updates default model to claude-opus-4-6 with 1M context window
- Adds opus-4.6 shorthand normalization and model alias
- Implements two-tier fallback system (model catalog and model resolver) to handle missing upstream model entries
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/agents/defaults.ts | Updates DEFAULT_MODEL to claude-opus-4-6 and DEFAULT_CONTEXT_TOKENS to 1M |
| src/config/defaults.ts | Updates the "opus" alias to point to claude-opus-4-6 |
| src/agents/model-selection.ts | Adds opus-4.6 shorthand normalization to claude-opus-4-6 |
| src/agents/model-catalog.ts | Adds KNOWN_MODEL_FALLBACKS array that injects claude-opus-4-6 when missing from upstream catalog |
| src/agents/pi-embedded-runner/model.ts | Adds ANTHROPIC_MODEL_FALLBACKS map in resolveModel() to construct model entries when ModelRegistry.find() returns nothing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
this is very urgent, CC @IanCarroll |
not true; |
Summary
Adds support for Claude Opus 4.6 (released 2026-02-05) with a 1M token context window.
Problem
When Anthropic releases a new model, OpenClaw crashes with
Unknown model: anthropic/claude-opus-4-6because:@mariozechner/pi-aimodel catalog hasn't been updated yetModelRegistry.find()returnsundefinedresolveModel()has no fallback for known Anthropic modelsopus-4.6as a shorthandChanges
Immediate Opus 4.6 support
src/agents/defaults.ts— UpdateDEFAULT_MODELtoclaude-opus-4-6,DEFAULT_CONTEXT_TOKENSto 1Msrc/config/defaults.ts— Updateopusalias toanthropic/claude-opus-4-6src/agents/model-selection.ts— Addopus-4.6→claude-opus-4-6normalizationFuture-proof fallback mechanism
src/agents/model-catalog.ts— AddKNOWN_MODEL_FALLBACKSarray that injects model entries when the upstream pi-ai catalog is missing them. Prevents allowlist/status check failures.src/agents/pi-embedded-runner/model.ts— AddANTHROPIC_MODEL_FALLBACKSmap inresolveModel(). WhenModelRegistry.find()returns nothing for a known Anthropic model, the fallback constructs a proper model entry with correct API, pricing, and context window. This is the crash fix.Why a fallback map?
The root cause is a dependency chain: OpenClaw → pi-coding-agent → pi-ai → models.generated.js. When Anthropic drops a new model, this chain can take days to update. The fallback map lets OpenClaw support new models immediately. Adding future models is a one-liner in each fallback map.
Testing
Tested on a live OpenClaw instance (macOS, Anthropic OAuth). Config set to
anthropic/claude-opus-4-6— gateway restarts cleanly, model resolves correctly, no crash.Greptile Overview
Greptile Summary
This PR updates OpenClaw’s Anthropic defaults to target
claude-opus-4-6(1M context) and adds two fallback mechanisms to avoid crashes when the upstreampi-aimodel catalog lags behind new Anthropic releases:src/agents/model-selection.tsnormalizes the shorthandopus-4.6toclaude-opus-4-6.src/agents/model-catalog.tsinjects a known model entry for Opus 4.6 when it’s missing from the discovered catalog.src/agents/pi-embedded-runner/model.tsadds a hardcoded Anthropic model map intended to be used whenModelRegistry.find()returns nothing.Main concern: in
resolveModel(), the new Anthropic fallback is currently ordered after a genericproviderCfgfallback that often triggers first, so known Anthropic models can still resolve to the wrong API/model definition even though the crash is avoided.Confidence Score: 3/5
resolveModel()’s fallback ordering can bypass the intended Anthropic fallback and return a generic model definition foranthropic/claude-opus-4-6. There’s also a cache-reset logic issue inloadModelCatalog()that contradicts its stated behavior.(2/5) Greptile learns from your feedback when you react with thumbs up/down!
Context used:
dashboard- CLAUDE.md (source)dashboard- AGENTS.md (source)