magpie's web-search-deepseek row in dsh's cordis.patch.yml was written
with the model dsh starts on (ref). The gateway then sent each search to
that model, which can't search itself and asked the searcher in turn:
two requests per search, and timeouts when the start model can't take
concurrent calls. The user had picked "6 Luna" under Settings › Web
search, and it was never written.
gateway.NamedSearchModel gives the searcher Settings names as
"<provider>/<model>" (empty when none is named, search is off, the one
named can't be used, or it searches with no model). dshSearchModel uses
it for the row on Set and on dshRouteAgain's ~30s pass, so a change in
Settings reaches dsh's file, and clearing it gives the start model
back. A row the user wrote themselves (no # magpie) stays untouched.
Run: go test -tags nogui ./internal/agent -run TestDsh (ok);
TestDshSearchAsksNamedSearcher fails with dsh.go and dsh_search.go
reverted; gofmt -l clean. Not tried with a real dsh, nor whether a real
searcher model answers dsh's web_search end to end.
dsh's llm-pi-ai sets one api for a whole route, so magpie's single
"magpie" route asked every model over Chat Completions. A GPT served on
Responses, or a Claude served on Messages, was translated from Chat, and
its sealed reasoning was lost between tool calls. 01huadalang asked for a
group per protocol.
What changed:
- dshPutRoute writes up to three routes from each model's catalog APIs
(dshRouteOf): magpie (openai-completions, as before, for Chat models,
Gemini-native ones, groups and agent-bridged sign-ins),
magpie-responses (openai-responses, gateway /v1) and magpie-anthropic
(anthropic-messages, the gateway root, forceAdaptiveThinking where
gateway.AdaptiveThinking). A route left with no models is taken out.
An api the user picked for a route in dsh's Models page is kept, and so
are keys they added to it.
- The start (agent-default-model) names its model's route on a pick, an
effort change, and the home layer's mirror. Sync moves a start on one of
magpie's routes to the route its model is now on (dshStartOnItsRoute),
keeping its mark, effort and other keys. A start on the user's own
route stays.
- dshCheck checks each route's baseURL against its own api, and asks the
route the start names to list its model.
- Disconnect, dshOurs, dshKeepPick and dshFillNewProfiles know all three
routes. sessions' dshGatewayProvider counts dsh sessions on any of
them as magpie's.
- docs/subsystems/agent-wiring.md: a line on the routes.
Known limit: a dsh session resumed on a model that has since moved
routes asks for the model to be picked again once, since dsh finds a
model by route and id.
Run:
- go test -tags nogui ./internal/agent (whole package, default order)
and ./internal/sessions -run TestDsh: pass. New tests
TestDshRoutesAModelOnItsNativeAPI,
TestDshSyncMovesAStartToItsModelsRoute,
TestDshCheckSaysAStartOnAnotherRoutesModel and
TestDshGatewayProviderTakesEveryRouteOfMagpies. With dshRouteOf forced
back to the single route, the three agent tests go red.
- Real dsh (headless, sandbox HOME and DSH_HOME) on patches magpie wrote,
pointed at a fake gateway: the start on magpie answered from
/v1/chat/completions, the one on magpie-responses from /v1/responses
(reasoning.effort high), and the one on magpie-anthropic sent
/v1/messages with thinking adaptive and output_config.effort high. dsh
accepted all three routes. Its Anthropic turn then ended on my fake's
SSE, not on the wiring.
- gofmt -l clean. go vet -tags nogui for darwin, GOOS=linux and
GOOS=windows on internal/agent and internal/sessions.
A Chinese window said "ZCode 已接入 magpie. ZCode reads its providers at
start-up — restart ZCode …": the notice an agent gives after a change
(state.notice) was English text written in place in each agent's file, and
i18n.js had no entry for any of them.
What changed:
- internal/agent/notice.go: a notice is a template registered with
newNotice ("Restart {agent} to …"), filled with say(kv...); Notices()
lists every one. All the agents' notices (claude, codex daemon, zcode,
agy, cursor-local, wsl, AstrBot's added today, …) are now such templates, the issue's list
being a sample of them.
- i18n.js: every template has a zh, zh-TW, ja and de translation, and
NOTICES lists them. tNotice() reads a notice of several joined: longest
template first, a {slot} never runs over a sentence's end, and a notice
with any part that has no template (a plugin's own) reads as given
rather than half in each language. withNotice() joins the status line
and the notice with 。 in zh/ja.
- app.js: the six places that showed state.notice use withNotice.
Tests:
- TestEveryNoticeIsTranslated: every Notices() template is in NOTICES and
in each language table, with the same slots. Fails with the zh ZCode
line deleted from i18n.js (tried).
- TestNoticesAreTemplates: an AST scan for English written in place as a
Notice. Fails with zcode.go's literal put back (tried).
- tests/agent-notice-lang.test.cjs: every template, filled, alone and
joined, plus a plugin's notice, and connecting ZCode as the reporter
did; en, zh, zh-TW, ja, de at 1100 and 420px, Chromium and WebKit:
22/22. Its zh subtests fail without the zh line.
Run: go test -tags nogui ./internal/agent ./internal/gui; gofmt -l;
GOOS=linux and GOOS=windows go vet -tags nogui ./internal/agent
./internal/gui; the full GUI suite (node --test, both engines, -concurrency 6,
machine load ~140): 5130/5195, 64 failing in 22 files. Rerun alone, 16
files pass; mobile-web, old-webkit, panel-usage and routing-context/
group/keys-fold fail the same on the base commit, b6a263b9.
go test -tags nogui -timeout 40m ./... on the rebased tree: every package
ok but internal/gateway, whose TestQueuedStreamKeptAliveForTheMinute hit
its 1.5s read deadline at a machine load of ~130; it passes -count=3 run
alone, and this change touches nothing it runs.
What dsh 0.2.0-rc.2 changed (read in @deepseek-ai/dsh-settings and
dsh-agent-default-model from npm): ~/.dsh/settings.yaml is gone. On its
first boot dsh renames it to settings.yaml.imported and merges its sections
into the booted profile's patch list (profiles/<name>/cordis.patch.yml);
nothing reads the .imported file afterwards. A /model pick is no longer
kept in settings.yaml either: agentDefaultModel.saveSelection goes through
ConfigEditor.edit, which replaces the config of the profile's last
agent-default-model entry. That entry is magpie's, so the user's pick sits
under magpie's "# magpie" mark. Profile paths, the home layer, .env and
.credentials.yaml are unchanged.
What broke: Disconnect took that entry for magpie's own, dropped it and put
back what magpie stashed from before it connected, so the model picked in
dsh (or imported from settings.yaml) was lost. Seen with real dsh
0.2.0-rc.2: after the import, Disconnect left `[]` and dsh started on its
shipped deepseek-flash instead of the imported deepseek-v4-flash.
Fix: dshKeepPick, run per profile before Disconnect takes magpie's wiring
out, hands a marked agent-default-model that is off magpie's route back to
the user (mark removed, old stash discarded). An entry on magpie's route,
or one on the pre-0.1.5 wiring, is still magpie's. dshStart still reads a
settings.yaml not yet imported, which dsh will put over the booted profile.
Run: TestDshPickSavedIntoMagpiesEntryOutlivesDisconnect (fixture from the
patch real dsh 0.2.0-rc.2 wrote) fails on the old code ("the pick made in
dsh was lost", the stashed deepseek-v4-pro came back) and passes. Real dsh
0.2.0-rc.2 under a temp HOME/DSH_HOME, fake gateway on 127.0.0.1:3561:
`dsh headless "say hi"` sent POST /v1/chat/completions, Bearer magpie,
model deepseek/pro to it, before and after a settings.yaml import; after
Disconnect `dsh headless --dump-config` keeps deepseek-v4-flash;
reconnecting sends deepseek/flash to the fake gateway. go test -tags nogui
./... (temp HOME, pinned caches) passes, -race -count=5 -run TestDsh
passes, gofmt -l clean, go vet and GOOS=linux/windows go vet -tags nogui
./internal/agent pass.
star on Discord reported DeepSeek Harness Desktop with the red
"已不经过 magpie" line. One way there that a desktop user meets: the
CLI's web profile wired, then the desktop app opened for the first time
while magpie runs. dsh makes profiles/desktop/cordis.patch.yml as its
empty template ([]), dshCheck says the desktop profile has none of
magpie's models (Drift "unwired"), and only dshSync — the catalog sync,
at magpie's start or a catalog change — filled new profiles, so it stayed
so until Reapply or a restart. The reporter's exact detail is cut off in
the screenshot, so this is a likely cause, not a confirmed one.
dshWiredOnce, the 30s serving round, now runs dshFillNewProfiles over a
profile that is dsh's empty template, beside the wired ones: magpie's
route and start go in as the catalog sync would put them. A profile with
entries of its own and no route is the user's and is still left alone.
Run: TestDshDesktopProfileMadeWhileServing fails on the old code ("the
round left the desktop profile bare"), passes with the fix, and checks a
user's own unrouted profile is not written. go test -tags nogui
./internal/agent ./internal/gui under a temp HOME with pinned caches: ok;
go test -race -run TestDsh -count=3: ok. gofmt clean; go vet darwin,
GOOS=linux -tags nogui, GOOS=windows; go build darwin, linux nogui,
windows: ok. Not tried with the real desktop app live.
star on Discord: "DeepSeek Harness 就是现在已经有桌面版了,但是他还是非要找CLI".
With DeepSeek Harness Desktop in use and no dsh on PATH, the Agents page
said 未找到 CLI and Install another agent offered npm's dsh: CLIMissing
(#843) took ~/.dsh without a CLI for an uninstall. The desktop app
(DeepSeek Harness.app, com.deepseek.dsh, 0.2.0-rc.2 from
download.deepseek.com) keeps the same ~/.dsh — its own profile,
profiles/desktop/cordis.patch.yml, and .credentials.yaml — and needs no
CLI; its terminal command (Manage dsh Command…) is optional.
- desktopapp.go: dsh's app is known by its bundle id on macOS and by
%LOCALAPPDATA%\Programs\DeepSeek Harness\DeepSeek Harness.exe on
Windows (electron-builder per-user NSIS, productName DeepSeek Harness,
getWindowsInstallationDirName); HasApp says either is installed.
- install.go: CLIMissing is false with the agent's desktop app installed,
so the GUI row, Install another agent and /api all follow; the app's
version shows through the existing CLI().App path.
- dsh.go: the restart notice also sees DeepSeek Harness.app running.
The red "已不经过 magpie" line in the report is a separate dshCheck
finding, not caused by the missing CLI: a desktop-only ~/.dsh shaped
from the app's real new-profile template wires cleanly (Check "", no
Drift; TestDshDesktopOnlyWired). The reporter's exact detail is cut off
in the screenshot and is not reproduced.
Run: TestDshDesktopAppIsNoMissingCLI fails on the old code ("with the
desktop app: missing true, offered true"; with the Windows path removed,
"with the Windows app: missing true, offered true"), passes with the
fix. go test -tags nogui ./internal/agent ./internal/gui under a temp
HOME with pinned caches: ok. gofmt -l clean; go vet darwin, GOOS=linux
-tags nogui, GOOS=windows on both packages; go build darwin,
GOOS=linux -tags nogui, GOOS=windows: ok. Not tried: the real desktop
app running live (not installed here; its userData isn't redirected by
a sandbox HOME), a real Windows install.
The drift check asked only whether refs.MAGPIE_GATEWAY_KEY equals the key
magpie writes into .env, so a caller key the gateway itself issued — which
dsh's store prefers and the gateway authenticates — was named as "another
MAGPIE_GATEWAY_KEY" and the user was told to remove it there, while
delete → disconnect → re-apply wrote the very same state back. The check
now asks the gateway's own Authenticate first: a key it takes means dsh is
going through magpie, and only a key it would refuse (a foreign one, a
switched-off one) is drift. The .env side needs nothing: the serving round
rewrites .env to magpie's key, so a stray value there heals itself.
TestDshStoreHoldingAGatewayCallerKey (a key from access.Update add-key in
the store's refs) failed without the change with the "holds another
MAGPIE_GATEWAY_KEY" drift; with it the check is quiet, and a key the
gateway doesn't take still reports.
Verified: go test -tags nogui ./internal/agent -count=1; the three dsh
store tests under -race -count=10; gofmt -l clean; go vet -tags nogui
./internal/agent; go build and GOOS=linux/GOOS=windows go build -tags
nogui.
Generated-by: GLM-5.3-Flash (ZCode)
dshWiredOnce built magpieModels("dsh") before looking for a profile, so every magpie, dsh or not, built the catalog every 30 s and threw it away: 93% of what a magpie at rest allocated (pprof heap?gc=1 delta over 120 s, a linux nogui `magpie web` in Docker on a copy of a real config with 13.5k Codex and Claude Code sessions mounted read-only). That garbage kept the heap at its GC goal, about twice what it keeps. It now returns before the catalog when there is no profile; with one, nothing changes.
Same measurement, this commit and the warm-up one together: idle allocation 73 MB per 2 min -> 6.8 MB (3.8 MB of it the profile read itself); RSS at rest after the first minutes ~250 MB -> ~203 MB, the heap no longer climbing 125 -> 192 MB between GCs. TestDshRoundWithoutDshBuildsNoCatalog fails without the change (475 allocations a round) and passes with it. go test -tags nogui ./internal/agent (Docker golang:1.26.8, non-root, temp HOME), go vet -tags nogui ./internal/agent for linux, windows and darwin, and gofmt -l pass. Not measured on macOS: a fresh build there hangs at exec behind syspolicyd today.
dsh reads a patch list live and keeps the model its sessions start on
across its own saves of the file (its desktop app writes the list anew
from a snapshot as it saves), but such a save has been seen to take
magpie's route out while keeping the start: the providers beside
magpie's stayed, the start still named magpie's, and the row went red
"no longer goes through magpie" until Apply again — which the next save
reddened again.
The start naming a model of magpie's is what says magpie was not taken
off: taking it off is the switch's doing and it takes the start with it,
and a list whose start is dsh's own or the user's stays as it is. So
dshRouteAgain writes the route back beside the user's own where the
start survives it, and dshCheck says nothing for the loss where a round
can repair it — said with no catalog to write from, it stands as before.
yetone's review of #1029: the home layer is only written into where it
already holds an llm-pi-ai entry of its own — its config replaces every
profile's whole entry (dshOver), so one magpie added there would take the
user's own providers out of dsh's list (#804) — and the loop over the
other profiles no longer skips itself with no catalog: only a profile the
round can write back is passed over, and one taken off magpie for real is
still said. A list still on the old wiring is dshMove's, not the round's
to write beside.
Co-authored-by: wizzy-yang <wizzy-yang@users.noreply.github.com>
dsh's web search is a plugin of its own, web-search-deepseek, which signs each search to DeepSeek's Anthropic API with DEEPSEEK_API_KEY, so a dsh that reaches its models through magpie alone failed every search asking for that key. While dsh starts on a model of magpie's, magpie writes a marked web-search-deepseek entry in each profile: the gateway's /v1 as baseURL, MAGPIE_GATEWAY_KEY as apiKeyEnv and that model. The gateway answers the plugin's web_search_20250305 request as Anthropic does, by the model's own search or magpie's (web_search_tool_result blocks). A row of the user's, or a DEEPSEEK_API_KEY dsh has in .env or its key store, is left as it is. The entry goes with dsh's own model or Disconnect, and moves with the gateway's address. The row's Notice says when magpie has nothing to search with. TestDshSearchThroughGateway is new and fails without the change. Tested end to end in a sandbox (own HOME and DSH_HOME, gateway on 3493, the real DeepSeek account): real dsh 0.2.0-rc.2 headless called web_search, got eight results through magpie, and answered https://golang.google.cn/blog/go1.26; magpie dsh default took the entry out of all three profiles. go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass.
* Add German translation and harden paths against unset env vars
Add a German locale to the GUI, tray menu, usage alerts and website home page, and refuse to start when the home folder is unset or relative so nothing is written under the working folder; the pi plugin no longer adopts the user's PI_CODING_AGENT_DIR, and an inherited APPIMAGE no longer selects portable mode. Scripts refuse to run from the wrong folder or empty a shared out folder, and a new internal/testenv sandboxes every test package from the user's real files, which also fixes the Claude picker and Termux installer tests on Windows.
* Makefile: know magpie's folder by its go.mod, so paths with spaces work
The check compared $(CURDIR) with $(dir $(abspath …)), which make splits on spaces, so a checkout under 'My Projects' or 'John Doe' refused every target. It now reads go.mod relative to the working folder and wants magpie's module there: make -C and a symlinked Makefile work, make -f from another folder still stops before any recipe runs.
* i18n: German for the strings main added since, with a parity test
75 strings main added (group order, patterns, slow-start wait, usage caps, RTK savings …) get their German, and two that main dropped go. gui-de.test.cjs checks, as gui-ja does, that de has every zh string with its placeholders and tags, and that the window reads in German when picked or on a German system.
* appdir: ignore relative folder variables when reading, keep them for children
CheckEnv no longer unsets anything. magpie reads the XDG folders, APPDATA/LOCALAPPDATA and every agent's folder variable through appdir.Getenv/LookupEnv, which pass over a relative value; the environment stays as it is, so the agents magpie starts get the variable as the user set it. That covers what proc.UserPath lends from the login shell too, which is set after main's check and reached the desktop app unchecked. On Windows a path rooted on the current drive (\Users\x, Git Bash's /c/x) counts as usable, and magpie version and help answer without a home, before run makes any folder.
* Sandbox the tests main added since
internal/wslrun gets testenv's TestMain, and four tests main added that set HOME alone set their home with testenv.SetHome, so on Windows they don't read the runner's profile through USERPROFILE.
* agentenv: PI_CONFIG_DIR and OPENCODE_DB take relative names on purpose
omp puts $PI_CONFIG_DIR under the home and OpenCode a relative $OPENCODE_DB in its data folder, so neither depends on the working folder: appdir no longer passes them over.
* i18n: German for the Library's multi-select and System One's decision API
The 19 strings main added since (#791's skill multi-select, the decision API snippets) get their German; the one main replaced (four APIs → five APIs) goes.
* appdir: tidy the import into magpie's group; say what Go makes of /c/x
The appdir import joins the group of magpie's own imports where a file has one. rooted's comment now says that Go takes a Git Bash path like /c/x as \c\x on the current drive, not C:\x.
dsh resolves a session's model from the patch list before it contacts the gateway, so a
route that lists a model magpie no longer gives dsh fails every session, with nothing
reaching magpie to show for it.
While magpie serves the gateway it now writes the fields it manages on existing dsh
magpie routes again every 30s where they are not what magpie would write now, from
gateway.WhileServing next to the WebDAV sync. A route the user removed stays removed,
agent-default-model stays the user's choice, and an empty catalog writes nothing.
models.dev lists some models' output above their context (deepseek-chat:
384000 out, 128000 in), and magpie handed that on as maxTokens. The limit
is now kept within the contextWindow written beside it; a model whose
window isn't known keeps its output as before. Follow-up to the review of