Pi set up by hand on a provider of its own named magpie (magpie/<model>
at the gateway) read as connected in magpie: every catalog change wrote
magpie's list over that provider, RenameProvider rewrote its refs, Drift
offered Reconnect, and Disconnect took the provider out.
0911a65e7 (yyddbds, MiMo) already holds a ListOnly agent's sync until
it is Wired; that still let a hand-written config that names a magpie
model (JFunfunfun's Pi) read as Wired. Both gates now apply.
Its test's last case said a magpie model picked by hand on MiMo's own
magpie provider connects it; that is JFunfunfun's case, so it now
stays the user's until connected in magpie (listonly_test.go, and the
doc's ListOnly line says so).
An agent whose magpie is a provider of its own config (Spelled, not
Native) is now connected only when magpie set it up (setUp): a field in
applied.json, the new applied.Kept that Keep leaves instead of deleting
the record, or the <id>.connect.was stash Connect has written since
10-03. Otherwise (handWired) it isn't Wired, has no Drift, and
SyncCatalog, RenameProvider and renameRefs skip it; Disconnect is a
no-op as it is for any unwired agent. Connecting it in magpie takes it
on as before; Disconnect after that skips putting back "was" values
that were themselves magpie's (dsh errored on them). RenameLegacy
records the dial/ -> magpie/ values it writes, and moveEfforts (the
Cursor/Antigravity effort ids, at start-up) leaves a hand-written
magpie/<ref> alone. Aside keeps its own
key-based ownership. OpenCode's own-gateway-provider test now connects
through Apply as `magpie opencode` does.
Run (on mote, at this head, rebased on f2c6831a3): go test -tags nogui
-count=1 ./internal/agent ./internal/cli ./internal/library
./internal/gui; go vet darwin/linux/windows of internal/agent and
internal/cli; gofmt -l. internal/agent again after the ListOnly test
change: ok. Pushed on ceef9e943, whose five commits since touch usage,
sessions, library, provider movers and gui only.
New tests: TestPiHandWiredMagpieProviderIsTheirs (pi's literal
settings.json/models.json in a sandbox HOME, files byte-identical after
SyncCatalog, RenameProvider and Disconnect), TestPiConnectedBefore-
StaysConnected (applied record, gone model, connect.was, applied then
Keep), TestHandWiredMagpieProviderSiblings (29 Spelled agents). All fail
on the old code.
Tests that wrote a connected agent's files by hand (Pi, OpenCode,
Hermes, omp, dsh, the Kilo plugin, Cursor efforts, and the cli's
save-then-sync test) now also mark it as Connect leaves it
(setUpInMagpie, the connect.was stash); without it they read as
hand-written, which is what this change is about.
Broken by hand, each red: the Sync gate, the rename gates, the Drift
gate, Keep deleting the record, the was-skip in Disconnect, the
moveEfforts gate (TestMoveCursorEfforts' hand-wired case).
Not tried: a real pi binary against the gateway. Users connected
between 09-23 and 10-03 who pressed Keep (record deleted before this)
read as not connected; one Connect brings them back and pi keeps
working meanwhile. Agents without Spelled (Claude Code, Codex, Gemini
and others) decide by their own checks and are unchanged.
yyddbds on Discord: in Xiaomi MiMo they added a custom provider pointing
at magpie and picked a few models by hand. MiMo's switch on the Agents
page was off, yet after an update the provider held every one of
magpie's models. SyncCatalog runs at each start and update and on every
catalog change, and MiMo Code's Sync (openCodeLike) brought any
provider.magpie block up to the catalog whether magpie wrote it or not.
magpie's default went over a list the user set.
An Agent whose Sync does nothing but keep a block of magpie's name up
to the catalog is now ListOnly, and SyncCatalog runs it only while the
agent is Wired, which is what the Agents page's switch shows. The same
sync was in every sibling, so ListOnly is on all of them: openCodeLike
(OpenCode, MiMo Code and their WSL forms), piLikeKeyed (Pi and forks),
Goose, Crush, Air, AtomCode, Command Code, Droid, Fx, jcode, Kimi,
MiniMax, Mothx, omp, OpenChamber, OpenClaw, OpenPencil, Penguin, Qwen
Code and T3 Code. Left out on purpose: Codex, Claude, Grok and Hermes,
whose Syncs also repair while not connected (Hermes keeps its bots'
magpie provider current) and have their own gates.
Trade-off: a list magpie wrote while connected doesn't follow the
catalog while the agent runs a model of its own (switch off); it does
again once a model of magpie's is picked. Users whose list was already
written over: magpie keeps no copy of the old list, so it stays full;
from this release on it is left alone, and they trim it once by hand
(or connect the agent in magpie and use its model list's Pick).
Tests: TestCatalogSyncLeavesAHandWrittenMagpieBlock (MiMo, Pi and Crush
with a hand-written magpie block stay byte for byte; connected, MiMo's
list follows the catalog; disconnected and written by hand again, left
alone; a magpie model picked in MiMo, followed again).
TestListOnlyAgentsReadConnected: every ListOnly agent magpie connects
reads as Wired (n >= 15), so none of them loses catalog updates.
Fixtures of TestSyncCatalogRewritesAgentLists,
TestModelNameAndLevelsReachAgentFiles, TestSuffixModesReachAgentFiles
and TestPiKeepsTheirKeysInMagpiesProvider, and internal/cli's
TestSaveAnswersBeforeTheAgentsSync (its Pi settings were {}), now have
Pi connected (settings.json defaultProvider magpie), as a block magpie
wrote implies.
docs/subsystems/agent-wiring.md says the rule.
Run (mote, sandbox HOME via the tests' syncHome/codexHome):
- old code + the new test: red (MiMo, Pi, Crush written over; after
Disconnect written over).
- broken by hand: ListOnly dropped from openCodeLike: red on MiMo
(lines 52, 82); the Wired gate in SyncCatalog replaced with true: red
on all three.
- go test -tags nogui -count=1 ./internal/agent: ok.
- gofmt -l clean; go vet ./... for darwin, GOOS=linux and GOOS=windows:
ok.
- full suite, go test -tags nogui -count=1 -timeout 45m ./... at base
3bebc3839 (logs kept in the worktree): every package ok but
internal/cli (TestSaveAnswersBeforeTheAgentsSync, mine, fixture fixed
above, then ok alone) and internal/gateway: TestAntigravityTurned*,
TestAntigravityTurnsCodexsGPT5ThreadAwayOnce and
TestCodexSpentGrokFailingIsTold, red the same on a fresh origin/main
b26fa0903 copy, filed as #4362.
- rebased on e8d42c02d: vet (darwin, linux, windows) of internal/agent and
internal/cli, and go test of internal/agent, internal/cli,
internal/library and internal/gui: all ok. Pushed on 764a032f6,
whose three commits since touch gateway, usage, provider and chat only.
Not tried: the real Xiaomi MiMo desktop app (the fixture is the OpenCode
shape MiMo Code writes; whether the reporter's provider id is literally
"magpie" is unconfirmed: a provider of another id was never touched).
Lists already written over are not restored.
CyberCaius on Discord (native Windows): "路由组和供应商编辑保存有时候保存会卡
很久才保存成功", at least 3s, while an agent's request runs.
Cause: every write of providers.json ends in catalog.Touched -> Changed,
which was agent.SyncCatalog, run inside the HTTP request. It rewrites
every agent's model list that differs. On Windows, a file another
program holds open refuses the rename over it, and steady.Rename retries
for 0.5s before giving up. So each such file costs a group save half a
second, and a provider save, which stores several times, costs more. In
WSL the same sync goes through wsl.exe and \\wsl.localhost.
Fix: catalog.Changed is agent.SyncCatalogSoon, which runs SyncCatalog
in the background (it already folds overlapping runs into one more
round). A CLI command waits for those rounds at the end of run()
(SyncCatalogSettled), so `magpie group add` still ends with the files
written, and run() puts catalog.Changed back for tests. The GUI's direct
SyncCatalog calls in providers.go (arrange, keeplogin, switchonly, login
actions, sign-in import) use SyncCatalogSoon too.
Run at the pushed head (parent d792e7ce4, gateway-only since the run
below): go build ./... and go test -tags nogui internal/cli: ok.
On parent a84d2ec80: go vet on darwin and windows for agent, cli and
gui, then go test -tags nogui -count=1 -timeout 45m for internal/agent,
cli, gui and provider: all ok.
Run one rebase earlier (on aa3112f4e, before d08b6118b and a84d2ec80):
- go test -tags nogui -count=1 -timeout 45m internal/agent, cli, gui,
provider, catalog, gateway: all ok. (Before the rebase, gui failed
TestCoreScriptBudget on app.js, which this change doesn't touch;
aa3112f4e fixed it.)
- After that run, only comments changed. Then go vet (darwin, windows)
on agent and cli, and -race on TestSaveAnswersBeforeTheAgentsSync and
TestSaveSharesOneCatalogBuild: ok.
- gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and
GOOS=windows; go build on darwin, windows, linux nogui: ok.
- GUI: routing-save, routing-save-blank, routing-save-keeps-the-row and
provider-levels-save: 40/40 (Chromium and WebKit).
Broken by hand:
- TestSaveAnswersBeforeTheAgentsSync (new) holds the sync on Pi's
models.json as a FIFO. With syncAgentsOnChange set back to
agent.SyncCatalog, both the group and the provider save waited the
test's full 20s and failed. With the fix, they answer in 0.06s and 1.1s,
and the sync is seen running afterwards.
- Native Windows (the test box, sandbox HOME, a cross-built test binary
with a scratch probe, not committed): a save during a streaming
request through the gateway took 120ms (group) and 245ms (provider)
with the old code, so a request in flight alone doesn't stall it. With
Pi's models.json held open by another handle, the old code took 650ms
and 785ms; the fix took 18ms and 204ms.
Not tried:
- CyberCaius's own machine. Which of their agents holds a file open
while it works is not known, so this is the likeliest cause, not the
proven one for them.
- agent.RenameProvider still syncs inline: its reply names the agents it
moved, and rename tests read the files after.
- The provider save's reply still runs agent.Detected.