agent: Snow CLI's light model (basicModel) can be picked apart from its main model on the Agents page (#1457)

zRain (#1457) asked for Snow's advancedModel and basicModel to be chosen
separately; magpie wrote the picked model to both. Snow 0.9.2 asks
basicModel for its summaries, compaction and file search
(utils/config/apiConfig.ts; agents/compactAgent, summaryAgent).

A "small" field, as OpenCode's and Crush's, sets basicModel on magpie's
profile (profiles/magpie.json, copied to config.json): a model through
magpie only, since both models go to the profile's one baseUrl, the
gateway. Empty, it follows the main model. A small model of its own stays
through a new main model and a catalog sync (snowProfileFor keeps a
basicModel that differed from the advancedModel it replaces), and one
the gateway no longer resolves goes back to following.

On a profile of the user's own the field reads empty, offers nothing and
refuses a pick: that profile's models are theirs to set in Snow. The
Agents row leaves a small field with nothing to offer and no value out,
as it does an effort with none (app.js none()).

Tests: TestSnowSmallModel (pick, read back, refuse a non-magpie model,
kept through a new model and Sync, follows again when cleared,
Disconnect). With the keep in snowProfileFor removed it fails "small
after a new model and sync". TestSnow* and TestSync* pass under a temp
HOME with pinned caches.
This commit is contained in:
yetone
2026-10-10 18:20:56 +08:00
parent 6ad5dc5855
commit e949c0ca8f
4 changed files with 144 additions and 4 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ something else shows up as drift.
- 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)).
- 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 only ChatGPT accounts' models, as a subagent's task is sealed for them. Its setter keeps a ChatGPT account's model no account serves now, so a profile or backup put back on another computer still applies (`ApplyFields` stops at the first failed Set), and refuses any other provider's model.
- 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 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.
- 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 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.
- A value an agent spells as its own provider's model is never taken for one of magpie's, even when magpie has a provider of the same name (`Spelled`, #835).
- `unreachable` never sets anything: the config is right, and the page's pill only says what has to listen. The exception is an address a WSL distro reached Windows at before (`distro.Was`, kept in `wsl.json`) while it reaches Windows at another now: the pill offers that one, and `Reapply` moves the config there (`Agent.move`, Codex's `codexMoveGateway`). An address no distro was seen at is the user's own and is never moved. An unknown answer (no probe yet) and a gateway down on loopback too are not drift. Tests stub `reachProbe` in `TestMain`.
- Listing never starts a stopped WSL distro. A stopped distro's agent shows what was last seen there (`asleep`, `wsl.json`); setting one of its fields writes its files, which starts the distro.
+54 -1
View File
@@ -341,6 +341,49 @@ func snowIn(at place) *Agent {
Options: func(cur map[string]string) []Option {
return append(snowOwnOptions(profiles, cur["model"]), viaMagpie("snow", magpieID+"/")...)
},
}, {
// basicModel, the light model Snow's summaries, compaction and
// file search ask (utils/config/apiConfig.ts): on magpie's
// profile only, where both models go to the gateway; a
// profile of the user's is theirs to set in Snow. Empty while
// it follows the main model.
Key: "small", Label: "small",
Get: func() string {
if !onOurs() {
return ""
}
b, _ := edit.GetJSON(ours, "snowcfg.basicModel")
if b == "" || b == model(snowProfile) {
return ""
}
return magpieID + "/" + b
},
Set: func(v string) error {
if !onOurs() {
if v == "" {
return nil
}
return errors.New("Snow CLI's light model can be set here on magpie's profile: pick a model through magpie as its model first")
}
ref := model(snowProfile)
if v != "" {
r, ok := strings.CutPrefix(v, magpieID+"/")
if !ok || !isMagpie(r) {
return errors.New("Snow CLI's light model goes to the gateway with its main model: pick one through magpie")
}
ref = r
}
if err := edit.SetJSON(ours, edit.KV{Path: "snowcfg.basicModel", Value: ref}); err != nil {
return err
}
return mirror(snowProfile)
},
Options: func(cur map[string]string) []Option {
if !strings.HasPrefix(cur["model"], magpieID+"/") {
return nil
}
return viaMagpie("snow", magpieID+"/")
},
}},
}, ours, activeFile, config, defaultProfile)
}
@@ -429,8 +472,18 @@ func snowProfileFor(from []byte, ours bool, v1, key, ref string, wrote map[strin
sc["baseUrlMode"] = "base"
sc["apiKey"] = key
sc["requestMethod"] = "chat"
// the light model follows the main one, unless picked apart from it
// (the small field): a magpie model of its own stays through a new
// main model and a sync
small := ref
if ours {
was, _ := sc["advancedModel"].(string)
if b, _ := sc["basicModel"].(string); b != "" && b != was && isMagpie(b) {
small = b
}
}
sc["advancedModel"] = ref
sc["basicModel"] = ref
sc["basicModel"] = small
cfg["snowcfg"] = sc
b, err := json.MarshalIndent(cfg, "", " ")
if err != nil {
+85
View File
@@ -487,3 +487,88 @@ func TestSnowUsersVisionModel(t *testing.T) {
})
}
}
// Snow's light model (basicModel) is picked apart from its main one on
// magpie's profile, stays through a new main model and a sync, and follows
// the main one again when cleared; on a profile of the user's it is
// theirs, and the field offers nothing.
func TestSnowSmallModel(t *testing.T) {
_, dir := snowHome(t)
snowUser(t, dir)
snowSees(t)
ours := filepath.Join(dir, "profiles", "magpie.json")
a, _ := Find("snow")
if opts := a.Field("small").Options(a.Values()); len(opts) != 0 {
t.Fatalf("small offered on the user's profile: %+v", opts)
}
if err := a.Apply("small", "magpie/relay/glm-4.6"); err == nil {
t.Fatal("small set on the user's profile")
}
if readFile(filepath.Join(dir, "profiles", "default.json")) != snowDefault {
t.Fatal("the user's profile was written")
}
if err := a.Apply("model", "magpie/deepseek/pro"); err != nil {
t.Fatal(err)
}
if v := a.Values()["small"]; v != "" {
t.Fatalf("small follows the model, got %q", v)
}
if opts := a.Field("small").Options(a.Values()); len(opts) == 0 {
t.Fatal("no small options on magpie's profile")
}
if err := a.Apply("small", "magpie/relay/glm-4.6"); err != nil {
t.Fatal(err)
}
sc := snowCfg(t, ours)
if sc["advancedModel"] != "deepseek/pro" || sc["basicModel"] != "relay/glm-4.6" {
t.Fatalf("small pick: %v", sc)
}
if readFile(filepath.Join(dir, "config.json")) != readFile(ours) {
t.Fatal("config.json not copied from magpie's profile")
}
if v := a.Values()["small"]; v != "magpie/relay/glm-4.6" {
t.Fatalf("small read back %q", v)
}
// a model of the user's own can't be Snow's light model beside the
// gateway's
if err := a.Apply("small", "glm-5"); err == nil {
t.Fatal("a non-magpie small model was taken")
}
// a new main model and a sync keep it
if err := a.Apply("model", "magpie/relay/glm-4.5v"); err != nil {
t.Fatal(err)
}
if err := a.Sync(); err != nil {
t.Fatal(err)
}
if sc := snowCfg(t, ours); sc["advancedModel"] != "relay/glm-4.5v" || sc["basicModel"] != "relay/glm-4.6" {
t.Fatalf("small after a new model and sync: %v", sc)
}
// cleared: it follows the main model, and keeps following it
if err := a.Apply("small", ""); err != nil {
t.Fatal(err)
}
if sc := snowCfg(t, ours); sc["basicModel"] != "relay/glm-4.5v" {
t.Fatalf("small cleared: %v", sc)
}
if err := a.Apply("model", "magpie/deepseek/pro"); err != nil {
t.Fatal(err)
}
if sc := snowCfg(t, ours); sc["basicModel"] != "deepseek/pro" {
t.Fatalf("small doesn't follow the model: %v", sc)
}
// Disconnect: the user's profile again, magpie's gone
if err := a.Apply("small", "magpie/relay/glm-4.6"); err != nil {
t.Fatal(err)
}
if err := a.Disconnect(); err != nil {
t.Fatal(err)
}
if _, err := os.Stat(ours); !os.IsNotExist(err) || snowActive(dir) != "default" {
t.Fatalf("after Disconnect: %v, active %q", err, snowActive(dir))
}
}
+4 -2
View File
@@ -298,8 +298,10 @@ function renderAgents() {
// an effort or ultracode the model has none of (Claude Code on Haiku
// 4.5, ultracode short of xhigh) isn't drawn at all, nor are subagents
// with no model to go on, or a sign-in with no other to take (Claude
// Code's, until it runs through magpie where magpie takes any key)
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.options.length && !f.value;
// Code's, until it runs through magpie where magpie takes any key), or
// a small model with none to pick (Snow CLI's, on a profile of the
// user's own)
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") && !f.options.length && !f.value;
const shownFields = a.fields.filter((f) => !TIERS.includes(f.label) && !TIER_EFFORTS.includes(f.label) && !none(f));
const tiers = tierMenu(a);
if (tiers) shownFields.push(tiers);