moer2831 on Discord: a model picked for one of Claude Desktop's tiers ran
in the Code tab on Claude Code's generic prompt, not the one of the
Claude model of that tier ("通用提示词和对应模型提示词差距挺大的,感觉直接
蠢了一个度"). Desktop 4.29 and later hand Claude Code behavesAs only from
a profile's inferenceModels (z3t in 4.4212's app.asar: modelPicker
options with each entry's behavesAs).
What changed:
- gateway.DesktopInferenceModels: while a model is picked for a tier,
the list is every row /v1/models gives Desktop, by its id and in its
order (a non-empty list replaces discovery, pzn), with supports1m,
prefer1m and labelOverride as Desktop read them off the row, and a
pick's anthropicFamilyTier/isFamilyDefault. A pick that isn't a Claude
model gets behavesAs = its tier's newest Claude id (claude-opus-5-5,
claude-sonnet-5-5, claude-haiku-5-5, claude-fable-5-1). Nothing picked
(or a pick no longer listed): no list. Unreadable picks are unknown.
- agent: desktopSyncModels writes it into magpie's Desktop profile on a
tier's Set, as Desktop comes on magpie and on Sync; temp+rename, only
when it changed; taken away when nothing is picked. The list is
magpie's only while its hash is one magpie recorded (stash mark
claude-desktop.models); any other list (the user's) is never written
over or removed.
- Claude Code's modelSettings gets the pick's own window even when it
matches the default (claudeBudget.behaves), since behavesAs would
otherwise give it the Claude model's.
- GUI: the tiers menu ends with one line, "Claude Desktop reads the
tiers as it starts: restart it after a change." (en, zh, zh-TW, ja,
de). The Agents row's Restart already lights from the profile hash.
- docs/subsystems/agent-wiring.md and gateway-routing.md.
Run on mote at this tree (base c86fa2a34): gofmt -l clean; GOOS=linux
(-tags nogui) and GOOS=windows go vet ./internal/agent ./internal/gateway;
go test -count=1 -timeout 45m ./internal/agent ./internal/gateway
./internal/gui ./internal/cli ./internal/tui ./internal/backup
./internal/davsync ./internal/library ./internal/profile ./internal/stats
./internal/uninstall: ok but internal/gateway's
TestCodexPoolSaysTheClientsVersion (passes alone here and at main; #4807)
and internal/gui's TestMainWindowCorners (red the same at origin/main
6a6e4fefa; #3949). GUI (chromium + webkit, every
language they cover): desktop-tiers, i18n-keys, and every file named for
tiers, picks, roles, Desktop, i18n or a language (887 tests,
871 pass; the 16 reds are 4 files red the same at origin/main 6a6e4fefa:
found-skill-pick-remove #4097, menu-input-scroll #3402,
phone-connect-menu #4706/#4707, provider-picks-stay #4397). Not the
whole GUI suite.
Rebased on origin/main a5c1fa4b4 (nothing there touches agent, gateway or
GUI assets but routing.css), then again at the pushed head: go vet
./internal/agent ./internal/gateway; the size budgets,
TestDesktopInferenceModels, TestClaudeDesktop*, TestClaudePlan;
desktop-tiers and i18n-keys in both engines: ok.
Broken by hand, each red: behavesAs left out (TestDesktopInferenceModels);
the window write's behaves check dropped (TestClaudePlan); the sync on a
tier's Set dropped (TestClaudeDesktopModelsList); the user-list guard
off (TestClaudeDesktopModelsList); the menu's line not shown
(desktop-tiers 0 of 4).
Not tried: a real Claude Desktop 4.29 or later (none on mote; this
Mac's is 2.7032 and live). Builds before 4.29 ignore behavesAs and take
the names. Desktop 1.x gets the mythos ids. A user's own gateway profile
applied in Desktop makes magpie's list do nothing.
Thanks moer2831 for the report.
87 lines
4.3 KiB
Go
87 lines
4.3 KiB
Go
package agent
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
// TestClaudePlan (#2025): the largest window of the models is the one
|
|
// Claude Code is told, and each model whose own differs from the one it
|
|
// would run at without an entry gets one; a "[1m]" model counts as 1M, the
|
|
// user's own entries are theirs, and one past its model's window holds the
|
|
// largest to that window.
|
|
func TestClaudePlan(t *testing.T) {
|
|
models := []claudeBudget{
|
|
{id: "mythos-magpie-1", window: 500000, compact: 272000},
|
|
{id: "mythos-magpie-2", window: 131000, compact: 272000},
|
|
{id: "anthropic/magpie-3[1m]", window: 1000000, long: true, compact: 272000},
|
|
{id: "anthropic/magpie-4", compact: -1},
|
|
{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": 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, the [1m] one's 1M
|
|
top, 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 != 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
|
|
// largest to its window
|
|
top, entries = claudePlan(models, 0, map[string]string{"mythos-magpie-2": "auto", "magpie/v/gpt-6.1-sol": "100000"})
|
|
want = map[string]int{"anthropic/magpie-3": 272000}
|
|
if top != 131000 || !reflect.DeepEqual(entries, want) {
|
|
t.Fatalf("the user's own: %d %v", top, entries)
|
|
}
|
|
// one within the model's window is kept as it is, and doesn't hold
|
|
// the largest
|
|
top, 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 != 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
|
|
// its own is held to; two ids Claude Code matches as one get the
|
|
// smaller window
|
|
top, entries = claudePlan([]claudeBudget{{id: "a", window: 1000000}, {id: "b", window: 200000}, {id: "B", window: 128000}}, 300000, nil)
|
|
if top != 1000000 || !reflect.DeepEqual(entries, map[string]int{"b": 128000}) {
|
|
t.Fatalf("the user's top-level: %d %v", top, entries)
|
|
}
|
|
// 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)
|
|
}
|
|
// a Desktop tier's pick Claude Code runs as a Claude model
|
|
// (behavesAs, moer2831) would run at that model's window: it is told
|
|
// its own, even where it is the largest
|
|
top, entries = claudePlan([]claudeBudget{{id: "a", window: 1000000}, {id: "b", window: 1000000, behaves: true}, {id: "c", window: 400000, behaves: true}}, 0, nil)
|
|
if top != 1000000 || !reflect.DeepEqual(entries, map[string]int{"b": 1000000, "c": 400000}) {
|
|
t.Fatalf("behavesAs: %d %v", top, entries)
|
|
}
|
|
// an id magpie's editor can't put in a key path gets no entry
|
|
if _, entries = claudePlan([]claudeBudget{{id: "a", window: 400000}, {id: "b*", window: 100000}}, 0, nil); len(entries) != 0 {
|
|
t.Fatalf("b*: %v", entries)
|
|
}
|
|
}
|
|
|
|
// TestBudgetPath: a dot in a model's id is part of its key, as Claude Code
|
|
// reads it, and the "[1m]" mark is not.
|
|
func TestBudgetPath(t *testing.T) {
|
|
if p := budgetPath("magpie/v/gpt-6.1-sol[1m]"); p != `modelSettings.magpie/v/gpt-6\.1-sol.autoCompactWindow` {
|
|
t.Fatal(p)
|
|
}
|
|
if got := budgetsRead(`{"a.b":{"autoCompactWindow":5},"c":{"autoCompactWindow":"auto"},"d":{"effortLevel":"high"}}`); !reflect.DeepEqual(got, map[string]string{"a.b": "5", "c": "auto"}) {
|
|
t.Fatal(got)
|
|
}
|
|
}
|