Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
agent: Desktop on magpie offers its own import of the signed-in sessions (lambdua on X)
yetone5be7d05d289f
diff --git a/docs/subsystems/agent-wiring.md b/docs/subsystems/agent-wiring.mdindex caffe53b1..5c3d4c6b2 100644--- a/docs/subsystems/agent-wiring.md+++ b/docs/subsystems/agent-wiring.md@@ -94,6 +94,7 @@ something else shows up as drift.- 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.- 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 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 bbc8217d8..d5f1dc1ff 100644--- a/internal/agent/claudedesktop.go+++ b/internal/agent/claudedesktop.go@@ -183,6 +183,19 @@ func claudeDesktop(home string) *Agent {Note: "Desktop's third-party gateway: Code and Cowork on magpie's models, no Anthropic sign-in (restart Desktop)"}}},}}, append(desktopTierFields(ps), desktopSubagentField(ps), desktopSubagentEffortField(ps))...),+ // a Desktop already on magpie gets the import policy too+ // (desktopSeedImport); nothing else is written here+ Sync: func() error {+ var errs []error+ for _, p := range ps {+ if desktopWired(p) {+ if err := desktopSeedImport(p); err != nil {+ errs = append(errs, err)+ }+ }+ }+ return joinErrs(errs)+ },}}@@ -386,9 +399,10 @@ const (desktopMade = "claude-desktop.made"desktopProfile = "claude-desktop.profile"desktopLocale = "claude-desktop.locale"+ desktopImport = "claude-desktop.import")-var desktopStashKeys = []string{desktopStashed, desktopMode, desktopMode3p, desktopApplied, desktopMade, desktopProfile, desktopLocale}+var desktopStashKeys = []string{desktopStashed, desktopMode, desktopMode3p, desktopApplied, desktopMade, desktopProfile, desktopLocale, desktopImport}// desktopAdoptStash moves the stash a packaged Desktop's folders got// before they had keys of their own (when magpie wrote only one set) onto@@ -481,6 +495,9 @@ func desktopOn(p desktopPaths) error {if err := edit.SetJSON(p.prof, kvs...); err != nil {return err}+ if err := desktopSeedImport(p); err != nil {+ return err+ }// _meta.json: magpie's entry (where it was, if it was), appliedif !wired {@@ -505,6 +522,44 @@ func desktopOn(p desktopPaths) error {return nil}+// desktopImportOn is Desktop's own "Claude.ai data import" policy+// (claudeAiImport, a 3p-only key of Desktop 1.28929 and later) turned on,+// with its banner shown only when there is something to import.+var desktopImportOn = map[string]any{"enabled": true, "bannerBehavior": "detect"}++// desktopSeedImport lets Desktop on magpie bring in the sessions it had+// signed in with Anthropic. 3p mode runs in a userData of its own+// (Claude-3p), whose Code and Cowork sessions are keyed by its install id+// and a fixed org (claude-code-sessions/<ant-did>/00000000-0000-4000-8000-+// 000000000001), so the Code tab came up empty and the signed-in sessions,+// in Claude/claude-code-sessions/<account>/<org>, were out of sight until+// Desktop was switched back (lambdua on X: 切换账号,对话都能全都不见).+// Nothing is lost; Desktop only offers its importer (Settings → Import,+// "earlier Claude sessions on this computer": Claude/, other Claude*+// folders and ~/.claude/projects, copied with the originals left in place)+// when claudeAiImport.enabled is true, false by default (Desktop 2.7032's+// B9/VKi). It is seeded into magpie's profile once, where the profile has+// no claudeAiImport of its own: one the user set, or took away in+// Desktop's window since, stays theirs. Run on every switch on and from+// Sync, so a Desktop already on magpie gets it at magpie's next start.+// The mark is read, never unstashed: it outlives the check and a switch+// off, or the next Sync would write the policy back.+func desktopSeedImport(p desktopPaths) error {+ if stashLoad()[desktopImport+p.key] != "" {+ return nil+ }+ if desktopObject(p.prof) != nil {+ return nil+ }+ if _, ok := edit.GetJSON(p.prof, "claudeAiImport"); !ok {+ if err := edit.SetJSON(p.prof, edit.KV{Path: "claudeAiImport", Value: desktopImportOn}); err != nil {+ return err+ }+ }+ stash(map[string]string{desktopImport + p.key: "1"})+ return nil+}+// 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$/).diff --git a/internal/agent/claudedesktop_test.go b/internal/agent/claudedesktop_test.goindex 3f17e530f..12e0279c2 100644--- a/internal/agent/claudedesktop_test.go+++ b/internal/agent/claudedesktop_test.go@@ -13,6 +13,7 @@ import ("time""github.com/yetone/magpie/internal/desktopdir"+ "github.com/yetone/magpie/internal/edit""github.com/yetone/magpie/internal/gateway""github.com/yetone/magpie/internal/provider")@@ -143,6 +144,7 @@ func TestClaudeDesktopFresh(t *testing.T) {"inferenceProvider": "gateway", "inferenceGatewayBaseUrl": gateway.URL(),"inferenceGatewayApiKey": "magpie-claude-desktop", "inferenceGatewayAuthScheme": "bearer","disableDeploymentModeChooser": true, "coworkEgressAllowedHosts": []any{"*"},+ "claudeAiImport": map[string]any{"enabled": true, "bannerBehavior": "detect"},}if prof := desktopJSON(t, p.prof); !reflect.DeepEqual(prof, want) {t.Errorf("profile: %v", prof)@@ -366,6 +368,7 @@ func TestClaudeDesktopOnKeepsTheUsersOwnGatewayProfile(t *testing.T) {json.Unmarshal([]byte(body), &want)want["inferenceGatewayApiKey"] = "magpie-claude-desktop"want["inferenceGatewayAuthScheme"] = "bearer"+ want["claudeAiImport"] = map[string]any{"enabled": true, "bannerBehavior": "detect"}if prof := desktopJSON(t, p.prof); !reflect.DeepEqual(prof, want) {t.Errorf("magpie's profile:\n%v\nwant\n%v", prof, want)}@@ -758,3 +761,87 @@ func TestClaudeDesktopLanguageOddValues(t *testing.T) {t.Errorf("takeover stopped: %v", m)}}++// lambdua on X: Desktop on magpie runs in Claude-3p, a userData of its own,+// so the Code and Cowork sessions it had signed in with Anthropic were out+// of sight. Desktop imports them itself (Settings → Import) once its+// claudeAiImport policy is on: magpie's profile gets it, once, on a switch+// on and, for a Desktop already on magpie, from Sync at the next start.+// A claudeAiImport the user has, or took away since, stays theirs, and+// Desktop's own sessions are never touched.+func TestClaudeDesktopOffersItsSessionImport(t *testing.T) {+ home, p := desktopSandbox(t)+ on := map[string]any{"enabled": true, "bannerBehavior": "detect"}+ // a session Desktop wrote signed in with Anthropic+ session := filepath.Join(p.dir, "claude-code-sessions", "acct", "org", "local_1.json")+ desktopWrite(t, session, `{"sessionId":"local_1","title":"mine"}`)+ a := claudeDesktop(home)+ if a.Sync == nil {+ t.Fatal("no Sync: a Desktop already on magpie never gets the import")+ }+ // not on magpie: Sync writes nothing+ before := desktopTree(t, p)+ if err := a.Sync(); err != nil {+ t.Fatal(err)+ }+ if after := desktopTree(t, p); !reflect.DeepEqual(after, before) {+ t.Fatalf("Sync off magpie wrote:\n%v", after)+ }++ // on magpie before this change: a profile with no claudeAiImport and+ // nothing in the stash; Sync seeds it+ if err := a.Field("provider").Set("magpie"); err != nil {+ t.Fatal(err)+ }+ if got := desktopJSON(t, p.prof)["claudeAiImport"]; !reflect.DeepEqual(got, on) {+ t.Fatalf("switch on: claudeAiImport %v", got)+ }+ prof := desktopJSON(t, p.prof)+ delete(prof, "claudeAiImport")+ b, _ := json.Marshal(prof)+ desktopWrite(t, p.prof, string(b))+ forget(desktopImport + p.key)+ if err := a.Sync(); err != nil {+ t.Fatal(err)+ }+ if got := desktopJSON(t, p.prof)["claudeAiImport"]; !reflect.DeepEqual(got, on) {+ t.Fatalf("Sync on magpie: claudeAiImport %v", got)+ }++ // the user turns it off in Desktop's window (the key gone): stays off+ desktopWrite(t, p.prof, string(b))+ if err := a.Sync(); err != nil {+ t.Fatal(err)+ }+ if err := a.Field("provider").Set("magpie"); err != nil {+ t.Fatal(err)+ }+ if _, has := desktopJSON(t, p.prof)["claudeAiImport"]; has {+ t.Fatal("seeded again over the user's choice")+ }++ // a claudeAiImport of the user's own, seen first: kept as it is+ if err := a.Field("provider").Set(""); err != nil {+ t.Fatal(err)+ }+ forget(desktopImport+p.key, desktopProfile+p.key)+ theirs := map[string]any{"enabled": false}+ if err := a.Field("provider").Set("magpie"); err != nil {+ t.Fatal(err)+ }+ if err := edit.SetJSON(p.prof, edit.KV{Path: "claudeAiImport", Value: theirs}); err != nil {+ t.Fatal(err)+ }+ forget(desktopImport + p.key)+ if err := a.Sync(); err != nil {+ t.Fatal(err)+ }+ if got := desktopJSON(t, p.prof)["claudeAiImport"]; !reflect.DeepEqual(got, theirs) {+ t.Fatalf("the user's claudeAiImport: %v", got)+ }++ // Desktop's own sessions are where they were, as they were+ if got, _ := os.ReadFile(session); string(got) != `{"sessionId":"local_1","title":"mine"}` {+ t.Fatalf("session: %q", got)+ }+}