KorenKrita on Discord (cause confirmed by them): with Claude Code's
subagent model unset ("Claude Code picks") and a subagent effort set,
claude.go wrote spell(tierWith(main model, effort)) into
env.CLAUDE_CODE_SUBAGENT_MODEL. That pinned every subagent to the main
model, so Claude Code's own pick (the Agent call's model, the subagent's
frontmatter) never ran.
Agent wiring (internal/agent/claude.go):
- With no subagent model, magpie writes no effort, and
CLAUDE_CODE_SUBAGENT_MODEL stays unset.
- The saved effort is kept, not deleted (the user set it). It lives in
the stash under claude.subagent_effort, and the subagent effort's Get
reads "" while there is no model. A model picked later takes it
("v/glm:high").
- A value an older magpie wrote that way (the main model at an effort,
not own, while routed: subagentFollowing) is moved into the stash and
taken out of the env by writeTiers and by Sync on start.
- subagentOwn no longer counts that value as the user's own model.
- Doc: docs/subsystems/agent-wiring.md, the Claude Code "subagents" entry.
GUI (window, opened Claude Code row):
- The subagent effort moves from its square under the session defaults
to the right of the Subagents row. It uses the tier rows' markup and
code (effortBtn in connectPanel, ag-eff), so it lines up with
Opus/Sonnet/Haiku's effort.
- While the subagent model is unset it shows Default, is disabled, and
its title says "Set a subagent model first". The new string is in zh,
zh-TW, ja and de.
- The old square is removed from the opened row. No other layout changes.
- The tray panel's own square is left alone: #3308.
Tests:
- New internal/agent/claude_subagent_effort_test.go
(TestClaudeSubagentEffortNeedsAModel). On the old code it is red:
an effort with no subagent model wrote
CLAUDE_CODE_SUBAGENT_MODEL="v/glm:high"
With the Sync branch broken by hand it is red at "Sync left an older
magpie's CLAUDE_CODE_SUBAGENT_MODEL="v/flash:high"". It also checks
that a set model plus effort still writes "v/glm:low".
- claude_tiereffort_test.go now expects no env for an effort with no
model.
- New internal/gui/tests/claude-subagent-effort-row.test.cjs (16 cases):
chromium/webkit x en/zh x 1100/560px x with/without a subagent model.
It checks:
- the control sits in the Subagents row at the tier efforts' x and
height;
- with no model it is disabled at Default and opens no slider;
- with a model it posts subagent_effort, with no scroll;
- the old square is gone.
It is red against the old app.js ("the old square is still there").
- tier-effort.test.cjs is updated for the moved control.
Run at this tree (parent f985d6bdb):
- go test -count=1 ./internal/gui/ ./internal/agent/ ./internal/provider/:
ok.
- GUI: claude-subagent-effort-row, tier-effort, i18n-keys,
subagent-effort, claude-subagents-pick, desktop-subagent-model,
agent-prefs, agent-tweak-fold, claude-signin and agent-field-names:
147/147.
- gofmt clean. go vet darwin, linux -tags nogui and windows: ok.
Run at the same change before its last rebase:
- Full Go suite (`go test -count=1 -timeout 45m ./...`, sandbox HOME,
through the suite lock) at 11b9d671c (on 45593cc1d): every package ok
but internal/gui's TestCoreScriptBudget. app.js was 1,337,535 bytes,
over its 1,337,000 budget, after the rebase brought in upstream growth.
This commit trims its own additions to 1,336,991 (one shared effortBtn,
shorter comments, a shorter new string) and raises no budget.
TestCoreScriptBudget now passes.
- Full Go suite at 41737d214 (on 802fb6e61): all 69 packages ok.
- Whole GUI suite at 41737d214 (11,741 tests, 5.8h at load ~250): 48 red,
none from this change.
- Red the same on origin/main 45593cc1d, all filed: quota-count-wrap
and quota-name-translated (#2228), quota-reads (#2150), s3-sync
(#2448), usage-agents-hide (#2276), usage-checkin (#2549, #3091),
usage-fold (#2163), usage-ledger (#3104, #3001).
- Red under load only and green alone: agent-notice-lang (#2960),
agent-stale-copies (#1949), modal-morph (#3179), plugin-card-update
(#3079), plugin-github (#3218), and agent-field-names and
api-key-theme (filed as #3307).
- Also seen red once under load: codex-subagent-model's fixed 300ms
wait (#3277).
Not tried:
- a real Claude Code run reading the written settings;
- the Windows box;
- the whole GUI suite again after the string was shortened (only the
files above were run);
- the tray panel (#3308).
98 lines
3.5 KiB
Go
98 lines
3.5 KiB
Go
package agent
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/catalog"
|
|
"github.com/yetone/magpie/internal/edit"
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// A subagent effort with no subagent model ("Claude Code picks") writes no
|
|
// CLAUDE_CODE_SUBAGENT_MODEL: the main model at that effort there pinned
|
|
// every subagent, an Explore asking for haiku too, to the main model
|
|
// (KorenKrita on Discord). The effort is kept, not applied, and goes with a
|
|
// model the subagents are given later; a model and effort together are
|
|
// written as before. One an older magpie wrote is taken out by Sync.
|
|
func TestClaudeSubagentEffortNeedsAModel(t *testing.T) {
|
|
home := t.TempDir()
|
|
t.Setenv("HOME", home)
|
|
t.Setenv("USERPROFILE", home)
|
|
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
|
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
|
|
if err := provider.Save(provider.Provider{ID: "v", Name: "V", Chat: "https://example.test/v1", Key: "k",
|
|
Models: []string{"glm", "flash"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := catalog.SaveLive("v", "https://example.test/v1", []catalog.Model{
|
|
{ID: "glm", Context: 200000, Efforts: []string{"low", "medium", "high", "max"}},
|
|
{ID: "flash", Context: 128000, Efforts: []string{"low", "high"}},
|
|
}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
path := filepath.Join(home, ".claude", "settings.json")
|
|
writeFile(t, path, `{}`)
|
|
a := claude(home)
|
|
sub := func() (string, bool) { return edit.GetJSON(path, "env.CLAUDE_CODE_SUBAGENT_MODEL") }
|
|
set := func(key, v string) {
|
|
t.Helper()
|
|
if err := a.Field(key).Set(v); err != nil {
|
|
t.Fatalf("%s=%s: %v", key, v, err)
|
|
}
|
|
}
|
|
set("model", "v/glm")
|
|
|
|
// no model of their own: the effort writes nothing
|
|
set("subagent_effort", "high")
|
|
if v, has := sub(); has {
|
|
t.Fatalf("an effort with no subagent model wrote CLAUDE_CODE_SUBAGENT_MODEL=%q", v)
|
|
}
|
|
if a.Field("subagent").Get() != "" || a.Field("subagent_effort").Get() != "" {
|
|
t.Fatalf("read back: %v", a.Values())
|
|
}
|
|
// nor does a new main model
|
|
set("model", "v/flash")
|
|
if v, has := sub(); has {
|
|
t.Fatalf("a new main model wrote CLAUDE_CODE_SUBAGENT_MODEL=%q", v)
|
|
}
|
|
|
|
// a model of their own takes the effort kept
|
|
set("subagent", "v/glm")
|
|
if v, _ := sub(); v != "v/glm:high" || a.Field("subagent_effort").Get() != "high" {
|
|
t.Fatalf("subagents on glm with the effort kept: %q %v", v, a.Values())
|
|
}
|
|
// a model and an effort set together, as before
|
|
set("subagent_effort", "low")
|
|
if v, _ := sub(); v != "v/glm:low" || a.Field("subagent").Get() != "v/glm" || a.Field("subagent_effort").Get() != "low" {
|
|
t.Fatalf("subagents on glm at low: %q %v", v, a.Values())
|
|
}
|
|
// back to Claude Code's pick: the variable goes, the effort is kept
|
|
set("subagent", "")
|
|
if v, has := sub(); has {
|
|
t.Fatalf("subagents back to Claude Code's pick left CLAUDE_CODE_SUBAGENT_MODEL=%q", v)
|
|
}
|
|
set("subagent", "v/flash")
|
|
if v, _ := sub(); v != "v/flash:low" {
|
|
t.Fatalf("subagents on flash with the effort kept: %q", v)
|
|
}
|
|
set("subagent", "")
|
|
|
|
// the main model at an effort, as an older magpie wrote it: Sync takes
|
|
// it out and keeps the effort for a later model
|
|
set("subagent_effort", "")
|
|
if err := edit.SetJSON(path, edit.KV{Path: "env.CLAUDE_CODE_SUBAGENT_MODEL", Value: "v/flash:high"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := a.Sync(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if v, has := sub(); has {
|
|
t.Fatalf("Sync left an older magpie's CLAUDE_CODE_SUBAGENT_MODEL=%q", v)
|
|
}
|
|
set("subagent", "v/glm")
|
|
if v, _ := sub(); v != "v/glm:high" {
|
|
t.Fatalf("the older magpie's effort wasn't kept: %q", v)
|
|
}
|
|
}
|