Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
agent: Claude Desktop on magpie gets the MCP servers the user added signed in (aa86222 on Discord)
yetone56900e4845df
diff --git a/docs/subsystems/agent-wiring.md b/docs/subsystems/agent-wiring.mdindex 5c3d4c6b2..89ecafd14 100644--- a/docs/subsystems/agent-wiring.md+++ b/docs/subsystems/agent-wiring.md@@ -95,6 +95,7 @@ something else shows up as drift.- Claude Desktop's "subagent effort" (`desktopSubagentEffortField`, `settings.DesktopSubagentEffort`) is also Quiet and Live. Default keeps the effort the request asks for, including disabled thinking; it never selects a new default. A picked level works independently of the subagent model: no model pick, the same model and an unavailable model pick all still take the effort. While wired, the field offers the selected model's levels, or the standard levels when its model is inherited or unavailable; a model marked reasonless offers none. The stored pick survives model changes. A disconnected preference can be saved or cleared without connecting Desktop or showing restart advice, so profile restoration and Disconnect can restore a value saved before connecting; reconnect returns to the last live pick. `subEffortTitle` gives Desktop the Claude Code default explanation; Codex's default meaning is unchanged. The gateway fits each attempt to its actual model and preserves fixed group-member efforts (see [gateway routing](gateway-routing.md)).- Claude Desktop's 3p mode runs in a userData of its own (`Claude-3p`), whose `config.json` (Desktop's own settings, not `claude_desktop_config.json`) starts with no `locale`, so Desktop on magpie came up in the system's language rather than the one picked signed in with Anthropic (memory and Osal on Discord). Turning Desktop onto magpie copies that one key, `locale`, from the signed-in userData's `config.json` (`Claude`, `%APPDATA%\Claude` on Windows, the first set's before the others) into `Claude-3p/config.json` when that file is missing or a JSON object without one (`desktopCarryLocale` in [`claudedesktop.go`](../../internal/agent/claudedesktop.go)); only a name Desktop takes for a catalog is carried. A `locale` already in `Claude-3p`, Desktop's or set by hand, is never written over, and no other key of that file is ever written. Off removes the file only when magpie made it and it still holds nothing but the language carried (`TestClaudeDesktopCarriesTheLanguage`, `TestClaudeDesktopKeepsThe3pLanguage`, `TestClaudeDesktopUserEditsThenReapply`). Desktop shows the language only where its 3p window has that catalog: the window is Desktop's bundled UI (`Resources/ion-dist`, 11 catalogs and no Chinese in 2.7032, 2.9939 and 3.6556.2, while 3.6556.2's main process has `zh-Hans` and `zh-Hant` for the signed-in window). On every start that window asks the main process for its own pick (`requestLocaleChange`: its localStorage, else `navigator.languages` mapped onto its 11, else `en-US`), and the main process writes it into `Claude-3p/config.json`. So a Chinese `locale` there, carried or set by hand, is `en-US` again after each start, written by Desktop and not by magpie (Dx25 on Discord, Windows); nothing magpie writes can keep it.- Claude Desktop's sessions (Code and Cowork, `claude-code-sessions` and `local-agent-mode-sessions`) are kept in the userData Desktop runs in, keyed by account and organization (the claude.ai login signed in; in 3p the install id in `ant-did` and the profile's organization, both stable). So on magpie, in `Claude-3p`, the sessions made signed in with Anthropic are out of sight but untouched in `Claude`, and they show again when Desktop is switched back (lambdua on X: "切换账号,对话都不见"); claude.ai chats live on Anthropic's servers and 3p never shows them. magpie never writes or removes a session. Desktop imports them itself (Settings → Import: the signed-in userData, `~/.claude/projects`, other `Claude*` folders), copying under new ids and leaving the originals, but in 3p only when the profile's policy `claudeAiImport.enabled` is true (off by default, 3p only, from 1.28929.0). magpie's profile gets `"claudeAiImport":{"enabled":true,"bannerBehavior":"detect"}` once per folder set (`desktopSeedImport`, marked in the stash as `claude-desktop.import`): on the switch on and, for a Desktop already on magpie, from `Sync` at magpie's start. A `claudeAiImport` already there is kept, and one the user removes is not written again (`TestClaudeDesktopOffersItsSessionImport`).+- Claude Desktop's 3p mode reads its MCP servers (Settings → Developer, its connector list) from `Claude-3p/claude_desktop_config.json`, a file of its own, so on magpie the servers the user added signed in with Anthropic, in `Claude/claude_desktop_config.json`, were gone from the list (aa86222 on Discord: connectors didn't sync). Turning Desktop onto magpie copies each of those `mcpServers` entries that `Claude-3p` has none of the same name for (`desktopCarryMCP` in [`claudedesktop.go`](../../internal/agent/claudedesktop.go)); one of that name already there, the user's or the Library's (which writes both files), stays. `Sync` does it once for a Desktop already on magpie (`claude-desktop.mcp-seen`), so a server the user takes out in 3p isn't brought back. What was copied is stashed (`claude-desktop.mcp`), and off takes back each one still as copied; one the user changed since stays (`TestClaudeDesktopCarriesTheMCPServers`, `TestClaudeDesktopMCPKeepsThe3pServers`, `TestClaudeDesktopSyncCarriesTheMCPServersOnce`). Claude's file is never written. A claude.ai account's connectors can't come along: Desktop calls them through claude.ai with that account (`/api/organizations/<org>/mcp/servers/<id>/tools/call`, refused with `no_active_org` without one, Desktop 2.7032), and 3p mode has no account; Anthropic's docs say "Made by Anthropic" connectors are only in standard Desktop, and others reach 3p through `managedMcpServers` or plugins (claude.com/docs/third-party/claude-desktop/extensions).- Claude Desktop names a Claude model with reasoning levels after its own catalog ("Opus 5.5"), not by the `display_name` magpie lists, because magpie lists it as `magpie-<number>.anthropic.<model>` to keep its effort picker (`claudeLooking` in [`desktop.go`](../../internal/gateway/desktop.go)). Two providers' rows of one model then differ in Desktop's menu only by that number, so the provider editor shows it on the model's chip (`gateway.DesktopNumber`, `desktopNumbers` in [`providers.go`](../../internal/gui/providers.go), #2578). The chip shows it only while Claude Desktop is installed and is shown that model. Every other model Desktop is shown carries no number on the chip: Desktop names it by `display_name`, which already says the provider, or by its own id.- Codex's `spawn_agent` tool names only the first five models of its catalog to the lead (codex-rs `MAX_SPAWN_AGENT_MODEL_OVERRIDES` in `child_config.rs`, `spawn_agent_models_description`), Codex's own ahead of magpie's, though it takes any catalog model by name (`find_spawn_agent_model_name`). So a lead could put its subagents on none of magpie's models (Gearclickist on Discord). The gateway adds the rest of the catalog Codex was handed to that tool's description, after Codex's own list, at most 200 (`spawnAgentModels` in [`codex_spawn_models.go`](../../internal/gateway/codex_spawn_models.go)). A model that can search tools (`supports_search_tool`) isn't handed it in the request's tools: Codex defers its multi-agent V1 tools behind `tool_search` (codex-rs `core/src/tools/spec_plan.rs`), and the lead gets `spawn_agent` in the `tool_search_output` Codex puts in the conversation and sends again every turn, so that one is widened too. That text goes upstream with the prompt, to OpenAI too for a ChatGPT lead, so its header (`spawnMore`) stays neutral: it names neither magpie nor Codex's limit. At `CodexPath` that is Codex's own listed models less the hidden ones, then `CodexListed` unless Codex is held to its own. At `/v1` it is `CodexCatalog` under the key's allowance. A lead the ChatGPT backend answers in multi-agent V2 seals its subagents' tasks for a ChatGPT account (#619), so it gets Codex's own only. The model catalog Codex puts in context under `model_catalog_in_context` (under development, off by default) is capped at five too, and isn't widened.- Snow CLI runs on one profile at a time (`profiles/<name>.json` in `~/.snow` or `$SNOW_CONFIG_DIR`, named in `active-profile.json`) and copies the active one over `config.json` at every start, `snow --ask` too ([`snow.go`](../../internal/agent/snow.go)). magpie writes a `magpie` profile, makes it the active one, and copies it to `config.json` itself, so a Snow already running and Snow App's "Sync Snow CLI API config" see the same. It is made from the profile the user was on, their settings kept and its OAuth sign-in left out. A vision model of that profile comes along only with an endpoint and key of its own (`snowOwnVision`), since one on the profile's would now go to the gateway. `maxContextTokens`, `maxTokens` and `supportsVision` follow the model from the catalog (`snowSynced`; `supportsVision` as every agent is told, true while magpie's Vision describes images); what magpie last wrote of them is stashed, and one the user changed since in Snow's own settings is kept through later picks and syncs. The small field is magpie's profile's `basicModel`, Snow's light model for summaries, compaction and file search: empty while it follows the main model, a model through magpie of its own kept through new main models and syncs; on a profile of the user's it offers nothing and is hidden. The thinking field is magpie's profile's `chatThinking` (`{enabled: true, reasoning_effort}`), the only thinking setting Snow reads on the chat protocol; empty deletes it, Snow's default, which sends thinking disabled. A chatThinking the user brought from their profile is shown, not written over. The profile they were on (or that there was no `active-profile.json`) and a `magpie.json` of their own are stashed and put back by Disconnect. A Snow from before profiles (`config.json` alone) gets the `default.json` Snow itself would have made of it, so its next start doesn't take magpie's for the user's. Picking a model of another of the user's profiles switches Snow to that profile. On magpie's profile, a value that is neither a model through magpie nor the model of one of the user's profiles is refused and changes nothing (#1457: `magpie snow --help` used to take magpie out and write `--help` as the model of the profile it went back to). Gemini CLI's auth field refuses an auth it doesn't know before it unroutes, for the same reason. On the CLI, `-h`/`--help` after any command or agent only prints its usage, before `run` reads or moves anything, and any other flag given to `magpie <agent> …` is refused (`help_cli.go`; `TestHelpOnEveryCommandDoesNothing` walks `run`'s switch and every agent).diff --git a/internal/agent/claudedesktop.go b/internal/agent/claudedesktop.goindex d5f1dc1ff..f5051f41c 100644--- a/internal/agent/claudedesktop.go+++ b/internal/agent/claudedesktop.go@@ -36,6 +36,7 @@ import ("net/url""os""path/filepath"+ "reflect""regexp""slices""strings"@@ -192,6 +193,13 @@ func claudeDesktop(home string) *Agent {if err := desktopSeedImport(p); err != nil {errs = append(errs, err)}+ // a Desktop on magpie from before the servers were+ // carried gets them once+ if stashLoad()[desktopMCPSeen+p.key] == "" {+ if err := desktopCarryMCP(p); err != nil {+ errs = append(errs, err)+ }+ }}}return joinErrs(errs)@@ -400,9 +408,11 @@ const (desktopProfile = "claude-desktop.profile"desktopLocale = "claude-desktop.locale"desktopImport = "claude-desktop.import"+ desktopMCP = "claude-desktop.mcp"+ desktopMCPSeen = "claude-desktop.mcp-seen")-var desktopStashKeys = []string{desktopStashed, desktopMode, desktopMode3p, desktopApplied, desktopMade, desktopProfile, desktopLocale, desktopImport}+var desktopStashKeys = []string{desktopStashed, desktopMode, desktopMode3p, desktopApplied, desktopMade, desktopProfile, desktopLocale, desktopImport, desktopMCP, desktopMCPSeen}// desktopAdoptStash moves the stash a packaged Desktop's folders got// before they had keys of their own (when magpie wrote only one set) onto@@ -512,6 +522,9 @@ func desktopOn(p desktopPaths) error {}desktopCarryLocale(p)+ if err := desktopCarryMCP(p); err != nil {+ return err+ }// the mode last: until here Desktop still starts as it didfor _, f := range []string{p.config3p, p.config} {@@ -560,6 +573,102 @@ func desktopSeedImport(p desktopPaths) error {return nil}+// desktopServers is the mcpServers object of a claude_desktop_config.json,+// nil when it has none or can't be read as one.+func desktopServers(path string) map[string]json.RawMessage {+ raw, ok := edit.GetJSONRaw(path, "mcpServers")+ if !ok {+ return nil+ }+ var m map[string]json.RawMessage+ if json.Unmarshal([]byte(raw), &m) != nil {+ return nil+ }+ return m+}++// desktopCarryMCP gives Desktop's 3p mode the MCP servers the user added+// signed in with Anthropic (Settings → Developer). 3p mode reads its+// servers from Claude-3p's claude_desktop_config.json, a file of its own,+// so on magpie Desktop's connector list had none of the user's+// (aa86222 on Discord: connectors didn't sync). Each server Claude's file+// has and Claude-3p's doesn't is copied; one of the same name in Claude-3p+// (the user's, or the library's, which writes both) stays as it is. What+// was copied is kept in the stash, so off takes back each one still as it+// was copied. The connectors of a claude.ai account don't come along:+// Desktop reaches them through claude.ai with that account+// (/api/organizations/<org>/mcp/servers/…), and 3p mode has none.+func desktopCarryMCP(p desktopPaths) error {+ stash(map[string]string{desktopMCPSeen + p.key: "1"})+ own := desktopServers(p.config)+ if len(own) == 0 || desktopObject(p.config3p) != nil {+ return nil+ }+ if _, has := edit.GetJSONRaw(p.config3p, "mcpServers"); has && desktopServers(p.config3p) == nil {+ return nil // not an object: Desktop's, or the user's, left alone+ }+ have := desktopServers(p.config3p)+ carried := map[string]json.RawMessage{}+ if prev := stashLoad()[desktopMCP+p.key]; prev != "" {+ json.Unmarshal([]byte(prev), &carried)+ }+ merged := map[string]json.RawMessage{}+ for k, v := range have {+ merged[k] = v+ }+ added := false+ for name, v := range own {+ if _, ok := merged[name]; ok {+ continue+ }+ merged[name], carried[name] = v, v+ added = true+ }+ if !added {+ return nil+ }+ if err := edit.SetJSON(p.config3p, edit.KV{Path: "mcpServers", Value: merged}); err != nil {+ return err+ }+ b, _ := json.Marshal(carried)+ stash(map[string]string{desktopMCP + p.key: string(b)})+ return nil+}++// desktopUncarryMCP takes the servers desktopCarryMCP copied out of+// Claude-3p again, each only while it is still as copied: one the user+// changed since is theirs. An mcpServers left empty goes with them.+func desktopUncarryMCP(p desktopPaths) error {+ prev := unstash(desktopMCP + p.key)+ var carried map[string]json.RawMessage+ if prev == "" || json.Unmarshal([]byte(prev), &carried) != nil || len(carried) == 0 {+ return nil+ }+ have := desktopServers(p.config3p)+ if have == nil {+ return nil+ }+ gone := false+ for name, v := range carried {+ if cur, ok := have[name]; ok && desktopSameJSON(cur, v) {+ delete(have, name)+ gone = true+ }+ }+ if !gone {+ return nil+ }+ if len(have) == 0 {+ return edit.DelJSON(p.config3p, "mcpServers")+ }+ return edit.SetJSON(p.config3p, edit.KV{Path: "mcpServers", Value: have})+}++func desktopSameJSON(a, b json.RawMessage) bool {+ var x, y any+ return json.Unmarshal(a, &x) == nil && json.Unmarshal(b, &y) == nil && reflect.DeepEqual(x, y)+}+// desktopLocaleName is a language Desktop takes for its "locale": the// names of its catalogs (lit in Desktop 2.7032's main process,// /^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*\.json$/).@@ -693,6 +802,10 @@ func desktopOff(p desktopPaths) error {return err}+ if err := desktopUncarryMCP(p); err != nil {+ return err+ }+// Claude-3p's config.json magpie made only to carry the language:// gone again when it still holds nothing but that languageif loc := unstash(desktopLocale + k); loc != "" && slices.Contains(made, p.app3p) {diff --git a/internal/agent/claudedesktop_test.go b/internal/agent/claudedesktop_test.goindex 12e0279c2..6a339891e 100644--- a/internal/agent/claudedesktop_test.go+++ b/internal/agent/claudedesktop_test.go@@ -845,3 +845,112 @@ func TestClaudeDesktopOffersItsSessionImport(t *testing.T) {t.Fatalf("session: %q", got)}}++// aa86222 on Discord: Desktop on magpie had none of the user's connectors.+// 3p mode reads its MCP servers from Claude-3p's claude_desktop_config.json,+// so the ones added signed in with Anthropic (Claude's file) were out of+// sight. Switching on copies each one Claude-3p doesn't have; one of the+// same name there stays theirs; Claude's file is never written; off takes+// the copies back and leaves the tree as it was.+func TestClaudeDesktopCarriesTheMCPServers(t *testing.T) {+ home, p := desktopSandbox(t)+ own := `{"mcpServers":{"fs":{"command":"npx","args":["-y","@modelcontextprotocol/server-filesystem","/tmp"]},"notes":{"command":"notes-mcp"}}}`+ desktopWrite(t, p.config, own)+ before := desktopTree(t, p)++ a := claudeDesktop(home)+ f := a.Field("provider")+ if err := f.Set("magpie"); err != nil {+ t.Fatal(err)+ }+ m := desktopJSON(t, p.config3p)+ want := desktopJSON(t, p.config)["mcpServers"]+ if !reflect.DeepEqual(m["mcpServers"], want) {+ t.Fatalf("Claude-3p's mcpServers: %v, want %v", m["mcpServers"], want)+ }+ if b, _ := os.ReadFile(p.config); !strings.Contains(string(b), `"notes":{"command":"notes-mcp"}`) {+ t.Fatalf("Claude's servers changed:\n%s", b)+ }+ // on again and Sync: nothing doubled, nothing more written+ once := desktopTree(t, p)+ if err := f.Set("magpie"); err != nil {+ t.Fatal(err)+ }+ if err := a.Sync(); err != nil {+ t.Fatal(err)+ }+ if again := desktopTree(t, p); !reflect.DeepEqual(again, once) {+ t.Fatalf("on again changed:\n%v\nwas:\n%v", again, once)+ }+ if err := f.Set(""); err != nil {+ t.Fatal(err)+ }+ if after := desktopTree(t, p); !reflect.DeepEqual(after, before) {+ t.Fatalf("off left:\n%v\nwas:\n%v", after, before)+ }+}++// A server Claude-3p has already, by the same name, is the user's (or the+// library's) and stays; one the user changed in 3p mode since it was+// copied is theirs and outlives off; Claude-3p's other servers stay.+func TestClaudeDesktopMCPKeepsThe3pServers(t *testing.T) {+ home, p := desktopSandbox(t)+ desktopWrite(t, p.config, `{"mcpServers":{"a":{"command":"a"},"b":{"command":"b-signed-in"},"c":{"command":"c"}}}`)+ desktopWrite(t, p.config3p, `{"mcpServers":{"b":{"command":"b-3p"},"x":{"command":"x"}}}`)+ f := claudeDesktop(home).Field("provider")+ if err := f.Set("magpie"); err != nil {+ t.Fatal(err)+ }+ got := desktopJSON(t, p.config3p)["mcpServers"]+ want := map[string]any{"a": map[string]any{"command": "a"}, "b": map[string]any{"command": "b-3p"},+ "c": map[string]any{"command": "c"}, "x": map[string]any{"command": "x"}}+ if !reflect.DeepEqual(got, want) {+ t.Fatalf("on: %v", got)+ }+ // the user changes c in 3p mode+ if err := edit.SetJSON(p.config3p, edit.KV{Path: "mcpServers.c.command", Value: "c-mine"}); err != nil {+ t.Fatal(err)+ }+ if err := f.Set(""); err != nil {+ t.Fatal(err)+ }+ m := desktopJSON(t, p.config3p)+ got = m["mcpServers"]+ want = map[string]any{"b": map[string]any{"command": "b-3p"}, "c": map[string]any{"command": "c-mine"}, "x": map[string]any{"command": "x"}}+ if !reflect.DeepEqual(got, want) {+ t.Fatalf("off: %v", got)+ }+ if _, has := m["deploymentMode"]; has {+ t.Fatalf("off kept the mode: %v", m)+ }+}++// A Desktop on magpie from before the servers were carried gets them from+// Sync at magpie's next start, once: a server the user then takes out in+// 3p mode isn't brought back by the next Sync.+func TestClaudeDesktopSyncCarriesTheMCPServersOnce(t *testing.T) {+ home, p := desktopSandbox(t)+ a := claudeDesktop(home)+ if err := a.Field("provider").Set("magpie"); err != nil {+ t.Fatal(err)+ }+ forget(desktopMCPSeen + p.key)+ if err := edit.SetJSON(p.config, edit.KV{Path: "mcpServers", Value: map[string]any{"fs": map[string]any{"command": "fs"}}}); err != nil {+ t.Fatal(err)+ }+ if err := a.Sync(); err != nil {+ t.Fatal(err)+ }+ if got := desktopJSON(t, p.config3p)["mcpServers"]; !reflect.DeepEqual(got, map[string]any{"fs": map[string]any{"command": "fs"}}) {+ t.Fatalf("Sync: %v", got)+ }+ if err := edit.DelJSON(p.config3p, "mcpServers"); err != nil {+ t.Fatal(err)+ }+ if err := a.Sync(); err != nil {+ t.Fatal(err)+ }+ if _, has := desktopJSON(t, p.config3p)["mcpServers"]; has {+ t.Fatal("Sync brought back a server the user took out")+ }+}