Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
agent: a 1M model Desktop lists by its [1m] id is told by its 1M, not a 272K GPT's beside it (dumplings on Discord)
yetone5206177704c9
diff --git a/docs/subsystems/agent-wiring.md b/docs/subsystems/agent-wiring.mdindex 9b263d41b..b73ad1767 100644--- a/docs/subsystems/agent-wiring.md+++ b/docs/subsystems/agent-wiring.md@@ -80,7 +80,7 @@ something else shows up as drift.- 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.-- Claude Code takes one window (`CLAUDE_CODE_MAX_CONTEXT_TOKENS`, `claudeContextEnv` in [`claude.go`](../../internal/agent/claude.go)) for every model it doesn't know. Claude Code alone on magpie is told its main model's (`claudeWindow`). While Claude Desktop is on magpie too, its Code tab runs Claude Code on the same `~/.claude/settings.json` with every model Desktop lists, so magpie tells it the largest window of those and of Claude Code's own models, and holds each model below it to its own with `modelSettings.<id>.autoCompactWindow` (`claudePlan` in [`claude_budget.go`](../../internal/agent/claude_budget.go), #2025: the least held a 1M model to 131K). Claude Code 2.1.296 matches that key by the id it was handed, lowercased and without `[1m]`; it comes before the top-level `autoCompactWindow`, which serves a model without one. `CLAUDE_CODE_AUTO_COMPACT_WINDOW` would take precedence over both, so in this mode magpie's working window goes in the top-level `autoCompactWindow` instead, and an entry is written only where a model's window or its own threshold differs from what it would run at without one. magpie's entries and top-level value are stashed (`claude.model_budgets`, `claude.compact_default`) and go when Desktop leaves magpie; the user's own entries, top-level value and variables stay, a user's entry past its model's window (or `auto`) holds the largest to that window, and with a `CLAUDE_CODE_AUTO_COMPACT_WINDOW` of the user's the least window is told as before.+- Claude Code takes one window (`CLAUDE_CODE_MAX_CONTEXT_TOKENS`, `claudeContextEnv` in [`claude.go`](../../internal/agent/claude.go)) for every model it doesn't know. Claude Code alone on magpie is told its main model's (`claudeWindow`). While Claude Desktop is on magpie too, its Code tab runs Claude Code on the same `~/.claude/settings.json` with every model Desktop lists, so magpie tells it the largest window of those and of Claude Code's own models, and holds each model below it to its own with `modelSettings.<id>.autoCompactWindow` (`claudePlan` in [`claude_budget.go`](../../internal/agent/claude_budget.go), #2025: the least held a 1M model to 131K). A model handed by a `[1m]` id (Desktop's under `DesktopLongest`, or Claude Code's own) counts by its 1M too, so it still runs at 1M when Claude Code stops taking the id for 1M (the 1M beta turned away once, `CLAUDE_CODE_DISABLE_1M_CONTEXT`); left out, a 1M model beside a 272K GPT was told 272K (dumplings on Discord). Claude Code 2.1.296 matches that key by the id it was handed, lowercased and without `[1m]`; it comes before the top-level `autoCompactWindow`, which serves a model without one. `CLAUDE_CODE_AUTO_COMPACT_WINDOW` would take precedence over both, so in this mode magpie's working window goes in the top-level `autoCompactWindow` instead, and an entry is written only where a model's window or its own threshold differs from what it would run at without one. magpie's entries and top-level value are stashed (`claude.model_budgets`, `claude.compact_default`) and go when Desktop leaves magpie; the user's own entries, top-level value and variables stay, a user's entry past its model's window (or `auto`) holds the largest to that window, and with a `CLAUDE_CODE_AUTO_COMPACT_WINDOW` of the user's the least window is told as before.- 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).diff --git a/internal/agent/claude.go b/internal/agent/claude.goindex 61f76c043..51f3d33ea 100644--- a/internal/agent/claude.go+++ b/internal/agent/claude.go@@ -1142,13 +1142,13 @@ func claudeIn(at place) *Agent {for _, t := range claudeTiers {refs = append(refs, tiers[t])}- for i, v := range refs {+ for _, v := range refs {m, _ := tierAt(v)bare := strings.TrimSuffix(m, "[1m]")if v == "" || claudeModel(bare) || provider.ClaudeGroup(bare) {continue}- models = append(models, claudeBudget{id: spell(v), window: window[bare], long: strings.HasSuffix(v, "[1m]"), main: i == 0, compact: work(bare)})+ models = append(models, claudeBudget{id: spell(v), window: window[bare], long: strings.HasSuffix(v, "[1m]"), compact: work(bare)})}// the one for every model else, as the variable gave it: none// on a Claude main model, which Anthropic runs to its owndiff --git a/internal/agent/claude_budget.go b/internal/agent/claude_budget.goindex 07f78823e..c6adc5e59 100644--- a/internal/agent/claude_budget.go+++ b/internal/agent/claude_budget.go@@ -26,10 +26,6 @@ type claudeBudget struct {id string // as Claude Code is handed it: its key under modelSettingswindow int // its window, 0 when unknownlong bool // Claude Code takes it for 1M by its id ("[1m]")- // Claude Code's main model: a long one's window is the one told too,- // so the main runs to its own should Claude Code stop taking it for- // 1M, and nothing written reads as holding it to a smaller tier's- main bool// the auto-compact window magpie gives it: 0 for the top-level one// (base), below 0 for none, its whole windowcompact int@@ -66,7 +62,13 @@ func claudePlan(models []claudeBudget, base int, theirs map[string]string) (topswitch {case !m.long && m.window > top:top = m.window- case m.long && m.main:+ case m.long:+ // a long one's window is the one told too, so it runs to its+ // own should Claude Code stop taking it for 1M (the 1M beta+ // turned away once, CLAUDE_CODE_DISABLE_1M_CONTEXT), and+ // nothing written reads as holding it to a smaller model's: a+ // 1M model Desktop lists by its 1M id alone beside a 272K GPT+ // ran at 272K (dumplings on Discord, Full window on)top = max(top, cmp.Or(m.window, claudeLong))}}diff --git a/internal/agent/claude_budget_test.go b/internal/agent/claude_budget_test.goindex c615f2e64..0444a9db2 100644--- a/internal/agent/claude_budget_test.go+++ b/internal/agent/claude_budget_test.go@@ -19,14 +19,14 @@ func TestClaudePlan(t *testing.T) {{id: "magpie/v/gpt-6.1-sol", window: 400000, compact: -1},}top, entries := claudePlan(models, 272000, nil)- want := map[string]int{"mythos-magpie-2": 131000, "anthropic/magpie-4": 500000, "magpie/v/gpt-6.1-sol": 400000}- if top != 500000 || !reflect.DeepEqual(entries, want) {+ want := map[string]int{"mythos-magpie-2": 131000, "anthropic/magpie-4": 1000000, "magpie/v/gpt-6.1-sol": 400000}+ if top != 1000000 || !reflect.DeepEqual(entries, want) {t.Fatalf("magpie's default: %d %v", top, entries)}- // no top-level window: every model runs at the largest, a [1m] one at 1M+ // no top-level window: every model runs at the largest, the [1m] one's 1Mtop, entries = claudePlan(models, 0, nil)want = map[string]int{"mythos-magpie-1": 272000, "mythos-magpie-2": 131000, "anthropic/magpie-3": 272000, "magpie/v/gpt-6.1-sol": 400000}- if top != 500000 || !reflect.DeepEqual(entries, want) {+ if top != 1000000 || !reflect.DeepEqual(entries, want) {t.Fatalf("no default: %d %v", top, entries)}// the user's own entries are theirs; "auto" on the 131K one holds the@@ -40,7 +40,7 @@ func TestClaudePlan(t *testing.T) {// the largesttop, entries = claudePlan(models, 0, map[string]string{"mythos-magpie-2": "50000"})want = map[string]int{"mythos-magpie-1": 272000, "anthropic/magpie-3": 272000, "magpie/v/gpt-6.1-sol": 400000}- if top != 500000 || !reflect.DeepEqual(entries, want) {+ if top != 1000000 || !reflect.DeepEqual(entries, want) {t.Fatalf("the user's 50000: %d %v", top, entries)}// the user's top-level window is the one a model without a threshold of@@ -50,10 +50,17 @@ func TestClaudePlan(t *testing.T) {if top != 1000000 || !reflect.DeepEqual(entries, map[string]int{"b": 128000}) {t.Fatalf("the user's top-level: %d %v", top, entries)}- // only 1M ones, or no window known: nothing to tell- if top, entries = claudePlan([]claudeBudget{{id: "x[1m]", window: 1000000, long: true}, {id: "y"}}, 0, nil); top != 0 || entries != nil {+ // no window known: nothing to tell+ if top, entries = claudePlan([]claudeBudget{{id: "y"}}, 0, nil); top != 0 || entries != nil {t.Fatalf("nothing known: %d %v", top, entries)}+ // a [1m] one is told by its own 1M too, not the next one's (dumplings+ // on Discord), so it runs to it should Claude Code stop taking it for+ // 1M; the smaller one is held to its own+ top, entries = claudePlan([]claudeBudget{{id: "x[1m]", window: 1000000, long: true, compact: -1}, {id: "g", window: 272000, compact: -1}}, 0, nil)+ if top != 1000000 || !reflect.DeepEqual(entries, map[string]int{"g": 272000}) {+ t.Fatalf("[1m] beside 272K: %d %v", top, entries)+ }// an id magpie's editor can't put in a key path gets no entryif _, entries = claudePlan([]claudeBudget{{id: "a", window: 400000}, {id: "b*", window: 100000}}, 0, nil); len(entries) != 0 {t.Fatalf("b*: %v", entries)diff --git a/internal/agent/claude_desktop_window_test.go b/internal/agent/claude_desktop_window_test.goindex b42a0ebc1..66193a11f 100644--- a/internal/agent/claude_desktop_window_test.go+++ b/internal/agent/claude_desktop_window_test.go@@ -52,9 +52,8 @@ func desktopWindowSandbox(t *testing.T) (home, path string) {// least held a 1M model to 256K (#2025, 6.1sol), so while Desktop is on// magpie it is the largest window of Desktop's and Claude Code's models,// and each model below it runs at its own through-// modelSettings.<id>.autoCompactWindow. A model Claude Code knows, and one-// listed by its 1M id, are left out of the largest; the user's own value-// is theirs.+// modelSettings.<id>.autoCompactWindow. A model Claude Code knows is left+// out of the largest; the user's own value is theirs.func TestClaudeDesktopContextWindow(t *testing.T) {home, path := desktopWindowSandbox(t)a := claude(home)@@ -326,9 +325,12 @@ func TestClaudeDesktopExploreKeepsUserValue(t *testing.T) {}// TestClaudeDesktopContextWindow1M: a model Desktop lists by its 1M id-// (settings.DesktopLongest) runs at 1M whatever the value says, so it adds-// nothing to it; listed plain too, it runs at the value, its own 1M when it-// is the only one.+// (settings.DesktopLongest) is told by its 1M too, as one listed plain is,+// so it runs to its own should Claude Code stop taking the id for 1M (the+// 1M beta turned away once, CLAUDE_CODE_DISABLE_1M_CONTEXT), and a smaller+// model beside it is held to its own. dumplings (Discord, v0.1.1295, Full+// window): Desktop's 1M model beside a 272K GPT showed 272K, the value+// magpie told, as the 1M id didn't count toward it.func TestClaudeDesktopContextWindow1M(t *testing.T) {home, path := desktopWindowSandbox(t)// Desktop is shown glm alone (the Agents page's model list)@@ -348,12 +350,30 @@ func TestClaudeDesktopContextWindow1M(t *testing.T) {}s := settings.Load()s.DesktopLongest = true+ s.FullContext = trueif err := settings.Save(s); err != nil {t.Fatal(err)}- if err := a.Sync(); err != nil || window() != "" {+ if err := a.Sync(); err != nil || window() != "1000000" {t.Fatalf("glm listed by its 1M id alone: %q %v", window(), err)}+ // GPT 272K shown beside it: glm's 1M is still the one told, GPT held+ // to its own+ if err := provider.SetHiddenModels("claude-desktop", []string{"v/grok", "v/plain", "v/claude-opus-4-6"}); err != nil {+ t.Fatal(err)+ }+ if err := a.Sync(); err != nil {+ t.Fatal(err)+ }+ ids := map[string]string{}+ for _, e := range provider.Catalog() {+ ids[e.ID] = gateway.DesktopID(e)+ }+ gpt, _ := edit.GetJSON(path, budgetPath(ids["v/gpt"]))+ glm, _ := edit.GetJSON(path, budgetPath(ids["v/glm"]))+ if window() != "1000000" || gpt != "272000" || glm != "" {+ t.Fatalf("glm by its 1M id beside GPT: window %q, gpt %q, glm %q: %s", window(), gpt, glm, readFile(path))+ }}// TestClaudeDesktopAloneContextWindow (#1458, marsxxl on v0.1.1154): with