`magpie claude sonnet` sets Claude Code's model to its own alias. That
isn't a model magpie serves, so magpie steps out (unroute) and puts back
the endpoint Claude Code had before magpie. In #2000 that endpoint was
DeepSeek's, which refused Sonnet with a 400. The command printed only
"✓ Claude Code model sonnet". An agent had run it as a read-only query of
the sonnet tier, and nothing in the output said the routing had changed.
set() now checks whether the agent was wired into magpie before the
write. When a non-empty value leaves it unwired, set() prints
"disconnected from magpie: <model> is <agent>'s own, sent to the endpoint
it had before magpie; magpie <agent> <model> with one of magpie's models
connects it again". This covers every agent and field set through
`magpie <agent> …`, not only Claude's aliases. Setting a field back to
default (empty) is left as it was. `magpie <agent> default` already says
it disconnects.
The behaviour itself is unchanged. On an Anthropic sign-in or a Claude
relay the aliases are a deliberate one-word way back to Claude Code's own
models.
`magpie claude help` now has a line under the aliases: "they are Claude
Code's own models, not magpie's: setting one takes magpie out; magpie
claude alone shows each".
Verified:
- TestClaudeAliasSaysItTookMagpieOut covers opus, sonnet, haiku and
fable. It starts from a DeepSeek-style own endpoint (.invalid host),
wires Claude Code to group/advanced and sets the alias. It checks the
notice, that the old endpoint is back, that nothing is printed when the
alias is set again while off magpie, and the help line.
- With the notice disabled by hand, the test fails:
"magpie claude opus: <nil> "✓ Claude Code model opus\n", want it to say
magpie is out" (and the same for the other three).
- TestAgentDefaultInAnyCase first went red on "codex model DEFAULT", so
empty values are excluded.
- HOME=<sandbox> go test -tags nogui ./internal/cli: ok.
- gofmt -l clean. go vet and GOOS=linux/windows go vet -tags nogui
./internal/cli: clean.
What: `magpie codex model` wrote model = "model" into config.toml (and
applied.json, stash.json); any agent's field name given alone, or as a
value, was set as its model, and `magpie codex DEFAULT` wrote
model = "DEFAULT". Now:
- `magpie <agent> <field>` (any case) prints that one field and writes
nothing;
- a field's name given as a value is refused with a hint
(`magpie claude effort Ultracode`);
- DEFAULT in any case takes magpie out, as `default` does;
- Claude Code's tier names (opus/sonnet/haiku/fable) still set the model,
since agent.ModelAliases marks them, and the agent's help says so.
agent.Field matches key and label in any case; agent.Running is a var
so the cli tests can say Codex isn't open.
Why: ported from waitingsnow's #1129 (commits bbe75c91f, 00bb38581,
244b24a67) onto internal/cli, where the CLI moved after the PR was
opened. The PR's --help part landed earlier as 76db4c6c2 (#1457).
Run: the five new internal/cli tests fail on origin/main without the
cli change (TestAgentFieldNameShowsIt: "✓ Codex model model" and
model = "model" written; TestAgentDefaultInAnyCase: "✓ Codex model
DEFAULT"; the tier-name help line and the Ultracode hint missing) and
pass with it. gofmt -l clean; go vet darwin, GOOS=linux -tags nogui,
GOOS=windows clean; go build for all three; go test -tags nogui ./...
green (an earlier run's internal/agent 10m timeout was a stuck open()
in TestWSLStoppedDistro under a 100%-full disk and load ~44; the WSL
tests pass alone and the full rerun passed).