roswellcsy on X (v0.1.2846). Claude Code was switched off magpie and on
its own sign-in, with several Claude accounts and one made first. Every
session said "There's an issue with the selected model
(claude/claude-opus-5-5)", while settings.json's model was the bare
claude-opus-5-5.
Cause: a name of magpie's left in Claude Code's env.
- The env's ANTHROPIC_MODEL outranks settings.json's model (Claude Code
2.1.316: Wg(), `i.ANTHROPIC_MODEL||settings.model`). The tier variables
stand in for opus/sonnet/haiku. On Anthropic's endpoint a
provider/model name is a 404, shown as that message.
- How it got there and kept coming back:
- Connecting a Claude Code that is not routed stashes its env models as
"the user's own" (claude.env.<VAR>), magpie's names included.
- Disconnect (unroute) then writes them back, again unchecked.
- Once one is there, every connect and switch-off keeps it.
- The bare model is the user's own, from connect.was or untouched.
- Nothing took the name out afterwards:
- unroute returned at once when not routed;
- Sync only did desktopOnly;
- Disconnect is a no-op once Wired() is false (a bare model with no
gateway URL).
- Sibling: wiring at an older gateway address (magpie's key) was left in
place by Disconnect, while set("") already took it out.
Fix (internal/agent/claude.go):
- claudeMagpieModel(v): v is a catalog ref, read through ClaudeRead and
with any :effort or [1m] taken off.
- It is never stashed as the user's own, and never given back from a
stash (one an older magpie wrote included).
- dropStray: with no ANTHROPIC_BASE_URL (Anthropic's own endpoint), every
claudeModelEnv key and `model` holding one of magpie's names is taken
out. ANTHROPIC_MODEL, SMALL_FAST, SUBAGENT, the four tiers and the
auto mode model are covered.
- It runs from Sync when not routed, so SyncCatalog repairs users
already in this state at the next start.
- It also runs from unroute when not routed (Disconnect, the default
model, a non-magpie model).
- An endpoint of the user's own may name its models so, and those
stay.
- unroute, when not routed: wiring at an older gateway address
(keyOurs) goes whole, as set("") takes it.
- docs/subsystems/agent-wiring.md says so.
Test: TestClaudeOffLeavesNoMagpieModel, in a sandbox HOME. Each subtest
reads settings.json as Claude Code starts on it (ANTHROPIC_MODEL over
model, the tiers, small fast, subagent, auto mode).
- start: the stray env, then SyncCatalog;
- connect + Disconnect twice;
- a stash an older magpie wrote;
- the user's own models come back;
- an older gateway address;
- another endpoint's names are left alone.
Red on the old code: start, connect+Disconnect and older-address fail
(red-old.log). "connected and switched off again" reproduces the report
exactly: model "claude-opus-5-5" with env ANTHROPIC_MODEL
"relay/claude-opus-5-5".
Broken by hand, each through mote-run:
- dropStray out of Sync: start red.
- Both stash guards out: connect+Disconnect red.
- The restore guard alone out: older-stash red.
- keyOurs cleanup off: older-address red.
- With the stash guard alone out, the restore guard still holds, so it
stays green.
Run on mote (mote-run, at d8501848a plus this change; the doc edit came
after the run):
- go test ./internal/agent/ ./internal/provider/ -count=1 -timeout 45m:
ok agent (200s), ok provider (136s).
- The new test: 7 of 7 PASS (the parent and 6 subtests).
- GOOS=windows go vet ./...: ok.
- GOOS=linux go vet -tags nogui ./...: ok. Without the tag it stops in
Wails' cgo-only Linux files when cross-compiling, which this change
doesn't touch. GOOS=linux go vet ./internal/agent/ ./internal/provider/
is ok too.
- gofmt -l: clean.
Not tried:
- A real Claude Code run against Anthropic. The 404 path was read from
the 2.1.316 bundle, not hit.
- The user's literal provider id claude/: the test uses a relay
provider. isMagpie resolves both the same way.
- WSL's Claude Code goes through the same claudeIn and wasn't run.
- A Claude Desktop Code tab with a provider/model in settings.json's
model and no base URL would also lose it at Sync. Desktop writes
mythos-magpie-<n> ids there, not provider/model ones.