dsh: a new desktop profile gets magpie's routes when the start is the user's (zyh6036 on X)
DeepSeek Harness Desktop 0.2.1-rc.5's picker listed only "DeepSeek 账号". The app reads $DSH_HOME/profiles/desktop (apps/desktop/src/paths.ts) and makes it from an empty template on its first start. dshFillNewProfiles gave such a profile magpie's routes only when a wired profile started on one of magpie's models; with the web profile wired but started on one of dsh's own, it returned early and the desktop profile stayed bare. Now a bare profile gets the routes alone in that case (no start written, the user's pick stays theirs), and nothing is filled when no profile is wired. Run: - go test ./internal/agent -run TestDshFillNewProfiles on mote ated5872d18: the new TestDshFillNewProfilesWhenTheStartIsTheUsers red on the old code (desktop profile left as the template), green after. - go vet ./internal/agent (darwin, GOOS=linux, GOOS=windows) and go test -count=1 -timeout 45m ./internal/agent on mote: ok (183s). - Real DeepSeek Harness Desktop 0.2.1-rc.5 (official zip, sha512 checked against nightly-mac.yml) on mote, sandbox DSH_HOME, not signed in: first start wrote profiles/desktop/cordis.patch.yml as the empty template; with a route-only patch (no agent-default-model), as this change writes, the picker listed the Magpie group (35 models). Broken by hand: the no-profile-wired guard taken out, the test's last check goes red (web and desktop templates filled). Not tried: the reporter's own patch (not sent yet); a signed-in DeepSeek account in the desktop app; the full go test ./... suite; Windows. At the pushed head (rebased one84870f17): go test -count=1 -run Dsh ./internal/agent on mote ok, gofmt -l clean.
This commit is contained in:
@@ -76,7 +76,7 @@ something else shows up as drift.
|
||||
- dsh takes a model's listed `maxTokens` as every request's output and reserves it, with 65536 of headroom, out of `contextWindow` before deciding when to compact (compaction-basic's `resolveCompactSpec`: the smaller of 80% of the window and window − maxTokens − 65536). A vendor's reply limit near its window had dsh compact at 41248 of a 500000 group (#2823) or fail with no budget (524288/524288, LoKi on Discord; 131072/65536), so magpie lists it held to what leaves dsh half the window to compact in (window/2 − 65536), or to a quarter of the window where that is more (every window under 262144, as VS Code and Copilot in JetBrains hold it), on every route and in the older `llm-deepseek` entry (`dshMaxTokens`). A quarter alone cut DeepSeek's 393216 on its 1000000 window to 250000 (#3298); now it keeps all of it and dsh compacts at 541248, while 500000/393216 is held to 184464 and compacts at 250000. A Max output the user set stays as they set it (`outputOr`), even one that leaves dsh no budget. `TestDshOutputLeavesCompactionRoom`.
|
||||
- Each of magpie's routes has `streamIdleTimeoutMs: 600000` (`dshIdleWait`), the gateway's own wait for a reply's headers (`upstreamHeaderWait`, 10 minutes). llm-pi-ai gives a turn up after 5 minutes without a pi-ai event (`DEFAULT_STREAM_IDLE_TIMEOUT_MS`, 0.1.5 to 0.2.2), and the gateway's `: keepalive` comments (`keepQueued`, `keepQuiet`) are not events: real dsh 0.2.1-rc.2 timed out at a route's 3000ms with comments every second. A turn queued behind dsh's own title request on a plugin serving one request at a time (magpie-gemini-web, `maxConcurrency: 1`) was cut while the gateway and the plugin still waited, and recorded as 499 (tim on Discord). A value already on the route, set in dsh or by hand, stays (`TestDshRoutesWaitAsLongAsTheGateway`, `TestDshRouteKeepsTheUsersIdleWait`). Codex's comment-blind limit is met in the gateway instead (`agentQuietMost`).
|
||||
- While magpie serves, `KeepDshWired` writes the routes again every 30 seconds, since dsh writes over its patch list. A round that writes nothing is kept (`dshRounds`), and the next round does nothing when nothing it reads has changed since. It checks the bytes of dsh's files (every profile's `cordis.patch.yml`, the home layer, `settings.yaml`, `.env`, `.credentials.yaml`, `config.yaml`) and the gateway's address. It also checks `provider.StampNow`: no Changed, plugin change or `filememo.Forget`, the same environment, and the providers', settings' and catalog's files unchanged. The models are built again when that stamp moves, and at least every `dshModelsFor` (5 minutes) for what no stamp sees, such as another app's account file or a date-retired model. Building the whole catalog and every route each round allocated 12 GB of a user's 35.7 GB in 48 minutes (`TestDshRoundWithNothingChangedBuildsNothing`, `TestDshRoundAfterAChangeWritesAgain`).
|
||||
- DeepSeek Harness Desktop (macOS arm64 and Windows x64; no Linux build) reads the same `$DSH_HOME` or `~/.dsh` as the CLI, as its own profile `profiles/desktop` (`resolveDshHome` and `resolveDesktopPaths` in the app's `lib/main.js`; `defaultDshHome` in github.com/deepseek-ai/deepseek-harness's `packages/util/home-paths/src/index.ts` and `apps/desktop/src/paths.ts`), so it takes magpie's routes with no wiring of its own (#2279, liangjinyuan-sihan). Only that app, from deepseek-ai/deepseek-harness (bundle id `com.deepseek.dsh`, productName DeepSeek Harness in `apps/desktop/scripts/electron-builder-config.mjs`), is dsh's: the community "DeepSeek Hermes" (motongv/deepseek-hermes-desktop) v0.1.1337 took for it is not listed or written for (WuSix on Discord, `TestDshOnlyTheOfficialApp`). It is found by `/Applications/DeepSeek Harness.app`, by `%LOCALAPPDATA%\Programs\DeepSeek Harness`, or by the folder its current-user installer records under `HKCU\Software\1bf39983-50d0-5fe0-9ef4-cece76f67c5e` (`InstallLocation`), whose Uninstall key gives the version (`registered` in [`desktopapp.go`](../../internal/agent/desktopapp.go)), so a user who picked another folder is found. With the app installed but never opened there is no `~/.dsh`: the row is still listed, and connecting writes `profiles/desktop/cordis.patch.yml` from dsh's own template (`dshProfileTemplate`) with magpie's routes, which the app keeps on its first start, since it writes only the files that are missing. The notice says the app starts on it the first time it opens (`noticeDsh5`). Disconnect before that first start removes the profile magpie made when nothing else is in it (`dshTidyUnopened`); once the app has opened it, the profile stays and only magpie's entries go (`TestDshDesktopNeverOpened`, `TestDshDesktopRegisteredFolder`; the registry as 0.2.1-rc.2's installer writes it, `TestDshWindowsAsTheInstallerRegistersIt`).
|
||||
- DeepSeek Harness Desktop (macOS arm64 and Windows x64; no Linux build) reads the same `$DSH_HOME` or `~/.dsh` as the CLI, as its own profile `profiles/desktop` (`resolveDshHome` and `resolveDesktopPaths` in the app's `lib/main.js`; `defaultDshHome` in github.com/deepseek-ai/deepseek-harness's `packages/util/home-paths/src/index.ts` and `apps/desktop/src/paths.ts`), so it takes magpie's routes with no wiring of its own (#2279, liangjinyuan-sihan). A profile dsh makes after another was wired (the app opened for the first time after the CLI's web profile) is given magpie's routes by the catalog sync and the serving round (`dshFillNewProfiles`), with the start model the wired ones start on when that is one of magpie's, and with no start when the user picked one of dsh's own there: only the routes, beside dsh's models. That second case was left as dsh's empty template, so the app's picker listed only the DeepSeek account (zyh6036 on X, `TestDshFillNewProfilesWhenTheStartIsTheUsers`). With no profile wired, none is filled. Only that app, from deepseek-ai/deepseek-harness (bundle id `com.deepseek.dsh`, productName DeepSeek Harness in `apps/desktop/scripts/electron-builder-config.mjs`), is dsh's: the community "DeepSeek Hermes" (motongv/deepseek-hermes-desktop) v0.1.1337 took for it is not listed or written for (WuSix on Discord, `TestDshOnlyTheOfficialApp`). It is found by `/Applications/DeepSeek Harness.app`, by `%LOCALAPPDATA%\Programs\DeepSeek Harness`, or by the folder its current-user installer records under `HKCU\Software\1bf39983-50d0-5fe0-9ef4-cece76f67c5e` (`InstallLocation`), whose Uninstall key gives the version (`registered` in [`desktopapp.go`](../../internal/agent/desktopapp.go)), so a user who picked another folder is found. With the app installed but never opened there is no `~/.dsh`: the row is still listed, and connecting writes `profiles/desktop/cordis.patch.yml` from dsh's own template (`dshProfileTemplate`) with magpie's routes, which the app keeps on its first start, since it writes only the files that are missing. The notice says the app starts on it the first time it opens (`noticeDsh5`). Disconnect before that first start removes the profile magpie made when nothing else is in it (`dshTidyUnopened`); once the app has opened it, the profile stays and only magpie's entries go (`TestDshDesktopNeverOpened`, `TestDshDesktopRegisteredFolder`; the registry as 0.2.1-rc.2's installer writes it, `TestDshWindowsAsTheInstallerRegistersIt`).
|
||||
- Ante's `catalog.json` keeps user-added fields in `providers.magpie` the same way (`ante` in [`ante.go`](../../internal/agent/ante.go)); its `auth`, `http_headers`, `extra_body` and `stream_idle_timeout_secs` are what a gateway shared on the local network or reached from WSL needs to send a key. Ante starts a session on the `provider` and `model` of `settings.json`, not on what its catalog holds (#1210), so magpie sets that pair and puts back what it found there; a pick the user makes in Ante while magpie is wired is theirs and stands.
|
||||
- QwenPaw keeps each agent's model in `active_model` of its workspace's `agent.json` (the agents listed in `config.json` under `$QWENPAW_WORKING_DIR`, a legacy `~/.copaw`, or `~/.qwenpaw`) and its providers as files under its secret folder (`$QWENPAW_SECRET_DIR`, also read from the working folder's `.env`, else `<working folder>.secret`) (`qwenpaw` and `qwenpawAgents` in [`qwenpaw.go`](../../internal/agent/qwenpaw.go)). magpie writes `providers/custom/magpie.json` as QwenPaw's console saves a custom provider (OpenAI Chat at the gateway's `/v1`, the key in plain text, which QwenPaw encrypts at its next start, magpie's models in `extra_models`), keeps what the user changes there (a model's `config_overrides`, headers, generation settings), and sets the agent's `active_model` to `magpie`/`<provider>/<model>`, putting back what it found there. A model with reasoning levels is declared `thinking_param_style: "effort"` with the levels QwenPaw names in `reasoning_effort_options` (no `none`: QwenPaw turns an off into Qwen's and DeepSeek's `extra_body` switches), since QwenPaw applies an agent's `thinking_level` only to a model whose card says how it thinks; the effort field is that `thinking_level` in `agent.json`, written with no `thinking_budget`, `inherit` when cleared. Each QwenPaw agent on QwenPaw's own backend is a row (`qwenpaw#<id>` beside the default's `qwenpaw`); the provider file goes when no agent's model, fallback or subagent model names it. QwenPaw reads `agent.json` again when it changes but its providers only at start-up, so the notice says to restart it after the first connect.
|
||||
- AstrBot keeps its providers in `data/cmd_config.json` under its root (`$ASTRBOT_ROOT`, else `~/.astrbot`, the desktop app's, else `~/astrbot`), written with a UTF-8 BOM, which magpie keeps (`astrbot` in [`astrbot.go`](../../internal/agent/astrbot.go)). magpie adds a `magpie` entry to `provider_sources` and one `magpie/<model>` entry per model to `provider`, keeps the user's own entries byte for byte and keeps what the user changes in magpie's (timeout, proxy, enable), and sets the default chat model (`agent_runner.config.model.provider_id`, or `provider_settings.default_provider_id` before the agent runner), putting back what it found there. A pick the user makes while magpie is wired is theirs and stands. The first connect copies the file to `cmd_config.json.before-magpie`. AstrBot reads the file only at start-up and its WebUI writes it back whole on save, so the agent's notice says to restart AstrBot before saving in the WebUI. A Docker install's root is inside its container, which magpie doesn't reach.
|
||||
|
||||
@@ -2487,12 +2487,14 @@ func dshSyncLegacy(f string, models []catalog.Model, gw string) error {
|
||||
// dshFillNewProfiles gives a profile dsh made after magpie set it up — the
|
||||
// desktop app's, opened for the first time after the web's was wired —
|
||||
// magpie's route, and the model magpie set in the others when it starts on
|
||||
// none of the user's: until then it lists dsh's own models alone.
|
||||
// none of the user's: until then it lists dsh's own models alone. Where no
|
||||
// wired profile starts on magpie's route (the user picked one of dsh's own
|
||||
// there), the route alone is given, beside dsh's models (zyh6036 on X).
|
||||
func dshFillNewProfiles(files []string, models []catalog.Model, gw string) error {
|
||||
if len(models) == 0 {
|
||||
return nil
|
||||
}
|
||||
model := ""
|
||||
model, wired := "", false
|
||||
var bare []string
|
||||
for _, f := range files {
|
||||
_, items, err := dshRead(f)
|
||||
@@ -2503,21 +2505,22 @@ func dshFillNewProfiles(files []string, models []catalog.Model, gw string) error
|
||||
bare = append(bare, f)
|
||||
continue
|
||||
}
|
||||
wired = true
|
||||
if i := dshFindLast(items, "agent-default-model"); i >= 0 && model == "" {
|
||||
if c := dshConfig(items[i]); isDshRoute(c["provider"]) {
|
||||
model = c["model"]
|
||||
}
|
||||
}
|
||||
}
|
||||
if model == "" {
|
||||
return nil
|
||||
if !wired {
|
||||
return nil // dsh not set up through magpie: nothing to give
|
||||
}
|
||||
for _, f := range bare {
|
||||
head, items, err := dshRead(f)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if i := dshFind(items, "agent-default-model"); i < 0 || dshOurs(items[i]) {
|
||||
if i := dshFind(items, "agent-default-model"); model != "" && (i < 0 || dshOurs(items[i])) {
|
||||
if err := dshSetFile(f, magpieID+"/"+model, true, models, gw); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -481,6 +481,57 @@ func TestDshFillNewProfilesFillsABareProfile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// zyh6036 on X: DeepSeek Harness Desktop's picker listed only "DeepSeek 账号"
|
||||
// while the web profile, wired, started on one of dsh's own models. A new
|
||||
// profile was filled only when a wired one started on magpie's route, so
|
||||
// the desktop app's stayed dsh's empty template. It now gets magpie's route
|
||||
// beside dsh's own models, and no start model: the user's pick stays theirs.
|
||||
func TestDshFillNewProfilesWhenTheStartIsTheUsers(t *testing.T) {
|
||||
home, dir, web := dshRouteHome(t)
|
||||
desktop := filepath.Join(dir, "profiles", "desktop", "cordis.patch.yml")
|
||||
os.MkdirAll(filepath.Dir(desktop), 0o755)
|
||||
os.WriteFile(web, []byte("# Your patch layer for this dsh profile.\n"+
|
||||
dshRouteFixture("deepseek/pro", "deepseek/flash")+
|
||||
"- id: agent-default-model\n config:\n provider: deepseek-account\n model: deepseek-v4-pro\n"), 0o644)
|
||||
os.WriteFile(desktop, []byte(dshProfileTemplate), 0o644)
|
||||
if err := dshSync(dir, gateway.URL()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
b, _ := os.ReadFile(desktop)
|
||||
for _, want := range []string{"id: llm-pi-ai", "displayName: Magpie", " magpie:", "id: deepseek/pro"} {
|
||||
if !strings.Contains(string(b), want) {
|
||||
t.Fatalf("the desktop profile not given %q:\n%s", want, b)
|
||||
}
|
||||
}
|
||||
if strings.Contains(string(b), "agent-default-model") {
|
||||
t.Fatalf("a start model written where the user had picked theirs:\n%s", b)
|
||||
}
|
||||
if d := dsh(home).Check(); d != "" {
|
||||
t.Fatalf("check: %s", d)
|
||||
}
|
||||
|
||||
// the serving round, for a profile the app makes while magpie runs
|
||||
os.WriteFile(desktop, []byte(dshProfileTemplate), 0o644)
|
||||
if trouble := dshWiredOnce(); trouble != "" {
|
||||
t.Fatal(trouble)
|
||||
}
|
||||
if b, _ := os.ReadFile(desktop); !strings.Contains(string(b), "apiKeyEnv: "+dshKeyRef) {
|
||||
t.Fatalf("the round left the desktop profile bare:\n%s", b)
|
||||
}
|
||||
|
||||
// no profile wired, dsh not set up through magpie: none is filled
|
||||
os.WriteFile(web, []byte(dshProfileTemplate), 0o644)
|
||||
os.WriteFile(desktop, []byte(dshProfileTemplate), 0o644)
|
||||
if err := dshSync(dir, gateway.URL()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, f := range []string{web, desktop} {
|
||||
if b, _ := os.ReadFile(f); string(b) != dshProfileTemplate {
|
||||
t.Fatalf("%s filled with nothing wired:\n%s", f, b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDshWriteErrorReadsTheSameEveryRound(t *testing.T) {
|
||||
one := dshWriteError(&os.PathError{Op: "open", Path: "/x/.cordis.patch.yml.4236419057.tmp", Err: os.ErrPermission})
|
||||
two := dshWriteError(&os.PathError{Op: "open", Path: "/x/.cordis.patch.yml.3958428140.tmp", Err: os.ErrPermission})
|
||||
|
||||
Reference in New Issue
Block a user