DSH compacts on the session's latest model (compaction-basic with no summarizationModel). A session on magpie/workbuddy/deepseek-v4.1-flash switched to another model compacted on WorkBuddy first, got 429, and the switch failed. DeepSeek Harness's opened row on the Agents page now has a "compaction model" square (compact_model), offered once dsh is on magpie's route. It is magpie's own Live setting (settings.DshCompactModel), so nothing is written into dsh's profiles and no restart is needed. The gateway moves a dsh compaction to it (dshCompactTo, Route.Moved why "dsh-compact") when the model is enabled, served by its exact id and allowed to the key; else the compaction stays as asked with a log line. The Routing page says why. On magpie's llm-pi-ai routes DSH sends no x-deepseek-harness-compact mark, so its compaction is now known by compaction-basic's own ask (@deepseek-ai/dsh-compaction-basic 0.0.1-rc.3, the latest) in compactAsks. As a result DSH compactions show as Compaction in Usage and Routing, and a group's Compact rule reaches them too. The options are spelt magpie/<id> like the model field's, so `magpie dsh deepseek/flash` still sets the model (fieldForValue gives a bare value to the first field offering it). CLI: `magpie dsh compact_model magpie/deepseek/flash`; API: /api/set. zh, zh-TW, ja and de strings added. Run (mote): go test -count=1 -timeout 45m on internal/gateway, provider: ok at the base before the rebase on 0842bc517; agent, gui, settings, settingsapi, and the gateway's TestDsh/TestCompacting/ TestRuleCompact: ok at this head. The first agent run caught the square reading dsh's profiles at a stopped WSL distro (TestWSLColdPlaceOpensNothing, #3896); its options now look at nothing at a cold place. go vet on darwin, GOOS=linux -tags nogui and GOOS=windows: clean. gofmt clean. GUI in chromium and webkit: dsh-compact-model (new, 5 languages x 2 widths), desktop-subagent-model, codex-subagent-model, routing-moved-why, i18n-keys, i18n-en-no-cjk, claude-subagent-effort-row, codex-start-model-field, model-test-why and agent-connect-no-models: 140 of 140 pass; after the rebase (i18n.js changed upstream) i18n-keys, i18n-en-no-cjk, dsh-compact-model and routing-moved-why 48 of 48. Broken by hand, each red: dropping the compactAsks line (TestCompacting, TestDshCompactMoved on all three protocols), skipping the move in serve (TestDshCompactMoved), dropping the agent check (TestDshCompactLeft's other agent), taking the square out of extra() and dropping the routing story's case (dsh-compact-model.test.cjs). Not tried: a real DeepSeek Harness desktop app (none on this Mac or on mote); the compaction text was checked against the npm package's source. DS Bot's requests can't be told from dsh's, so its compactions follow the same setting, though it has no square of its own.
65 lines
2.4 KiB
Go
65 lines
2.4 KiB
Go
package agent
|
|
|
|
import (
|
|
"os"
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// #5395 (Musikrv77852 on X): DeepSeek Harness's row picks the model its
|
|
// compactions go on, offered once dsh is on magpie's route. It is magpie's
|
|
// setting, read by the gateway on each request: picking it writes nothing
|
|
// into dsh's profiles, and needs no restart. DS Bot, whose requests the
|
|
// gateway can't tell from dsh's, has no square of its own.
|
|
func TestDshCompactionModelField(t *testing.T) {
|
|
home, dir, web := dshRouteHome(t)
|
|
dshKeyFixture(dir)
|
|
if err := os.WriteFile(web, []byte(dshProfileTemplate), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
a := dsh(home)
|
|
f := a.Field("compact_model")
|
|
if f == nil || !f.Live || !f.Quiet || f.Label != "compaction model" {
|
|
t.Fatalf("no live compaction model field: %+v", f)
|
|
}
|
|
if opts := f.Options(nil); len(opts) != 0 {
|
|
t.Fatalf("offered %d models before dsh is on magpie's route", len(opts))
|
|
}
|
|
if err := a.Field("model").Set("magpie/deepseek/pro"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
dshWiredOnce()
|
|
a = dsh(home)
|
|
f = a.Field("compact_model")
|
|
// spelt as the model field's, magpie/<id>, so a bare value is still
|
|
// the model's to the CLI (fieldForValue gives it to the first field
|
|
// offering it)
|
|
if !slices.ContainsFunc(f.Options(nil), func(o Option) bool { return o.Value == "magpie/deepseek/flash" }) {
|
|
t.Fatalf("magpie's models not offered: %+v", f.Options(nil))
|
|
}
|
|
if slices.ContainsFunc(f.Options(nil), func(o Option) bool { return o.Value == "deepseek/flash" }) {
|
|
t.Fatal("a bare id is offered, which the CLI would take from the model")
|
|
}
|
|
before, _ := os.ReadFile(web)
|
|
for _, v := range []string{"magpie/deepseek/flash", "deepseek/flash"} {
|
|
if err := f.Set(v); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := provider.DshCompactModel(); got != "deepseek/flash" || f.Get() != "magpie/deepseek/flash" {
|
|
t.Fatalf("set %q: held %q, read %q", v, got, f.Get())
|
|
}
|
|
}
|
|
if after, _ := os.ReadFile(web); string(after) != string(before) {
|
|
t.Fatalf("the pick wrote dsh's profile:\n%s", after)
|
|
}
|
|
if err := f.Set(""); err != nil || provider.DshCompactModel() != "" {
|
|
t.Fatalf("unset: %v, %q", err, provider.DshCompactModel())
|
|
}
|
|
bot := dshOn(here(home), dir, dsbotID, func() string { return "" }, func() string { return dsbotProfile })
|
|
if bot.Field("compact_model") != nil {
|
|
t.Fatal("DS Bot has a compaction model square of its own")
|
|
}
|
|
}
|