#19927: fix(agents): replace hardcoded Anthropic model IDs with pattern matching
agents
size: S
Cluster:
OpenAI Model Fixes and Updates
## Summary
Static version lists (`claude-sonnet-4-5`, etc.) broke on every Anthropic model upgrade, requiring manual code changes. This PR replaces all hardcoded model ID lists with regex patterns that auto-match any future versions.
### Changes
- **live-model-filter**: `ANTHROPIC_PREFIXES[]` → `/^claude-(opus|sonnet|haiku)-\d+-\d+/`
- **model-selection**: `ANTHROPIC_MODEL_ALIASES{}` → dynamic `{family}-{major}.{minor}` parser via `ANTHROPIC_ALIAS_RE`
- **defaults**: Remove hardcoded Anthropic aliases (config aliases handle resolution)
- **cli-backends**: Strip version-specific aliases from `CLAUDE_MODEL_ALIASES`, keep only bare family names (`opus`, `sonnet`, `haiku`)
- **cloudflare-ai-gateway**: Update default to latest model
- **configure.gateway-auth**: Add latest model to OAuth model keys
### Why
Every time Anthropic releases a new model version (4.5 → 4.6, etc.), multiple files need manual updates to add the new IDs. With regex patterns, `claude-opus-5-0` or `claude-sonnet-4-7` would work automatically without any code changes.
### Testing
- Existing `model-alias-defaults.test.ts` passes (5 tests)
- Pattern `{family}-{major}.{minor}` correctly normalizes to `claude-{family}-{major}-{minor}` for any version
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR replaces hardcoded Anthropic model ID lists with regex patterns across multiple files to avoid manual updates on each model release. It also bumps the Cloudflare AI Gateway default from `claude-sonnet-4-5` to `claude-sonnet-4-6`.
- **Duplicate entry**: `ANTHROPIC_OAUTH_MODEL_KEYS` in `configure.gateway-auth.ts` now contains `"anthropic/claude-sonnet-4-6"` twice (lines 32 and 35).
- **Breaking change for bare aliases**: Removing `opus` and `sonnet` from `DEFAULT_MODEL_ALIASES` in `defaults.ts` breaks resolution for users who set `model.primary: "opus"` or `model.primary: "sonnet"` without explicit alias config. These will now resolve to invalid model IDs like `anthropic/opus`.
- **Regex-based matching in `live-model-filter.ts` and `model-selection.ts`**: Correctly replaces static lists with regex patterns for future-proofing.
- **CLI model normalization**: New `CLAUDE_FAMILY_RE` fallback in `normalizeCliModel` correctly handles versioned model IDs.
- **Import reordering**: Several files have cosmetic import reordering (type imports moved before value imports), which is fine but unrelated to the stated purpose.
<h3>Confidence Score: 2/5</h3>
- This PR has a duplicate array entry and a potential breaking change for users relying on bare Anthropic aliases in their config.
- Two issues lower confidence: (1) a duplicate entry in ANTHROPIC_OAUTH_MODEL_KEYS that suggests an accidental copy-paste, and (2) removing opus/sonnet from DEFAULT_MODEL_ALIASES breaks backwards compatibility for configs using bare alias names without explicit alias definitions. The regex changes themselves are sound.
- Pay close attention to `src/config/defaults.ts` (breaking alias removal) and `src/commands/configure.gateway-auth.ts` (duplicate entry).
<sub>Last reviewed commit: 013b615</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#18697: fix: include forward-compat models in model catalog for allowlist val…
by dmitry-orabey · 2026-02-17
78.0%
#17560: fix: Anthropic Prompt Caching Not Working - Missing cache_control H...
by MisterGuy420 · 2026-02-15
77.6%
#19533: fix: allow forward-compat models in buildAllowedModelSet
by Anthony-g-dev · 2026-02-17
77.5%
#16687: fix(antigravity): default to Gemini 3 Pro and remove broken depreca...
by vincentkoc · 2026-02-15
77.4%
#20049: fix(model-selection): resolve short-name alias keys correctly
by widingmarcus-cyber · 2026-02-18
77.1%
#12220: fix: forward-compat models now respect user-configured contextWindow
by Batuhan4 · 2026-02-09
76.8%
#20104: Fix Anthropic 1M model ID: strip -1m suffix before API call
by Clawborn · 2026-02-18
76.8%
#23250: feat: add Sonnet 4.6 forward compat for google-antigravity
by Oceanswave · 2026-02-22
76.5%
#11198: fix(models): strip @profile suffix from model selection
by mcaxtr · 2026-02-07
76.4%
#6632: fix(cli-runner): replace {model} placeholder in resumeArgs
by JorgeAlan · 2026-02-01
76.2%