Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

agent: Claude Code's auto mode classifier model is set on its Agents row (Linka on Discord)

yetoneeb3f1742895c
diff --git a/docs/reference.md b/docs/reference.md
index e1106c862..f04068a3e 100644
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -89,7 +89,7 @@ line; agents connected to magpie lose it when it quits.
| Agent | File | Fields |
| ------------ | --------------------------------- | --------------- |
-| Claude Code | `~/.claude/settings.json` | provider, model, opus/sonnet/haiku/fable, sign-in (through magpie) |
+| Claude Code | `~/.claude/settings.json` | provider, model, opus/sonnet/haiku/fable, auto mode, sign-in (through magpie) |
| Claude Desktop | `Claude/` + `Claude-3p/configLibrary/` in `~/Library/Application Support` (`%LOCALAPPDATA%` on Windows, `~/.config` on Linux). A Desktop installed as an MSIX package on Windows keeps them in its package instead (`%LOCALAPPDATA%\Packages\Claude_<publisher>\LocalCache\Local`, or `AnthropicPBC.Claude_<publisher>` for the Store's package, its own data in `LocalCache\Roaming\Claude`). Desktop 2.31226 and later, packaged, reads the real `%LOCALAPPDATA%\Claude-3p` instead, so for a packaged Desktop magpie writes both ([`desktopdir`](../internal/desktopdir/desktopdir.go)) | provider (its third-party gateway mode: Code and Cowork on magpie, no Anthropic sign-in; restart Desktop), opus/sonnet/haiku/fable, subagent model and subagent effort (magpie's settings, applied by the gateway to subagent tool turns; no restart) |
| Codex | `~/.codex/config.toml` | provider, model, effort |
| Gemini CLI | `~/.gemini/settings.json`, `~/.gemini/.env` | auth, model |
diff --git a/docs/subsystems/agent-wiring.md b/docs/subsystems/agent-wiring.md
index 51ba4f7aa..c0d85c17a 100644
--- a/docs/subsystems/agent-wiring.md
+++ b/docs/subsystems/agent-wiring.md
@@ -72,6 +72,7 @@ something else shows up as drift.
- A Claude Code tier or its subagents given a model of their own keep it when the main model moves onto that model and on again (`ownKey` in `claudeIn`), whether the main model is picked in magpie or in Claude Code's `/model`. Same as model, picked for them, has them follow again.
- While this machine's Claude Desktop is on magpie, Claude Code's shared settings get `CLAUDE_CODE_DISABLE_EXPLORE_INHERIT_CAP="1"` (`writeExplore` in `claudeIn`, [`claude.go`](../../internal/agent/claude.go)). Claude Code 2.1.295's Explore inherit cap can otherwise replace Desktop's `mythos-magpie` compatibility alias with Opus. This disables that cap, not the model choices of all subagents. It applies with Desktop alone or beside a connected Claude Code, including model picks and Sync; WSL twins do not get it. A user's existing value, including an empty string, stays. The stash (`claude.explore_inherit_cap`) marks only magpie's value: taking Claude Code off magpie leaves it while Desktop is on, and taking Desktop off removes it only if the user has not changed it. Since the settings file is shared, other Claude Code sessions reading it see the flag while Desktop is connected too.
- Claude Code's tier and subagent models the user had set for their own endpoint (`claudeOwnEnv`) are stashed with that endpoint and token when magpie is wired in, and come back with them when magpie steps out, by Disconnect or by Claude Code's own model (#1050). So does their main model in the env (`ANTHROPIC_MODEL`, a Bedrock model id beside `CLAUDE_CODE_USE_BEDROCK` for one), which magpie takes out while wired in because it outranks a pick in `/model`.
+- Claude Code's auto mode field (`auto_mode`, `claudeAutoModeEnv` in [`claude.go`](../../internal/agent/claude.go)) is `CLAUDE_CODE_AUTO_MODE_MODEL`, the model Claude Code 2.1.302's client-side auto mode classifier judges each action with (Linka on Discord). It changes nothing about server-side auto mode, and a classifier model Anthropic configures for the account comes before it. Unset, Claude Code picks its own (the sonnet tier's model, else Sonnet), so it follows no field and isn't `Follows`. It is set only while Claude Code is routed through magpie, only to one of magpie's models, dashed as the other model keys are, and never to Sonnet 5.5, Opus 5.5 or Opus 5 (`claudeNoClassifier`), which Claude Code 2.1.303 refuses there and replaces with its own pick. A value the user had before magpie routed Claude Code is stashed and taken out with their tiers (`claudeOwnEnv`), and comes back when magpie steps out, unless they set one again since; magpie's own value (`claude.auto_mode_model` in the stash, or any of magpie's models) goes then, and one the user set while wired in is left alone. Claude Code reads it as it goes, so it is Quiet and needs no restart.
- Claude Code's provider switches (`agentenv.ClaudeProviders`: `CLAUDE_CODE_USE_BEDROCK`, `_VERTEX`, `_FOUNDRY`, `_ANTHROPIC_AWS`, `_ANTHROPIC_GOOGLE_CLOUD`, `_MANTLE`, Claude Code 2.1.300) send it to that cloud's own endpoint and pass `ANTHROPIC_BASE_URL` over, so with one on it never reaches magpie (jw1dev on X: Bedrock refused magpie's model, and magpie showed nothing). Claude Code reads 1, true, yes and on as on (`claudeSwitchOn`). One that is on in the settings magpie writes is taken out on every route that writes the wiring (`dropClouds` in `writeTiers` and `Sync`), its raw value stashed (`claude.cloud.<var>`, under the distro's id for a WSL twin), and put back as written when magpie steps out (`putClouds` in `unroute`), unless the user set it again since. The cloud's own variables (`AWS_*`, `ANTHROPIC_VERTEX_PROJECT_ID`, …) and a switch that is off stay. Where magpie doesn't write it, Check says so, naming the variable, the cloud and where (`claudeCloud`): the managed settings, which win over the user's; `~/.claude.json`'s env, under the user's settings; and, for this machine's Claude Code, the login shell's environment (`proc.LoginEnv`, read but never set in magpie's), under every settings file. A project's `.claude/settings.json` isn't read: magpie doesn't know which folders Claude Code runs in. T3 Code's Check says the same of the user's `~/.claude` settings, which are put over its magpie instance's environment, and a switch put on that instance goes at its next write; that Check first says when the instance's `ANTHROPIC_BASE_URL` no longer reaches the gateway (`t3EnvOf`), as every agent's Check does, so a port move rewrites it too. The drift's detail is shown in the row's line and its pill through `tNotice` (`claude-cloud-drift.test.cjs`). Claude Desktop's Code tab runs with `CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST`, under which Claude Code ignores a switch in settings files, so Desktop needs neither.
- Claude Code's sign-in (`login`) is magpie's key (`""`, the default) or claude.ai (`claudeai`). claude.ai writes `ANTHROPIC_AUTH_TOKEN` empty, which Claude Code reads as no key: it keeps its claude.ai login and sends that to magpie, which never passes it on (`claudeSignIn` in the gateway). Every later write keeps the token empty (`wiredKey`), and a caller key of the gateway's own put there by hand is taken for magpie's, by Check and a model pick alike, kept as the user left it (`keyHolds`, #2545); a key the gateway would refuse is reported by Check and wired over, and so is the sharing key magpie itself made (`access.Default`), once sharing is off — magpie's own, however well the gateway still takes it. It's offered only where the gateway takes any key (`gwKey() == gateway.Token`: loopback, a WSL distro mirrored), not from a distro under NAT while magpie is shared on the network, where only the sharing key gets in. The choice is stashed, so it survives Disconnect and a port move. An empty token counts as magpie's only beside the address magpie last wrote (`claude.wired_at` in the stash, which Rewire carries to the new port, `keyOurs`): an endpoint of the user's own with an empty token stays theirs when the model goes back to Claude Code's own.
- Claude Code's auto mode review (`CLAUDE_CODE_AUTO_MODE_SERVER`, `claudeReviewEnv` in [`claude.go`](../../internal/agent/claude.go)) is written `"0"` while Claude Code is routed through magpie and none of the models it can reach there is one Anthropic reviews (`claudeReviewed`, by `gateway.AutoModeReviewed`): those it is shown (and Claude Desktop's while Desktop is on magpie), a shown group's members, those providers' fallbacks, and the models it is set to, each judged on the provider (or group, or fallback) it resolves to, as the gateway judges its requests, so a Claude model on Copilot or Kiro alone writes `"0"` and a name magpie doesn't know is judged by the name (`TestClaudeReviewedJudgesTheSetModelWhereItGoes`). Off, it classifies locally from the start, as it does anyway behind a gateway that doesn't answer, without the "isn't eligible because your requests go through 127.0.0.1:3425" notice (1EFLOPS on X). Any reviewed model leaves it unset, since `/model` can take the session there; a model hidden from Claude Code doesn't count. It is rewritten on every model set and `Sync`, so adding a Claude provider turns the review back on. magpie's value is kept apart in the stash (`claude.auto_mode_server`), a user's own is left alone, and it goes when Claude Code is taken off magpie (`desktopOnly`, `unroute`). T3 Code's magpie instance, which runs Claude Code on the gateway through its own environment, carries the same `"0"` there by the models it lists (`t3InstanceJSON` in [`t3code.go`](../../internal/agent/t3code.go)); a value in the user's `~/.claude` settings comes after it.
@@ -79,7 +80,7 @@ something else shows up as drift.
- Claude Code is told what each of magpie's models can do in `CLAUDE_CODE_MODEL_CAPABILITIES` (`claudeCapsEnv`, `claudeCapabilities` in [`claude.go`](../../internal/agent/claude.go)): `<model>=effort[,xhigh_effort][,max_effort]` for those it is shown, and, while Claude Desktop is on magpie, for Desktop's `mythos-magpie-<number>` ids its Code tab hands it. A Claude model Claude Code knows gets no more than Claude Code gives it (Opus and Sonnet 4.6: no xhigh), and one with no known levels isn't named. A model that reaches max without xhigh (GLM-5.3 at low/high/max, DeepSeek V4 at high/max) is said to have xhigh too: the gateway runs xhigh at max for it (`fitEffort`), and Claude Code 2.1.299 turns Ultracode down without `xhigh_effort` ("Ultracode isn't available on …"), which in Desktop is the Ultracode level and dynamic workflows (leesunrise2364 on Discord; `TestClaudeModelCapabilities`). A value of the user's is left alone.
- MiniMax Code takes a model ref with one slash in the whole (a SubAgent's `model` must match `^[^/\s]+\/[^/\s]+$`, #1387), and magpie's refs there are `custom_provider:magpie/<model>`. So a model under `custom_provider.magpie` is written with `~` for each slash of its catalog id (`bb-codex~gpt-6.1-sol`, `provider.FlatID`), only when that spelling stands for one served id (`provider.Flattened`); the gateway takes it back. A config an older magpie wrote moves over on the next sync: the user's keys on a model go to its new key, `defaultModel`, `defaultLightModel` and `memory.captureModel`/`consolidationModel` follow (`mcodeRefs`), and the slashed key stays, switched off (`enabled: false`), so a session begun on it still resumes. magpie never edits the user's own `agents/<name>/agent.md`. No other agent was found with this limit ([`minimax.go`](../../internal/agent/minimax.go)).
- Claude Code's `/model` list (`modelPicker` in its settings.json) is magpie's while it is marked in the stash (`claude.model_picker`, `claude@wsl:<distro>.model_picker` for a WSL distro) or while every row's description ends "via magpie", as every row magpie writes does (`magpiesPicker` in [`claude.go`](../../internal/agent/claude.go)). magpie keeps its own list up to date on every model set and `Sync`, and removes it when Claude Code is taken off magpie; a list the user wrote is left alone. The fingerprint covers a list whose mark an older magpie's stash lost, which otherwise stayed without every model added since (#2046).
-- Claude Code 2.1.296 reads a Claude model whose version has a dot (`relay/claude-opus-4.6-us`) as Claude Opus 4: a retired warning, budget thinking, 32000 output tokens, no effort. With dashes (`relay/claude-opus-4-6-us`) it knows the model (misteer_ti. on Discord). So every model magpie writes into its settings (`model`, the tier envs, `ANTHROPIC_SMALL_FAST_MODEL`, `CLAUDE_CODE_SUBAGENT_MODEL`, `modelPicker`), T3 Code's Claude slugs and Claude Desktop's Code-tab ids (`claudeLooking`) spell a dotted Claude version with dashes (`provider.ClaudeSpelled`), only when that spelling stands for one served id. A Claude model listed to Desktop with reasoning levels is given as `magpie-<n>.anthropic.<model>`, its dotted version dashed as well (`claudeModel`: Copilot's `claude-opus-5.5` is `…anthropic.claude-opus-5-5`, which Claude Code knows; it was `mythos-magpie-<n>`, an unknown model, and Haiku 4.5 got an effort Copilot refuses, #1819); a request for it is served by `<n>` alone (`aliased`), so that spelling needn't be unique. Mythos counts as Claude here too: Claude Code matches `claude-mythos-5-1` by substring, so `claude-mythos-5.1` would read as Mythos 5. Every read of those keys takes it back (`provider.ClaudeRead`: `claudeIn`'s `env`, `claudeMain`, `claudeStandInAt`), so magpie's fields, applied state and Drift keep the dotted id. The user's own values are stashed and given back as written. Values an older magpie wrote dotted are rewritten on the next Sync. Other vendors' ids are never respelled ([`claudedash.go`](../../internal/provider/claudedash.go)).
+- Claude Code 2.1.296 reads a Claude model whose version has a dot (`relay/claude-opus-4.6-us`) as Claude Opus 4: a retired warning, budget thinking, 32000 output tokens, no effort. With dashes (`relay/claude-opus-4-6-us`) it knows the model (misteer_ti. on Discord). So every model magpie writes into its settings (`model`, the tier envs, `ANTHROPIC_SMALL_FAST_MODEL`, `CLAUDE_CODE_SUBAGENT_MODEL`, `CLAUDE_CODE_AUTO_MODE_MODEL`, `modelPicker`), T3 Code's Claude slugs and Claude Desktop's Code-tab ids (`claudeLooking`) spell a dotted Claude version with dashes (`provider.ClaudeSpelled`), only when that spelling stands for one served id. A Claude model listed to Desktop with reasoning levels is given as `magpie-<n>.anthropic.<model>`, its dotted version dashed as well (`claudeModel`: Copilot's `claude-opus-5.5` is `…anthropic.claude-opus-5-5`, which Claude Code knows; it was `mythos-magpie-<n>`, an unknown model, and Haiku 4.5 got an effort Copilot refuses, #1819); a request for it is served by `<n>` alone (`aliased`), so that spelling needn't be unique. Mythos counts as Claude here too: Claude Code matches `claude-mythos-5-1` by substring, so `claude-mythos-5.1` would read as Mythos 5. Every read of those keys takes it back (`provider.ClaudeRead`: `claudeIn`'s `env`, `claudeMain`, `claudeStandInAt`), so magpie's fields, applied state and Drift keep the dotted id. The user's own values are stashed and given back as written. Values an older magpie wrote dotted are rewritten on the next Sync. Other vendors' ids are never respelled ([`claudedash.go`](../../internal/provider/claudedash.go)).
- Codex's "subagents" field is `[agents] default_subagent_model`: only the model a subagent starts on when its lead names none in `spawn_agent` (codex-rs `core/src/agent/child_config.rs`). Unset, it isn't "same as model": the lead may still name another, so the GUI calls it the lead's pick, else the model (`leadPicks` in app.js), and its title points at the "subagent model" field.
- Codex's "subagent model" field writes nothing to Codex's config: its lead names each subagent's model in `spawn_agent`, which `[agents]` can't overrule. It is magpie's setting (`settings.CodexSubagentModel`, [`codex_subagent.go`](../../internal/provider/codex_subagent.go)), and the gateway moves the subagent's request onto it (see [gateway routing](gateway-routing.md)). Its options are every model and routing group Codex's own lists show (`CatalogFor("codex")`, so a model taken out of them or not picked is left out here too), ChatGPT accounts' first (#1633: a lead on a chat provider wants its subagents there too). A task a ChatGPT-backed lead sealed opens only on a ChatGPT account, so the gateway keeps such a subagent on its own model when the one set is another provider's. Its setter takes any `provider/model` or `group/<id>`, also one magpie doesn't serve now, so a profile or backup put back on another computer still applies (`ApplyFields` stops at the first failed Set), and refuses one of Codex's own bare names.
- Claude Desktop's "subagent model" field (`subagent_model`, `desktopSubagentField` in [`claudedesktop.go`](../../internal/agent/claudedesktop.go)) writes nothing to Desktop's config: Desktop runs its Code tab's Claude Code with `CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1`, under which Claude Code ignores `CLAUDE_CODE_SUBAGENT_MODEL`, `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` and the tier variables in its settings files' `env` ("Ignoring … this session's provider routing is managed by the host", Claude Code 2.1.295), and the env Desktop builds for the Code tab has no key for it (Desktop 2.31226). It is magpie's setting (`settings.DesktopSubagentModel`, [`desktop_subagent.go`](../../internal/provider/desktop_subagent.go)), and the gateway moves each subagent's turn onto it (see [gateway routing](gateway-routing.md)). It is labelled as Codex's, so the Agents page gives it the same square. Its options are magpie's models and groups as Desktop's list shows them (`viaMagpie("claude-desktop")`), while Desktop is on magpie, as for the tiers. A Desktop alias picked is kept by its catalog id (`DesktopCatalogID`). Like Codex's, its setter takes any `provider/model` or `group/<id>`, also one magpie doesn't serve now, so a profile or backup still applies, and refuses a bare name. It is `Live`: the gateway reads it on each request.
diff --git a/internal/agent/claude.go b/internal/agent/claude.go
index e8634ee3e..61f76c043 100644
--- a/internal/agent/claude.go
+++ b/internal/agent/claude.go
@@ -62,14 +62,31 @@ var claudeAboutEnv = func() []string {
// own endpoint, which magpie's take the place of while it is wired in and
// gives back when it steps out, with what the user's env says about each
// tier's model. ANTHROPIC_MODEL, their main model, too: magpie takes it
-// out while wired in (writeTiers), and it was lost for good.
+// out while wired in (writeTiers), and it was lost for good. So is their
+// auto mode classifier's model (claudeAutoModeEnv), which isn't in
+// claudeEnv: one set while magpie is wired in is left to the user.
var claudeOwnEnv = append([]string{
"ANTHROPIC_MODEL",
"ANTHROPIC_DEFAULT_OPUS_MODEL", "ANTHROPIC_DEFAULT_SONNET_MODEL",
"ANTHROPIC_DEFAULT_HAIKU_MODEL", "ANTHROPIC_DEFAULT_FABLE_MODEL",
"ANTHROPIC_SMALL_FAST_MODEL", "CLAUDE_CODE_SUBAGENT_MODEL",
+ claudeAutoModeEnv,
}, claudeAboutEnv...)
+// claudeAutoModeEnv is the model Claude Code's client-side auto mode
+// classifier runs on, the one that judges each action before it runs
+// (2.1.302; Linka on Discord). Unset, Claude Code picks its own (the
+// sonnet tier's model, else Sonnet). It doesn't move server-side auto
+// mode, and a classifier model Anthropic configures for the account
+// comes before it.
+const claudeAutoModeEnv = "CLAUDE_CODE_AUTO_MODE_MODEL"
+
+// claudeNoClassifier are the Claude models Claude Code 2.1.303 won't run
+// its classifier on from claudeAutoModeEnv ("the API's safeguards refuse
+// the classifier's escalated check on it"): it warns and takes its own
+// pick instead, so the auto mode field doesn't offer them.
+var claudeNoClassifier = []string{"claude-sonnet-5-5", "claude-opus-5-5", "claude-opus-5"}
+
// claudeClouds are the clouds Claude Code's provider switches
// (agentenv.ClaudeProviders) send its requests to, named as Claude Code
// 2.1.300 names them. Each has an endpoint variable of its own
@@ -509,7 +526,7 @@ func tierEnv(tier string) string { return "ANTHROPIC_DEFAULT_" + strings.ToUpper
// claudeModelEnv are the keys of Claude Code's env that name a model, each
// written as Claude Code is given it (provider.ClaudeSpelled).
var claudeModelEnv = []string{
- "ANTHROPIC_MODEL", "ANTHROPIC_SMALL_FAST_MODEL", "CLAUDE_CODE_SUBAGENT_MODEL",
+ "ANTHROPIC_MODEL", "ANTHROPIC_SMALL_FAST_MODEL", "CLAUDE_CODE_SUBAGENT_MODEL", claudeAutoModeEnv,
"ANTHROPIC_DEFAULT_OPUS_MODEL", "ANTHROPIC_DEFAULT_SONNET_MODEL",
"ANTHROPIC_DEFAULT_HAIKU_MODEL", "ANTHROPIC_DEFAULT_FABLE_MODEL",
}
@@ -648,6 +665,14 @@ func claudeIn(at place) *Agent {
// model changes
ownKey := func(t string) string { return at.key("claude.tier_own." + t) }
own := func(t string) bool { return stashLoad()[ownKey(t)] != "" }
+ // the auto mode classifier's model as magpie last wrote it (the auto
+ // mode field); autoOurs: the env's is that one or another of magpie's
+ // models, which goes when magpie steps out. Any other is the user's.
+ autoKey := at.key("claude.auto_mode_model")
+ autoOurs := func() bool {
+ v := rawEnv(claudeAutoModeEnv)
+ return v != "" && (v == stashLoad()[autoKey] || isMagpie(env(claudeAutoModeEnv)))
+ }
// set once magpie has taken what the env said about each tier's model
// from before it routed Claude Code (claudeAbout): what is there after
// that the user wrote about magpie's model, and stays while the tier
@@ -1344,10 +1369,18 @@ func claudeIn(at place) *Agent {
return "", err
}
forget(aboutKey)
+ // the auto mode classifier's model goes only where it is magpie's
+ if autoOurs() {
+ if err := edit.DelJSON(path, "env."+claudeAutoModeEnv); err != nil {
+ return "", err
+ }
+ }
+ forget(autoKey)
was := unstash(at.key("claude.model"))
var back []edit.KV
for _, k := range claudeOwnEnv {
- if v := unstash(at.key("claude.env." + k)); v != "" {
+ // one the user set again since is theirs as it is
+ if v := unstash(at.key("claude.env." + k)); v != "" && rawEnv(k) == "" {
back = append(back, edit.KV{Path: "env." + k, Value: v})
}
}
@@ -1407,7 +1440,19 @@ func claudeIn(at place) *Agent {
// as the user wrote it, never respelled
kept[at.key("claude.env."+k)] = rawEnv(k)
}
+ // the auto mode classifier's model of their own
+ // endpoint waits in the stash, out of the env, as
+ // their tiers' do; one of magpie's stays as it is
+ theirs := rawEnv(claudeAutoModeEnv) != "" && !autoOurs()
+ if !theirs {
+ kept[at.key("claude.env."+claudeAutoModeEnv)] = ""
+ }
stash(kept)
+ if theirs {
+ if err := edit.DelJSON(path, "env."+claudeAutoModeEnv); err != nil {
+ return err
+ }
+ }
}
}
// tiers that followed the old model follow the new one; the
@@ -1870,6 +1915,49 @@ func claudeIn(at place) *Agent {
fields = append(fields, effortField(tier+"_effort", tier+" effort", tier, at, put))
}
fields = append(fields, effortField("subagent_effort", "subagent effort", "its subagents", subagentAt, setSubagent))
+ // auto mode: the model Claude Code's client-side auto mode classifier
+ // runs on (claudeAutoModeEnv). Unset, Claude Code's own pick; it
+ // follows no field, so it isn't Follows "model". The env is read as a
+ // session goes, so a pick needs no restart.
+ fields = append(fields, Field{
+ Key: "auto_mode", Label: "auto mode", Quiet: true,
+ Get: func() string {
+ if !routed() {
+ return ""
+ }
+ return env(claudeAutoModeEnv)
+ },
+ Set: func(v string) error {
+ v = strings.TrimSpace(v)
+ if !routed() {
+ if v == "" {
+ return nil
+ }
+ return fmt.Errorf("pick a model through magpie for Claude Code first; its auto mode can then have a model of its own")
+ }
+ if v != "" && !isMagpie(v) {
+ return fmt.Errorf("auto mode: %q is not a model magpie serves", v)
+ }
+ if contains(claudeNoClassifier, claudeName(v)) {
+ return fmt.Errorf("auto mode: Claude Code doesn't run its classifier on %s, and would take its own pick instead", v)
+ }
+ if v == "" {
+ forget(autoKey)
+ return edit.DelJSON(path, "env."+claudeAutoModeEnv)
+ }
+ w := spell(v)
+ stash(map[string]string{autoKey: w})
+ return edit.SetJSON(path, edit.KV{Path: "env." + claudeAutoModeEnv, Value: w})
+ },
+ Options: func(map[string]string) []Option {
+ if !routed() {
+ return nil
+ }
+ return slices.DeleteFunc(claudeViaMagpie(false), func(o Option) bool {
+ return contains(claudeNoClassifier, claudeName(o.Value))
+ })
+ },
+ })
// its sign-in while it runs through magpie: magpie's key, or its own
// claude.ai sign-in kept (loginKey), where the gateway takes any key
fields = append(fields, Field{
diff --git a/internal/agent/claude_automode_test.go b/internal/agent/claude_automode_test.go
new file mode 100644
index 000000000..07471e470
--- /dev/null
+++ b/internal/agent/claude_automode_test.go
@@ -0,0 +1,173 @@
+package agent
+
+import (
+ "os"
+ "path/filepath"
+ "testing"
+
+ "github.com/yetone/magpie/internal/edit"
+ "github.com/yetone/magpie/internal/provider"
+)
+
+// claudeAutoModeHome is a sandbox HOME with a provider serving a Claude
+// model the classifier runs on, one Claude Code refuses for it, and
+// another vendor's, and Claude Code's settings.json holding before.
+func claudeAutoModeHome(t *testing.T, before string) (*Agent, string, func(string) string) {
+ t.Helper()
+ home := t.TempDir()
+ t.Setenv("HOME", home)
+ t.Setenv("USERPROFILE", home)
+ t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
+ t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
+ if err := provider.Save(provider.Provider{ID: "relay", Name: "Relay", Chat: "https://relay.example/v1", Key: "k", Models: []string{"claude-haiku-4-5", "claude-opus-5-5", "deepseek-pro"}}); err != nil {
+ t.Fatal(err)
+ }
+ path := filepath.Join(home, ".claude", "settings.json")
+ if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(path, []byte(before), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ env := func(k string) string { v, _ := edit.GetJSON(path, "env."+k); return v }
+ return claude(home), path, env
+}
+
+// Claude Code's auto mode classifier can have a model of its own
+// (CLAUDE_CODE_AUTO_MODE_MODEL, 2.1.302; Linka on Discord): only while
+// magpie routes Claude Code, only one of magpie's models, never one Claude
+// Code refuses to run its classifier on, and gone again with magpie.
+func TestClaudeAutoModeModel(t *testing.T) {
+ a, _, env := claudeAutoModeHome(t, `{}`)
+ f := a.Field("auto_mode")
+ if f == nil {
+ t.Fatal("no auto_mode field")
+ }
+ if err := f.Set("relay/claude-haiku-4-5"); err == nil {
+ t.Fatal("an auto mode model before Claude Code is routed should fail")
+ }
+ if len(f.Options(nil)) != 0 || f.Get() != "" {
+ t.Fatalf("unrouted: %q %v", f.Get(), f.Options(nil))
+ }
+ if err := a.Field("model").Set("relay/deepseek-pro"); err != nil {
+ t.Fatal(err)
+ }
+ // unset, Claude Code's own pick: magpie writes nothing for it
+ if f.Get() != "" || env(claudeAutoModeEnv) != "" {
+ t.Fatalf("auto mode should be unset: %v", a.Values())
+ }
+ opts := f.Options(nil)
+ if !containsOption(opts, "relay/claude-haiku-4-5") || !containsOption(opts, "relay/deepseek-pro") {
+ t.Fatalf("options miss magpie's models: %v", opts)
+ }
+ if containsOption(opts, "relay/claude-opus-5-5") {
+ t.Fatalf("Opus 5.5 is offered, which Claude Code won't classify with: %v", opts)
+ }
+ if err := f.Set("relay/claude-opus-5-5"); err == nil || env(claudeAutoModeEnv) != "" {
+ t.Fatalf("Opus 5.5 taken: %v %q", err, env(claudeAutoModeEnv))
+ }
+ if err := f.Set("claude-haiku-4-5"); err == nil || env(claudeAutoModeEnv) != "" {
+ t.Fatalf("a model magpie doesn't serve taken: %v %q", err, env(claudeAutoModeEnv))
+ }
+ if err := f.Set("relay/claude-haiku-4-5"); err != nil {
+ t.Fatal(err)
+ }
+ // written as Claude Code is given a model, with dashes
+ if got := env(claudeAutoModeEnv); got != provider.ClaudeSpelled("relay/claude-haiku-4-5") {
+ t.Fatalf("env %q", got)
+ }
+ if f.Get() != "relay/claude-haiku-4-5" {
+ t.Fatalf("get %q", f.Get())
+ }
+ // a new main model leaves it be: it follows no field
+ if err := a.Field("model").Set("relay/claude-haiku-4-5"); err != nil {
+ t.Fatal(err)
+ }
+ if f.Get() != "relay/claude-haiku-4-5" {
+ t.Fatalf("a new model moved auto mode: %v", a.Values())
+ }
+ if err := f.Set(""); err != nil {
+ t.Fatal(err)
+ }
+ if env(claudeAutoModeEnv) != "" {
+ t.Fatal("clearing left the env behind")
+ }
+ if err := f.Set("relay/deepseek-pro"); err != nil {
+ t.Fatal(err)
+ }
+ // back to Claude Code as installed: magpie's pick goes with it
+ if err := a.Field("model").Set(""); err != nil {
+ t.Fatal(err)
+ }
+ if env(claudeAutoModeEnv) != "" {
+ t.Fatalf("reset left the auto mode model behind")
+ }
+ if err := f.Set(""); err != nil {
+ t.Fatalf("clearing while unrouted: %v", err)
+ }
+}
+
+// An auto mode model the user set before magpie routed Claude Code waits
+// out of the env while magpie is wired in (it would name a model magpie
+// doesn't serve) and comes back after; one they set while magpie is wired
+// in is theirs, and magpie never takes it out.
+func TestClaudeAutoModeUserValue(t *testing.T) {
+ t.Run("before", func(t *testing.T) {
+ a, path, env := claudeAutoModeHome(t, `{"env":{"CLAUDE_CODE_AUTO_MODE_MODEL":"claude-sonnet-4-6"}}`)
+ if err := a.Field("model").Set("relay/deepseek-pro"); err != nil {
+ t.Fatal(err)
+ }
+ if env(claudeAutoModeEnv) != "" || a.Field("auto_mode").Get() != "" {
+ t.Fatalf("the user's own auto mode model stayed in while routed: %q", env(claudeAutoModeEnv))
+ }
+ if err := a.Field("auto_mode").Set("relay/claude-haiku-4-5"); err != nil {
+ t.Fatal(err)
+ }
+ if err := a.Disconnect(); err != nil {
+ t.Fatal(err)
+ }
+ if got := env(claudeAutoModeEnv); got != "claude-sonnet-4-6" {
+ b, _ := os.ReadFile(path)
+ t.Fatalf("the user's own auto mode model not back: %q\n%s", got, b)
+ }
+ })
+ t.Run("while routed", func(t *testing.T) {
+ a, _, env := claudeAutoModeHome(t, `{}`)
+ if err := a.Field("model").Set("relay/deepseek-pro"); err != nil {
+ t.Fatal(err)
+ }
+ v := "claude-sonnet-4-6"
+ if err := edit.SetJSON(filepath.Join(os.Getenv("HOME"), ".claude", "settings.json"), edit.KV{Path: "env." + claudeAutoModeEnv, Value: v}); err != nil {
+ t.Fatal(err)
+ }
+ // another main model, then Claude Code as installed
+ if err := a.Field("model").Set("relay/claude-haiku-4-5"); err != nil {
+ t.Fatal(err)
+ }
+ if env(claudeAutoModeEnv) != v {
+ t.Fatalf("a new model took the user's auto mode model: %q", env(claudeAutoModeEnv))
+ }
+ if err := a.Field("model").Set(""); err != nil {
+ t.Fatal(err)
+ }
+ if env(claudeAutoModeEnv) != v {
+ t.Fatalf("stepping out took the user's auto mode model: %q", env(claudeAutoModeEnv))
+ }
+ })
+ t.Run("set again before stepping out", func(t *testing.T) {
+ a, _, env := claudeAutoModeHome(t, `{"env":{"CLAUDE_CODE_AUTO_MODE_MODEL":"claude-sonnet-4-6"}}`)
+ if err := a.Field("model").Set("relay/deepseek-pro"); err != nil {
+ t.Fatal(err)
+ }
+ v := "claude-haiku-4-5"
+ if err := edit.SetJSON(filepath.Join(os.Getenv("HOME"), ".claude", "settings.json"), edit.KV{Path: "env." + claudeAutoModeEnv, Value: v}); err != nil {
+ t.Fatal(err)
+ }
+ if err := a.Disconnect(); err != nil {
+ t.Fatal(err)
+ }
+ if env(claudeAutoModeEnv) != v {
+ t.Fatalf("the stash wrote over the user's newer auto mode model: %q", env(claudeAutoModeEnv))
+ }
+ })
+}
diff --git a/internal/agent/disconnect_test.go b/internal/agent/disconnect_test.go
index d9efb494c..907d95942 100644
--- a/internal/agent/disconnect_test.go
+++ b/internal/agent/disconnect_test.go
@@ -90,12 +90,16 @@ func TestCodexDisconnect(t *testing.T) {
// The tier and subagent models the user set for their relay come back with
// it (#1050), whether magpie steps out by Disconnect or by Claude Code's
// own model. So does the main model set for the relay in the env
-// (ANTHROPIC_MODEL), which magpie takes out while wired in.
+// (ANTHROPIC_MODEL), which magpie takes out while wired in, and the auto
+// mode classifier's model (CLAUDE_CODE_AUTO_MODE_MODEL).
func TestClaudeDisconnect(t *testing.T) {
for name, before := range map[string]string{
"own relay": `{"theme":"dark","model":"opus","env":{"ANTHROPIC_BASE_URL":"https://relay.example","ANTHROPIC_AUTH_TOKEN":"sk-relay","DISABLE_TELEMETRY":"1"}}`,
"own tiers": `{"model":"sonnet","env":{"ANTHROPIC_BASE_URL":"https://relay.example","ANTHROPIC_AUTH_TOKEN":"sk-relay","ANTHROPIC_DEFAULT_OPUS_MODEL":"relay-opus","ANTHROPIC_DEFAULT_SONNET_MODEL":"relay-sonnet","ANTHROPIC_DEFAULT_HAIKU_MODEL":"relay-haiku","ANTHROPIC_SMALL_FAST_MODEL":"relay-haiku","CLAUDE_CODE_SUBAGENT_MODEL":"relay-sonnet"}}`,
"nothing set": `{"theme":"dark"}`,
+ // the auto mode classifier's model the user set themselves, which
+ // magpie takes out while wired in and puts back
+ "own auto mode": `{"env":{"ANTHROPIC_BASE_URL":"https://relay.example","ANTHROPIC_AUTH_TOKEN":"sk-relay","CLAUDE_CODE_AUTO_MODE_MODEL":"relay-haiku"}}`,
// the main model set for the relay in the env (with no settings
// model, and beside one), which magpie takes out while wired in:
// it outranks a pick in /model
@@ -150,6 +154,9 @@ func TestClaudeDisconnect(t *testing.T) {
if err := a.Apply("subagent", "deepseek/flash"); err != nil {
t.Fatal(err)
}
+ if err := a.Apply("auto_mode", "deepseek/flash"); err != nil {
+ t.Fatal(err)
+ }
if !a.Wired() {
t.Fatal("not wired on a magpie model")
}
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index 3b3d4226c..b69bdea15 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -421,7 +421,7 @@ function renderAgents() {
// a small model with none to pick (Snow CLI's, on a profile of the
// user's own)
// nor Aside's account with one account only (#1499)
- const none = (f) => (f.key === "effort" || f.key === "ultracode" || f.label === "subagents" || f.label === SUB_EFFORT || f.label === SUB_MODEL || f.label === MEMORIES || f.label === "sign-in" || f.key === "small" || asideAccount(a, f)) && !f.options.length && !f.value;
+ const none = (f) => (f.key === "effort" || f.key === "ultracode" || f.label === "subagents" || f.label === SUB_EFFORT || f.label === SUB_MODEL || f.label === AUTO_MODE || f.label === MEMORIES || f.label === "sign-in" || f.key === "small" || asideAccount(a, f)) && !f.options.length && !f.value;
const shownFields = a.fields.filter((f) => !grouped(a, f) && !none(f));
const tiers = tierMenu(a);
if (tiers) shownFields.push(tiers);
@@ -618,9 +618,10 @@ function renderAgents() {
// picks among magpie's models itself
const sw = connectable(a) ? connectSwitch(a) : null;
if (kind) {
- // Claude Code's tiers and subagents have rows of their own when opened
+ // Claude Code's tiers, subagents and auto mode have rows of their own
+ // when opened
if (a.id === "claude") {
- for (const f of a.fields.filter((f) => TIERS.includes(f.label) || f.label === "subagents")) extras.querySelector(`[data-key="${CSS.escape(f.key)}"]`)?.remove();
+ for (const f of a.fields.filter((f) => TIERS.includes(f.label) || f.label === "subagents" || f.label === AUTO_MODE)) extras.querySelector(`[data-key="${CSS.escape(f.key)}"]`)?.remove();
extras.querySelector('[data-key="tiers"]')?.remove();
}
row.append(agentHandle(a, row, inFold), who);
@@ -1905,6 +1906,9 @@ function connectPanel(a, { fields, fieldBtn }) {
});
const sub = a.fields.find((f) => f.label === "subagents" && (f.options.length || f.value));
if (sub) rows.push(line(el("span", "ag-tier", t("Subagents")), fieldBtn(sub, "ag-pick")));
+ // the model its auto mode classifier runs on; unset, Claude Code's own
+ const auto = a.fields.find((f) => f.label === AUTO_MODE && (f.options.length || f.value));
+ if (auto) rows.push(line(el("span", "ag-tier", t("Auto mode")), fieldBtn(auto, "ag-pick"), el("span", "ag-hint", t("the model that checks each action in auto mode"))));
if (rows.length) kv(t("Tiers"), ...rows);
const main = a.fields.find((f) => f.key === "model");
const hasSub = main?.options.some((o) => (o.ref || "").startsWith("claude/"));
@@ -3675,9 +3679,14 @@ const SUB_MODEL = "subagent model";
// the model: the lead may name another, and GPT-6.1-Sol's spawned GPT-6-Astra
// (willz on Discord). So it says the lead picks, and points at the subagent
// model square, which holds every subagent to one.
+// Claude Code's auto mode square: the model its client-side auto mode
+// classifier runs on (CLAUDE_CODE_AUTO_MODE_MODEL); unset, Claude Code's own
+// pick, not the model's
+const AUTO_MODE = "auto mode";
+const AUTO_MODE_UNSET = "Claude Code's own pick";
const leadPicks = (a, f) => f.label === "subagents" && a.id.split("@wsl:")[0] === "codex";
const LEAD_PICKS = "Codex's lead may name another model for a subagent; set the subagent model to hold every subagent to one";
-const extra = (f) => f.key === "tiers" || FOLLOWS_MODEL.includes(f.label) || f.label === "sign-in" || f.key === "ultracode" || f.label === SUB_EFFORT || f.label === SUB_MODEL || f.label === MEMORIES;
+const extra = (f) => f.key === "tiers" || FOLLOWS_MODEL.includes(f.label) || f.label === "sign-in" || f.key === "ultracode" || f.label === SUB_EFFORT || f.label === SUB_MODEL || f.label === AUTO_MODE || f.label === MEMORIES;
const EXTRA_GLYPH = {
subagents: "M4.5 2.75v10.5M4.5 9.25c0-2.2 1.6-3.75 3.9-3.75h3.35M9.9 3.6l1.9 1.9-1.9 1.9",
// a feather for omp's smol role, an hourglass for its slow one
@@ -3690,6 +3699,8 @@ const EXTRA_GLYPH = {
[SUB_EFFORT]: "M3.25 2.75v10.5M3.25 9.25c0-2.2 1.6-3.75 3.9-3.75h.6M9.25 13.25v-2M11.5 13.25v-4M13.75 13.25v-6",
// the subagents' branch, ending on a pin: their model, set by magpie
[SUB_MODEL]: "M4 2.75v10.5M4 9.25c0-2.2 1.6-3.75 3.9-3.75h1.1M11.75 3.25a2.25 2.25 0 1 1 0 4.5 2.25 2.25 0 0 1 0-4.5zM11.75 7.75v4",
+ // a shield with a tick: the auto mode classifier, which lets an action through
+ [AUTO_MODE]: "M8 2.25 3.25 4v3.75c0 2.9 2 5 4.75 6 2.75-1 4.75-3.1 4.75-6V4zM5.75 8l1.6 1.6 2.9-3",
// a notebook: Codex's memories
[MEMORIES]: "M4.25 2.75h7.5v10.5h-7.5zM6.25 2.75v10.5M8.25 5.75h1.75M8.25 8h1.75",
};
@@ -3703,7 +3714,7 @@ function extraField(a, f) {
b.append(svg(EXTRA_GLYPH[f.label] || EXTRA_GLYPH.tiers, 13, 1.5));
const opt = optionFor(f, f.value);
b.title = f.label === SUB_EFFORT ? subEffortTitle(a, f, opt) : f.menu ? menuTitle(f)
- : t("{label}: {value}", { label: f.label === MEMORIES ? t("Codex memories model") : t(f.label), value: t(opt?.label || f.value || (f.label === MEMORIES ? MEMORIES_DEFAULT : f.label === SUB_MODEL ? "the model the lead asks for" : leadPicks(a, f) ? "the lead's pick, else same as model" : "same as model")) }) + (opt?.note && !FOLLOWS_MODEL.includes(f.label) ? "\n" + t(opt.note) : "") + (leadPicks(a, f) ? "\n" + t(LEAD_PICKS) : "");
+ : t("{label}: {value}", { label: f.label === MEMORIES ? t("Codex memories model") : t(f.label), value: t(opt?.label || f.value || (f.label === MEMORIES ? MEMORIES_DEFAULT : f.label === SUB_MODEL ? "the model the lead asks for" : f.label === AUTO_MODE ? AUTO_MODE_UNSET : leadPicks(a, f) ? "the lead's pick, else same as model" : "same as model")) }) + (opt?.note && !FOLLOWS_MODEL.includes(f.label) ? "\n" + t(opt.note) : "") + (leadPicks(a, f) ? "\n" + t(LEAD_PICKS) : "");
b.setAttribute("aria-label", b.title);
b.dataset.key = f.key;
b.onclick = (ev) => openPicker(a, f, b, ev);
@@ -4557,6 +4568,7 @@ function openPicker(agent, field, anchor, ev, only) {
: PICKS_ITSELF.includes(agent.id) && field.key === "model" ? "clears the default model; {agent} picks one on its own"
: field.label === MEMORIES ? MEMORIES_DEFAULT
: field.label === SUB_MODEL ? "each subagent on the model {agent}'s lead asks for"
+ : field.label === AUTO_MODE ? "the model {agent} picks for its auto mode classifier"
: ompAgent(agent) && OMP_OWN_PICK.includes(field.label) ? OMP_UNSET[field.label]
: asideAccount(agent, field) ? "the account active in {agent}"
: "what {agent} ships with";
@@ -4568,7 +4580,7 @@ function openPicker(agent, field, anchor, ev, only) {
const at = options.findIndex((o) => !o.reset);
options.splice(at < 0 ? options.length : at, 0, { value: "\0disconnect", label: t("Disconnect from magpie"), note: t("put back what {agent} had before magpie", { agent: agent.name }), svg: UNPLUG, reset: true, run: () => askDisconnect(agent) });
}
- const modelPicker = ["model", "small", "large", MEMORIES, SUB_MODEL, "executor", "planner", ...ROLE_MODELS].includes(field.label) && !only;
+ const modelPicker = ["model", "small", "large", MEMORIES, SUB_MODEL, AUTO_MODE, "executor", "planner", ...ROLE_MODELS].includes(field.label) && !only;
pick = { agent, field, options, groups, anchor, cursor: 0, free: !only && !field.menu, modelPicker, effortPicker, groupFilter: "all" };
anchor.classList.add("open");
const pop = $("#pop");
diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js
index aae6e937a..4c89ea749 100644
--- a/internal/gui/assets/i18n.js
+++ b/internal/gui/assets/i18n.js
@@ -3201,6 +3201,11 @@ const I18N = {
"Codex's lead may name another model for a subagent; set the subagent model to hold every subagent to one": "Codex 的主代理可以给子代理指定别的模型;要让每个子代理都用同一个模型,请设置子代理模型",
"the model the lead asks for": "主代理请求的模型",
"each subagent on the model {agent}'s lead asks for": "每个子代理都用 {agent} 主代理请求的模型",
+ "auto mode": "自动模式",
+ "Auto mode": "自动模式",
+ "Claude Code's own pick": "由 Claude Code 自己挑选",
+ "the model that checks each action in auto mode": "自动模式下检查每个操作的模型",
+ "the model {agent} picks for its auto mode classifier": "{agent} 为自动模式分类器挑选的模型",
"no ChatGPT account is on in magpie": "magpie 中没有启用的 ChatGPT 账号",
"no ChatGPT account on in magpie serves it": "magpie 中启用的 ChatGPT 账号都不提供该模型",
"the gateway key may not use it": "网关密钥不允许使用该模型",
@@ -6893,6 +6898,11 @@ const I18N = {
"Codex's lead may name another model for a subagent; set the subagent model to hold every subagent to one": "Codex 的主代理可以給子代理指定別的模型;要讓每個子代理都用同一個模型,請設定子代理模型",
"the model the lead asks for": "主代理請求的模型",
"each subagent on the model {agent}'s lead asks for": "每個子代理都用 {agent} 主代理請求的模型",
+ "auto mode": "自動模式",
+ "Auto mode": "自動模式",
+ "Claude Code's own pick": "由 Claude Code 自己挑選",
+ "the model that checks each action in auto mode": "自動模式下檢查每個操作的模型",
+ "the model {agent} picks for its auto mode classifier": "{agent} 為自動模式分類器挑選的模型",
"no ChatGPT account is on in magpie": "magpie 中沒有啟用的 ChatGPT 帳號",
"no ChatGPT account on in magpie serves it": "magpie 中啟用的 ChatGPT 帳號都不提供該模型",
"the gateway key may not use it": "閘道金鑰不允許使用該模型",
@@ -10603,6 +10613,11 @@ const I18N = {
"Codex's lead may name another model for a subagent; set the subagent model to hold every subagent to one": "Codex のリードはサブエージェントに別のモデルを指定できます。すべてのサブエージェントを同じモデルにするには、サブエージェントのモデルを設定してください",
"the model the lead asks for": "リードがリクエストしたモデル",
"each subagent on the model {agent}'s lead asks for": "各サブエージェントは {agent} のリードがリクエストしたモデルを使います",
+ "auto mode": "自動モード",
+ "Auto mode": "自動モード",
+ "Claude Code's own pick": "Claude Code が自分で選ぶ",
+ "the model that checks each action in auto mode": "自動モードで各操作をチェックするモデル",
+ "the model {agent} picks for its auto mode classifier": "{agent} が自動モードの分類器に選ぶモデル",
"no ChatGPT account is on in magpie": "magpie で有効な ChatGPT アカウントがありません",
"no ChatGPT account on in magpie serves it": "magpie で有効な ChatGPT アカウントはどれもこのモデルを提供していません",
"the gateway key may not use it": "ゲートウェイキーではこのモデルを使えません",
@@ -14321,6 +14336,11 @@ const I18N = {
"Codex's lead may name another model for a subagent; set the subagent model to hold every subagent to one": "Der Haupt-Agent von Codex kann einem Subagenten ein anderes Modell geben; setze das Modell der Subagenten, um alle auf eines festzulegen",
"the model the lead asks for": "das Modell, das der Haupt-Agent anfordert",
"each subagent on the model {agent}'s lead asks for": "jeder Subagent auf dem Modell, das der Haupt-Agent von {agent} anfordert",
+ "auto mode": "Auto-Modus",
+ "Auto mode": "Auto-Modus",
+ "Claude Code's own pick": "wählt Claude Code selbst",
+ "the model that checks each action in auto mode": "das Modell, das im Auto-Modus jede Aktion prüft",
+ "the model {agent} picks for its auto mode classifier": "das Modell, das {agent} für den Klassifikator des Auto-Modus wählt",
"no ChatGPT account is on in magpie": "in magpie ist kein ChatGPT-Konto eingeschaltet",
"no ChatGPT account on in magpie serves it": "kein eingeschaltetes ChatGPT-Konto in magpie bietet es an",
"the gateway key may not use it": "der Gateway-Schlüssel darf es nicht verwenden",
diff --git a/internal/gui/tests/claude-auto-mode.test.cjs b/internal/gui/tests/claude-auto-mode.test.cjs
new file mode 100644
index 000000000..43795d659
--- /dev/null
+++ b/internal/gui/tests/claude-auto-mode.test.cjs
@@ -0,0 +1,126 @@
+// Run with Node's test runner and Playwright on the module path; see README.md.
+// Claude Code's auto mode classifier can run on a model of its own
+// (CLAUDE_CODE_AUTO_MODE_MODEL, Claude Code 2.1.302; Linka on Discord).
+// Connected, the opened row's Tiers has an Auto mode line after Subagents:
+// unset it says default, a click opens the app's model picker with Default
+// first, noted as Claude Code's own pick, and a model picked is posted;
+// Default posts it empty. It is no square of the row's own. Before Claude
+// Code goes through magpie it has no options, so neither line nor square
+// shows. No click scrolls the page. In English and Chinese, at a normal
+// and a narrow width. No backend: the API is faked here.
+const assert = require("node:assert/strict");
+const fs = require("node:fs/promises");
+const path = require("node:path");
+const { test } = require("node:test");
+const { chromium, webkit } = require("playwright");
+
+const assets = path.resolve(__dirname, "../assets");
+const models = [{ value: "magpie/v/glm", label: "GLM", ref: "v/glm" }, { value: "magpie/v/flash", label: "Flash", ref: "v/flash" }];
+const tiers = ["opus", "sonnet", "haiku", "fable"];
+const claude = (id, routed) => ({
+ id, name: "Claude Code", path: "/test/settings.json", icon: "claudecode-color", wired: routed,
+ fields: [
+ { key: "model", label: "model", value: routed ? "magpie/v/glm" : "opus", options: routed ? models : [{ value: "opus" }] },
+ ...tiers.map((tier) => ({ key: tier, label: tier, value: "", options: models })),
+ { key: "subagent", label: "subagents", value: "", options: routed ? models : [] },
+ { key: "auto_mode", label: "auto mode", value: "", options: routed ? models : [] },
+ ],
+});
+const fresh = () => ({ agents: [claude("claude", true), claude("cc-own", false)], profiles: [] });
+
+function server(lang, sets) {
+ let cur = fresh();
+ return async (route) => {
+ const req = route.request(), url = new URL(req.url());
+ if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
+ if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
+ if (url.pathname === "/api/state") return route.fulfill({ json: { ...cur, settings: { lang, theme: "light" } } });
+ if (url.pathname === "/api/set") {
+ const body = req.postDataJSON();
+ sets.push(body);
+ cur = JSON.parse(JSON.stringify(cur));
+ cur.agents.find((a) => a.id === body.agent).fields.find((f) => f.key === body.field).value = body.value;
+ return route.fulfill({ json: { ...cur, settings: { lang, theme: "light" } } });
+ }
+ if (url.pathname === "/api/usage/quotas") return route.fulfill({ json: [] });
+ if (url.pathname === "/api/groups") return route.fulfill({ json: { groups: [] } });
+ if (url.pathname === "/api/agents/cli") return route.fulfill({ json: { agents: {}, pending: false } });
+ if (url.pathname === "/api/providers") return route.fulfill({ json: { providers: [], gateway: { running: true } } });
+ if (url.pathname === "/api/plugins") return route.fulfill({ json: { plugins: [] } });
+ if (url.pathname.startsWith("/api/")) return route.fulfill({ json: {} });
+ const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
+ const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
+ await route.fulfill({ body: await fs.readFile(file), contentType });
+ };
+}
+
+// the words as i18n.js has them
+const W = {
+ en: { line: "Auto mode", hint: "the model that checks each action in auto mode", def: "Default", note: "the model Claude Code picks for its auto mode classifier", unset: "auto mode: agent default", set: "auto mode: magpie/v/flash" },
+ zh: { line: "自动模式", hint: "自动模式下检查每个操作的模型", def: "默认", note: "Claude Code 为自动模式分类器挑选的模型", unset: "自动模式:Agent 默认值", set: "自动模式:magpie/v/flash" },
+};
+
+const cc = '.row.agent[data-id="claude"]';
+
+for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
+ for (const lang of ["en", "zh"]) {
+ for (const width of [1100, 560]) {
+ test(`${engine} ${lang} ${width}px: Claude Code's auto mode model is picked in its Tiers`, async (t) => {
+ const w = W[lang];
+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
+ const page = await browser.newPage({ viewport: { width, height: 800 } });
+ page.setDefaultTimeout(5000);
+ const errors = [], sets = [];
+ page.on("pageerror", (e) => errors.push(e.message));
+ await page.route("**/*", server(lang, sets));
+ t.after(async () => {
+ if (process.env.ARTIFACT_DIR) {
+ await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
+ await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}-claude-auto-mode.png`) });
+ }
+ await browser.close();
+ });
+ await page.goto("http://magpie.test/");
+ await page.locator(cc).waitFor();
+ // not through magpie: nothing to pick, so nothing shows
+ assert.equal(await page.locator('.row.agent[data-id="cc-own"] [data-key="auto_mode"]').count(), 0);
+ await page.locator(`${cc} .ag-link`).click();
+ await page.locator(`${cc} .ag-exp`).waitFor();
+
+ // a line of the opened row's Tiers, after Subagents; no square
+ assert.equal(await page.locator(`${cc} .field.extra[data-key="auto_mode"]`).count(), 0);
+ const pick = page.locator(`${cc} .ag-exp .field.ag-pick[data-key="auto_mode"]`);
+ assert.equal(await pick.count(), 1);
+ const keys = await page.locator(`${cc} .ag-exp .field.ag-pick`).evaluateAll((es) => es.map((e) => e.dataset.key));
+ assert.deepEqual(keys.slice(-2), ["subagent", "auto_mode"]);
+ const line = pick.locator("xpath=..");
+ assert.equal(await line.locator(".ag-tier").textContent(), w.line);
+ assert.equal(await line.locator(".ag-hint").textContent(), w.hint);
+ assert.equal(await pick.getAttribute("title"), w.unset);
+ assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), "the Agents view overflows");
+
+ // the app's model picker, Default first, noted as Claude Code's pick
+ const y = await page.evaluate(() => scrollY);
+ await pick.click();
+ await page.locator("#pop:not([hidden]) #list li").first().waitFor();
+ assert.equal(await page.evaluate(() => scrollY), y, "the click scrolled the page");
+ assert.equal(await page.locator("#pop").evaluate((e) => e.classList.contains("model-picker")), true);
+ const first = await page.locator("#pop #list li").first().innerText();
+ assert.ok(first.includes(w.def) && first.includes(w.note), first);
+ await page.locator("#pop #list li", { hasText: "Flash" }).first().click();
+ await page.waitForFunction(() => document.querySelector('.row.agent[data-id="claude"] .ag-exp .field[data-key="auto_mode"] .v:not(.empty)'));
+ assert.deepEqual(sets, [{ agent: "claude", field: "auto_mode", value: "magpie/v/flash" }]);
+ assert.equal(await page.locator(`${cc} .ag-exp .field.ag-pick[data-key="auto_mode"]`).getAttribute("title"), w.set);
+
+ // Default takes it out again
+ await page.locator(`${cc} .ag-exp .field.ag-pick[data-key="auto_mode"]`).click();
+ await page.locator("#pop:not([hidden]) #list li").first().waitFor();
+ await page.locator("#pop #list li").first().click();
+ await page.waitForFunction(() => document.querySelector('.row.agent[data-id="claude"] .ag-exp .field[data-key="auto_mode"] .v.empty'));
+ assert.deepEqual(sets.at(-1), { agent: "claude", field: "auto_mode", value: "" });
+ assert.equal(await page.evaluate(() => scrollY), y, "a pick scrolled the page");
+ assert.deepEqual(errors, []);
+ });
+ }
+ }
+}