After #2081 gave Desktop a subagent model, its effort still came from the request. Add subagent_effort beside that model, using the existing effort slider. The live setting DesktopSubagentEffort belongs to magpie; no Claude client file or binary is changed. Empty preserves the request's effort, including disabled thinking. A pick applies only to Desktop requests with an agent id and tools, independently of model replacement: unset, equal and unavailable model picks all work. Reuse the attempt-level fitting; fixed group-member efforts and reasonless models keep their existing precedence. count_tokens applies the pick after unmasked-body restoration. A Codex SubagentPick is not evidence of a Desktop tool turn. Route.Effort keeps the incoming level, SubagentEffort records the configured pick, and tries/usage keep the actual level. Routing explains the pick even without a model replacement. Options follow the target model; a saved level survives a model change. POST /api/settings preserves it. Disconnected preferences, Disconnect/reconnect and restored settings work; a Live pick gives restart advice only when it actually connects the agent. Codex's own settings and default-effort explanation are unchanged. Verification onb9c589ebplus this change, with temp HOME and pinned Go caches: - go test -tags nogui ./...: 53 packages pass. - Gateway effort tests under -race -count=20: pass. - gofmt -l: empty; darwin, linux nogui and windows vet/build: exit 0. - 23 intentional Go behavior breaks produce real FAILs, then pass restored: application, scope, model independence, Default/none, disabled thinking, fitting/member priority, counts, next request, trace, saving/validation, Live notices and model-dependent options. - Three UI breaks fail in both engines at 1100/420: default explanation, missing effort story and missing translation. Restored: Desktop's new controls/story matrix passes 20/20 across five languages. Desktop, Codex, tier/effort and translation regressions pass 97/97. - Desktop-bundled Claude Code 2.1.295 runs real Agent calls through the built gateway, temporary HOME and loopback-only sandbox, all replies local fixtures. Low/high/Default sends its child low/high/xhigh on m2; its lead remains xhigh on m1. All three runs exit 0. The expanded Routing run is not green: Chromium 510/525, WebKit 485/525. These failures reproduce on untouchedb9c589eb, including targeted reruns. The day/row anchor assertions conflict with #2134's at-top rule: undoing that one guard makes all 12 tests pass. A narrow request lies below the viewport; user wheel input makes the failed click pass. WorkBuddy's wheel pointer/hidden-button failures overlap #2115; moving the wheel to the view gutter fixes 3/4 selected cases, one WebKit 420 case remains. The held-member clipping assertion also reproduces on base; its timing cause is not established. This baseline evidence is reported separately in the follow-up feature issue, not counted as passed or fixed here. Not run: the complete GUI suite, the Electron window/Cowork, native Linux/Windows or WebKitGTK. Cross-builds are not runtime checks. Reported-by: Koohoko
125 lines
4.2 KiB
Go
125 lines
4.2 KiB
Go
package agent
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/gateway"
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// Claude Desktop's subagent model field: offered magpie's models once
|
|
// Desktop is on magpie, a pick connecting it as any model pick does, an
|
|
// alias kept by its catalog id, one not served now kept, a bare name
|
|
// refused. Desktop's tiers and Codex's subagent model aren't Live, and a
|
|
// stopped WSL copy keeps the flag.
|
|
func TestDesktopSubagentModelField(t *testing.T) {
|
|
home, _ := desktopSandbox(t)
|
|
if err := provider.Save(provider.Provider{ID: "fake", Name: "Fake", Chat: "http://127.0.0.1:1/v1", Key: "k", Models: []string{"m1"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
a := claudeDesktop(home)
|
|
f := a.Field("subagent_model")
|
|
if f == nil || f.Label != "subagent model" || !f.Quiet || !f.Live {
|
|
t.Fatalf("subagent field: %+v", f)
|
|
}
|
|
if f.Options(nil) != nil {
|
|
t.Fatal("subagent options offered while unwired")
|
|
}
|
|
if err := a.Pick(f.Key, "fake/m1"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !a.Wired() || len(f.Options(nil)) == 0 {
|
|
t.Fatal("subagent pick did not wire Desktop or offer its models")
|
|
}
|
|
if err := f.Set(gateway.DesktopID(provider.Entry{ID: "fake/m1"})); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := f.Get(); got != "fake/m1" {
|
|
t.Fatalf("alias pick %q, want fake/m1", got)
|
|
}
|
|
if err := f.Set("gpt-6"); err == nil {
|
|
t.Fatal("accepted a bare model")
|
|
}
|
|
if err := f.Set("missing/m"); err != nil || f.Get() != "missing/m" {
|
|
t.Fatalf("restored model %q: %v", f.Get(), err)
|
|
}
|
|
if err := f.Set(""); err != nil || f.Get() != "" {
|
|
t.Fatalf("clear %q: %v", f.Get(), err)
|
|
}
|
|
for _, tier := range gateway.DesktopTierNames {
|
|
if a.Field(tier).Live {
|
|
t.Fatalf("tier %s is Live", tier)
|
|
}
|
|
}
|
|
if codex(home).Field("subagent_model").Live {
|
|
t.Fatal("Codex's subagent model became Live")
|
|
}
|
|
stopped := asleep(a, wslKind{}, distro{Name: "Stopped"})
|
|
if !stopped.Field("subagent_model").Live {
|
|
t.Fatal("stopped WSL agent lost the Live flag")
|
|
}
|
|
}
|
|
|
|
func TestDesktopSubagentEffortField(t *testing.T) {
|
|
home, _ := desktopSandbox(t)
|
|
if err := provider.Save(provider.Provider{ID: "fake", Name: "Fake", Chat: "http://127.0.0.1:1/v1", Key: "k", Models: []string{"m1", "m2"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := provider.SetModelEfforts("fake/m1", []string{"low", "high"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
a := claudeDesktop(home)
|
|
f := a.Field("subagent_effort")
|
|
if f == nil || !f.Live || !f.Quiet || f.Label != "subagent effort" {
|
|
t.Fatalf("effort field: %+v", f)
|
|
}
|
|
if len(f.Options(nil)) != 0 || f.Set("high") != nil || a.Wired() {
|
|
t.Fatal("saving an unwired effort offered choices or connected Desktop")
|
|
}
|
|
if err := a.Pick("provider", "magpie"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(f.Options(nil)) != len(provider.MemberEfforts) {
|
|
t.Fatal("inherited model lost effort choices")
|
|
}
|
|
if err := a.Pick("subagent_model", "fake/m1"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
opts := f.Options(nil)
|
|
if len(opts) != 2 || opts[0].Value != "low" || opts[1].Value != "high" {
|
|
t.Fatalf("model's effort choices: %+v", opts)
|
|
}
|
|
if err := a.Pick(f.Key, " HIGH "); err != nil || f.Get() != "high" {
|
|
t.Fatalf("effort pick %q: %v", f.Get(), err)
|
|
}
|
|
if d := a.Drift(); d != nil {
|
|
t.Fatalf("gateway effort caused config drift: %+v", d)
|
|
}
|
|
if !asleep(a, wslKind{}, distro{Name: "Stopped"}).Field(f.Key).Live {
|
|
t.Fatal("stopped WSL field lost Live")
|
|
}
|
|
if err := provider.SetModelReasonless("fake/m1", true); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(f.Options(nil)) != 0 || f.Get() != "high" {
|
|
t.Fatal("reasonless model offered levels or discarded the saved pick")
|
|
}
|
|
if err := f.Set("hard"); err == nil || f.Get() != "high" {
|
|
t.Fatal("invalid effort overwrote the pick")
|
|
}
|
|
if err := f.Set(""); err != nil || f.Get() != "" {
|
|
t.Fatalf("clear effort: %v", err)
|
|
}
|
|
// The effort that was there before connecting (a restored setting)
|
|
// can be restored while disconnected, and the last live pick returns.
|
|
if err := a.Pick(f.Key, "low"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := a.Disconnect(); err != nil || a.Wired() || f.Get() != "high" {
|
|
t.Fatalf("disconnect did not restore the saved preference: %q, %v", f.Get(), err)
|
|
}
|
|
if err := a.Connect(); err != nil || !a.Wired() || f.Get() != "low" {
|
|
t.Fatalf("reconnect did not restore the live pick: %q, %v", f.Get(), err)
|
|
}
|
|
}
|