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.
52 lines
1.8 KiB
Go
52 lines
1.8 KiB
Go
package provider
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
// DeepSeek Harness compacts its context on the model of the session's
|
|
// latest request (compaction-basic's summarizationProvider and
|
|
// summarizationModel unset), so a switch away from a model whose provider
|
|
// has run out of its limit compacts on that model first, and the switch
|
|
// fails with it (#5395). Its own setting for the model lives in each
|
|
// agent preset's whole config, which a profile patch can only replace
|
|
// whole, and a copy of the preset would go stale with the next dsh.
|
|
// settings.DshCompactModel is the model the gateway puts each of its
|
|
// compactions on instead, read on each request, so dsh needn't restart.
|
|
|
|
// DshCompactModel is the model DSH's compactions are put on, "" for the
|
|
// one each asks for. A provider renamed since it was set is named by its
|
|
// new id (RenamedRef).
|
|
func DshCompactModel() string {
|
|
id := strings.TrimSpace(heldSettings().DshCompactModel)
|
|
if id == "" {
|
|
return ""
|
|
}
|
|
return RenamedRef(id)
|
|
}
|
|
|
|
// SetDshCompactModel puts DSH's compactions on id, a model or routing
|
|
// group of magpie's (provider/model, group/<id>); "" leaves each on the
|
|
// model it asks for. One magpie doesn't serve now is kept all the same,
|
|
// as Desktop's subagent model is: the gateway leaves compactions where
|
|
// they are until it is served.
|
|
func SetDshCompactModel(id string) error {
|
|
id = strings.TrimSpace(id)
|
|
if pid, model, ok := strings.Cut(id, "/"); id != "" && (!ok || pid == "" || model == "") {
|
|
return fmt.Errorf("DeepSeek Harness's compaction can't be put on %q: pick one of magpie's models (provider/model)", id)
|
|
}
|
|
s := settings.Load()
|
|
if s.DshCompactModel == id {
|
|
return nil
|
|
}
|
|
s.DshCompactModel = id
|
|
if err := settings.Save(s); err != nil {
|
|
return err
|
|
}
|
|
Changed()
|
|
return nil
|
|
}
|