Skip to content

fix(server): custom Claude models named like a Claude Code alias reach the API unchanged - #34938

Merged
juliusmarminge merged 2 commits into
mainfrom
factory/issue-22326
Nov 12, 2026
Merged

juliusmarminge merged 2 commits into
mainfrom
factory/issue-22326

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Claude Code expands the bare aliases opus, sonnet, haiku and fable to its own built-in models. When a custom Claude model has one of those names, scopeClaudeModelCatalog removes the alias from the built-in entry, so T3 sends the custom slug (for example opus) unchanged, and the CLI then swapped it for claude-opus-5-5. makeClaudeQueryOptions now adds ANTHROPIC_DEFAULT__MODEL= to the flag settings env whenever the outgoing apiModelId is one of those four aliases. This is the same merge path the ENABLE_TOOL_SEARCH override uses, so a user's settings.json env cannot override it. A built-in alias selection never reaches this branch because it resolves to the full slug first. The alias list and env var names were read from the installed Claude Code CLI binary. Checked against a local recording proxy: claude -p --model opus sent claude-opus-5-5, and adding --settings '{"env":{"ANTHROPIC_DEFAULT_OPUS_MODEL":"opus"}}' made it send opus. No new regex or parser: the check is a lookup in a fixed set of four names.

Fixes #22326

Reproduction on main

Commit 4e0b528 (origin/main). Started a local recording proxy that logs the model of each Anthropic request and replies with it. Ran T3CODE_DEV_SEED=0 vp run dev with ANTHROPIC_BASE_URL pointing at the proxy and a dummy API key; Settings > Providers showed Claude 'Authenticated · Custom API endpoint'. In Settings > Providers > Claude, added the custom model opus. Opened a new thread, picked opus under Claude in the model picker, sent 'Say hi'. The proxy received POST /v1/messages with model claude-opus-5-5, and the thread reply showed 'proxy saw model=claude-opus-5-5'. T3's provider event log showed the outgoing query.open had options.model = "opus", so T3 passes the custom slug through unchanged (the missing-catalog cause in the report was fixed by #27034). Running the Claude CLI 2.1.322 directly against the proxy: claude -p --model opus sent claude-opus-5-5, --model xpus sent xpus, and ANTHROPIC_DEFAULT_OPUS_MODEL=opus claude -p --model opus sent opus. Claude Code expands its own built-in alias.

Evidence

Select custom Claude model opus in a new thread and send Say hi. Both sides use fresh isolated databases, Claude CLI 2.1.322, the same local recording endpoint, and a 1280×800 light-theme web browser. The endpoint streams a diagnostic response determined by the actual request model.

Before After
4e0b52806b bf3c153112
Before: endpoint detects alias expansion After: endpoint receives exact custom route
Before recording After recording

Recording endpoint script · Reproduction instructions · Sanitized runtime transcript

Base sent an expanded built-in identifier; head sent exactly opus. AI-assisted; verified with the tests and tools listed above.

Not shown:

  • Other alias names and settings supplied as file paths were not exercised; this proof covers the requested opus flow.
  • Desktop and mobile clients were not run; all captures show the web client.

Tests

vp test run src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts (apps/server): 399 passed, including the repro test from factory/repro-22326. vp run check:changed: format, lint, knip, graphql, typecheck (3 packages) and test (2 files, 401 tests) all passed. Manual: Claude CLI against a local recording proxy, with and without the alias override in flag settings env (claude-opus-5-5 vs opus).

Not in this change

  • When the user's --settings launch argument is a settings file path rather than JSON, flag settings cannot take extra keys, so the alias override (like the existing ENABLE_TOOL_SEARCH override) is not applied in that case.
  • Compound Claude Code aliases such as opusplan or best are not custom-model collisions covered here; only the bare model aliases with ANTHROPIC_DEFAULT__MODEL overrides are pinned.

AI-assisted; verified with the tests and tools listed above.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Claude doesn't use custom model when the name collides with a model alias

1 participant