Repository navigation
feat(server): Claude on a Magpie gateway lists Magpie's whole catalog - #93
Conversation
A Claude instance whose ANTHROPIC_BASE_URL points at Magpie showed only T3's built-in Claude list. Claude Code's own gateway discovery keeps only ids containing "claude" or "anthropic", so Codex, Magpie Go and routing-group models never reached the picker, though Magpie routes them. The Claude driver now reads the gateway's /v1/models after each status check. A catalog whose entries carry `magpie_label` is Magpie's. The picker then keeps the built-in Claude models Magpie serves, with their full options, and adds every other Magpie model grouped by route. Each added model gets the reasoning levels its catalog entry states that Claude Code can send. Non-Claude routes are labelled "200K context", because Claude Code runs unrecognised model names with a 200K window and a 32K output cap. Any other endpoint, or no answer, keeps the built-in list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bot review round 1 (Claude Sonnet 5.5, independent) @ 392e419Scope: No blocking findings. The merge and dedupe logic holds up, and I could not construct an input that breaks it. Details:
Non-blocking
Simplicity check. The change is a smaller sufficient fix. It adds one pure module, one |
A redirect from the gateway would carry the x-api-key header to another host. Refuse redirects as Claude Code's own gateway discovery does. From bot review round 1 on 392e419. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Repair round 1 @ 24ed84bResponds to bot review round 1 on 392e419. There were no blocking findings.
Verified on the repair: |
A Claude instance whose
ANTHROPIC_BASE_URLpoints at a Magpie gateway listed only T3's built-in Claude models. Kameron saw "Claude shows only Claude models." Magpie routes Anthropic Messages requests to Codex, Magpie Go and routing groups too. But Claude Code's gateway discovery fetches/v1/modelsand keeps only ids that match/(claude|anthropic)/i(checked in the 2.1.322 binary), so those models never reached the picker.Fix
apps/server/src/provider/MagpieGatewayModels.ts. After each Claude status check, the driver reads<base>/v1/modelsfrom the effectiveANTHROPIC_BASE_URL(settings env, then process env). It only does this for non-Anthropic hosts, with a 3-second timeout. A catalog counts as Magpie when its entries carrymagpie_label, which catches the real gateway rather than guessing from the hostname.claude/claude-sonnet-4-5.-20251001) fold into one entry. A custom model with the same slug wins.supported_reasoning_levels, keeping only levels Claude Code can send (noneis dropped), plus Default. These models get no Ultracode, Fast Mode or thinking toggles.<Route> · 200K context.claude-direct, which points at Anthropic, is untouched.What Claude Code does with a non-Claude model name
Captured with a local stub gateway at no model cost, Claude Code 2.1.322:
unrecognized_model, then runs with a 200K context window and a 32Kmax_tokens(a Claude model gets 1M and 128K). Its cost reads asunknown.thinking: adaptive,output_config.effort(it defaults tohighwhen none is set),context_managementand threecache_controlmarkers. It drops theper-turn-controlbeta. Magpie has to translate or ignore these.CLAUDE_CODE_MAX_CONTEXT_TOKENSlifts the window. It's left as a follow-up, because it is process-wide.Verification
vp test run src/provider/MagpieGatewayModels.test.ts: 3 tests pass.check:changedagainstorigin/release/native-0.1.10: format, lint, typecheck and graphql pass. knip andAgentContextBudget.test.ts(mcpToolListJsonBytes52637 vs 52839) fail identically on the unmodified base, so both are pre-existing..t3), the Claude picker shows the 4 current Claude models, Claude Sonnet 4.5 (latest) labelled "Claude Code", 7 Codex models, 4 Magpie Go models and 1 routing group. Legacy Claude models sit under Show more.t3 thread start --wait:claude-stubinstance onmagpie-go/glm-5.3-flashagainst a stub gateway serving Magpie's real catalog: the reply wasok, and the stub receivedmodel: magpie-go/glm-5.3-flashwith 16 tools. No paid call was made.claudeAgentinstance onclaude/claude-sonnet-4-5, a Magpie-only id, with the prompt "Reply with exactly: ok": completed withokon the included Claude Max route.magpie-gorequest, because those keys show no Go subscription and could cost money.The Codex half of the report is a config fix in the
t3_nodetemplate: nullStack65/Closura#1955.Model and harness: Claude Opus 5.5 in Claude Code, running in T3 Code.
🤖 Generated with Claude Code