Files
magpie/docs
yetone 90932ed1fa gateway: Claude Code's model discovery is shown every model by an id it keeps
Claude Code's Gateway Model Discovery (CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY)
puts in /model only the ids matching /(claude|anthropic)/i: Tvi in the
2.1.316 bundle, te.data.data.filter((se)=>/(claude|anthropic)/i.test(se.id)),
on GET <ANTHROPIC_BASE_URL>/v1/models?limit=1000 with User-Agent
claude-code/<version> (Xs(), not claude-cli/) and anthropic-version:
2023-06-01. A remote magpie's Kimi, GLM and DeepSeek never showed (zent00
on X, tweet 2121440002244747428).

That request alone (claudeCodeDiscovers: the User-Agent and the header,
never another magpie) is now shown a chat model whose id says neither by
Claude Desktop's alias anthropic/magpie-<n> (aliasFor), which unprefixed
already serves as the model for every client, before any provider's
model of that spelling; no Claude id is spelled so. Its display_name is
the agents' list name, which /model shows. Ids Claude Code keeps, names a
gateway key gives models, and every other client's list are unchanged; a
bare-id row it wouldn't keep is left out (its full id's row is there).
"anthropic/<magpie id>" was not used: a provider named anthropic (the
Anthropic preset's id) serves any model asked by that spelling. Zero
config, so no switch.

Run:
- TestClaudeCodeDiscoveryKeepsEveryModel, on mote: red on the old
  gateway.go ("not shown anthropic/magpie-9301644634 for auto/kimi-k3"),
  green with the change; with the anthropic-version check broken by hand
  it fails on the claude-cli/ client. TestCindyDiscovery and the Desktop
  tests green.
- Real Claude Code 2.1.316 binary on mote, sandbox HOME, against the
  gateway with a fake Anthropic upstream: its cache gateway-models.json
  held {"id":"anthropic/magpie-4484984192","display_name":"DeepSeek V4 ·
  DeepSeek"}; `claude -p --model anthropic/magpie-4484984192` answered
  PONG and the upstream was asked model deepseek-v4. Claude Code warns it
  assumes a 200k window for an id it doesn't know, as for any non-Claude
  id.
- gofmt -l: clean. Package vets/builds and go test ./internal/gateway
  started on mote; the full suite (go vet, GOOS=linux/windows vet,
  builds, go test -tags nogui -timeout 45m ./...) is queued under
  mote's suite.lock and runs after the push, per the ship-at-once rule;
  its reds get their own commits.
Not tried: interactive /model screen (the rows come from that cache
file), a real remote magpie over LAN with a gateway key.
2026-11-14 11:43:27 +08:00
..