ac4af582301a4e8a29245dbba767eba31334ddf9
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
eb3f174289 |
agent: Claude Code's auto mode classifier model is set on its Agents row (Linka on Discord)
Claude Code 2.1.302 reads CLAUDE_CODE_AUTO_MODE_MODEL for the model its client-side auto mode classifier checks each action with. It doesn't change server-side auto mode, and a classifier model Anthropic sets for the account comes first. The installed 2.1.303 binary has the variable: unset, Claude Code picks the sonnet tier's model, else Sonnet. It refuses claude-sonnet-5-5, claude-opus-5-5 and claude-opus-5 with a warning and uses its own pick instead. - Claude Code gets an "auto mode" field (key auto_mode, Quiet, follows nothing). It can be set only while Claude Code is routed through magpie, only to one of magpie's models, and is written dashed like the other model keys. Its options leave out the three models Claude Code refuses, and Set refuses them too. - A value the user had before magpie routed Claude Code is stashed with their tiers (claudeOwnEnv). It is taken out while wired in and comes back on Disconnect or Claude Code's own model, unless they have set one again since. The restore loop now skips any claudeOwnEnv key the user wrote again. - magpie's own value goes when magpie steps out. A value the user sets while wired in is never touched. - GUI: an "Auto mode" line in the opened row's Tiers, after Subagents, using the app's model picker. Default is noted as Claude Code's own pick. Strings are translated for zh, zh-TW, ja and de. - Docs: agent-wiring.md and reference.md. Run, in a worktree at origin/main |
||
|
|
bc470c6b63 |
agent: Claude Code's own ANTHROPIC_MODEL comes back when magpie steps out
Wiring Claude Code in deletes env.ANTHROPIC_MODEL (writeTiers), because it outranks a pick in /model. Unlike the tiers' models (#1050), the user's own value was never stashed, so Disconnect or Claude Code's own model left it gone for good. A Bedrock user like jw1dev keeps the Bedrock model id there, so after the previous commit put the switch back, Claude Code would come back on Bedrock without its model. ANTHROPIC_MODEL now joins claudeOwnEnv: it is stashed raw beside the endpoint and token when first routed from the user's own endpoint, put back by unroute, and forgotten with the rest. A value an older magpie wrote, at its own key, is still not kept (keyOurs), as before. Run: - gofmt -l: clean. - go vet ./internal/agent: native, GOOS=linux -tags nogui, GOOS=windows: clean. - go test -tags nogui ./internal/agent ./internal/gui: ok 4 times. One earlier run of the two together had internal/gui red, and only `tail -5` of it was kept, so the failing test's name was lost. It passed alone 3 of 3 and with internal/agent 3 of 3. Nothing in internal/gui reads claudeOwnEnv. - Targeted: ClaudeCloud, TestClaudeDisconnect, TestClaudePick, legacy, stand-in and T3 tests: ok. Broken by hand: before the fix, TestClaudeDisconnect's new "own env model" cases (with no settings model and beside one, [1m] kept; each by Disconnect and by default) went red. The bedrock fixture of TestClaudeCloudSwitchStepsAsideForMagpie now carries a Bedrock ANTHROPIC_MODEL and compares the whole env after. Not tried: WSL twins for real (the stash key goes through at.key as for the tiers). |
||
|
|
76db4c6c28 |
main, agent: --help on any command or agent only prints its usage, and Snow and Gemini CLI refuse a value they don't know instead of taking magpie out (#1457, blackrion)
`magpie snow --help` printed "✓ Snow CLI model --help" and did what
`magpie snow default` does. It deleted profiles/magpie.json, put back the
active profile, and wrote "--help" as advancedModel into the profile it
went back to. There were two causes:
- run's agent forms took any second argument as a model. The `len(args)==2`
branch special-cased only `default`.
- Snow's model Set, on magpie's profile, treated a value no profile of the
user's is on as "leave, and write it into the profile left for".
The arguments were the class, not Snow alone. Under the old code, `magpie
claude --help` and `magpie codex --help` wrote "--help" as Claude Code's
and Codex's model, and `magpie save --help` saved a profile named
"--help" (the new guard test caught each of these).
What changed:
- help_cli.go and run: -h or --help anywhere in the arguments, or help as
the word after the command, prints that command's usage and returns
first, before run reads, moves or starts anything. It prints the
command's own usage where it has one (model, group, group rule, library,
plugin, quota, sessions, search, visible, webdav, s3, claude-code), its
lines of magpie's usage otherwise, and for an agent its forms and
fields. The usage gains a `magpie <command> --help` line.
- `magpie <agent> …` refuses any other argument starting with "-"
(negative numbers aside): "unknown flag X: nothing was changed".
- snow.go: on magpie's profile, a model that is neither through magpie
nor any profile's model is refused, and the files stay as they were.
A `magpie/<x>` that isn't in the catalog is refused on or off magpie's
profile; it used to fall through to the same leave. A model of one of
the user's profiles still switches Snow there, and empty still goes
back to the profile they were on.
- gemini.go, a sibling found by auditing every agent's Set: provider is
Gemini CLI's first field, so `magpie gemini <a model with no option>`
reached it. It unrouted Gemini CLI (stashed key, sign-in and model put
back) and only then said "unknown provider". An auth it doesn't know is
now refused before unroute. The audit found no other Set that leaves
on an unknown value. The other model Sets write an unknown value as the
agent's own model, which is the intended own-model pick. The on/off
provider fields of ante, claudedesktop, copilotjetbrains, cursorlocal,
pencil, t3code, workbuddy and zcode take any non-empty value as "on".
Both are left as they are.
- docs/subsystems/agent-wiring.md says the above.
Tests:
- TestHelpOnEveryCommandDoesNothing reads the commands from run's switch
in main.go's AST, so a new command is covered without a list to keep.
It adds every agent id. For each one it runs --help, -h and help in
several positions under a sandbox home, and checks that nothing is
written, the run returns within 20s and usage is printed.
- TestAgentHelpLeavesSnowWired is the reporter's case: Snow wired, then
`snow --help`, `-h`, `help`, `model --help` and `snow-cli --help`,
unknown flags, and `snow nonsense`. Snow's files must stay the same.
- TestSnowUnknownModelChangesNothing and TestGeminiUnknownAuthChangesNothing
cover the Sets.
What was run:
- Each test was run against the old code. Old main.go: the save, snow,
claude and codex subtests FAIL ("✓ saved profile --help" with
profiles.json written; "✓ Snow CLI model --help"; "✓ Claude Code model
--help"; "✓ Codex model --help"), and so does TestAgentHelpLeavesSnowWired.
- Old snow.go with old main.go: TestAgentHelpLeavesSnowWired FAILs with
Snow's files changed, and TestSnowUnknownModelChangesNothing FAILs with
`"--help" taken`.
- Old gemini.go: TestGeminiUnknownAuthChangesNothing FAILs with
`"nonsense-model" changed Gemini CLI`.
- All pass with the fix.
- In a sandbox HOME with pinned Go caches, at origin/main
|
||
|
|
0c08b1d5bb |
agent: Claude Code's tier and subagent models the user set for their own endpoint come back with it when magpie steps out (#1050)
They were stashed nowhere: Connect took ANTHROPIC_DEFAULT_*_MODEL, ANTHROPIC_SMALL_FAST_MODEL and CLAUDE_CODE_SUBAGENT_MODEL over and Disconnect or Claude Code's own model deleted them, giving back only the base URL and token. |
||
|
|
dfc074afdb |
agents: Disconnect from magpie takes out everything magpie wrote into an agent's config and puts back what it had before (Fate on Discord: 移除由Magpie写入的配置,也就是重置功能,这个好像不是很明显。初步体验好像是选择默认就会清除写入的配置吗?希望能有一个更直接的交互动作,来代表移除由Magpie写入的配置。) — there was no one action for it, and picking Default isn't it: Default is the agent as installed, and for Codex, Claude Code and Gemini CLI it also forgets the stash, so the user's own provider or relay (model_provider + its table, ANTHROPIC_BASE_URL/AUTH_TOKEN, GOOGLE_GEMINI_BASE_URL/GEMINI_API_KEY and sign-in) was lost rather than put back. agent.Disconnect reuses each agent's own restore path: a new Agent.Unwire, for those three, runs the unroute their own-model pick already used (codex.go and claude.go have it pulled out of set as unroute; gemini.go's was there) and then forgets the stash, and every other field magpie set — each one reading a magpie value, or the value applied.json recorded and Unwire left — is set to "" through its own Set, which for every other agent unstashes what it had. applied.json forgets the agent (Keep), so no drift says it was switched off magpie. Agent.Wired (magpie or a magpie model in any field) goes to the GUI as agentJSON.wired; an agent magpie isn't in is left byte for byte. POST /api/agents/disconnect/{id} runs it under edit.Atomically as Sync and the fields' Sets are.
In the GUI, an agent magpie is in has "Disconnect from magpie" (断开 magpie(还原配置)) in its row's menu (its logo, or a right-click; beside Apply again), with a tooltip saying what it does, and in its model picker right under Default, so the two aren't taken for each other; the logo's title says the menu has it. It asks first in the app's own dialog (askDisconnect, as askReset and askForgetSaved do; no native confirm), and the row is then drawn from the answer: the model the agent had, no longer wired, and the status line says so. Every new string has its Chinese. The drag grip stays hover-only; no click moves the page. What it leaves: Codex keeps magpie's [model_providers.magpie] table, as its own-model pick does, for threads started on it; with several ChatGPT accounts in magpie, Codex failover may write openai_base_url again on a later sync. A relay's own ANTHROPIC_MODEL in Claude Code's env was never stashed, so it doesn't come back; modelSettings effort entries for magpie models may stay in settings.json. Tests: TestCodexDisconnect (own provider, own provider signed in, nothing set: the top keys as before, the user's provider table untouched, no subagent model, no catalog file, no stash, not wired, no drift), TestClaudeDisconnect (own relay and nothing set: settings.json as before), TestGeminiDisconnect, TestDisconnectUnwiredLeavesConfig, TestAgentDisconnectAPI; internal/gui/tests/agent-disconnect.test.cjs (WebKit, English and Chinese: only a wired agent has it in the menu and the picker, the in-app dialog, Cancel posts nothing, Disconnect posts and the row shows the old model, no native dialog, the page doesn't move). click-scroll, agent-grip, agent-layout, agent-models, agent-model-groups, model-pick, favorite-star, claude-picker-fold and panel-effort pass under WebKit; menu-scroll fails on /api/plugins/updates unmocked, as it does on main. go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui -count=1 ./... under a temp HOME pass. Not run against a live agent config. |