isaac_bai on Discord missed the "Open magpie" button beside the quick
panel's Quit, and was setting the tray click to open the main window just
to get back to it; he asked for a double-click on the tray icon.
History: the foot's button (#openMain) was taken out on purpose in
e0ad48641 (10-30, yogurt36 on Discord): the panel had two buttons to the
same window, the header's open-as-a-window icon (#open) and the foot's
"Open magpie". The header icon stayed, but its tooltip said "Open as a
window", which reads as this panel in a window. Rather than bring the
second button back (and undo yogurt36's ask four days later), the icon now
says what it opens: "Open the main window", a string every language
already had (Settings' tray-click choice). "Open as a window" is out of
i18n.js, nothing else used it.
Double-click, per OS, from Wails v3.0.0-beta.24's source:
- Windows: systemtray_windows.go passes WM_LBUTTONDBLCLK on as
OnDoubleClick. A double-click arrives as LBUTTONUP (the click: the panel
opens), LBUTTONDBLCLK (now: ShowMain, whose openMain hides the panel),
LBUTTONUP again; that last one is swallowed once (trayDouble, within
2s) so it doesn't open the panel over the window.
- macOS: the status item's action runs per mouse-down with no click count
(systemtray_darwin.m statusItemClicked); a double-click would be the
panel opened and closed. Not added.
- Linux: StatusNotifierItem has Activate only (systemtray_linux.go); the
same. Not added.
docs/subsystems/gui-shell.md step 10 says so.
Tests:
- TestTrayDoubleClickOpensTheWindowOnWindowsOnly: windows on, darwin and
linux off, and app.go wires OnDoubleClick to ShowMain and checks the
swallow first in OnClick.
- TestTrayDoubleClickReleaseSwallowedOnce: the release after a
double-click opens nothing, once; the next click, or one past the bound,
opens the panel. Fixed instants, no sleeps.
- panel-open-once.test.cjs: the header icon's title and accessible name
are "Open the main window" in en, zh, zh-TW, ja and de, both engines.
Run (at the pushed head's tree before rebase onto 78667e9b7, which changes
only docs/subsystems/gui-shell.md among these files):
- mote: gofmt -l internal/gui clean; GOOS=windows go vet ./internal/gui ok;
go test -run TrayDouble ./internal/gui ok.
- Linux (wsl-run, magpie-desktop): go vet -tags gtk3 ./internal/gui ok;
go test -tags gtk3 -run 'TrayDouble|TrayMenu' ./internal/gui ok.
- Windows (win-run, xiaomi-gpu): go test -run TrayDouble ./internal/gui ok.
- mote GUI, both engines: panel-*, phone-web, old-webkit and i18n-keys
(24 files), 280/280 ok.
- Broken by hand (a copy on mote): trayDoubleClicks false for windows and
the swallow never reset are both red; the old "Open as a window" title
is red in every language, Chromium 0/5 and WebKit 0/5.
At the pushed head (rebased on 78667e9b7), mote: gofmt clean, go test -run
TrayDouble ./internal/gui ok, panel-open-once + i18n-keys 14/14 ok.
Not run: the whole GUI suite (a tooltip only, no layout or API change) or
the whole Go suite. Not tried: a real double-click on the Windows tray
icon in the built app, or the panel in the real tray on any OS.
why8023: Codex switched off and on again showed 「已接入」 with its
subagents' and memories' models back, while its own model never reached
magpie. fae438b4a (NancyTom18 on X) made reconnect call Join first, which
fixed the ChatGPT sign-in case, but where Join can't apply then (a
model_provider of the user's own, magpie API) reconnect still put the
helper fields back alone and answered Wired(), which a helper field on
one of magpie's models makes true. So the switch said connected while
Codex's own turns went to the user's provider.
Now, when Join doesn't join and the model Codex was on wasn't one of
magpie's, reconnect gives up and the switch connects Codex as at first,
on one of magpie's models. Where its model was magpie's, that model
routes it, as before. docs/subsystems/agent-wiring.md says so.
coffemon's (JoeyWu-tech) patch 9ee95ba9, re-ported onto fae438b4a: main
already joins first, so only the !ok check is taken, with his
TestCodexOffAndOnJoinsAgainWithItsHelpersOnMagpie (seven cases, all
green on main too since fae438b4a). TestCodexOwnProviderOffAndOnIsNot-
ConnectedByItsHelpers is new and covers the case that was left: a relay
model_provider, Connect, subagents' model on magpie, gpt-5.5 picked
back, off and on.
Run (mote-run, macOS, go1.26.8, -tags nogui):
- the new test: ok. With the check turned off by hand (if false && ...):
red, "on again ({How:again ...}) with its own model off magpie".
- TestCodexOffAndOnJoinsAgainWithItsHelpersOnMagpie,
TestCodexReconnectStaysJoined, TestCodexConnectKeepsItsPick,
TestReconnectKeepsTheLastPick, TestCodexDisconnectStaysWithAccountsOn
and the OpenCode/OpenChamber tests: ok.
Not tried: the Agents page and a real Codex on a relay afterwards; the
test drives ConnectHow and Disconnect, which the switch calls, with
config.toml in a sandbox HOME.
Batch run, at tree 104d75f0a (the twelve coffemon ports together, on
origin/main 7d022bdb6), mote, macOS, go1.26.8:
- go test -tags nogui -count=1 -timeout 45m on the packages the batch
changes (agent, autostart, daemon, gateway, library, proc, provider,
sessions, testenv, tui, gui): ok each.
- GUI, node --test with Playwright 1.62.0, Chromium and WebKit:
library-*.test.cjs and i18n-keys.test.cjs, 1044 of 1044 pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... and go build ./...: ok at cdd7c8e46, the same
batch on origin/main 00098f12b one rebase before.
- The whole go test ./... at cdd7c8e46: 86 packages ok, one red,
internal/cli TestEveryRouteHasACommandOrIsNamed (GET
/api/context/reply has no command), red on main too (#5026).
- Linux (wsl-run, Ubuntu 24.04, at 339055896, the batch on f4c664a09):
proc, autostart, testenv, tui ok; agent: only TestGrokInstalled red
(#3548); #4033's proc.Look reds (Zed, Copilot, Qoder, Cursor, Omp)
pass.
- Windows (win-run, Windows 11, at 339055896): proc, autostart, testenv,
tui ok; library and agent red in the same tests as on origin/main
f4c664a09 (#4115, #1827, #4786; #5068, #5069, #5070 filed now).
- Rebased onto origin/main fb1f4856a (three commits, no file in
common with the batch) and run again at the pushed tree: gofmt -l
nothing, go build ./... and go vet ./... ok; go test -tags nogui
sessions, agent, autostart, tui, proc, testenv ok; i18n-keys and
library-* 1044 of 1044 pass.
- Not run before the push: the whole GUI suite (a run at cdd7c8e46 was
cut off at 1170 of ~1174 tests when mote rebooted; it runs again after
the tag and any red is filed).
Co-authored-by: yetone <9rqwv2ak@gmail.com>
Found while fixing #3883. OpenCode 2 keeps a provider under providers,
its base URL in settings.baseURL, and reads it there before the same
name under provider, OpenCode 1's spelling: the one under providers is
taken whole, and the other is only a WARN, "retained native value over
legacy value" (packages/core/src/config/normalize.ts, mergeMaps, at
v2.1.4). OpenChamber's provider form saves a provider there and takes
it out of provider (packages/web/server/lib/opencode/config-v2.js,
writeSectionEntry). magpie read the user's own providers under provider
only, in the two places that look for them:
- ownGatewayProvider: a provider of the user's own at magpie's gateway
that lists the model, as a layout of one provider per family of
magpie's models has, gets a pick of that model of magpie's as
<theirs>/<model>, with no provider.magpie beside it. One under
providers wasn't seen, so the pick went to magpie/<model> and
magpie's provider was added beside the user's.
- openCodeSpelled: a model on a provider named as one of magpie's and
at the gateway (relay/glm-4.6 on the user's own relay) counts as
magpie's. Under providers it didn't, so Agent.Models left it out.
On origin/main e056779a, the same provider under each spelling:
provider: pick -> magpie-relay/relay/glm-4.6, no provider.magpie
providers: pick -> magpie/relay/glm-4.6, provider.magpie added
provider: Spelled=true Models=[relay/glm-4.6]
providers: Spelled=false Models=[]
Both now read a provider under providers as OpenCode 2 reads it: the
base URL from settings.baseURL (openCodeBaseURL), and a name under both
is the one under providers. They serve OpenCode, OpenChamber's pickers
on OpenCode's config, MiMo Code and DevEco Code; a config without
providers, as OpenCode 1 and the forks on it write, is read as before.
This changes what magpie reads, not what it writes, so there is no old
data to bring up. agent-wiring.md says so beside DevEco Code.
What was run (tree 77e2237e, on origin/main 2b038757, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077:
- TestOpenCodeKeepsItsOwnGatewayProvidersUnderProviders, new: a pick
of magpie/relay/glm-4.6 with the user's magpie-relay under providers
is written as magpie-relay/relay/glm-4.6 with no provider.magpie; a
model on relay under providers at the gateway is in Models; with
relay under both, the one under providers is read, for Models and
for a pick: ok
- broken by hand, one at a time, with
TestOpenCodeKeepsItsOwnGatewayProviders (the same under provider)
green under each:
- openCodeSpelled reading provider only, as on main: red, "models =
[]"
- ownGatewayProvider reading provider only, as on main: red, "model
= "magpie/relay/glm-4.6""
- the one under provider read over the one under providers, in
openCodeBaseURL: red, "the provider under provider read over the
one under providers: [relay/glm-4.6]"; in ownGatewayProvider: red,
"picked on the provider under provider: model =
"mine/relay/glm-4.6""
- the 26 internal/agent tests matching OpenCode, OpenChamber, MiMo,
DevEco or Spelled: ok
- OpenCode 2.1.4 itself (opencode models, sandbox HOME): with
magpie-relay under providers as the test writes it, it lists
magpie-relay/relay/glm-4.6; with relay under both, it logs "retained
native value over legacy value" for $.providers.relay and lists only
the models under providers (a model only under provider is gone)
- go test -tags nogui -count=1 -timeout 45m ./... (log kept), Bun
1.4.2: 68 packages ok and 8 red, none in what this changes; in
internal/agent every test this adds or touches passes. The reds: agent
TestFolderVarsAreListed (#3884, fixed on main since in 3116b8f5),
TestCodexDriftReached (#3398), TestInstalledVersion,
TestCursorFolderFromTheEditorIsNotTheCLI,
TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
TestOmpDetectedWithPiDir (#3141),
TestReasonixCLIRequiresSupportedNativeVersion and
TestReasonixCLIRecoversAfterProbeTimeout (#3641); edit
TestWriteAtomicReadOnlyHardLink and testenv TestProgram (umask 077,
#3640); gateway TestPluginToldWhereTheAgentWorks (#3675); gui
TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
(#3649); proc TestEnvOfChild and provider TestCodexAppServersOnHome
(#3906), then "close of synctest channel from outside bubble" from
TestUnreadLoginsWriteErrorsKeepCredentials (#3632); tui
TestTUIFetchesSubscriptionModels/agent (#3919).
- gofmt -l clean. go vet -tags nogui and go build -tags nogui for linux,
windows and darwin, and go vet and go build for windows without the
tag: exit 0 each. go vet and go build without the tag on linux: exit 1
(this box has no GTK or WebKitGTK dev packages).
Not tried: OpenChamber's app itself, a request sent through such a
provider, Windows and macOS.
Batch run, at tree 104d75f0a (the twelve coffemon ports together, on
origin/main 7d022bdb6), mote, macOS, go1.26.8:
- go test -tags nogui -count=1 -timeout 45m on the packages the batch
changes (agent, autostart, daemon, gateway, library, proc, provider,
sessions, testenv, tui, gui): ok each.
- GUI, node --test with Playwright 1.62.0, Chromium and WebKit:
library-*.test.cjs and i18n-keys.test.cjs, 1044 of 1044 pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... and go build ./...: ok at cdd7c8e46, the same
batch on origin/main 00098f12b one rebase before.
- The whole go test ./... at cdd7c8e46: 86 packages ok, one red,
internal/cli TestEveryRouteHasACommandOrIsNamed (GET
/api/context/reply has no command), red on main too (#5026).
- Linux (wsl-run, Ubuntu 24.04, at 339055896, the batch on f4c664a09):
proc, autostart, testenv, tui ok; agent: only TestGrokInstalled red
(#3548); #4033's proc.Look reds (Zed, Copilot, Qoder, Cursor, Omp)
pass.
- Windows (win-run, Windows 11, at 339055896): proc, autostart, testenv,
tui ok; library and agent red in the same tests as on origin/main
f4c664a09 (#4115, #1827, #4786; #5068, #5069, #5070 filed now).
- Rebased onto origin/main fb1f4856a (three commits, no file in
common with the batch) and run again at the pushed tree: gofmt -l
nothing, go build ./... and go vet ./... ok; go test -tags nogui
sessions, agent, autostart, tui, proc, testenv ok; i18n-keys and
library-* 1044 of 1044 pass.
- Not run before the push: the whole GUI suite (a run at cdd7c8e46 was
cut off at 1170 of ~1174 tests when mote rebooted; it runs again after
the tag and any red is filed).
Murciee (#3883, OpenCode 2.1.4 as OpenChamber bundles it, Windows): a
model added in magpie never reached OpenCode 2, though magpie said it
was exposed. ~/.config/opencode/opencode.json held magpie's provider
twice, provider.magpie with 43 models and providers.magpie with 38, and
opencode models listed the 38. OpenCode 2 keeps a provider under
providers, in words of its own, and still reads OpenCode 1's provider:
a provider named under both is the one under providers, whole, and the
other only a WARN in its log, "retained native value over legacy value"
(packages/core/src/config/normalize.ts, mergeMaps, at v2.1.4).
OpenChamber's provider form saves a provider under providers and takes
it out of provider (packages/web/server/lib/opencode/config-v2.js,
writeSectionEntry). Once it had saved magpie's, magpie's next sync put
provider.magpie back, as a model of magpie's was picked, and from then
on brought only that one up to date.
Where an OpenCode config keeps magpie's provider under providers, each
sync and model pick now write it there too, and the wiring check reads
it there (opencode_providers.go). It is written as OpenCode 2 reads
magpie's provider.magpie (packages/core/src/v1/config/migrate.ts,
migrateStandardProvider and migrateModel): npm as package
"aisdk:<npm>", options as settings, a model's modalities as
capabilities beside tools, its variants a list of {id, settings, body}
with the options OpenCode 2 reads itself in settings and the rest in
body (provider-options.ts, COMPATIBLE_KEYS: a fast variant's
service_tier), and reasoning, which it doesn't read, left out. As under
provider (theirsKept, openCodeKept), magpie's models are written whole,
a key of the user's in the block stays, and so does a variant the user
put on a model of magpie's. A variant is magpie's when it says what
magpie's of its name says, split as OpenCode 2 splits it or all in
settings, as OpenChamber carries one over from provider
(toModelVariants). A config without providers.magpie doesn't get one:
provider.magpie is still what magpie writes, and OpenCode 1 and 2 both
read it. Taking magpie out of OpenCode or OpenChamber takes out both
blocks, as OpenChamber's own delete does. agent-wiring.md says so
beside #2379's variants.
Old data: a config already in the reporter's state is brought up to
date by the next sync, which SyncCatalog runs over every agent at each
start and update of magpie. A providers.magpie an older magpie left
behind when taking magpie out (it took out provider.magpie alone) is
kept up to date from now on, and goes the next time magpie is taken
out.
Not changed:
- Air: its magpie-opencode.json is magpie's own and holds
provider.magpie alone. With OpenChamber's providers.magpie in the
global config and nothing else of magpie's there, OpenCode 2.1.4
handed Air's file as OPENCODE_CONFIG still listed the model only
Air's file had.
- MiMo Code and DevEco Code go through the same code. Their configs
hold no providers block unless something of theirs writes one; not
checked against their source.
- A provider of the user's own at magpie's gateway kept under providers
isn't read by openCodeSpelled and ownGatewayProvider, which read
provider alone: #3915, filed with this.
- What else OpenChamber's form puts on a model of magpie's under
providers (a modelID, a cost) goes with the rest of the model at the
next sync, as a key on one under provider does today.
What was run (tree 61b3fff7, on origin/main e056779a, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077:
- TestOpenCodeNativeIsOpenCode2s, new: openCodeNative of a block with
levels, fast variants, an image model and one without levels is what
OpenCode 2.1.4's opencode debug config printed under providers.magpie
for that block in an opencode.json (its apiKey, shown as ***, put
back).
- TestOpenCodeProvidersKeptCurrent and
TestOpenChamberProvidersKeptCurrent, new: a config as OpenChamber's
form leaves it, provider.magpie gone and providers.magpie from before
think/new (a stale baseURL and key, a header and a timeout of the
user's, a modelID, magpie's variants of levels deep no longer has,
one of them in OpenChamber's form, one the user wrote over, one of
their own, and a model the catalog dropped). A sync, and a model
picked, bring it to the models under provider with the user's keys
and two variants kept; a second sync writes nothing; stepping off
magpie takes out both. A config without providers gets none.
TestOpenCodeCheckReadsProviders, new: a providers.magpie at another
address is off until a sync.
- The 21 tests named TestOpenCode*, TestOpenChamber* and TestDevEco*:
ok. -race -count=5 over the four new ones: ok.
- Broken by hand, one at a time, each red where it says: no sync under
providers in OpenCode's Sync, in a pick, in OpenChamber's Sync; no
delete there for OpenCode or for OpenChamber; the check reading
provider alone; no theirsKept; the user's variants dropped; no
variant taken for magpie's; only OpenCode 2's split taken for
magpie's (OpenChamber's high-fast stayed); providers written into a
config without it; a write on every sync; every option in settings;
no capabilities. The sync, pick, delete and check breaks at once,
which is what e056779a does: three of the four new tests red.
- The reporter's case with the real binaries, in a sandbox HOME: magpie
at e056779a wired OpenCode to think/deep; OpenChamber's own
toProviderEntity (openchamber main 6b48aecb, its zod import stubbed
so the module loads) turned that provider.magpie into the
providers.magpie its form saves, and provider.magpie was taken out,
as its form does; think/new was added, and magpie at e056779a synced.
OpenCode 2.1.4's opencode models (npm @opencode/cli-linux-x64,
integrity checked) listed magpie/think/deep alone, and its log had
two "retained native value over legacy value" lines. The same file
synced by this commit: magpie/think/deep and magpie/think/new, no
such line, and a second sync left the file as it was, mtime too.
- go test -tags nogui -count=1 -timeout 45m ./... (log kept), Bun
1.4.2: 69 packages ok and 7 red, none in what this changes; in
internal/agent every test this adds or touches passes. The reds: agent
TestFolderVarsAreListed (#3884, main's CI red), TestInstalledVersion,
TestCursorFolderFromTheEditorIsNotTheCLI,
TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
and TestZedAppPath (#3141: alone at -count=40, TestZedAppPath is red
37 and 35 times at e056779a, 35 and 38 here),
TestReasonixCLIRequiresSupportedNativeVersion and
TestReasonixCLIRecoversAfterProbeTimeout (#3641); davsync TestSync
(#3420: alone at -count=20, red 3 times at e056779a and 2 here); edit
TestWriteAtomicReadOnlyHardLink and testenv TestProgram (umask 077,
#3640); gateway TestPluginToldWhereTheAgentWorks (#3675); gui
TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
(#3649); provider TestCodexAppServersOnHome (#3906, main's CI red),
then "close of synctest channel from outside bubble" from
TestUnreadLoginsWriteErrorsKeepCredentials (#3632, main's CI red).
- gofmt -l clean. go vet -tags nogui and go build -tags nogui for linux,
windows and darwin, and go vet and go build for windows without the
tag: exit 0 each. go vet and go build without the tag on linux: exit 1
(this box has no GTK or WebKitGTK dev packages).
Not tried: Windows, the reporter's system, and OpenChamber's app
itself: its converter alone was run.
Ported onto main by yetone. Since this was written, cdd470ce9 (#4575)
made the models of magpie's provider under provider an ordered list
(orderedJSON) instead of a map, so the block under providers came out
with no models at all (TestOpenCodeProvidersKeptCurrent and
TestOpenChamberProvidersKeptCurrent red on main with the patch as it
was), and #4575 added a model's cost. openCodeNative now reads that list
and writes the models under providers in the same order, and a cost in
OpenCode 2's words: a list of tiers, cache prices under cache
(migrateModel's costs in packages/core/src/v1/config/migrate.ts).
OpenCode's source read at v2.1.4 (68bc26b7) and v2.2.5: in both,
normalize.ts merges provider into providers (mergeMaps), and a name
under both is the one under providers, taken whole, so the fix holds
on the current 2.2.x too. TestOpenCodeNativeKeepsOrderAndCost is new,
and providersCurrent checks the order.
Run for the port (mote-run, macOS, go1.26.8): go test -tags nogui
-count=1 -run 'OpenCode|OpenChamber|MiMo|DevEco|Spelled|Wiring'
./internal/agent: ok.
Batch run, at tree 104d75f0a (the twelve coffemon ports together, on
origin/main 7d022bdb6), mote, macOS, go1.26.8:
- go test -tags nogui -count=1 -timeout 45m on the packages the batch
changes (agent, autostart, daemon, gateway, library, proc, provider,
sessions, testenv, tui, gui): ok each.
- GUI, node --test with Playwright 1.62.0, Chromium and WebKit:
library-*.test.cjs and i18n-keys.test.cjs, 1044 of 1044 pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... and go build ./...: ok at cdd7c8e46, the same
batch on origin/main 00098f12b one rebase before.
- The whole go test ./... at cdd7c8e46: 86 packages ok, one red,
internal/cli TestEveryRouteHasACommandOrIsNamed (GET
/api/context/reply has no command), red on main too (#5026).
- Linux (wsl-run, Ubuntu 24.04, at 339055896, the batch on f4c664a09):
proc, autostart, testenv, tui ok; agent: only TestGrokInstalled red
(#3548); #4033's proc.Look reds (Zed, Copilot, Qoder, Cursor, Omp)
pass.
- Windows (win-run, Windows 11, at 339055896): proc, autostart, testenv,
tui ok; library and agent red in the same tests as on origin/main
f4c664a09 (#4115, #1827, #4786; #5068, #5069, #5070 filed now).
- Rebased onto origin/main fb1f4856a (three commits, no file in
common with the batch) and run again at the pushed tree: gofmt -l
nothing, go build ./... and go vet ./... ok; go test -tags nogui
sessions, agent, autostart, tui, proc, testenv ok; i18n-keys and
library-* 1044 of 1044 pass.
- Not run before the push: the whole GUI suite (a run at cdd7c8e46 was
cut off at 1170 of ~1174 tests when mote rebooted; it runs again after
the tag and any red is filed).
Co-authored-by: yetone <9rqwv2ak@gmail.com>
With #3372, Open at login on Linux reads a package's own autostart entry
in $XDG_CONFIG_DIRS (nixpkgs ships one). JoeyWu-tech's #3756 asked what
`magpie daemon install`'s guard and `magpie tui`'s hand-off as it quits
should count on a box no desktop logs into (NixOS-WSL, a server over SSH),
where nothing ever starts that entry.
Decided: both keep counting what Open at login shows (autostart.Enabled).
A session check can't tell (an SSH login into a desktop box has no
DISPLAY either), and counting less than the switch shows would install
the service beside an app the desktop does start. The install already
refuses with "run `magpie autostart off` first", which is the way out.
The terminal's quit only said "the gateway stopped", with nothing about
why or what to do; it now says magpie opens at login and serves it then,
and that `magpie autostart off` has magpie tui hand it on where no
desktop logs in (atLoginNote). Off Linux and with nothing connected the
note is as before.
What was run (wsl-run, magpie-desktop Ubuntu 24.04, go1.26.8):
go test -tags nogui -count=1 ./internal/autostart ./internal/daemon
./internal/testenv ./internal/tui: ok
With keep.go as before (the test kept): TestKeepGatewayAsTheTerminalQuits
red, "app at login: ... the gateway stopped with magpie tui; ..."
gofmt -l: nothing
Not tried: a real NixOS-WSL login; mtul0729 ran the #3372 patch on real
NixOS + COSMIC, at the systemd generator's level.
Batch run, at tree 104d75f0a (the twelve coffemon ports together, on
origin/main 7d022bdb6), mote, macOS, go1.26.8:
- go test -tags nogui -count=1 -timeout 45m on the packages the batch
changes (agent, autostart, daemon, gateway, library, proc, provider,
sessions, testenv, tui, gui): ok each.
- GUI, node --test with Playwright 1.62.0, Chromium and WebKit:
library-*.test.cjs and i18n-keys.test.cjs, 1044 of 1044 pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... and go build ./...: ok at cdd7c8e46, the same
batch on origin/main 00098f12b one rebase before.
- The whole go test ./... at cdd7c8e46: 86 packages ok, one red,
internal/cli TestEveryRouteHasACommandOrIsNamed (GET
/api/context/reply has no command), red on main too (#5026).
- Linux (wsl-run, Ubuntu 24.04, at 339055896, the batch on f4c664a09):
proc, autostart, testenv, tui ok; agent: only TestGrokInstalled red
(#3548); #4033's proc.Look reds (Zed, Copilot, Qoder, Cursor, Omp)
pass.
- Windows (win-run, Windows 11, at 339055896): proc, autostart, testenv,
tui ok; library and agent red in the same tests as on origin/main
f4c664a09 (#4115, #1827, #4786; #5068, #5069, #5070 filed now).
- Rebased onto origin/main fb1f4856a (three commits, no file in
common with the batch) and run again at the pushed tree: gofmt -l
nothing, go build ./... and go vet ./... ok; go test -tags nogui
sessions, agent, autostart, tui, proc, testenv ok; i18n-keys and
library-* 1044 of 1044 pass.
- Not run before the push: the whole GUI suite (a run at cdd7c8e46 was
cut off at 1170 of ~1174 tests when mote rebooted; it runs again after
the tag and any red is filed).
mtul0729, packaging magpie for nixpkgs (#3372, COSMIC on Wayland,
v0.1.1334): a package that ships its own autostart entry
($XDG_CONFIG_DIRS/autostart/magpie.desktop, /etc/xdg when unset) has
magpie open at login, but enabled() read only
$XDG_CONFIG_HOME/autostart, so Open at login said off over it. Off
removed a user file that wasn't there, and the package's entry went on
starting magpie. On wrote this copy's own path over the package's entry:
under a package manager a versioned path, gone once the package is
upgraded and collected. The package doc says the switch "can't say one
thing while the system does another"; on such a system it did.
Now, as the XDG Autostart spec has it:
- The entry that counts is the user's, else the first of the
$XDG_CONFIG_DIRS folders (/etc/xdg when unset or empty) that has one.
A relative folder has none, as the spec says, and neither has a file
listed there, a folder this user can't search or a name too long,
which systemd's generator and GLib can't open either. The user's own
folder listed there too, by any name (os.SameFile, so /home linked to
/var/home too), is still the user's.
- An entry is read as GLib's key file and systemd's parser read it: the
keys of its [Desktop Entry] group alone (a [Desktop Action]'s Exec is
not the entry's), spaces around = and CRLF lines as any others, the
last of a key given twice, true or 1 for Hidden. It opens magpie when
it is an application (Type=Application) with an Exec other than true
(below), not Hidden.
- X-GNOME-Autostart-enabled=false (or 0) reads off too, as the issue
asks. GNOME's and Cinnamon's sessions read it; systemd's generator
(KDE's and COSMIC's sessions under systemd) doesn't, so there such an
entry reads off while it starts.
- Off, over a package's entry that some desktop starts, writes an entry
of the user's that hides it; that includes one GNOME has off, which
systemd's generator still starts. Otherwise off removes the user's
entry, as before. On, over a package's entry that starts magpie,
removes the user's entry and writes no path; otherwise (no package
entry, a hidden one, or one GNOME has off) it writes this copy's
entry, as before.
The hiding entry is "[Desktop Entry] Type=Application Name=magpie
Exec=true Hidden=true". A session holds back the entries of a name only
once it has read one, and each reads differently (from their source):
- gnome-session (main and 42.0) and cinnamon-session load an entry with
g_desktop_app_info_new_from_filename. GLib (main,
g_desktop_app_info_load_from_keyfile) refuses one with no Type or
Name, or whose Exec names a program it can't find, and the session
skips an entry it can't load, so the package's starts.
- mate-session's egg_desktop_file_new refuses an application entry with
no Exec, and the entry then takes no app id.
- cosmic-session without systemd never reads Hidden: it starts what Exec
names, and takes the name once that ran.
- systemd's generator (main, xdg-autostart-service.c) reads Hidden
first, and hides an entry it can't parse, which still holds back the
rest.
true is on every system by that name, so each session reads the entry,
and COSMIC's runs true where it would have run magpie. A copy of the
package's own Exec would stop holding the package's back on GNOME once
its store path is collected. With this box's GLib 2.72.4 (Ubuntu
22.04's) and 2.84.2 (anaconda's), through ctypes: Exec=true and no Exec
load, hidden; an Exec naming a store path that is gone, and a bare
"[Desktop Entry] Hidden=true", don't load. An entry that runs true opens
nothing, so it reads off: XFCE's Session and Startup lists the hiding
entry as magpie, unticked, and ticking it there writes Hidden=false into
it (xfae-model.c), which runs true, not magpie. On takes it away for the
package's.
What is no entry, and what can't be read: a path where no regular file
is (a folder, a link that leads nowhere or round in a loop) is no entry,
as systemd's generator and GLib pass over it, and on leaves a folder
there alone. A file that can't be read (EACCES, EPERM, EIO) counts and
starts nothing, as systemd's generator has it; GLib passes over it, so
where the first entry is unreadable GNOME starts the next folder's while
Open at login reads off. Any other failed read, magpie out of files or
memory, says nothing of what the desktop reads at login: Set returns it
and writes nothing, and Open at login reads on, as the package's doc has
it for a system that can't be asked (Windows' Run key that can't be read
is not a no either).
The user's entry is written where the desktop reads it. A link there (to
magpie's launcher, which install.sh writes, the usual way to have an app
open at login; or into a read-only store), or a hard link, is replaced
by the entry, not written through: edit.WriteAtomic writes a link's
target, and a hard-linked file in place, so off over a package's entry
would have left the launcher running true, and failed over a read-only
target with the switch still on. Main's enable() wrote through such a
link too, when on was asked over one (a linked launcher already reads
on); it goes through the same write now.
Old entries: a user entry an older magpie wrote stays and still counts
over a package's, as before. The switch reads on over it, so in the app
taking it away is off, then on; `magpie autostart on` does it in one
step. One whose store path was collected reads on as well, though
systemd's generator starts nothing for it and still holds the package's
back, so on COSMIC or KDE magpie doesn't open while the switch says on;
GLib passes over it, and GNOME starts the package's.
The daemon and the terminal: `magpie daemon install` refuses while
magpie opens at login, so the app and the service don't both serve the
gateway, and `magpie tui` quitting hands the gateway on (keepGateway,
75e78a5a) only where nothing opens magpie at login. Both read
autostart.Enabled, code unchanged, so a package's entry counts for both
now. Where a desktop session runs XDG autostart that is the point:
install says to run `magpie autostart off` first, which now hides the
entry, where before the service went in beside an app the package's
entry went on opening. On a box no desktop logs into (NixOS-WSL, a NixOS
server over SSH) nothing runs the entry, yet install refuses and
keepGateway only says the gateway stopped; `magpie autostart off` gets
both going. That is #3756, filed with this, for yetone to say what they
should count on Linux; a session check wouldn't settle it, since install
over SSH into a desktop box has no DISPLAY either.
An entry the desktop's own settings switched off reads off for the guard
as well: XFCE writes Hidden=true into the user's entry, which main still
counted (it read Type and Exec alone), so install refused; now it goes
in. I kept that reading, and daemon.go's comment now says so, rather
than have the guard count such an entry. The switch and `magpie
autostart` read it off, and a guard counting it would refuse with
"magpie already opens at login" where `magpie autostart` says it
doesn't. The Mac has a state for that case (NeedsAllowing, which the CLI
and the app explain in System Settings' words), and Linux has none to
show it; Windows reads a Run value Task Manager switched off as off, and
on switches it back, as Set(true) does here. What it costs: ticking
magpie again in the desktop's settings after the install opens the app
beside the service, in #3756 too. For an AppImage or a tarball, with no
package entry, on and off write and remove as before, and what changes
is how an entry reads (Hidden, the GNOME key, a failed read, as above)
and that a link at the entry is replaced, not written through.
docs/subsystems/gui-shell.md says how Open at login reads on Linux, and
that the terminal's hand-off counts a package's entry (#3756).
Rebased onto origin/main 58fb3a77: 824100f3 added a line to
gui-shell.md next to the one this patch changes, so 7e9003aa no longer
applied. The code and the docs line are as they were (the same patch
for internal/).
What was run (tree 59fb33a8, on origin/main 58fb3a77, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077:
- go test -tags nogui ./internal/autostart ./internal/testenv -v:
autostart ok, its new tests among them; testenv ok but TestProgram,
red under this box's umask 077 (#3640), as on main.
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
vet for windows without the tag, go build -tags nogui for linux and
darwin, and go build for windows: exit 0 each; untagged linux vet and
build stop at pkg-config (no GTK headers here). GOOS=freebsd vet: not
run at this tree.
- go test -tags nogui -count=1 -timeout 45m ./... (log kept), Bun
1.4.2, 8m35s, load 19 at its start: 70 packages ok, autostart,
daemon, cli and tui among them; reds in 6, each known: agent
TestInstalledVersion, TestCursorFolderFromTheEditorIsNotTheCLI,
TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
and TestZedAppPath (#3141), TestCodexDriftReached (#3398) and the two
Reasonix tests (#3641); davsync TestSyncTeraCloudStillSeesOtherWrites
(#3420);
edit TestWriteAtomicReadOnlyHardLink and testenv TestProgram
(umask 077, #3640); gateway TestPluginToldWhereTheAgentWorks (#3675),
the package ran to its end; gui TestGatewayHeldByAContainer and
TestGatewayFixQuitsOnlyAMagpie (#3649).
The rest is what was run for 7e9003aa, at tree 719db0e7 on origin/main
6e6aba51, the same code (not this tree):
- Real use (real.log): the built magpie (-tags nogui) and origin/main's,
each in a sandbox HOME under env -i, with a package entry (Exec=magpie
tray, magpie on PATH) in XDG_CONFIG_DIRS, and systemd 249's
systemd-xdg-autostart-generator after each step:
- the package's entry alone: main says magpie doesn't open at login
while the generator starts magpie tray; this says on.
- off, twice: main writes nothing and it still starts; this writes the
hiding entry, and the generator starts nothing.
- on: main writes its own path, which it starts; this takes the hiding
entry away, and the generator starts the package's magpie tray.
- no package entry, on then off: both write their own path, which
starts, then remove it, and nothing starts. The package's entry put
back, off again: as the first off.
- the package's entry with X-GNOME-Autostart-enabled=false: both say
off while the generator starts it. Off: main writes nothing and it
still starts; this writes the hiding entry, and nothing starts. On:
both write their own path.
- the hiding entry ticked again as XFCE does (Exec=true, Hidden=false)
over the package's: the generator runs /usr/bin/true; main says on,
this says off. On: this takes it away and the package's magpie tray
starts; main writes its own path.
- the user's entry a link to magpie's launcher, off over the
package's: main takes the link away and the package's entry still
starts; this writes the hiding entry in the link's place, and
nothing starts. The launcher is unchanged in both.
- an old entry of magpie's naming a store path that is gone, over the
package's: both say on, and the generator starts nothing. On: this
takes it away and the package's starts; main writes its own path.
- The new tests over origin/main's autostart_other.go, with a nil
systemRecords and readEntry added so they build (red-on-main.log): all
9 new ones red, and TestSet and TestSetThenTruncatedRecordReadsAsOff,
which main has, pass. The first red of each: :101 "the package's entry
opens magpie at login, and Open at login reads off"; :226 "the second
system folder's alone: off, want on" (and 5 more rows: three more
where a system folder alone has the entry, the user's own entry
Hidden, and the user's own off by the GNOME key); :241
"XDG_CONFIG_DIRS unset: [], want
["/etc/xdg/autostart/magpie.desktop"]"; :311 and :373, no hiding entry
written; :440, off over a link to the launcher left no entry of the
user's, and :437, on over it with no package's entry wrote through to
the launcher (main's own enable(), the sibling above); :491 "a folder
at the user's entry, the package's entry there: true: off, want on";
:534, on over an unreadable user entry leaves it; :568, no hiding
entry to read.
- Broken by hand (breaks.log), each one part of the fix undone, all 36
red, the fix put back ok after. The first red of each:
- where entries come from: no system folders :101; the system's
folders over the user's :108; unset XDG_CONFIG_DIRS with no /etc/xdg
:241; a relative folder kept :266; the user's folder, by any name,
taken for a system's :290.
- how an entry reads: Hidden ignored, Hidden=false read as hidden,
Hidden=1 not read, all :226; the GNOME key ignored, and its 0 not
read, :226; the system's entry starting whatever its Type :226;
spaces around = kept, a line's CR kept, every group's keys read as
the entry's, all :226; an entry that runs true read as opening
magpie :120.
- what off and on write: off always removing :108; off writing the
hiding entry with no package entry :173; off deciding by GNOME's
reading :373; on always writing this copy's path :131; on over a
package's entry keeping the hiding entry :127; on taking away a
folder of the entry's name :495.
- the hiding entry: with no Exec :323, no Type :318, a store path for
Exec :326, true named by a path :326.
- what can't be read: a file in XDG_CONFIG_DIRS, a folder this user
can't search and a name too long, each read as a failed read, :269;
a folder at the entry's path, and a link loop, read as one :491; an
unreadable entry read as no entry :528; every failed read an entry
that starts nothing :576; magpie's own failed read read as no entry
:576, and taken for a no :580.
- links: a symlinked entry written through :437, and a hard-linked one
:437.
- internal/autostart, daemon, cli and tui (pkgs.log): ok.
internal/autostart with -race -count=3 (race.log): ok; nothing in it
runs in a goroutine of its own.
- Probes at this tree, thrown away after (probes-3756.log): keepGateway
with the real reading and all else stubbed, and Install behind
daemon_test's fakes (fake systemctl, launchctl and loginctl alone on
PATH). With the package's entry, keepGateway only says the gateway
stopped and Install refuses before any systemctl call. Under the
hiding entry off writes, and with no package entry but the user's own
entry Hidden=true as XFCE writes it, keepGateway installs the service
and Install goes through (the fake's daemon-reload, enable and
restart).
- Full suite, -tags nogui (CI's Linux job tags gtk3), outside graftcp
(systemd-run, umask 077, Bun 1.4.2 first on PATH as on CI, -timeout
45m, log kept): 64 packages ok, autostart, daemon, cli and tui among
them, and 8 packages red, each filed:
- agent TestCodexDriftReached: #3398; TestInstalledVersion,
TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
TestQoderSettingsFromAnIDEPluginIsNotTheCLI,
TestOmpDetectedWithPiDir and TestZedAppPath: #3141;
TestReasonixCLIRequiresSupportedNativeVersion and
TestReasonixCLIRecoversAfterProbeTimeout: this box's /tmp/.git,
#3641.
- davsync TestSyncTeraCloudStillSeesOtherWrites: #3420.
- edit TestWriteAtomicReadOnlyHardLink: this box's umask 077, #3640.
- gateway TestPluginToldWhereTheAgentWorks: this box's /tmp/.git,
#3675.
- gui TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie:
this box's millions of open fds, #3649.
- #3741.
- provider: "fatal error: close of synctest channel from outside
bubble" in TestUnreadLoginsWriteErrorsKeepCredentials, main's CI
red, #3632; the package's tests after it didn't run.
- testenv TestProgram: this box's umask 077, #3640, red so at
origin/main 6e6aba51 alone too (testprogram-main.log).
- gofmt -l: clean. go vet -tags nogui for linux, windows and darwin,
GOOS=windows go vet ./..., GOOS=freebsd go vet ./internal/autostart/
./internal/daemon/, go build -tags nogui for linux and darwin and
GOOS=windows go build ./...: all clean. Untagged linux vet and build
stop at pkg-config here (no GTK headers on this box).
Not changed: gnome-session also reads $XDG_DATA_DIRS/gnome/autostart,
between the user's folder and $XDG_CONFIG_DIRS; it isn't in the spec,
and this doesn't read it. systemd reads an XDG_CONFIG_DIRS that is set
but empty as no folders, and opens a relative folder from its working
directory; this follows the spec: /etc/xdg for an empty one, and no
relative folder. Whether the program an entry's Exec or TryExec names is
there isn't checked, and an entry with any Exec (Exec=magpie serve,
another program's magpie.desktop) reads as magpie opening at login. With
no package entry that starts magpie (none, a hidden one, or one GNOME
has off), on still writes the path self() gives, a versioned one under a
package manager (#3621, where skygunner has a branch, 0aac5452, which
git apply --check takes over this one); a Linux refresh() that took away
an old entry of magpie's whose Exec is gone, where a package's entry
starts magpie, belongs there too.
Not tried: a real login into GNOME, KDE, MATE, Cinnamon, XFCE or COSMIC
(what each session does is read from its source, GLib's loading tried
with the two GLibs above); NixOS itself, and home-manager's links; a
real `magpie daemon install` or keepGateway over a package's entry,
which would reach this box's own systemd and gateway
(TestRefusedBesideAutostart and TestKeepGatewayAsTheTerminalQuits stub
what they read, and the probes above use the real reading).
Batch run, at tree 104d75f0a (the twelve coffemon ports together, on
origin/main 7d022bdb6), mote, macOS, go1.26.8:
- go test -tags nogui -count=1 -timeout 45m on the packages the batch
changes (agent, autostart, daemon, gateway, library, proc, provider,
sessions, testenv, tui, gui): ok each.
- GUI, node --test with Playwright 1.62.0, Chromium and WebKit:
library-*.test.cjs and i18n-keys.test.cjs, 1044 of 1044 pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... and go build ./...: ok at cdd7c8e46, the same
batch on origin/main 00098f12b one rebase before.
- The whole go test ./... at cdd7c8e46: 86 packages ok, one red,
internal/cli TestEveryRouteHasACommandOrIsNamed (GET
/api/context/reply has no command), red on main too (#5026).
- Linux (wsl-run, Ubuntu 24.04, at 339055896, the batch on f4c664a09):
proc, autostart, testenv, tui ok; agent: only TestGrokInstalled red
(#3548); #4033's proc.Look reds (Zed, Copilot, Qoder, Cursor, Omp)
pass.
- Windows (win-run, Windows 11, at 339055896): proc, autostart, testenv,
tui ok; library and agent red in the same tests as on origin/main
f4c664a09 (#4115, #1827, #4786; #5068, #5069, #5070 filed now).
- Rebased onto origin/main fb1f4856a (three commits, no file in
common with the batch) and run again at the pushed tree: gofmt -l
nothing, go build ./... and go vet ./... ok; go test -tags nogui
sessions, agent, autostart, tui, proc, testenv ok; i18n-keys and
library-* 1044 of 1044 pass.
- Not run before the push: the whole GUI suite (a run at cdd7c8e46 was
cut off at 1170 of ~1174 tests when mote rebooted; it runs again after
the tag and any red is filed).
keeyangyy (#3938) named their client: Reasonix 1.x, which sends no
session header (it sets x-opencode-session on its OpenCode Go paths
only) and opens every conversation on a snapshot it writes, the same
bytes in every conversation started in one workspace while its memory
and skills catalog don't change:
{"role":"user","content":"<session-context version=\"1\">\nThis host-generated snapshot supersedes every earlier session-context snapshot.\n\n## Environment\n...\nDigest: sha256:<hex>\n</session-context>"},
{"role":"user","content":"the question the user actually typed"}
userWords didn't know the block, so the commit before this one still
hashed it alone: every conversation a workspace opened had one id, and
under Stays = session each new one was kept on the account that
answered the first.
"<session-context" joins injected, beside Codex's
"<environment_context>", with no closing ">" so that its version
attribute matches. What asks userWords now passes over the snapshot as
it passes over Codex's context:
- the conversation's id runs from the snapshot through what the user
typed (conversationOpening);
- the turn count: [snapshot][typed] is turn 1, where it was 2
(turnIn);
- a group's conversation key is the typed words, where it was the
snapshot, the same for every conversation in the workspace
(firstWords, in ruleKey and the affinity scope);
- the turn before, which the classifier is told (turnBefore): on a
conversation's first turn, and on each turn a new snapshot comes
with, it was the snapshot, workspace and memory and all, as the
user's previous message with no reply; now it is nothing on a first
turn, and the user's words before the snapshot and the reply to them
on a later one;
- the classifier's question, Copilot's Auto and gatewayQuery take the
user's last words before a snapshot sent after them, and the Claude
subscription takes one after tool results as the agent's notice
(agentNotice).
A Reasonix conversation under way when this lands gets an id of its
own on its next turn and is routed once as a new conversation, as the
previous commit says of the others: it may move to another account,
and its cache there starts over.
The shape is the report's, which keeyangyy read from Reasonix's source
(internal/sessioncontext) and didn't capture; its folder and digest
are left out as they left them, and the tests use it as written.
Not changed: the prompt breakdown (promptBuilder.userText) keeps its
own list of Codex's blocks and still files the snapshot as a chat
turn, so a Reasonix conversation's first turn shows there as two
turns, where Codex's context adds none. That is left for a commit of
its own.
What was run (tree 71364f08, on origin/main a5315c70, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077:
- With the previous commit's prompt.go and the tests as committed, the
four tests this commit touches are red:
TestReasonixConversationsInOneWorkspaceAreApart on every protocol
("chat: two conversations opened on one snapshot:
magpie-310d1b42730f273079337f01 and magpie-310d1b42730f273079337f01
(the snapshot alone: magpie-310d1b42730f273079337f01)");
TestNewConversationsInOneFolderAreRoutedApart ("Reasonix's second
conversation went to k2 as "session", conv
magpie-310d1b42730f273079337f01; its first is on k2, conv
magpie-310d1b42730f273079337f01"); TestTurnInSkipsWhatTheAgentPutIn
("Reasonix's snapshot, then the user's words: turn 2 within false,
want 1 false"); TestFirstWordsAreWhatTheUserSaid ("key changed for
conversation 4").
- Here, those four -count=5: 20 pass.
- The tests of the opening and of what userWords feeds, in
internal/gateway, sessions, gui and provider (the conversation id,
dsh's ids, affinity, rotate, strict, OpenCode's sessions, the turn
count, the classifier's question, firstWords, Copilot's Auto, a
rule's turn held past an agent's message): ok, 121 top-level tests
passed, none failed.
- The previous commit's 12 hand-breaks of conversationOpening,
userOpens and writeOpening, each alone on this tree: each red on the
same tests as at a6037f68, and the first (the first user message
hashed alone) also on TestReasonixConversationsInOneWorkspaceAreApart.
- -race -count=5 of the routing and opening tests with the new ones:
85 pass, no race. -race -count=3 of the two allocation bounds: 6
pass.
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
build -tags nogui for linux and darwin, and go vet and go build for
windows without the tag: exit 0 each. go vet and go build without the
tag on linux: exit 1 (no libsoup-3.0 or gio-unix-2.0 here).
- go test -tags nogui -count=1 -timeout 45m ./... (Bun 1.4.2, log
kept; 8m43s, load 28 at its start): 72 packages ok, 5 red, none of
them this commit's tests or what they cover. internal/gateway ran to
its end (510s), so the new tests passed in it. The reds: agent
TestInstalledVersion, TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
TestOmpDetectedWithPiDir (#3141), and
TestReasonixCLIRequiresSupportedNativeVersion and
TestReasonixCLIRecoversAfterProbeTimeout (#3641, the Agents page's
check of the Reasonix CLI, which this doesn't reach); edit
TestWriteAtomicReadOnlyHardLink and testenv TestProgram (umask 077,
#3640); gateway TestPluginToldWhereTheAgentWorks (#3675) and
TestUploadStillUnderwayIsNotCutByHealthPing (red on main, #3909,
which has a test-only patch); gui TestGatewayHeldByAContainer and
TestGatewayFixQuitsOnlyAMagpie (#3649).
Not tried: Reasonix itself, or a body it sent. Its source
(internal/agent/session_context.go, 1.39.10) sends a new snapshot only
when its digest changes, as a user message of its own; the openai
provider magpie writes for it (internal/agent/reasonix.go) sends each
message as a Chat message of its own, and its Anthropic provider,
which merges adjacent user messages, keeps the snapshot a text block of
its own, which userWords reads alone.
Ported with the commit before onto origin/main 5ee5274bd from
JoeyWu-tech/magpie fix/3938-opening-run-4 (02c1de292, f50687a46; posted
on #3938, sha256 7cdb7e83...). The code applied as is; the docs and
extrabody.go's comment were merged by hand beside main's newer text
(${threadId}, ${subagentId}).
What was run for the port (mote, macOS, go1.26.8): the five tests in
conversation_opening_test.go and user_said_test.go's new case, with
the conversation id, dsh, affinity, rotate, strict, sticks and extra
body tests: ok. The same tests on 5ee5274bd (old code, new tests):
TestConversationsOnOneEnvironmentMessageAreApart (chat, messages,
responses, gemini, gemini without roles),
TestReasonixConversationsInOneWorkspaceAreApart,
TestCacheMarkMovingOnKeepsTheID, TestOpeningHashReadsInPlace and
TestNewConversationsInOneFolderAreRoutedApart red.
Batch run, at tree 104d75f0a (the twelve coffemon ports together, on
origin/main 7d022bdb6), mote, macOS, go1.26.8:
- go test -tags nogui -count=1 -timeout 45m on the packages the batch
changes (agent, autostart, daemon, gateway, library, proc, provider,
sessions, testenv, tui, gui): ok each.
- GUI, node --test with Playwright 1.62.0, Chromium and WebKit:
library-*.test.cjs and i18n-keys.test.cjs, 1044 of 1044 pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... and go build ./...: ok at cdd7c8e46, the same
batch on origin/main 00098f12b one rebase before.
- The whole go test ./... at cdd7c8e46: 86 packages ok, one red,
internal/cli TestEveryRouteHasACommandOrIsNamed (GET
/api/context/reply has no command), red on main too (#5026).
- Linux (wsl-run, Ubuntu 24.04, at 339055896, the batch on f4c664a09):
proc, autostart, testenv, tui ok; agent: only TestGrokInstalled red
(#3548); #4033's proc.Look reds (Zed, Copilot, Qoder, Cursor, Omp)
pass.
- Windows (win-run, Windows 11, at 339055896): proc, autostart, testenv,
tui ok; library and agent red in the same tests as on origin/main
f4c664a09 (#4115, #1827, #4786; #5068, #5069, #5070 filed now).
- Rebased onto origin/main fb1f4856a (three commits, no file in
common with the batch) and run again at the pushed tree: gofmt -l
nothing, go build ./... and go vet ./... ok; go test -tags nogui
sessions, agent, autostart, tui, proc, testenv ok; i18n-keys and
library-* 1044 of 1044 pass.
- Not run before the push: the whole GUI suite (a run at cdd7c8e46 was
cut off at 1170 of ~1174 tests when mote rebooted; it runs again after
the tag and any red is filed).
keeyangyy (#3938): with no session header, conversationID named a
conversation by the raw bytes of its first user message alone. Some
agents open every conversation on a message they write themselves and
send what the user typed as the next user message:
{"role":"user","content":"<environment_context>cwd=/w/proj ...</environment_context>"},
{"role":"user","content":"the question the user actually typed"}
That message is the same in every conversation started in one folder,
so all of them had one id: under Stays = session each new one was kept
on the account that answered the first, and rotate never moved on.
conversationOpening now says what is hashed, from the first user
message on (Chat and Anthropic messages, Responses input, Gemini
contents, where an omitted role is the user's):
- A first user message that holds anything of the user's own is hashed
alone, as the request has it, exactly as before: their words
(userWords, which already tells an <environment_context> or
<user_instructions> block or an instruction file from what the user
typed), an image, a file or a recording (userOpens). So is one that
holds a tool's result.
- One the agent wrote alone is hashed with the user messages after it,
in order, through the first that holds the user's own. A system or
developer message between them is passed over.
- A reply, a call, its output, reasoning, a tool's result (Gemini's
function result too), an item without a role (Chat, Responses) or
one that can't be read ends the opening. With nothing of the user's
before it, the first message is hashed alone, as before.
Every later turn repeats the opening before the first reply, so the id
holds through the conversation. A Responses input that is one string
is hashed as before.
An opening of several messages is hashed as writeOpening reads them,
one after another: every object's members in key order with no space
between, no cache_control at any depth, and a content of one text part
as that part's text. An agent marks its newest user message for the
cache and moves the mark on next turn, so the typed message's bytes
change at turn 2; some spell a marked message as a list of one part and
an unmarked one as a plain string (dsh does). Hashed as sent, an
opening of several would get a new id at its second turn, and on
/v1/messages under rotate that turn would go to the other key as a new
conversation (below). writeOpening reads the messages where they are:
the id of a 1.1 MB body whose opening holds a screenshot allocates
about 10 KB (TestOpeningHashReadsInPlace).
Every conversation whose first user message is the user's own keeps
the id it has, so no stick record needs moving. One that opened on an
agent's message and is under way when this lands gets an id of its own
on its next turn and is routed once as a new conversation: it may move
to another account, and its cache there starts over. The record they
all shared stays under the old id.
A tool's result (Anthropic clients send it as a user message) ends the
opening: it answers a call the model made, so the opening is over. A
history that starts with one was cut by its client (magpie takes such
orphans, TestMessagesOrphanToolResultWithoutACallBecomesText). Its
opening is gone, and whatever was taken in after the cut would move the
id each time the client cuts again, so its first message is hashed
alone, as before.
Not the issue's "first two user messages", nor every user message up
to the first reply: in an ordinary conversation the second user message
is the next turn, so the id would move when it arrives, and every
record would need the migration the issue describes. And a run of
every user message takes in what dsh sends after the typed prompt, its
runtime context, where the Context page finds dsh's sessions by the
typed prompt's hash alone; TestDshSessionConvsAreTheGatewayIDs and
TestDshRoutesCarryTheSessionConvs go red under such a run (below).
What reads the id moves with it: stickKey (session, turn and strict
affinity, and rotate's spread of new conversations), the Routing
trace's conv (convOf), a sealed task's lead (leadProvider,
loggedAnswerers), extraBody's ${sessionId}, Kilo's task and session
headers (KiloClient), X-Magpie-Conversation to plugins and OpenCode's
x-opencode-session fallback (openCodeSeed). A group rule's key reads
conversationID without a body, beside firstWords, which already passes
over the agent's blocks, so it doesn't change. One reader rebuilds the
id itself: sessions' dshConvs, which the Context page joins dsh's
sessions by (joinConvs). It hashes dsh's typed prompt, a first user
message of the user's own, which is still hashed alone, so its ids stay
the same. Nothing else in sessions, gui or elsewhere rebuilds a
"magpie-" id. The comments that named the first user message, and the
Gateway routing and Providers and accounts pages, say what the id is
now.
Siblings left for a decision, each in an issue filed with this
patch: #3988, ChatGPT accounts (conversationKey in
internal/provider/codex_request.go, for a client that sends no
prompt_cache_key), and #3989, Antigravity accounts (antigravitySession
in internal/provider/google.go). Both hash the first user message in the
provider package, and userWords is the gateway's.
Not changed: a fixed first message that userWords doesn't read as the
agent's is still hashed alone, so the conversations an agent opens on
it still share one id. A first user message hashed alone is hashed as
the request has it, cache mark and all, so a client without a session
header that marks that message on its first turn only gets a new id at
its second, as before. An agent that answers its own first message
with a fixed reply before the user's turn ends the opening at that
reply, so its first message is hashed alone too.
What was run (tree 523c770b, on origin/main a5315c70, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077:
- This commit's tree alone: not run. It is a6037f68 rebased: its
internal/ diff is the same (one patch-id), and
docs/subsystems/gateway-routing.md was merged by hand beside main's
new One try row. At the next commit's tree (71364f08), which adds a
line to userWords' list and tests: this commit's tests, every break
below again, -race, vet and the full suite, recorded in the next
commit.
The rest is what was run for a6037f68, at tree e8fc1eee on origin/main
e9dd8e83, the same code (not this tree):
- New: TestConversationsOnOneEnvironmentMessageAreApart, on Chat,
Messages, Responses and Gemini bodies, the last with and without
roles. The issue's two conversations from one folder get two ids,
neither the environment message's own, and each keeps its id on its
next turn. A conversation that opens in the user's words has
"magpie-" and the hex of sha256(its first user message)[:12], alone,
on a later turn and with the agent's message after it. A screenshot
after the agent's message opens a conversation as words do. A
developer or system message between them doesn't move the id. dsh's
turn, its runtime context marked for the cache, has the typed
message's own. A history cut at a tool's result keeps its first
message's own, and so do these after the agent's message: a tool's
result, a Chat message without a role, a Responses call, its output
or reasoning, and a Gemini function's result, in a user content or
in its own role. A Responses string input is hashed as before.
TestCacheMarkMovingOnKeepsTheID: the issue's opening on Messages,
Chat and Responses, the mark on each turn's newest user message,
turns 1, 2 and 3 with one id, the typed message going on unmarked as
one part, as a plain string or with a screenshot, and on Chat marked
on the message itself. TestOpeningHashReadsInPlace: the 1.1 MB body
above under image_input_test.go's bar of an eighth of the body.
TestNewConversationsInOneFolderAreRoutedApart: two keys, rotate,
Stays = session, no session header. On /v1/chat/completions the two
conversations are each "first", on different keys with different
convs, and each next turn stays on its key as "session" with its
conv. On /v1/messages a third conversation, its mark moving on, is
"first" and turns 2 and 3 stay on its key as "session" with its conv.
- Broken by hand, each red:
- back to the first user message alone (the old rule):
TestConversationsOnOneEnvironmentMessageAreApart on all five bodies
("two conversations opened on one environment message": one id, the
message's own; and the screenshot case),
TestCacheMarkMovingOnKeepsTheID (each of its ten first turns the
environment message's own),
TestOpeningHashReadsInPlace ("the environment message was hashed
alone") and TestNewConversationsInOneFolderAreRoutedApart (the
second conversation on k1 as "session", with the first's conv).
- every consecutive user message, unread: the five bodies' cases
with the agent's message after the user's, the screenshot cases,
dsh's two turns, the cut history, the tool's result after the
agent's message and Gemini's function result in a user content,
and TestDshSessionConvsAreTheGatewayIDs and
TestDshRoutesCarryTheSessionConvs (the turn's conv not among the
session's).
- a tool's result taken into the opening, and passed over like a
developer message: the cut history, the tool's result after the
agent's message and Gemini's function result, each way.
- a system or developer message ending the opening: the Chat and
Responses pairs.
- an image, a file or a recording not counted as the user's: the
screenshot case on all five bodies.
- an item without a role passed over like a developer message: the
Chat message without a role and the Responses call, output and
reasoning.
- Gemini's functionResponse not read as a tool's result: its case.
- an opening of several hashed as sent:
TestCacheMarkMovingOnKeepsTheID at turns 2 and 3 in all ten
spellings, and on /v1/messages turn 2 went to k2 as "first" with a
new conv, where turn 1 was on k1.
- cache marks kept: the screenshot spellings and the message marked
on Chat, at turns 2 and 3 (a one-part content is read as its text
either way).
- a content of one text part not read as its text: the three plain
string spellings at turns 2 and 3.
- each string copied before it is hashed: TestOpeningHashReadsInPlace,
2,233,788 bytes an id.
- With their neighbours, -v: TestConversationID, the Dsh tests in
gateway and sessions, TestContextDshSessionTitles,
TestImageWalkReadsTextOnlyTurnsInPlace, the orphan tool result tests,
TestClaudeConversationKeepsItsAccountsCache, and the affinity,
rotate, strict, sticks, session route, OpenCode, extra body,
WorkBuddy session and gateway conversation tests: 115 tests in
gateway, sessions, gui and provider pass (154 with subtests).
- -race -count=5: TestConversationsOnOneEnvironmentMessageAreApart,
TestCacheMarkMovingOnKeepsTheID,
TestNewConversationsInOneFolderAreRoutedApart, TestAffinity,
TestRotateSpreadsSessions, TestRotateSpreadsABurstOfNewConversations,
TestGeminiFallbackSessionAffinity, TestSticksWrittenBehind, the three
TestStrictAffinity tests, the two dsh conv tests and
TestClaudeConversationKeepsItsAccountsCache: 14 tests, 5 of 5 each.
-race -count=3: TestOpeningHashReadsInPlace and
TestImageWalkReadsTextOnlyTurnsInPlace, 3 of 3 each (the id under
-race: 17 to 32 KB).
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
build -tags nogui for linux and darwin, and go vet and go build for
windows without the tag: exit 0 each. go vet and go build without
the tag on linux: exit 1 (this box has no GTK or WebKitGTK dev
packages).
- go test -tags nogui -count=1 -timeout 45m ./... (tools/suite.sh, Bun
1.4.2, log kept; 8m23s, load 21 at its start): 71 packages ok, 5
red, none in what this changes: agent TestInstalledVersion,
TestCursorFolderFromTheEditorIsNotTheCLI,
TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
and TestZedAppPath (#3141), TestCodexDriftReached (#3398) and the two
Reasonix tests (#3641); edit TestWriteAtomicReadOnlyHardLink and
testenv TestProgram (umask 077, #3640); gateway
TestPluginToldWhereTheAgentWorks (#3675), the package ran to its
end, so the new tests passed in it too; gui
TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
(#3649).
Not tried: keeyangyy's own client, or any real agent end to end.
Batch run, at tree 104d75f0a (the twelve coffemon ports together, on
origin/main 7d022bdb6), mote, macOS, go1.26.8:
- go test -tags nogui -count=1 -timeout 45m on the packages the batch
changes (agent, autostart, daemon, gateway, library, proc, provider,
sessions, testenv, tui, gui): ok each.
- GUI, node --test with Playwright 1.62.0, Chromium and WebKit:
library-*.test.cjs and i18n-keys.test.cjs, 1044 of 1044 pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... and go build ./...: ok at cdd7c8e46, the same
batch on origin/main 00098f12b one rebase before.
- The whole go test ./... at cdd7c8e46: 86 packages ok, one red,
internal/cli TestEveryRouteHasACommandOrIsNamed (GET
/api/context/reply has no command), red on main too (#5026).
- Linux (wsl-run, Ubuntu 24.04, at 339055896, the batch on f4c664a09):
proc, autostart, testenv, tui ok; agent: only TestGrokInstalled red
(#3548); #4033's proc.Look reds (Zed, Copilot, Qoder, Cursor, Omp)
pass.
- Windows (win-run, Windows 11, at 339055896): proc, autostart, testenv,
tui ok; library and agent red in the same tests as on origin/main
f4c664a09 (#4115, #1827, #4786; #5068, #5069, #5070 filed now).
- Rebased onto origin/main fb1f4856a (three commits, no file in
common with the batch) and run again at the pushed tree: gofmt -l
nothing, go build ./... and go vet ./... ok; go test -tags nogui
sessions, agent, autostart, tui, proc, testenv ok; i18n-keys and
library-* 1044 of 1044 pass.
- Not run before the push: the whole GUI suite (a run at cdd7c8e46 was
cut off at 1170 of ~1174 tests when mote rebooted; it runs again after
the tag and any red is filed).
hheei (#3887): a Codex conversation with a web search in it (OpenAI's
own web_search, a web_search_call in its history) failed on every turn
with "HTTP 400: Codex: Encrypted content could not be decrypted or
parsed. (code: invalid_encrypted_content)" once magpie had moved it to
another ChatGPT account of the same routing group: after its affinity
went cold ("why": "cold", over two hours on), or after the account it
was on was used up or rate limited.
What an account's turn wrote comes back sealed for that account
(encrypted_content): its reasoning, a web search, and with Codex's
output token replay on (codex-rs core/src/client.rs: only for a provider
named "OpenAI", which Codex signed in reaches magpie as) each message
and call. Codex hands it all back on every turn, and between ChatGPT
accounts, or a ChatGPT account and an OpenAI API key, magpie sends it as
it came (forVendor, 2a19245c). The account asked next can't read the
first's seals and says so. serve asked again without the reasoning only
(withoutReasoning), was refused again over the web search, had no
compaction to leave out, and passed the 400 on. What it remembered as
refused for the conversation's later turns (refusedSeals) was reasoning
and compactions only, so each later turn went the same way. The relay of
Codex's own sign-in (withoutUnreadable) left only the reasoning out as
well.
Now such a refusal is asked again without every seal but a compaction's
(withoutSeals): reasoning goes whole, as before, and any other item
keeps all but its encrypted_content (withoutItemSeal, the rest of it
byte for byte). refused records what was taken out for the key or
account that refused, and withoutRefused leaves it out of the
conversation's later requests there up front, reasoning whole and the
rest by its seal alone. What that one sealed itself still goes along,
and a request on the account that sealed what it carries goes as it
came, so a turn that doesn't move keeps OpenAI's cache and replay as
before. A compaction keeps its own step (withoutCompaction after a
second refusal, unless native compaction is on). The relay asks again
the same way after its 400. The retry is serve's, so it holds whatever
moved the conversation: an account used up, rate limited or resting, the
next member of a group, routing's own pick once the affinity went cold;
on the backend path (one of Codex's own models, signed in) and on
/v1/responses (the codex provider's model, a group of it) alike.
gateway-routing.md says so.
A refusal doesn't say whose seal it couldn't read, so the account asked
loses its own seals from an earlier stay in the conversation too, and
they are remembered as refused, as its reasoning already was.
Not changed, each as on main (#3934): a context_compaction
another account sealed stays in through both steps (keepsSeal has it,
compactionKinds doesn't); the relay keeps no record of what was refused,
so each later turn there is refused once and asked again, and a refusal
in its stream reaches Codex as it came; the relay's /responses/compact
isn't asked again; the Routing view still calls such a try "another
account's reasoning" (client.js and its translations).
What was run (tree 326b178e, on origin/main f8cd964a, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077:
- TestForeignSealedItemsMoveToAnotherAccount, new: a conversation
holding acct-1's sealed reasoning, web search, call and answer moves
to acct-2 as acct-1 answers 429 or response.failed
rate_limit_exceeded, signed in, as codex/gpt-5.5 and as group/g,
acct-2 refusing with a 400 or in its stream (12 cases). acct-2 is
asked with every seal, refuses, is asked again bare and answers, and
the next turn asks it bare with its own seals on: ok
- TestForeignSealedItemsAfterAColdSwitch, new: the same conversation
moved back to acct-1 by its affinity gone cold (Why "cold"), 6 cases:
ok
- TestForeignSealedItemsRelayedToAnotherSignIn, new: Codex's own sign-in
relayed as acct-2, the history sealed by acct-1: ok
- TestSealsTakenOutLeaveTheRest, new: the exact bytes withoutSeals and
withoutRefused leave (a seal first, in the middle and last in its
item; compactions keeping theirs; reasoning alone taken as
withoutKinds took it), and nothing taken out for another account or
conversation: ok
- the three new end-to-end tests with affinity.go, gateway.go,
codex_backend.go and routing.go as on main (swapped in through go test
-overlay, the checkout left as committed; the unit test left out, as
it calls withoutSeals): 21 of 21 red. The 400 cases: "moved on: 400
{"error":{"code":"invalid_encrypted_content","message":"Codex:
Encrypted content could not be decrypted or
parsed.","param":null,"type":"invalid_request_error"}}", and "gone
cold: 400" with the same; in the stream: "moved on: 200" and "gone
cold: 200", the response.failed invalid_encrypted_content passed on to
Codex; the relay: "400 {"error":{"message":"Encrypted content could
not be decrypted or parsed.", ...
"code":"invalid_encrypted_content"}}"
- broken by hand, one at a time, each swapped in the same way, beside
the tests already there for foreign seals, compactions, reasoning and
output replay (TestForeignSeal*, TestForeignCompaction*,
TestForeignReasoning*, TestCodexOwnModelAfterAnotherVendor,
TestCodexSpentMovesToGrokWithSealedReasoning, TestCodexOutputReplay*),
all green under each but where named:
- serve's retry taking the reasoning only (withoutKinds(body,
"reasoning")): TestForeignSealedItemsMoveToAnotherAccount (12 of 12)
and TestForeignSealedItemsAfterAColdSwitch (6 of 6) red, "moved on:
400" and "gone cold: 400" with the error as on main
- the relay's taking the reasoning only:
TestForeignSealedItemsRelayedToAnotherSignIn red, "400
{"error":{"message":"Encrypted content could not be decrypted or
parsed.",...}}"
- refused recording reasoning and compactions only (seals as on main):
the same 18 cases and TestSealsTakenOutLeaveTheRest red, the next
turn refused once more, "then asked [{"acct-2" "message user,
web_search_call 上海天气 gAAAA-acct-1-w1, function_call c1
gAAAA-acct-1-f1, ..."} {"acct-2" ...}]", and "next turn:" with the
seals left on
- withoutRefused taking out reasoning and compactions only: the same
19 red, with the same lines
- withoutRefused dropping each refused item whole: the same 19 red,
"then asked [{"acct-2" "message user, message assistant, message
user, message assistant, message user, reasoning gAAAA-acct-2-r3,
..."}]", the searches and calls gone
- withoutItemSeal writing the item out again (marshalPlain):
TestSealsTakenOutLeaveTheRest red, "got {...}" with the web search's
keys sorted,
{"action":{...},"id":"ws_1",...,"type":"web_search_call"}
- withoutItemSeal without its keepsSeal check:
TestSealsTakenOutLeaveTheRest and TestForeignCompactionToGrok red,
"grok was sent [["compaction:sealed-by-openai-compaction"
"reasoning:sealed-by-openai"] []]": the compaction lost its seal in
the first step instead of going in its own
- the related tests (TestForeign*, TestCodexOwnModel*, TestCodexSpent*,
output replay, the rewrite equivalence tests, TestAffinity*,
TestNativeCompaction*, TestRemoteMagpie*, TestGatewayKey*, groups and
Codex accounts): 257 passed with their subtests, none skipped (Bun
1.4.2)
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway (log
kept), Bun 1.4.2: 5418 passed with their subtests, 3 skipped, and one
red, TestPluginToldWhereTheAgentWorks (#3675): "not in one: the plugin
was told "/tmp/TestPluginToldWhereTheAgentWorks191044475/005", git
"yes"; want "/tmp/TestPluginToldWhereTheAgentWorks191044475/005",
"no"". It is red the same alone, and with the four code files as on
f8cd964a: this box has an empty /tmp/.git, and GitOnDisk counts a .git
in any folder above.
- read against main's 7f0f71a0 (#2481) and fff05e55 (#2725), which
change code beside this: 7f0f71a0 puts the route on two of the relay's
record exits, which come after withoutUnreadable has chosen the body
asked again; fff05e55 changes only whether Codex's compaction trigger
is kept native (plannedCarrier), not serve's retry or the step it
skips for a provider compacting natively (compactsNatively), so a
trigger it now has magpie summarise goes through serve and the same
retry. Neither changes what withoutSeals or withoutUnreadable do.
- go test -tags nogui -count=1 -timeout 45m ./... (log kept), Bun
1.4.2: 69 packages ok and 7 red, none in what this changes; gateway's
only red is TestPluginToldWhereTheAgentWorks (#3675), the new tests
pass in it. The reds: agent TestInstalledVersion,
TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
TestOmpDetectedWithPiDir (#3141), the two Reasonix tests (#3641) and
TestWSLColdPlaceOpensNothing (#3924); edit
TestWriteAtomicReadOnlyHardLink and testenv TestProgram (umask 077,
#3640); gui TestGatewayHeldByAContainer and
TestGatewayFixQuitsOnlyAMagpie (#3649); provider
TestCodexAppServersOnHome (#3906), then "close of synctest channel
from outside bubble" (#3632); tui
TestTUIFetchesSubscriptionModels/agent (#3919).
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
build -tags nogui for linux and darwin, and go vet and go build for
windows without the tag: exit 0 each. go vet and go build without the
tag on linux: exit 1 (this box has no GTK or WebKitGTK dev packages).
Not tried: real ChatGPT or OpenAI accounts. Whether the ChatGPT backend
takes a web_search_call with neither its id (magpie's Codex account
route sends none, as on main) nor its seal; hheei's 200 was OpenAI's
Responses API with the id kept. Whether one account refuses another's
replayed message and call seals at all (the fake does; if it reads them,
they are still taken out on a hop, where the conversation's cache is
gone anyway). OpenAI refusing in the stream: the fake does, as xAI may;
hheei's refusal came as a 400. An OpenAI API key as the next member of a
group: forVendor keeps the seals for *openai.com only, so a fake on
127.0.0.1 can't stand in for it; it reaches the same retry in serve. Nor
magpie's summary of a Codex compaction after a move: codexCompact asks
through serve, so the same retry should apply, but no test drives it.
Ported onto origin/main 5ee5274bd from yinwu01/magpie 2d764b1c (posted
on #3887, sha256 d9185e84...). Conflicts resolved by hand: main had
since grown noteRefused (also used by reasoning_carry.go's
refuseCarried), so refused(key, who, sent, left) now hands it the seals
sent minus those left; foreignReasoning keeps main's broader pattern;
foreign_seal_test.go keeps main's TestForeignSealAzureSummary and
TestForeignSealGrokRelayCompactionBlob beside the four new tests; the
Affinity row and the new bullet in gateway-routing.md were merged into
main's text.
What was run for the port (mote, macOS, go1.26.8):
- go vet -tags nogui ./internal/gateway, and go test -tags nogui
-count=1 -run 'TestForeign|TestSeals|TestCodexOutputReplay|
TestCodexOwnModel|TestCodexSpent|TestRefused|TestReasoningCarr|
TestWithout|TestNativeCompaction' ./internal/gateway: ok
- the three new end-to-end tests on 5ee5274bd (old code, the unit test
left out as it calls withoutSeals): all red,
TestForeignSealedItemsMoveToAnotherAccount and ...AfterAColdSwitch
"moved on: 400 {...invalid_encrypted_content... Codex: Encrypted
content could not be decrypted or parsed.}" and "gone cold: 400",
...RelayedToAnotherSignIn "400 {...Encrypted content could not be
decrypted or parsed...}"
Batch run, at tree 104d75f0a (the twelve coffemon ports together, on
origin/main 7d022bdb6), mote, macOS, go1.26.8:
- go test -tags nogui -count=1 -timeout 45m on the packages the batch
changes (agent, autostart, daemon, gateway, library, proc, provider,
sessions, testenv, tui, gui): ok each.
- GUI, node --test with Playwright 1.62.0, Chromium and WebKit:
library-*.test.cjs and i18n-keys.test.cjs, 1044 of 1044 pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... and go build ./...: ok at cdd7c8e46, the same
batch on origin/main 00098f12b one rebase before.
- The whole go test ./... at cdd7c8e46: 86 packages ok, one red,
internal/cli TestEveryRouteHasACommandOrIsNamed (GET
/api/context/reply has no command), red on main too (#5026).
- Linux (wsl-run, Ubuntu 24.04, at 339055896, the batch on f4c664a09):
proc, autostart, testenv, tui ok; agent: only TestGrokInstalled red
(#3548); #4033's proc.Look reds (Zed, Copilot, Qoder, Cursor, Omp)
pass.
- Windows (win-run, Windows 11, at 339055896): proc, autostart, testenv,
tui ok; library and agent red in the same tests as on origin/main
f4c664a09 (#4115, #1827, #4786; #5068, #5069, #5070 filed now).
- Rebased onto origin/main fb1f4856a (three commits, no file in
common with the batch) and run again at the pushed tree: gofmt -l
nothing, go build ./... and go vet ./... ok; go test -tags nogui
sessions, agent, autostart, tui, proc, testenv ok; i18n-keys and
library-* 1044 of 1044 pass.
- Not run before the push: the whole GUI suite (a run at cdd7c8e46 was
cut off at 1170 of ~1174 tests when mote rebooted; it runs again after
the tag and any red is filed).
Adapt JoeyWu-tech f9d7eac9: do not retain lookup answers or directory listings while their timestamps are fresh. Freeze the clock in the same-tick regression so scheduler delays cannot age the fixture. Keep the settled/future directory cache and document the 100ms resolution limit.
Validation: the same-tick regression fails with both old layers, only the stamp fixed, and only the listing fixed. Restored proc lookup and four affected agent tests pass five race runs.
Batch run, at tree 104d75f0a (the twelve coffemon ports together, on
origin/main 7d022bdb6), mote, macOS, go1.26.8:
- go test -tags nogui -count=1 -timeout 45m on the packages the batch
changes (agent, autostart, daemon, gateway, library, proc, provider,
sessions, testenv, tui, gui): ok each.
- GUI, node --test with Playwright 1.62.0, Chromium and WebKit:
library-*.test.cjs and i18n-keys.test.cjs, 1044 of 1044 pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./... and go build ./...: ok at cdd7c8e46, the same
batch on origin/main 00098f12b one rebase before.
- The whole go test ./... at cdd7c8e46: 86 packages ok, one red,
internal/cli TestEveryRouteHasACommandOrIsNamed (GET
/api/context/reply has no command), red on main too (#5026).
- Linux (wsl-run, Ubuntu 24.04, at 339055896, the batch on f4c664a09):
proc, autostart, testenv, tui ok; agent: only TestGrokInstalled red
(#3548); #4033's proc.Look reds (Zed, Copilot, Qoder, Cursor, Omp)
pass.
- Windows (win-run, Windows 11, at 339055896): proc, autostart, testenv,
tui ok; library and agent red in the same tests as on origin/main
f4c664a09 (#4115, #1827, #4786; #5068, #5069, #5070 filed now).
- Rebased onto origin/main fb1f4856a (three commits, no file in
common with the batch) and run again at the pushed tree: gofmt -l
nothing, go build ./... and go vet ./... ok; go test -tags nogui
sessions, agent, autostart, tui, proc, testenv ok; i18n-keys and
library-* 1044 of 1044 pass.
- Not run before the push: the whole GUI suite (a run at cdd7c8e46 was
cut off at 1170 of ~1174 tests when mote rebooted; it runs again after
the tag and any red is filed).
Co-authored-by: JoeyWu-tech <joey110551567@gmail.com>
Sky (skyhuang1994) on Discord, on their real ZCode database after
v0.1.2847 (1d0fc2bb0): September's message table holds 57,787 rows,
13.552B tokens; 5,204 rows (1.537B) carry a forkOrigin and are copies,
and ZCode's cloud usage says 12.057B. The new version took 5.094B out,
3.6B of it real. The biggest was the "msc" session: forked at the end of
August, then 11,409 calls of its own in September (3.489B), none with a
forkOrigin, a custom-UUID provider. The Usage page had 0 of them.
Cause (ZCode): readZCodeCalls marked copies in a map keyed by m.ID. A
row's id is in the message table's id column, not in its data (OpenCode
writes data without id; checked on this machine's real opencode.db: 2 of 2
rows have no $.id), so every message decodes with ID "". One copy in a
session set copies[""], and every assistant message of that session was
left out: a fork that went on working lost all of its own calls. The test
fixtures had "id" inside data, so they never saw it. The Sessions page
(parseOpenCode) asks zcDB.copied per message and was right.
Fix: copies are marked by row index. Only a message whose forkOrigin
names a messageId still in the database is skipped.
Codex: a fork's checkpoint was a copy whenever its {total, last} was one
the parent's rollout holds, anywhere in the fork. A fork goes on working,
and its first own call can carry exactly the numbers of the parent's
next call after the fork (same history, same next prompt). The copies
are now the head of the fork only: the fork's first turn_id the parent
never had (turn_context or task_started) ends them (ownTurn,
CopiedTurns, read with the parent's checkpoints). A rollout with no turn
ids is matched as before; its running total keeps later calls apart.
callParseVersions codex 2, zcode 2 and parseVersions codex 2, so the
parses kept by v0.1.2847 are read again once. ZCode's Sessions parse
didn't change and stays at 1.
Tests (fixtures follow Sky's case: a parent of 08-30, a fork with
forkOrigin copies of its replies, ZCode's fork notice, then 40 replies of
its own in September with no forkOrigin, no id in data, provider a UUID):
- TestZCodeForkThatWentOnWorkingKeepsItsOwnCalls: red on origin/main
7d022bdb6 ("the fork's calls: 0 {...}, want its 40 own"), as Sky saw.
- TestCodexForkThatWentOnWorkingKeepsItsOwnCalls: red on main and with
ownTurn turned off by hand (1 call on the fork, want its 2 own).
docs/subsystems/gateway-sessions.md says this.
Run on mote (mote-run) at this change on origin/main 7d022bdb6; rebased
on 08d7bfaaa (gui, redact, gateway-key only), go build ./... and
internal/sessions run again: ok.
- gofmt -l internal: empty
- GOOS=linux go vet -tags nogui ./... ; GOOS=windows go vet ./... : ok
- go test -count=1 -timeout 45m ./internal/sessions ./internal/usage
./internal/tune ./internal/otlp ./internal/davsync ./internal/tui : ok
- go test -run 'Session|Usage|Calls|Ledger|Stats|ZCode|Codex|Fork'
./internal/gui ./internal/cli : ok
Broken by hand:
- the copies keyed by message id again (origin/main): the ZCode test red,
0 calls on the fork.
- ownTurn's call in context() off: the Codex test red, 1 call on the fork.
Not tried:
- Sky's real ZCode database; there is none on this machine and no ZCode
source to read its writer. That ZCode's data has no id, as OpenCode's,
rests on the symptom (every row of the fork gone) and OpenCode's real
rows here.
- a real forked Codex rollout that went on working; the turn ids of a
real 0.117 fork were read from the fixtures' shape, not a real file.
- the whole gui and gateway suites, and a full go test ./...: other
sessions' suites were running on mote.
Cause: an agent in a WSL distro could only get copies (Target.Copy).
A distro can't follow a link to the library's folder on Windows. A
link Windows makes through \\wsl.localhost (os.Symlink) is an empty
folder inside the distro. Windows can't use a link the distro has: it
can Lstat one (irregular), but Readlink fails ("Incorrect function"),
and Stat, ReadDir and Remove all say it isn't there. Probed on
xiaomi-gpu with magpie-desktop. So every agent there got a copy of
its own of every skill.
Now each distro keeps one copy of each skill its agents are given,
magpie's and marked, in ~/.local/share/magpie/skills (Target.Store,
storeSkill). Each agent there gets a link to it, which wsl.exe makes,
reads and removes inside the distro (agent.WSLSymlink, WSLReadlink,
WSLRemoveLink). The scripts refuse to put a link over a folder or file.
- An edit made through the link is in that copy, and takeEdits reads
it like any copy of magpie's.
- When no agent there links to a copy or is given its skill any more,
sweepWSLStores removes it. An edited copy goes to the backups.
- A folder in the store that isn't magpie's is never touched. Each
agent it blocks reports a problem and keeps what it had.
- An agent set to copies (SkillHow) still gets copies of its own.
- So does one whose skills folder or the store is on a Windows drive
(#4502): a link the distro makes there can't be read from Windows.
- The copy isn't put in the distro's ~/.agents/skills. Every agent
there that reads that folder would get each skill, ticked or not.
- A stopped distro's agents are now shown as linked (HowLink), not as
forced to copies.
Agents that read ~/.agents/skills on their own (readsShared, checked
against each one's source or docs when the list was made): Codex,
Gemini CLI, OpenCode, DevEco Code, Crush, dsh, Command Code, Devin,
Droid, Cline, Grok Build, Grok App, fx, Alma, Kimi Code and OmO, plus
Pi from 0.54.0 and omp from 11.0.0. Claude Code doesn't. Ticks are per
agent, so the store keeps per-agent choices working in WSL.
Existing users: nothing to do. On the next sync, each per-agent copy
magpie made in a distro is replaced by a link:
- its edit is taken into the library first (newest edit wins);
- a copy whose edit lost is set aside with the backups (wslRelink);
- unmarked folders (the user's own skills) are left alone.
Run:
- mote, at 3f1f1882a plus this change:
- go test ./internal/library ./internal/agent -timeout 45m -count=1:
both ok (493 and 1210 Test funcs; library 184s, agent 312s).
- gofmt -l .: empty.
- GOOS=windows, linux and darwin go vet of both packages: ok.
- xiaomi-gpu, Windows 11, WSL 2, distro magpie-desktop only:
- TestWSLLinksLive passes. A link made through wsl.exe is followed by
the distro, read back from Windows, refused over a folder and
removed alone.
- TestWSLSkillsLinkedLive passes. Working in a /tmp home inside the
distro, it checks:
- links for Codex and Claude Code that the distro follows;
- a second sync changes nothing;
- an edit made in WSL through the link reaches the library and
Windows' Claude Code;
- copies, then links again;
- an untick removes the links and the store copy.
- go test ./internal/library ./internal/agent -run 'WSL|Wsl|Skill'
with MAGPIE_WSL_TEST_DISTRO set: library ok. In agent, only the
older TestWSLCodexLive is red. It calls wslList() without -l -q, so
it lists no distros. Filed as #5077; this change doesn't touch it.
New tests:
- TestWSLLinks (fake);
- TestWSLOldCopiesBecomeLinks, which edits a copy and then syncs;
- TestWSLEditThroughLinkReachesTheLibrary;
- TestWSLStoreSweepKeepsEdits;
- the two live tests above.
TestWSLSkillsCopied is now TestWSLSkillsLinked.
Broken by hand (logs in wsl-skills-scratch):
- WSL targets given copies again: 7 red, including TestWSLTargets,
TestWSLSkillsLinked and TestWSLOldCopiesBecomeLinks.
- takeEdits not following the link to the store: 1 red,
TestWSLEditThroughLinkReachesTheLibrary.
- ours not counting a link to the store: 3 red.
- wslLinkScript's folder refusal dropped: TestWSLLinksLive red on the
real distro.
Not tried:
- the magpie GUI on Windows against a real distro, and agents running
in a real WSL reading a skill through the link (the distro reads the
link's files, checked with cat);
- WSL 1;
- a distro whose home is on a Windows drive (covered by the fake
#4502 tests only);
- the GUI suite, since no GUI file changed.
roswellcsy on X (v0.1.2846). Claude Code was switched off magpie and on
its own sign-in, with several Claude accounts and one made first. Every
session said "There's an issue with the selected model
(claude/claude-opus-5-5)", while settings.json's model was the bare
claude-opus-5-5.
Cause: a name of magpie's left in Claude Code's env.
- The env's ANTHROPIC_MODEL outranks settings.json's model (Claude Code
2.1.316: Wg(), `i.ANTHROPIC_MODEL||settings.model`). The tier variables
stand in for opus/sonnet/haiku. On Anthropic's endpoint a
provider/model name is a 404, shown as that message.
- How it got there and kept coming back:
- Connecting a Claude Code that is not routed stashes its env models as
"the user's own" (claude.env.<VAR>), magpie's names included.
- Disconnect (unroute) then writes them back, again unchecked.
- Once one is there, every connect and switch-off keeps it.
- The bare model is the user's own, from connect.was or untouched.
- Nothing took the name out afterwards:
- unroute returned at once when not routed;
- Sync only did desktopOnly;
- Disconnect is a no-op once Wired() is false (a bare model with no
gateway URL).
- Sibling: wiring at an older gateway address (magpie's key) was left in
place by Disconnect, while set("") already took it out.
Fix (internal/agent/claude.go):
- claudeMagpieModel(v): v is a catalog ref, read through ClaudeRead and
with any :effort or [1m] taken off.
- It is never stashed as the user's own, and never given back from a
stash (one an older magpie wrote included).
- dropStray: with no ANTHROPIC_BASE_URL (Anthropic's own endpoint), every
claudeModelEnv key and `model` holding one of magpie's names is taken
out. ANTHROPIC_MODEL, SMALL_FAST, SUBAGENT, the four tiers and the
auto mode model are covered.
- It runs from Sync when not routed, so SyncCatalog repairs users
already in this state at the next start.
- It also runs from unroute when not routed (Disconnect, the default
model, a non-magpie model).
- An endpoint of the user's own may name its models so, and those
stay.
- unroute, when not routed: wiring at an older gateway address
(keyOurs) goes whole, as set("") takes it.
- docs/subsystems/agent-wiring.md says so.
Test: TestClaudeOffLeavesNoMagpieModel, in a sandbox HOME. Each subtest
reads settings.json as Claude Code starts on it (ANTHROPIC_MODEL over
model, the tiers, small fast, subagent, auto mode).
- start: the stray env, then SyncCatalog;
- connect + Disconnect twice;
- a stash an older magpie wrote;
- the user's own models come back;
- an older gateway address;
- another endpoint's names are left alone.
Red on the old code: start, connect+Disconnect and older-address fail
(red-old.log). "connected and switched off again" reproduces the report
exactly: model "claude-opus-5-5" with env ANTHROPIC_MODEL
"relay/claude-opus-5-5".
Broken by hand, each through mote-run:
- dropStray out of Sync: start red.
- Both stash guards out: connect+Disconnect red.
- The restore guard alone out: older-stash red.
- keyOurs cleanup off: older-address red.
- With the stash guard alone out, the restore guard still holds, so it
stays green.
Run on mote (mote-run, at d8501848a plus this change; the doc edit came
after the run):
- go test ./internal/agent/ ./internal/provider/ -count=1 -timeout 45m:
ok agent (200s), ok provider (136s).
- The new test: 7 of 7 PASS (the parent and 6 subtests).
- GOOS=windows go vet ./...: ok.
- GOOS=linux go vet -tags nogui ./...: ok. Without the tag it stops in
Wails' cgo-only Linux files when cross-compiling, which this change
doesn't touch. GOOS=linux go vet ./internal/agent/ ./internal/provider/
is ok too.
- gofmt -l: clean.
Not tried:
- A real Claude Code run against Anthropic. The 404 path was read from
the 2.1.316 bundle, not hit.
- The user's literal provider id claude/: the test uses a relay
provider. isMagpie resolves both the same way.
- WSL's Claude Code goes through the same claudeIn and wasn't run.
- A Claude Desktop Code tab with a provider/model in settings.json's
model and no base URL would also lose it at Sync. Desktop writes
mythos-magpie-<n> ids there, not provider/model ones.
Sky (skyhuang1994) on Discord: on ZCode, 10-31 showed ~0.70B GLM-5.3
tokens where ZCode's own model_usage had ~0.28B. A selection side chat
opened on 11-02 from a 10-31 session holds a copy of its 860 assistant
messages, with the 10-31 times and the same 421,041,276 tokens, and made
no calls. On Codex, a week of 2026-03 read 5,136,041,178 gpt-5.4 tokens,
where the machine had spent ~0.27B.
ZCode: ZCode 3.17's CLI copies a session's messages (gce, for a side
chat, a fork and a checkpoint restored) with a new id and session, the
original's time, model and tokens, and metadata.forkOrigin
{sessionId, messageId}. zcDB.copied says a message is a copy of one still
in the database, and readZCodeCalls and parseOpenCode (for ZCode) leave
it out. A copy of a copy names the copy it came from, so of each chain
one is counted. A copy whose original is gone is counted. ZCode's own
fork notices carry a forkOrigin with no messageId, and are not copies.
Codex: a fork (/fork, spawn_agent with the parent's context) writes every
line of the parent's rollout into its own first, token_count events too,
stamped at the fork's time (codex-rs 0.117 record_initial_history,
InitialHistory::Forked). Each copied checkpoint was booked as a call on
the fork's day. The fork's session_meta has forked_from_id. The parent's
rollout is found in the same Codex home: the UUIDv7 day of its id ±1
day, then every day, then archived_sessions. Its checkpoints, {total,
last}, are read once (8 parents kept), and a fork's checkpoint found among
them only advances the running total, on Usage (calls) and Sessions
(stats) both. A parent not found leaves the fork read as before.
callParseVersions and parseVersions raise codex and zcode to 1, so their
kept parses are read again once. The version tests (call_versions,
parse_versions, cache_decode) now hold the versions at none raised: they
test the mechanism, not the current numbers.
docs/subsystems/gateway-sessions.md says all of this. Filed #5072:
OpenCode's fork copies the same way and names no original, so it is
still counted twice.
Run at this head on mote (mote-run):
- gofmt -l internal: empty
- GOOS=linux go vet -tags nogui ./... ; GOOS=windows go vet ./... : ok
- go test -count=1 -timeout 45m ./internal/sessions ./internal/usage
./internal/tune ./internal/otlp ./internal/davsync ./internal/tui : ok
- go test -run 'Session|Usage|Calls|Ledger|Stats|ZCode|Codex'
./internal/gui ./internal/cli : ok
Broken by hand:
- zcDB.copied returning false: TestZCodeCopiesCountedOnce red. msg_c1 and
msg_d1 were counted as calls, and the Sessions page's 10-31 read
{1200 300 1800} for {400 100 600}.
- the copied() check in count() off: TestCodexForkCountsOnlyItsOwnCalls
red. 4 calls on the fork, {87984 5950 268416} for {45744 3550 179584}.
Not tried:
- a real ZCode database or side chat. There is none on this machine.
The copy shape was read from ZCode 3.17.2's zcode.cjs (gce).
- a real forked Codex rollout or one from 2026-03. ~/.codex/sessions here
spans 2026-07 to 11 and has no forks. The fixtures follow codex-rs
0.117's writer. Whether Sky's 5.1B week is all fork copies is not
known; a cumulative count read as per-turn in an older format was not
found in that source.
- newer rollouts' token_usage_record copies in a fork, and a parent in
another Codex home (WSL, CODEX_HOME).
- the whole gui and gateway suites. Another session's suite was running
on mote; gui and cli ran only the tests above.
axelburks on Discord listed what /v1/images/generations did to a Seedream
request against Ark's images API (docs 82379/1541523). Checked against
those docs and draw.go / draw_volcengine.go; the real ones:
- Image params were dropped. drawing read OpenAI's fields alone, so
sequential_image_generation and its options (a group of up to 15),
optimize_prompt_options, tools, layer_decomposition and every other
Ark field never reached Ark. Now the request's fields magpie doesn't
read (drawingRead) are drawing.Extra, from a JSON body or a multipart
form, masked as the prompt is (fails closed), and sent to Ark as they
came; a form's values are typed as Ark takes them (formValue, with
Ark's text fields kept as text). layer_decomposition with an image
needs no prompt.
- watermark and response_format were forced. Every request went with
watermark false and response_format b64_json. Now watermark false is
magpie's default only, and a caller's watermark wins; response_format
"url" asks Ark for its URL and answers it, anything else still asks
b64_json.
- stream true would have gone to Ark and come back as events this route
can't read: it is a 400 that names
/v1/magpie/native/<provider>/images/generations.
Kept as it was: n stays OpenAI's, that many requests, each one image or
one group.
Tests: TestArkImagesPassOnTheirOwnFields (a group, optimize_prompt_options,
a caller's watermark, tools and url reach Ark as sent; a form's fields
typed; stream refused naming the native route). Docs: gateway-routing.md
(the Ark images row and paragraph), docs/integrating.md and the site's
integrate page (en, zh) on the vendor fields and the native route.
Run on mote at the head of this stack (the Ark video fields, the native
route and the Ark image fields, three commits on af9ac3d25):
- go test -count=1 -timeout 45m ./internal/gateway ./internal/gui
./internal/access: gateway and access ok; gui red only in
TestMainWindowCorners/macOS_26_SDK (#3949, red on main).
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./...: clean. gofmt -l: nothing.
- No GUI file or script changes in this stack, so no GUI run.
The commits between were not run on their own at this base.
Broken by hand, each red, then put back:
- Extra not merged into Ark's request: TestArkImagesPassOnTheirOwnFields red
- response_format url not asked of Ark: TestArkImagesPassOnTheirOwnFields red
Not tried: no real Ark image was drawn (no money spent); the shapes are
from Ark's docs, on a fake Ark.
Credit: axelburks on Discord.
axelburks on Discord asked for a way to reach what the OpenAI-shaped
routes can't carry: Ark's image stream, its task list and cancel, a
field newer than magpie. A coordinator asked for it to stay behind the
gateway's key and auth like every route, and for the design to be said.
Decided:
- One route, /v1/magpie/native/{provider}/{path...} (POST, GET, DELETE),
for Volcengine Ark only (isArk, not a remote magpie), at the paths it
makes images and videos at: POST images/generations; POST/GET
contents/generations/tasks (with Ark's query); GET/DELETE
contents/generations/tasks/<id> (nativeArkPath). Never Ark's chat,
whose routing, usage and masking are the chat routes'. Another
provider or path is a 404 that says what is served.
- Behind every guard a /v1 route has (a key beyond loopback, corsGuard,
the key's rate), and refused to a read-only key (readOnlyRefused).
- Refused (403) to a key held to models, accounts or a spend limit, or
issued by one (nativeHeld): a poll or a cancel can't be tied to a
model, and magpie prices no answer it doesn't read, so it couldn't
hold such a key to them. Such keys use /v1/images/generations and
/v1/videos, which now pass the vendor's own fields on.
- A model the user switched off is refused. The body's strings are
masked (fails closed) and put back in the answer (restoring); numbers
go exact (UseNumber, a 17-digit seed is kept).
- Signed with the provider's key and magpie's User-Agent; no caller
header goes on but Accept. The answer comes back as it came, an event
stream flushed as it arrives.
- Each request is a Requests row and a usage record (Operation
"native", no tokens).
Tests: TestNativeArkRoute (the stream, the task list's query and a
cancel reach Ark signed with the provider's key, the body as sent; chat,
a wrong method, a deeper path, another provider, an unknown one and
every held key are refused without Ark being asked),
TestNativeArkStreamsAsItComes (the first event reaches the caller while
Ark holds the rest), TestReadOnlyKeyEveryRoute (the three patterns in
readOnlyRefused). Docs: gateway-routing.md's native route section.
Run on mote at the head of this stack (the Ark video fields, the native
route and the Ark image fields, three commits on af9ac3d25):
- go test -count=1 -timeout 45m ./internal/gateway ./internal/gui
./internal/access: gateway and access ok; gui red only in
TestMainWindowCorners/macOS_26_SDK (#3949, red on main).
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./...: clean. gofmt -l: nothing.
- No GUI file or script changes in this stack, so no GUI run.
The commits between were not run on their own at this base.
Broken by hand, each red, then put back:
- nativeHeld skipped: TestNativeArkRoute red
- an issuer's hold not read: TestNativeArkRoute red
- nativeArkPath skipped: TestNativeArkRoute red
- isArk not checked: TestNativeArkRoute red
- no flush: TestNativeArkStreamsAsItComes red (its 30s bound)
- the DELETE pattern out of readOnlyRefused: TestReadOnlyKeyEveryRoute red
Not tried: no real Ark request through the route (it would spend money);
Ark's answers are a fake shaped from its docs.
Credit: axelburks on Discord.
axelburks on Discord listed what /v1/videos did to a Seedance request
against Ark's own API (docs 82379/1520757 create, 1521309 query). Each
item checked against those docs and video.go; the real ones:
- A caller's content was overwritten. volcengineVideoBody built content
from the prompt and OpenAI's image fields and set it over the caller's,
so reference_video, reference_audio and draft_task items were lost.
Now a content sent is Ark's own and kept whole; the prompt goes first
only when it has no text item, OpenAI's image fields after it.
- Image-to-video needed a prompt; asset:// and seconds -1 were refused.
Ark's image-to-video takes no prompt, its asset library's asset://
ids are images, and duration -1 lets the model choose. Now the prompt
is optional with an image or a content, asset:// is kept as it is, and
-1 goes as -1. These three are Ark's alone: arkOnly turns them away
with a 400 before another vendor (MiniMax, Grok, an OpenAI-compatible
one) is asked.
- size overrode an explicit ratio/resolution, and its mapping was wrong.
size went through to ratio and resolution after the caller's own were
copied, so ratio "adaptive" was lost; its resolutions stopped at 1080p
and its ratios were Grok's, without 21:9 (3840x2160 went as 1080p). Now a ratio, resolution
or duration the caller sends is never overridden; size is the nearest
of Ark's tiers by pixels (480p, 720p, 1080p, 4k) and of Ark's
ratios (arkVideoSize).
- Every string field, a JSON body's too, was read as JSON when it parsed
as a bool or a number, and nothing else was: a form's tools stayed the
string "[{...}]", and safety_identifier "12345" became 12345. Now only a
multipart form's values are parsed (formValue), and Ark's text fields
(arkTextFields: safety_identifier, callback_url, service_tier, ratio, …) stay strings. A
JSON body's values keep their JSON types.
- The query answer dropped Ark's extras. Now every field of Ark's task
that OpenAI's video object doesn't have (content.last_frame_url, usage,
resolution, ratio, framespersecond, seed, tools, output_format, …) is
passed on as it came (videoState.Ark, all but arkOwnFields).
- A MOV was served as mp4. /content now reads the ftyp brand ("qt " is
video/quicktime), then the vendor's video/* type, then Ark's
output_format; mp4 only when none says otherwise (videoType).
- The expired message was wrong: Ark's expired is a task that ran past
its execution_expires_after (48h by default) unfinished, not a link
that expired. It now says so.
Not real: watermark is not forced on videos (it went as sent already).
Tests (internal/gateway/ark_video_fields_test.go):
TestArkVideoKeepsCallersContent, TestArkVideoFromImageNeedsNoPrompt,
TestOnlyArkTakesItsOwnVideoAsks, TestArkVideoSize,
TestArkVideoFieldTypes, TestArkVideoAnswersItsOwnFields, TestVideoType.
Docs: gateway-routing.md's Ark video paragraph and /content row.
Run on mote at the head of this stack (the Ark video fields, the native
route and the Ark image fields, three commits on af9ac3d25):
- go test -count=1 -timeout 45m ./internal/gateway ./internal/gui
./internal/access: gateway and access ok; gui red only in
TestMainWindowCorners/macOS_26_SDK (#3949, red on main).
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./...: clean. gofmt -l: nothing.
- No GUI file or script changes in this stack, so no GUI run.
The commits between were not run on their own at this base.
Broken by hand, each red, then put back:
- the caller's content not read: TestArkVideoKeepsCallersContent red
- the prompt required with an image: TestArkVideoFromImageNeedsNoPrompt red
- arkOnly skipped: TestOnlyArkTakesItsOwnVideoAsks red
- size overriding a named ratio: TestArkVideoSize red
- Grok's ratios in place of Ark's: TestArkVideoSize red
- Ark's text fields parsed as JSON: TestArkVideoFieldTypes red
- a JSON body's values parsed as a form's: TestArkVideoFieldTypes red
- Ark's extra fields not copied: TestArkVideoAnswersItsOwnFields red
- the old expired wording: TestArkVideoAnswersItsOwnFields red
- a MOV served as mp4: TestVideoType red
Not tried: no real Ark video was made (no money spent); the request and
answer shapes are from Ark's docs, on a fake Ark.
Credit: axelburks on Discord.
axelburks on Discord asked that /v1/models return the image and video
models too, so a client can find them. It listed chat models alone, with
no way to ask for the others.
Decided: they are listed only when asked for, with ?kind=image,video
(or ?kind=chat,image,video, or ?kind=all), each row marked "kind":
"image" or "kind": "video". Without ?kind= the list is the same chat
list as before. Why not add them by default:
- Agents and clients offer every id this list gives as a model to chat
with: OpenCode's and Cherry Studio's model lists, ZCode's and others'
pasted ?format=text. An image or video id there would sit in their chat
pickers and fail on the first message (an image model on
/v1/chat/completions).
- OpenAI's own list mixes gpt-image and sora in with nothing to tell them
apart, so a client has no field it would already read to skip them.
- magpie's own callers that want them already ask (another magpie's
drawers header, kind=image/video/decision on the MCP list); ?kind=
gives any other client the same.
An unknown kind is a 400 that names the kinds, not read as none. A
gateway key held to models or accounts sees only its own image and video
models, as on the chat list (drawerObjects/videomakerObjects already
check modelAllowed and accountServes). Unticked image and video models
(HiddenDrawers, HiddenVideomakers) are left out.
TestModelsListMediaOnlyWhenAsked: the default list and ?kind=chat have no
image or video row (so no agent's chat picker that reads it can offer
one), ?format=text likewise; ?kind=image / video / image,video / all give
them, marked; a bad kind is 400.
Docs: docs/integrating.md, providers-accounts.md, site docs (en, zh).
Run on mote, this change rebased on f4c664a09:
- go test -count=1 -timeout 45m ./internal/catalog ./internal/provider
./internal/gateway ./internal/gui: catalog, provider and gateway ok;
gui red only in TestMainWindowCorners/macOS_26_SDK (#3949, red on main).
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./...: clean. gofmt -l: nothing.
- GUI: the 51 provider-*, drawers, image-models, i18n and
video-models-hide files, both engines, every language, wide and narrow:
1161 of 1188 ok. The 27 reds are 5 files that are red the same 27 at
origin/main d1cdce130 run alone: provider-fetch-again (#3292/#5057),
provider-models-rest (#4396), provider-picks-stay (#4397),
provider-levels-scroll (#4395), provider-typed (#4673).
video-models-hide: 22 of 22 ok.
- The whole GUI suite (all files) ran earlier at this change on 8af751987,
347 of 19153 red at load 100 to 200; the 66 files with a red, run again
alone, are red in the same tests at origin/main 17f2387e1 (all filed:
#4388, #4391, #4398, #4320, #4541/#5013, #2564, #4244, #4304 and the
above).
Rebased again onto d1cdce130 (sessions, Cursor mover, library and routing
plugins, group-unlists; nothing this change touches but gateway.go,
which merged clean) and run there: TestCoreScriptBudget and internal/gui's
new tests, the gateway's ?kind= and video tests, internal/provider and
internal/catalog, video-models-hide 22 of 22: ok.
Broken by hand, each red, then put back:
- listKinds' default returning all three kinds:
TestModelsListMediaOnlyWhenAsked red
- an unknown kind let through: TestModelsListMediaOnlyWhenAsked red
Not tried: no real client was pointed at ?kind=; the agents' pickers were
checked by what they read (the default list, unchanged), not by opening
each one.
Credit: axelburks on Discord.
axelburks on Discord: "供应商里方舟的配置页,有图像模型选项能勾选模型,但是没
有视频模型选项不能勾选视频模型". A Volcengine Ark key's editor listed its
Seedream models under Image models, to tick, and had its Seedance models
among the chat models or nowhere.
Cause, two parts:
- The editor had no video section at all: video models had no list and no
hidden set (gateway-routing.md said "Video models aren't listed in the
editor, so there is nothing to hide there").
- catalog's live parse read only "kind" and modalities.input/output. Ark's
/api/v3/models marks no kind: it says domain "VideoGeneration" /
"ImageGeneration" and modalities.input_modalities/output_modalities. So
Seedance came back as a chat model, and 3D models (output 3d, no text)
as chat models too.
Change:
- catalog: a live row with no kind is a video model when its domain is
VideoGeneration or it outputs video without text, an image model for
ImageGeneration or image without text; Ark's input_modalities /
output_modalities are read when input/output aren't there, so a model
that gives no text (Ark's 3D) is left out of the chat list.
TestFetchArkMarksVideoModels runs on a captured Ark list
(testdata/volcengine-ark-models-2026-11-03.json, fetched read-only
with GET /api/v3/models, no key in it).
- provider: HiddenVideomakers beside HiddenDrawers, VideomakerHidden.
- gateway: VideomakersOf (Videomakers on a given list, for the editor),
OfferedVideomakers = Videomakers less the unticked ones, read by
AutoVideomaker, videomakerObjects (another magpie's list) and
mediaModels(true) (generate_video). A hidden one still makes its video
when named: bareVideomaker, videosCreate and arkFilms read Videomakers.
- gui: the editor's Video models section (renderVideomakers), filmIds and
hiddenVideomakers on /api/providers, kept on save as hiddenDrawers is;
i18n for every language. app.js comments cut to stay under
TestCoreScriptBudget, which this change reached; no raise.
- docs: gateway-routing.md's Hidden image models section.
Old data: an Ark list fetched before keeps Seedance among its chat models
until its list is fetched again;
customVideomakers already counts any Seedance id an Ark key lists or picks
as a video model, so it makes videos and shows under Video models now.
Run on mote, this change and the next (/v1/models ?kind=, gateway and
docs only) rebased on f4c664a09; this commit's own tree, on 17f2387e1,
gave the same Go results with Linux and Windows vet of ./internal/...
clean:
- go test -count=1 -timeout 45m ./internal/catalog ./internal/provider
./internal/gateway ./internal/gui: catalog, provider and gateway ok;
gui red only in TestMainWindowCorners/macOS_26_SDK (#3949, red on main).
- GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: clean. gofmt -l: nothing.
- GUI (at the next commit's tree, which adds no GUI file or script): the 51 provider-*, drawers, image-models, i18n and
video-models-hide files, both engines, every language, wide and narrow:
1161 of 1188 ok. The 27 reds are 5 files that are red the same 27 at
origin/main d1cdce130 run alone: provider-fetch-again (#3292/#5057),
provider-models-rest (#4396), provider-picks-stay (#4397),
provider-levels-scroll (#4395), provider-typed (#4673).
video-models-hide: 22 of 22 ok.
- The whole GUI suite (all files) ran earlier at this change on 8af751987,
347 of 19153 red at load 100 to 200; the 66 files with a red, run again
alone, are red in the same tests at origin/main 17f2387e1 (all filed:
#4388, #4391, #4398, #4320, #4541/#5013, #2564, #4244, #4304 and the
above).
Rebased again onto d1cdce130 (sessions, Cursor mover, library and routing
plugins, group-unlists; nothing this change touches but gateway.go,
which merged clean) and run there: TestCoreScriptBudget and internal/gui's
new tests, the gateway's ?kind= and video tests, internal/provider and
internal/catalog, video-models-hide 22 of 22: ok.
Broken by hand, each red, then put back:
- the domain/output check in catalog's live parse:
TestFetchArkMarksVideoModels red
- OfferedVideomakers returning Videomakers whole:
TestHiddenVideomakerLeavesListsButStillFilms red
- the editor's filmIds left empty: TestVideoModelsHidden red
- a save without hiddenVideomakers dropping the old ones:
TestVideoModelsHidden red
- renderVideomakers' call in the editor left out: video-models-hide
22 of 22 red
- a chip's click not changing the draft: video-models-hide 22 of 22 red
Not tried: no real Ark video was made (no money spent); the list parse was
checked on a real Ark list fetched read-only. The editor was not opened in
the real app, only in the GUI tests' fake API.
Credit: axelburks on Discord.
shaoyang. on Discord (#general, 11-03): with a routing group's Model
lists set to the group alone (its card's 成员模型不单独列出), the model
list fetched still had every model of the group.
Cause: 88e6fb9cf (v0.1.2176, 10-30) had catalogOf keep a signed-in
subscription's models (SubscriptionKept: a ChatGPT, Claude, Copilot or
plugin account's) for every agent, leaving the group alone only for a
client that is no agent (""). Over HTTP no client is "": agentOf falls
back to usage.AgentOf(User-Agent), which is "other" or the UA's name, so
every /v1/models fetch, every agent's written list and every picker
listed a subscription member beside the group. For a group made of
subscription models, as most are, the option changed nothing.
Fix: catalogOf gives every agent but Codex Catalog(), as before
88e6fb9cf; Codex keeps its ChatGPT sign-in's own models (CodexOwn,
a3ee00c05), which its app reaches on that sign-in. SubscriptionKept is
gone; Unlisted() and GroupKept() name subscription members again, so the
picker's "kept for routing groups" note and the provider editor's
"listed alone" line (3d063e34f) say where they went. The routing editor's
hint says Codex keeps its own, in en, zh, zh-TW, ja and de. Docs:
reference.md, gateway-routing.md.
Behaviour change for 士奇's case (88e6fb9cf): with "The group alone" on,
Hermes, WorkBuddy and the rest lose the group's subscription models
again; that is what the option says. Listing its models too keeps them beside
the group, which the new test checks.
Tests:
- gui TestGroupAloneKeepsSubscriptionModelsOutOfEveryAgentsList (replaces
TestSubscriptionModelsStayInEveryAgentsListWithGroupOn): a sandbox
ChatGPT sign-in's 5 models in a group listing alone. For every agent
but Codex that lists the group, its Agents-page list, CatalogFor and
model pickers leave them out; Unlisted names them; with "Its models
too" hermes, workbuddy, claude and codex list them.
- gateway TestGroupAloneKeepsSubscriptionModelsOffAgentsModelList:
GET /v1/models with no key, "magpie" and magpie-hermes/-claude/-opencode
lists group/mine and not its members; /v1/models/{id} doesn't find one
for Hermes; Codex's key lists and finds them; listed again with
listed too.
- TestCodexOwnModelsListedOnlyThroughGroups again expects Claude Code not
to list a group-alone member.
Run on mote at 3da80330a (rebased on origin/main c3593dc49): gofmt -l
clean; go vet (darwin -tags nogui, GOOS=linux -tags nogui at the base,
GOOS=windows) on provider, gateway, gui ok; go test -timeout 45m
internal/provider ok, internal/gui ok, internal/gateway -run
"TestGroup|TestCodex|TestUnlisted|TestModels|TestDesktop" ok. At the
base 40a287b21: internal/provider, gateway, gui and agent whole ok;
internal/cli red only in TestEveryRouteHasACommandOrIsNamed (GET
/api/context/reply, #5026, red on main since 0872bc2a0). GUI:
group-unlists (en/zh/zh-TW/ja/de, 1100 and 420px), unlisted-group-kept,
unlisted-models, agent-models-group-on, i18n-keys in chromium and webkit,
56 of 56.
Broken by hand: catalogOf back to SubscriptionKept with the new tests in
place; the gui test failed with 484 "the group alone" errors (codex/gpt-5.5
in claude's, claude-desktop's, claude-science's lists and pickers among
them) and the gateway test for every key, no key and "magpie" included.
Not tried: a real ChatGPT/Claude sign-in or the running app, and the
reporter's Docker deployment (same /v1/models path, no OS branch); which
agent fetched the list isn't known.
tao0194 on Discord (v0.1.2828, zh, panel-width window): in Library > MCP
servers the magpie-browser row showed the connected ask (green dot, the
question, a button per agent) inside the name's column, wrapped into a
narrow strip between the command and the row's Scope and agent chips,
three lines tall beside every other server's two.
browserAsk's element was appended to the row's .who. It is now the row's
own child: the row gets lib-asking while it shows, wraps, and the ask
takes a line under the name, command and chips, from the name's left
edge (the picture plus the row's gap, 37px, 38px in the window's rows)
to the row's right edge. The first line keeps the name, command and
chips as the other rows have them (.who flex-basis 0 above 560px). At
560px and under, where rows already wrap, a long command now ellipsizes
beside the row's picture instead of taking the name to a line of its
own under it; that was so for any server with a long command, and the
ask's left edge follows the name. docs/subsystems/library.md says where
the ask sits.
library-browser-ask.test.cjs now has three agents (Codex, Zed among
them) and a context7 row beside it, runs at 1100, 600, the panel's 440
and 360, and checks the ask starts under the first line, at the name's
left edge, reaches the chips' right edge, that the first line is as
tall as another server's, and that the name sits beside the picture.
Run (mote, Playwright 1.62.0, Chromium and WebKit, en/zh/zh-TW/ja/de):
- library-browser-ask.test.cjs on the old client.js/library.css: 42 of
44 red (every layout subtest; the two not-connected/given ones pass).
With the change: 44 of 44 green.
- The 84 GUI files that open the Library, name lib-row/lib-server or
library.css, or check budgets and i18n keys: 1480 of 1480 ok, before
the rebase onto c3593dc49 (no upstream change touches these files);
library-browser-ask, i18n-keys and builtins again after it: 52 of 52
ok. go test ./internal/gui at the rebased head: TestMainWindowCorners
red only (an AppKit window test, the same on origin/main 78cd4e6dd,
#3949); everything else ok.
Not tried: the real app's panel (WKWebView) with a connected extension;
the full GUI suite.
The second way acezan's 57 <defunct> magpie-bun (v0.1.2819, a Linux
systemd service, 47 hours) pile up: magpie web's restart to update
(AutoRestart) runs the new version with syscall.Exec in the same pid.
The running plugin host was the old image's child, and the old image's
host.read held the only Wait for it. After the exec nothing waits for
it, so it ends on stdin EOF and stays <defunct> under that pid, one per
restart to update. skygunner reproduced it and AAEE86 counted 22 zombies
for 23 images under one pid (#3285). With about a hundred releases a
day, an AutoRestart service makes about one a hour, as acezan's did.
- plugin.EndHosts (host.go) stops every host started and not yet
reaped, including the retiring ones, waits until each one has been
waited for, and refuses to start another (errHostsEnded). startOn
starts the host and records it under one lock (live), so a host that
starts during EndHosts isn't missed.
- Web.Wait calls it right before update.Reexec.
Run at 72bc741ef (on origin/main 40a287b21, after the previous commit):
- mote (macOS): gofmt -l clean; go vet ./internal/gui ./internal/plugin,
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: ok.
go test -count=1 -timeout 45m ./internal/plugin: ok; -run Web
./internal/gui: ok.
- WSL magpie-desktop (Linux): ./internal/plugin ok, including
TestEndHostsLeavesNoChild and TestHostReapedWhileItsChildHoldsStdout
with a real Bun host; -race -count=3 of both: ok; go vet -tags nogui
and -run Web of ./internal/gui: ok.
Both commits were then rebased onto 0acba61a3, which changes only
app.js and plugin-checkin.test.cjs; no Go file these runs built moved,
and they were not run again there.
Broken by hand: EndHosts returning at once makes
TestEndHostsLeavesNoChild fail on Linux ("children left once EndHosts
returned: [16459 S bun]").
Not tried: a real magpie web restart to update (a downloaded update
exec'd in the same pid) on Linux. The test covers EndHosts, not the
exec. Not changed: anything else alive at the exec (pii's helper,
awake's caffeinate, #4188) still outlives it the same way.
Reported by acezan on Discord. Diagnosed in #3285 by skygunner and
AAEE86.
acezan on Discord (v0.1.2819, Linux x86_64, a systemd service): after
47 hours, 57 <defunct> magpie-bun children of magpie, growing toward the
unit's TasksMax until a restart.
One cause: the plugin host's only cmd.Wait ran in host.read after its
stdout reached EOF. A program a plugin started that kept a copy of the
host's stdout (Bun.spawn given Bun.stdout, which host.js's spawn guard
doesn't catch, #5063; a daemon left behind) held that pipe open past the
host's end, so EOF never came, Wait never ran, the host was never marked
dead, and every host stopped (Restart, a moved proxy, hostStale) stayed a
zombie until magpie quit. Reproduced on Linux (WSL magpie-desktop,
Bun 1.4.2): one more Z-state bun under the test process per Restart,
1, 2, 3, 4 over four rounds. The other cause, magpie web's restart to
update leaving the running host behind its exec (#3285), is the next
commit.
- proc.Output (new, internal/proc/output.go) gives a command's stdout and
stderr pipes of magpie's own and waits for the command the moment it
ends. Its readers then have OutputGrace (2s) to read the last lines;
the pipes are closed after that, which ends a read held up by a
grandchild. startOn uses it, and a reap goroutine fails the host when
its child ends. host.read no longer calls Wait. The tests' fake hosts
(no child) keep cmd.Wait.
- Every other start that wasn't waited for now goes through
proc.StartReaped (Start, then go cmd.Wait()). Process.Release doesn't
reap on Unix: codexrelay.Start (a relay that can end while magpie
runs), tui serveInBackground, uninstall's startAfter, update's
runAfterExit and OpenBeside (no Wait at all), and Windows' Reexec.
- TestEveryStartedCommandIsWaited (internal/proc) parses every non-test
.go file. In each function, an x.Start() on a command needs an
x.Wait(), or x handed on (a call's argument, a struct field), and
.Process.Release() is refused. It found exactly the sites above.
- docs/subsystems/provider-plugins.md says how the host is reaped.
Checked and left as they are (each waits): the StartTree callers
(provider/install, library mcp_run and mcp_check, gateway claude_warmup
and claude_subscription), pii/serve, provider grok and claude_signin,
claudetui child_unix and wslread, awake, every other bun start (bun.go,
bunupdate, store, dist use Output/CombinedOutput).
Run at 82460a2f9 (on origin/main 40a287b21):
- mote (macOS): gofmt -l clean; go vet on the touched packages,
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: ok.
go test -count=1 -timeout 45m ./internal/plugin ./internal/proc
./internal/codexrelay ./internal/tui ./internal/uninstall
./internal/update: all ok. -race -count=3 of the new proc tests: ok.
- WSL magpie-desktop (Linux): the same six packages ok, including
TestHostReapedWhileItsChildHoldsStdout with a real Bun host; -race
-count=3 of it and the Output tests: ok.
- Windows (xiaomi-gpu), at the tree before the rebase (base 5ee5274bd):
proc and codexrelay ok. plugin and update had TestPiPackage,
TestLoadConcurrentWithSavesAndEdits and TestPackagedByDpkg red; each
fails the same at untouched origin/main 40a287b21 on that box, 3 of 3,
and is filed (#4115, #1827, #4603).
Broken by hand, each red:
- host.go back to StdoutPipe with Wait only after EOF:
TestHostReapedWhileItsChildHoldsStdout fails on Linux ("the host isn't
marked ended 15s after Restart").
- Output.Start waiting for the readers before Wait:
TestOutputWaitsPastWhatHoldsIt fails (not waited for in 10s).
- codexrelay back to Process.Release: TestEveryStartedCommandIsWaited
names relay.go:89 and :92.
Not tried: a full go test ./... (mote and WSL were each running other
sessions' package runs, load 39 and 110); a real magpie serve or web
running for hours on Linux; the host test on macOS (no /proc; the
Output test runs there). Not changed: killing what a host left behind
(its process group) when it is stopped; an orphan like the sleep above
stays in the service's cgroup until it ends on its own.
Reported by acezan on Discord.
A streamed Claude subscription turn whose run says nothing for minutes
(the interactive mode tells a message only once it is whole; a long
conversation replayed to a new Claude Code is prefilled uncached first)
gave its client the held stream's 200 and comments, and those stop at
keepaliveLongest (5 min). Claude Code 2.1.316's byte watchdog then ended
the request 300s later, at 599s: the reporter's 599.29s and 599.33s.
Each cancel aborts the TUI run (letGo), so the retry is a new Claude Code
that replays the history and writes it to the cache again (#3808).
keepBridgeHeard wraps the run's events for a stream: after
bridgeHeardAfter (1 min) of a quiet run it sends an empty KStart, which
makes relay begin the reply (message_start), and a KAlive every
keepaliveEvery while it stays quiet, up to translatedQuietLongest, so the
client gets its protocol's pings (#2316's pattern). The hold still holds
the frames to holdLead and passes an error over. The run's own start
later adds its usage (collector), and a failure in the first minute is
still a status.
The gain is bounded. Claude Code 2.1.316 turns every 10s with bytes into
a ping of its own (RSr, __n=1e4) and counts 30 pings in a row (vSr=30),
so a stream of pings and comments alone ends 600s after its last other
event. The run now has until about 14 minutes (message_start at ~4 min
plus 600s), where it had 599s. The reporter's retries answered first at
385s and 527s.
Run:
- Real claude.exe 2.1.316 (-p, sandbox HOME, env -i) against a fake
Anthropic server:
- headers at 3s, comments to 300s: ended at 598.38s ("[byte-watchdog]
... no bytes for 300000ms"; "Stream idle timeout before first event").
- comments forever: ended at ~600s from headers ("no chunks received
for 300s").
- no headers: "Request timed out" at 360s.
- this fix's shape (message_start + ping at 300s, a ping every 60s):
lasted to 904s, then "no chunks received for 300s" and fell back to
non-streaming. That is the 600s bound above.
- mote-run: go test -tags nogui -count=1 -timeout 45m ./internal/gateway
ok (675.8s), at this change before its comment-only edits.
- mote-run: go test -tags nogui -count=1 -timeout 45m ./internal/gateway
ok (680.2s) again at this tree, rebased on origin/main 5ee5274bd.
- mote-run: TestClaudeBridgeQuietRunKeepsClientAlive -count=3 ok, and
gofmt -l internal/gateway clean, at the committed tree.
- mote-run: GOOS=linux and GOOS=windows go vet -tags nogui
./internal/gateway ok.
Broken by hand:
- Without the keepBridgeHeard call, the new test fails: no
message_start or ping before the reply.
- Without the synthetic KStart (KAlive alone), it fails with "0 pings
while the run was quiet": the client gets comments only.
Not tried:
- A real Claude account, the interactive (TUI) mode, a real replay.
The test uses a -p fake Claude Code. The wrapper doesn't depend on
the mode.
- Chat and Responses clients through the bridge. Their encoders take an
empty KStart, but no test covers it here.
- A run quiet for longer than ~14 min still ends. Only a real event of
the reply would keep it alive (#5060).
- magpie's pingEvery comment in gateway.go describes 2.1.311's count
without the synthetic pings. Not changed here.
Jiabubu on Discord: with the capsule in sight, a click that opened a
Routing group left it over the editor's member rows (Remove beside Up
and Down) and its held Cancel and Add, and it moved off them only once
the page was scrolled.
scrollends.js placed the capsule on a scroll, a resize, focus or the
pointer leaving it, and a hidden attribute set anywhere. Opening a group
in place sets none, unless something else on the page happened to be
hidden again in the same draw (an empty pool list is, on every draw,
which is why the earlier tests saw it move). It now also watches the
open page and each of its own children with a ResizeObserver, and the
page's child list, so any change of size under it (a group opened or
closed, rows added or taken out) places it again on the next frame: it
rises above a held foot, steps aside at the page's foot, or comes back.
One file serves every page with the capsule (Agents, Providers, Routing,
Library, Settings, plugin pages), so they all take it. No core script
changed; scrollends.js loads lazily and has no budget.
view-ends-relayout.test.cjs: with no scroll after the change, the capsule
must be where the reader's next scroll puts it, and over nothing of the
editor's:
- Routing, 16 groups of the reporter's rows ("低-ultra", 922K), a pool in
the list: a screen down, a click on the card lowest in sight opens its
editor; then Cancel closes it.
- Agents, 40 rows: a little above the foot, a block at the list's end
taken out so the foot comes up under the capsule.
Desktop 1100, 700, 560; browser page 1100, 440, 360; Chromium and WebKit,
en/zh/zh-TW/ja/de.
Run on mote (mote-run) at this tree:
- view-ends-relayout, both engines, every language: 10 of 10 ok.
- On 5ee5274bd (origin/main just fetched) plus this change:
view-ends-relayout, view-ends, routing-editor-foot, old-webkit and
i18n-keys: 62 of 62 ok.
- Before the rebase (on c0d4f17a3), with group-editor-selected,
group-editor-fits, group-member-drag, drag-rows-shift, routing-rows-fit,
click-scroll, add-button, library-discover-jump and account-eye beside
those: 214 of 214 ok.
Broken by hand: scrollends.js as at origin/main, 20 of 20 red (both
engines, every language), each part on its own:
- Routing: "desktop 1100px: opened, the capsule above the held Cancel
and Add, with no scroll: 569-624, bar from 591".
- Agents only: "desktop 1100px agents shorter: the capsule stepped aside
as a scroll has it, with no scroll: [[true,569,624,1739],[false,...]]".
Not tried: the whole GUI suite. Both machines already had full suites of
other sessions running (WSL: four, at load ~140; mote: one, 49 minutes
in), and one full suite runs on a machine at a time. The capsule's
behaviour is the only change, no layout and no new API call. Also not
tried: the Windows app (WebView2) and the Linux app (WebKitGTK) themselves,
and the reporter's own groups.
qianxunji (#feedback) and curtinp118 on Discord: a VPS restored from a
backup, or a new computer joining sync, had to sign in to every
subscription again. Sign-ins (subscription accounts in logins.json,
Codex's auth.json, plugins' sign-ins in plugin-auth.json) can now go too,
in each place only when picked; all are off by default, so an upgrade
carries nothing new.
- Sync (WebDAV, S3, GitHub): a "Sign-ins" tick in the form, with a line
saying anyone with the passphrase and the server's file can use the
accounts, and that an account on two computers can be signed out on one
when the other renews it. CLI: `magpie webdav|s3|github set sign-ins=yes`.
- Export: "With the sign-ins", off; ticked, the passphrase hint says the
file holds them. CLI: `magpie backup --sign-ins`.
- Import: "Bring in the sign-ins too, when the file has them", on. CLI:
`magpie restore --no-sign-ins` leaves them out.
- Back up by itself: "Sign-ins in backups", Off/On. On asks for a
passphrase (twice) that seals the sign-ins alone (the rest of an
automatic backup stays unsealed, as before); it is kept in
autobackup.json (0600), never sent in the view. A backup whose sign-ins
another passphrase sealed restores without them and says so.
What goes (provider.CollectSignIns, plugin.CarriedAuth): magpie's own
copies only, not an agent's own account, an agent-home row, a hidden or
plugin: row, or a retired built-in. Each record is keyed by agent +
email + org (or the account key); ids two rows share go on neither side.
Restore/import (RestoreSignIns) adds what is missing and updates only
when the incoming copy was renewed later; nothing here is removed.
Before writing over a row it counts every row that could be the same
account (same login, same refresh token, same id): none adds, several
keeps all, one is kept when it isn't magpie's own copy, is held, or is
the agent's live account. Codex's auth.json is written temp-and-rename,
0600, only where Codex is signed out.
Sync merges per record against the last sync's hashes (MergeSignIns):
the later renewal wins; a removal crosses only when the other side still
had it as of the last sync; ApplySignIns re-checks each row's hash
before writing so a renewal in between is kept. A computer with the tick
off sends none, so others remove nothing for it; turning it off, a
Restore, or a replaced server file clears the last-sync record.
Export's and Import's forms moved out of app.js into syncfiles.js,
imported when one opens (as autobackup.js is), so the core is 3.2KB
under its budget with no raise (app.js 3.2KB smaller than before).
docs/subsystems/sync-backup.md has a "Sign-ins, when picked" section;
subscription_signin_test.go's header now says it pins the default.
Run at the pushed head (678d28cba on origin/main bc10a6198):
- wsl-run go test -tags nogui -timeout 45m: backup, davsync, plugin, gui
ok (TestCoreScriptBudget in it). provider: one red,
TestCancelledPluginSignInSavesNothing, the late sign-in saved after
Cancel. It is green 20 of 20 alone, at this head and at origin/main
alike, and this change adds only new files there whose tests run after
it; filed as #5047. cli there hung in proc.lookStamp's os.Stat on WSL
at load 100, so it ran again on mote: one red,
TestEveryRouteHasACommandOrIsNamed (GET /api/context/reply, #5026),
the same at origin/main. gateway -run TestCompactionOverByteCapEveryTime
ok (#4862 on mote's full run). TestMainWindowCorners on mote: red the
same at origin/main (#3949).
- GUI, on mote: the 16 files that open Sync, plus i18n-keys and
old-webkit, Chromium and WebKit, every language: 255 of 294 pass. The 39
reds are segs-press-redraw's searchAllRow (#4566), s3-sync in WebKit
(#2448) and usage-agents-hide (#3414). The same files at origin/main
bc10a6198 give the same 39 pass and 39 fail. sync-signins, auto-backup,
sync-sign-in, i18n-keys and old-webkit alone on WSL: 92/92.
- The whole GUI suite on WSL, stopped at 737 of its tests (1162 files,
load ~100 there): 9 reds, all WebKit, none in a Sync file:
account-eye (#4244, #5052), add-button (#4792), account-plugin-user
and agent-expand-steady. The last two pass at this head and at
origin/main on mote. The rest of the suite was not run.
- gofmt -l: clean. go vet: darwin (internal/gui, internal/cli),
GOOS=linux and GOOS=windows -tags nogui for backup, davsync, provider,
plugin, cli, gui: ok.
- win-run and wsl-run: go test -tags nogui -run
'SignIns|Carries|AutoBackupSignIns' ./internal/provider
./internal/backup ./internal/davsync: ok on Windows 11 and Ubuntu 24.04.
- sync-signins.test.cjs: 20/20, Chromium and WebKit, 1100 and 420px,
en/zh/zh-TW/ja/de, no horizontal overflow, no page errors.
Then rebased on origin/main 5ee5274bd (12 commits; davsync.go, app.js and
i18n.js merged with no conflict) and run again at the pushed head on mote:
gofmt clean; go test -run 'TestCoreScriptBudget|SignIns|Carries|
AutoBackup|Sync' for gui, davsync, backup and provider: ok; sync-signins,
auto-backup, sync-sign-in, i18n-keys, old-webkit: 92/92.
Broken by hand, each red, then restored:
- RestoreSignIns writing an older token over a newer one:
TestRestoreSignInsNeverWritesAnOlderTokenOver red.
- The ambiguous-account guard has two layers (more than one match, and
a single match with another record id); with only the first removed
the test stayed green, with both removed
TestRestoreSignInsLeavesAnAmbiguousAccount went red.
- MergeSignIns removing a row renewed here: TestMergeSignInsRemovedOnlyWhenTheOtherSideRemovedIt
red.
- Codex auth.json written over a signed-in Codex:
TestRestoreSignInsSignsCodexInOnlyWhereSignedOut red.
- ApplySignIns not re-checking the hash: TestApplySignInsKeepsWhatChangedSinceTheMerge
red.
- davsync forgetting the last-sync record (st.SignIns = nil):
TestSyncSignIns red.
- GUI: Export's tick on by default, and auto backup's On posting with
no passphrase: sync-signins.test.cjs red for each.
Not tried: real accounts carried to a real VPS or second computer (all
Go tests use testenv homes, fake DAV and fake tokens; the Keychain is
never reached); a real vendor's refresh after a carried sign-in, and how
each vendor treats one refresh token used from two machines; the CLI
flags against a sandbox HOME (covered by the cli package's tests only);
auto backup's sign-ins have no CLI switch.
prgrmrwy runs magpie on a home server and uses it from work through a
remote magpie (and DSH). The remote Codex card said "1 reset", but the
reset could only be used from the GUI of the computer that holds the
sign-in.
What changed:
- Gateway: POST /v1/magpie/quotas/codex-reset?user=<email>[&credit=<id>]
(Server.codexReset) spends one of that account's resets with
provider.SpendCodexReset. That is the Usage page's own code
(UseCodexResetCard, then AwaitAllowance), moved out of
internal/gui/usage.go so both use it. A reset can't be undone, so the
route needs an enabled gateway key with full access, from loopback too.
No key gets 401, and that covers every corsGuard exemption that has no
key: Origin null, app schemes, *.localhost and a missing Origin. A
read-only key gets 403 gateway_key_read_only (readOnlyGuard, which
readOnlyRefused now lists, and again in the handler). A held key gets
403 gateway_key_held, even one told quotas. The account must be named
(400 otherwise). One ask runs per account at a time (409). When the
reset is used, that card is read again.
- Remote client: UseRemoteCodexReset (remote_quotas.go) asks the remote
with the provider's key. remoteJSON's status mapping is shared through
remoteBody. A read-only key there is told as such, and a 404 as a
remote too old. With no answer in time it says the reset may have been
used, and it never asks again by itself. A remote Codex card now keeps
its Resets; a GLM team's (byWindow) and every check-in are still
dropped.
- GUI: "Use a reset" / "Use one..." show on a remote Codex card
(codexResetCard). They open the same in-app confirmation sheet, with a
line saying which computer's magpie uses it, and send the card's
provider to /api/usage/codex-reset. The remote's errors are put in the
user's words. New strings are in all 5 languages.
- DSH: no code here. Its provider plugin reads /v1/magpie/quotas/cards
and can call the new route with a full key.
- resetOutcome (a reset's result in words) moved from app.js into
resetask.js, the only place that says it, so the core's scripts stay
in TestCoreScriptBudget's 1,533,802 with no raise (1,533,003 after;
origin/main b967b1620 is 1,533,756).
- Docs: reference.md (remote quotas, gateway keys), gateway-routing.md
(read-only list, the route's admission), providers-accounts.md.
What was run (rebased on origin/main b967b1620, then on 2e4735f8f):
- mote, at the head before the rebase and the resetOutcome move:
go test -count=1 -timeout 45m ./internal/provider ./internal/gateway
./internal/gui at load ~300-450. provider ok. gateway: only
TestCompactionOverByteCapEveryTime (#4862). gui: TestCoreScriptBudget
(this change, 158 bytes over; fixed by the move), TestMainWindowCorners
(#3949) and TestGatewaySkewOfAnotherIsSaidNotQuit/own_build (#5053,
passes alone here and at b967b1620).
- mote, same run: 155 GUI files (reset|quota|usage-|panel-|i18n|budget|
remote|gui-|old-webkit|core-script|script-size), 1856 of 1904 pass.
- WSL (magpie-desktop), the 9 red files alone, at this change and at
origin/main b967b1620: this change 147 pass / 43 fail, main 146 / 44;
every test red here is red on main too: codex-auto-reset webkit de
(#4790), remote-magpie (#4398), usage-agents-hide (#3414), usage-fold
(#3415, #4790), usage-heatmap (#4718), usage-ledger (#5048).
codex-reset-lead (#5054) and panel-routing-providers (#5055) were red
only under mote's load and pass alone on both.
- mote, at this head: TestCoreScriptBudget and
TestGatewaySkewOfAnotherIsSaidNotQuit ok.
- WSL, at this head: account-every-reset, codex-resets-used, i18n-keys,
providers-reset-use, remote-codex-reset, reset-each-title,
reset-pick-card, reset-providers, quota-used-no-reset: 99 of 102 pass.
The 3 reds are providers-reset-use's 420px Windows cases ("a click
moved the page", #4873); that file alone is red on origin/main
b967b1620 too (3 of 40 there, 2 of 40 here).
- WSL, rebased on 2e4735f8f (main had changed internal/gateway): the new
tests and the read-only, CORS, LAN-guard, held-key, remote-magpie and
UseCodexResetCard tests in ./internal/gateway ./internal/provider ok;
core scripts 1,532,960 under 1,533,802; gofmt clean.
- Earlier on mote: TestCodexResetNeedsAFullKey,
TestRemoteCodexResetThroughTheGateway, TestRemoteCodexResetAnswers, the
read-only, CORS, LAN-guard, held-key and remote-magpie tests ok;
remote-codex-reset and reset-pick-card 20 of 20 (chromium and webkit,
5 languages, 900/390/440px). gofmt clean; go vet darwin, windows ok,
linux for provider and gateway.
Broken by hand:
- With the handler's key check turned off, TestCodexResetNeedsAFullKey
went red: "this computer, no key: 200 {code: reset}" and a reset was
spent.
- With codexResetCard put back to provider === "codex",
remote-codex-reset.test.cjs went red ("one Use, on the remote Codex
card"). On the old code the route doesn't exist, so the full-key case
gets 404.
Not tried:
- A real Codex reset spent between two real magpies: none was spent, to
keep the owner's resets. The ChatGPT backend is the fake from
codex_autoreset_test.
- DSH's plugin calling the route.
- GOOS=linux vet of internal/gui: it needs gtk4/webkitgtk, which neither
mote nor magpie-desktop has. Its change is usage.go only, and that was
vetted on darwin and windows.
Thanks to prgrmrwy for the report and the proposal.
pluviophile714 on Discord: a gpt-6.1-sol row on Routing read 1,539
tok/s (input 21,617, output 392, first token 8.2 s, total 8.3 s), where
another monitor measures ~70. The reply came whole about 255 ms after an
8.2 s wait. Its content was spread over that short window (flow 230 ms),
so the HeldShare flow check passed, and so did the 100 ms floor, and
392/0.255 s read as 1,539 tok/s.
New rule, usage.HeldWindowMs: a window under 1,000 ms whose start
(first token, first text or first reasoning) is more than HeldShare (4)
times the window tells no speed. One rule in every place that computes
one:
- usage.DecodeOf: the Usage page's speed and totals, the CLI, the GUI's
model speeds, and the gateway's Speed first pacing (noteTrySpeed);
- routing/client.js decodeOf: the Routing row's speed and its story line;
- usage/page.js ledDecode, plus a ledNoSpeed_ reason for the dash's
tooltip, in en, zh, zh-TW, ja and de.
docs/reference.md and docs/subsystems/gateway-sessions.md say so.
On the owner's usage.jsonl (read only), 103 of the 106 rows over 600
tok/s were such windows (e.g. 448 tokens in 107 ms after 8.1 s) and are
dropped. The 3 that stay have windows of 2 to 5 s. The overall speed
goes from 103.8 to 97.9 tok/s.
What it costs: a short reply that really streamed after a long wait
tells no speed either. The live visible-reasoning fixture (76 tokens
over 731 ms after 6.8 s, ~104 tok/s) and #2637's grok record (307 tokens
403 ms after a 4.6 s first token, 531 tok/s) now read "—". Their tests
keep their guarantees with the same timings after a short wait, and also
check the long-wait case.
Tests:
- New: internal/usage TestShortWindowAfterLongWaitTellsNoSpeed (the
reporter's numbers, a reasoned row from the ledger, the boundary, a
second after a long wait, Totals) and internal/gateway
TestShortWindowAfterLongWaitNotesNoPace.
- GUI: usage-speed-every-row has the reporter's row (dash, and the
tooltip in all five languages); routing-burst-speed has it (first
token 8.2 s, no tok/s).
- Updated to the new rule: TestVisibleReasoningSpeed's decode-minimum
and max-speed cases (short wait now), TestCodexTurnMeasured...'s
gateway/Claude rows, TestLiveVisibleReasoningFixture and
TestUsageIngestTellsSpeed.
Run on mote at this tree (rebased on e41ef6288):
- go test -timeout 45m: internal/usage ok, internal/tui ok.
- internal/gateway: red only in TestCompactionOverByteCapEveryTime
(#4862, full package run; passes 3 of 3 alone).
- internal/gui: red only in TestMainWindowCorners (#3949, macOS 27).
- internal/cli: red only in TestEveryRouteHasACommandOrIsNamed (#5026,
red on main since 0872bc2a0).
- The two speed fixtures that failed in the gateway run pass on rerun.
- GUI, chromium and webkit: 36 files (every speed, ledger, i18n,
routing-request and burst file), 609 tests, 603 pass. The 6 reds are
usage-ledger's "newest live route needs no return-to-live button"
(#5048, #4078, #3104 on main).
- Rebased on 1af868a15 (f0e0385a0 changed routing/client.js), then
run again at the pushed head: internal/usage ok; the gateway speed
tests (-run ...Speed|Pace|Decode|TTFT...) ok; 8 GUI files (both
speed files, routing-request-metrics/-model, routing-speed-first,
i18n-keys, reasoning-speed, usage-speed-tip) 94 of 94 in both engines.
- gofmt -l clean. GOOS=windows go vet of usage, gateway, gui and cli ok.
GOOS=linux go vet of usage and gateway ok; gui and cli need cgo/GTK
for Linux, the same on main.
Broken by hand: with the check off in usage.go, client.js and page.js,
the new Go tests, TestCodexTurnMeasured..., TestLiveVisibleReasoningFixture,
TestUsageIngestTellsSpeed and both GUI files (1537 tok/s shown) go red.
Not tried:
- the reporter's own request;
- a real GPT stream, to confirm that a 255 ms window after 8.2 s is a
held reply from this vendor;
- the whole GUI suite (no new API call or layout change);
- the Linux and Windows app.
ferock4669 asked on Discord whether magpie has a screen to price each
model, since one model can cost differently on each provider. It has:
each row in a provider's per-model list has a price box (input, output,
cache read, cache write, 1h cache write, long-context tier, $ / 1M
tokens), saved in settings' ModelPrices under pid/model. It wins over
the list price in Usage (usage.Pricer through provider.BasePriceIn) and
in a key's spend cap (usage.KeySpent through NewCoster). Nothing has to
be built; the button opening it said only "Names & levels", so nobody
finds a price there.
What changed:
- The button, its panel's heading and fold, and every note that sends
the user there say "Names, prices & levels" (zh 名称、价格与推理档位,
zh-TW 名稱、價格與推理檔位, ja 名前・価格・推論レベル, de "Namen,
Preise & Stufen"); the gateway's vision and compaction notes, the
provider package's text, the subsystem pages and the site's start
docs (en, zh, ja) follow.
- The button's tooltip says it sets what each model costs at this
provider; Usage's "estimated" tooltip says where a provider's own
price is set and that it counts over the list price. Both in en, zh,
zh-TW, ja and de.
- Not changed: the Codex model description text in internal/codexcat
(it goes to Codex, so a vendor sees it) and core_budget_test's
history comment.
- app.js: a comment above the price box is shortened so the core
script stays under its budget, not raised (app.js 116 bytes under
origin/main).
Run at the pushed head (rebased on origin/main 1af868a15), on mote:
- go test -run 'Budget|ModelPrice|ModelPref|Vision|Compaction'
./internal/gui ./internal/provider ./internal/gateway: ok.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows:
ok (before the rebase, which touched no Go of this change).
- GUI, both engines, every language each file runs: the 149 files that
name the label or open a provider's editor (before the rebase): 1191
ok, 30 red in 7 files. Each of the 7 is red the same way alone at
origin/main without this change: provider-fetch-again (#5057),
provider-typed (#4673), provider-levels-scroll webkit (#4395),
provider-picks-stay (#4397), usage-agents-hide (#3414), usage-ledger
Requests (#5048), mobile-web (#3952, no .git in mote-run's copy).
name-suffix-remote "chromium de" (ERR_NAME_NOT_RESOLVED once) passed
alone at the head. After the rebase: model-price-edit, i18n-keys,
name-suffix-remote, usage-ledger, usage-agents-hide again: go tests above ok; model-price-edit, i18n-keys and
name-suffix-remote (all 10 cases) ok; usage-ledger Requests and
usage-agents-hide red as at origin/main 1af868a15.
Broken by hand: model-price-edit.test.cjs at origin/main's label is red
in all 4 cases (the button "Names, prices & levels" is not found).
Not tried: the whole GUI suite (another session's full suite was on
mote, WSL at load ~100 with 31 test runners); the real app.
v0.1.2826 (1dead5dc7) added Restart the Codex app when magpie switches
its account, off by default, so that atom0964's ChatGPT app stopped
relaunching at every switch magpie made between two Plus accounts. Its
guard in codexAppStep left the app-server running for every change
magpie made by itself, and that covered too much:
- the takeover in, where magpie becomes Codex's provider for its used-up
account;
- the first look on a used-up account;
- magpie's switch off an account at 98% (SwitchWhenSpent).
The Codex app greys Send for every model while its signed-in account's
rate limit says not allowed, and reads the account only as its
app-server starts (ChatGPT.app 26.1013, 8b0132b3d). Left running, the
app stayed on the used-up account with Send grey, so neither magpie's
fallback nor the next account could serve it until the user restarted
it by hand. With the default off, that broke the takeover for every
user with a fallback.
Now those three restart the app-server tick or not (`needed` in
codexAppStep: `into || c.switched && c.spent`). The tick covers only
what the app works without: the switch back once the first account has
room, and Codex given its account back at the reset. The label, tooltip
and toasts say "switches its account back" in en, zh, zh-TW, ja and de.
The tooltip adds that a used-up account restarts the app anyway.
SwitchWhenSpent's stale-app log, RestartApp's comment and
agent-wiring.md say the same.
atom0964 will still see one restart when an account runs out. Send
needs it. The restarts at the switch back and at the reset are gone.
Run at the pushed head (on mote, rebased on c0d4f17a3):
- gofmt -l clean; GOOS=linux (-tags nogui) and GOOS=windows go vet of
provider and gui clean.
- go test -count=1 -timeout 45m ./internal/provider ./internal/davsync
./internal/backup: ok. ./internal/gui -run "Budget|I18n|Restart": ok
(the core script budget holds with the longer strings, no raise).
- GUI (chromium + webkit, narrow and wide, en/zh/ja/de): restart-app,
switch-only, i18n-keys, codex-accounts-via: 76/76.
Broken by hand: codexAppStep's guard without `!needed`:
TestCodexAppLeftRunningForMagpiesOwnChanges ("magpie switched off the
used-up account: ended [], want [60]") and
TestCodexAppFirstLookOnAUsedUpAccountRestarts go red.
Not tried: a real ChatGPT desktop app on a real used-up account (the
app-server end is stubbed); Windows, where an end is followed by
CodexAppReopen.
atom0964 on Discord (#help) has two ChatGPT Plus accounts in magpie, with
Codex always signed in to the first and Only switch Codex's sign-in both
off, on Smart routing. The Codex desktop app kept restarting by itself.
They tried several combinations of the ticks and it still did.
Why: with both off, SwitchWhenSpent signs Codex in to the next account at
98% and back to the first below 90%. Each switch was noted for the Codex
app (codexAppSpentSwitch), and KeepCodexAppOnItsProvider ended its
app-server once no turn ran; the ChatGPT app shows that as an error and
relaunches (#4550). With Codex kept on the first account there is no
switch, but the used-up takeover (magpie made Codex's provider for a
used-up account and given back once it has room; f37742e14 only limits
it to when another account can serve, which two accounts always can)
changed Codex's route, and that ended it too. So every combination
restarted the app.
What changed:
- Provider.RestartApp (restartApp), off by default, set by
provider/restartapp (SetRestartApp, Codex only). This computer's own,
like KeepLogin: Mirror keeps it and davsync's hash leaves it out.
- switchLoginBy(agent, user, byMagpie): SwitchWhenSpent marks its
switch magpie's own (codexApp.auto). In codexAppStep, a change that is
magpie's own (its switch, the takeover in or out, the first look at an
app on a used-up account) ends nothing unless RestartApp is on; it
logs why and the app follows once restarted. The switch notice's
Restart, the Agents row's Restart, and uninstall are unchanged.
- Still restarted: a switch the user makes (Switch, the Agents row, the
CLI), a Connect or Disconnect, failover written or taken out (any
route change while the takeover state is unchanged), and a user's
switch pending when magpie's comes.
- GUI: under Codex's accounts, with more than one on (or the tick set),
"Restart the Codex app when magpie switches its account", with a tip
and toasts in en, zh, zh-TW, ja and de. app.js paid for it with five
account-row comments cut; TestCoreScriptBudget is not raised.
- docs/subsystems/agent-wiring.md says which changes restart the app.
Known edge: a takeover flip in the same 3s tick as a Connect is taken
as the Connect's (restarted), since the route changed by the user.
Run at the pushed head (on mote, rebased on b967b1620; then rebased on 2a19043af, a Library change touching none of these files, with the core budget checked again: 160 bytes under):
- gofmt -l clean; GOOS=linux (-tags nogui) and GOOS=windows go vet of
provider, gui, davsync clean.
- go test -count=1 -timeout 45m ./internal/provider ./internal/davsync
./internal/backup: ok. ./internal/gui: ok except
TestMainWindowCorners/macOS_26_SDK, red alone on origin/main 694f4a6d6
too (#3949). ./internal/cli: ok except TestEveryRouteHasACommandOrIsNamed
on GET /api/context/reply (#5026).
- GUI (chromium + webkit, 1100 and 420 wide, en/zh/ja/de):
restart-app (new), switch-only, claude-switch-only, keep-login,
codex-accounts-via, account-arrange, i18n-keys: 110/110 and 94/94.
account-arrange's webkit case went red once in a 5-file run on an
aborted /api/lanes request; it passes alone on origin/main and at
this head.
Broken by hand:
- codexAppStep's guard turned off: TestCodexAppLeftRunningForMagpiesOwnChanges
and TestCodexAppFirstLookLeftRunning go red (ended [60]).
- SwitchWhenSpent marking its switch as the user's: TestCodexSwitchedWhenUsedUp
goes red ("magpie's own switch is counted the user's").
Not tried: a real ChatGPT desktop app on a real used-up account (the
app-server end is stubbed as before); Windows, where the app is quit and
reopened (CodexAppReopen runs only after an end, so leaving it running
skips it too); no CLI command for the tick (switch-only has none either).
refeccd on Discord kept skills in ~/.agents/skills, handed them over to
magpie ("let magpie manage"), and then had nowhere to edit them: the
Library's skill view showed SKILL.md as raw text with no way to change
it. There never was an edit path; this adds one.
- GET /api/library/skill takes `file` and answers library.ReadSkillFile:
the file (SKILL.md by default), its text, the skill's folder and its
text files (UTF-8, no NUL, up to 1 MB each, 200 listed, SKILL.md first;
links, hidden folders and what installing writes left out).
- POST /api/library/skills/save {name, file, text, was} is
library.SaveSkillFile, through change(): it writes only a regular
file already in the skill's library folder (no .., no absolute path,
no link, no folder that is a link out of the skill, nothing under
node_modules/.venv/…), refuses when the file no longer holds `was`
(the text the page opened), keeps CRLF line ends, and writes with
edit.WriteAtomic. The sync after it reaches every agent: a linked
one reads the library's folder, a copy is made again. A copy edited in
an agent before the save is older, so takeEdits sets it aside in the
backups. A GitHub skill saved here reads as Changed here, so an update
asks first.
- The page (viewSkill in plugins/library/client.js) draws a Markdown
file with the Plugins page's own renderer (plugins.js exports it as
window.mdRender, 27 bytes of core script) and its front matter as
rows; other files as text. Edit swaps in a text box; Save or ⌘S/Ctrl+S
sends it; Cancel asks when there are changes. Other files are the
app's menu under the name (no native select). New code is in the
library plugin, so the core script budget is not raised.
- SkillText is gone (its only caller was the route). One new string, in
all five languages. docs/subsystems/library.md says all this.
Run on mote at the change rebased on 9335e23d3:
- go test -count=1 -timeout 45m ./internal/library ./internal/gui
./internal/cli: library ok. gui: TestCoreScriptBudget passes; the only
red is TestMainWindowCorners/macOS_26_SDK (#3949, mote's macOS 27).
cli: the only red is TestEveryRouteHasACommandOrIsNamed on GET
/api/context/reply (#5026, from 0872bc2a0). Both are red on main and
filed.
- GOOS=linux and GOOS=windows go vet -tags nogui on the three packages;
gofmt -l clean.
- skill-edit.test.cjs: 22/22 (chromium and webkit; en, zh, zh-TW, ja,
de; 860px and 400px). It checks the drawn Markdown and front matter,
no sideways scroll, ⌘S posting the exact body with `was`, the status,
the file menu, Cancel sending nothing, Save on a second file, no click
scrolling the page, no left-border stripe or gradient. i18n-keys ok.
- Whole GUI suite (a new API call), on the Linux box (wsl-run; mote had
two other full suites): ~4460 of its results in at the push, not
finished. Its reds are all WebKit and none is in a file this touches.
The ones near it, run alone at this change and at origin/main
bc10a6198: click-scroll, found-skill-pick-remove and account-eye fail
the same on both (#4385, #4097/#5013, #4244).
Again at the pushed head (rebased on b967b1620; its commits change
app.js and the core budget), on the Linux box: TestCoreScriptBudget ok,
go test ./internal/library ok, gofmt -l clean, skill-edit.test.cjs and
i18n-keys 26/26.
Broken by hand: without the `was` check, without the linked-folder check
and without the CRLF handling, TestSkillFileSaveRefusesAChangedFile,
TestSkillFileStaysInTheSkill and TestSkillFileKeepsLineEnds each went red.
skill-edit.test.cjs on the old assets: 0/11 in chromium (.lib-mdview
never appears).
Not tried: refeccd's own skills (the fixture is a made-up handover from
~/.agents/skills, with a copy agent and a link agent); the real app
window (the GUI tests fake the API); the TUI and CLI, which have no
editor; making, renaming or removing a file from the page; Windows.
nam.haid on Discord: the Usage page showed no balance for a Zhipu key,
and SiliconFlow's card always said only "暂时无法获取额度".
Zhipu / Z.ai: nothing read a pay-as-you-go key's balance. BigModel has no
documented balance API; its console asks
/api/biz/account/query-customer-account-report with the key as a Bearer,
and it answered a real key (the owner's, 2026-11-03) the same at
open.bigmodel.cn, www.bigmodel.cn and api.z.ai:
{"code":200,...,"data":{"balance":0E-9,...,"availableBalance":0E-9,
"frozenBalance":0E-9,...},"success":true}; a bad key gets code 1000 at
HTTP 200. zhipuBalanceSource reads availableBalance at the key's own host
(¥ on bigmodel.cn, $ on api.z.ai). A refused key says so in the words the
Coding Plan card already uses (zhipuRefused), another code says its code
and msg, a reply without availableBalance is an error, never a balance. A
GLM Coding Plan key (a base under /api/coding/, or a key on the "coding"
plan) isn't asked: its plan windows are its card. A key seen only at the
shared /api/anthropic endpoint gets a card only once the account was ever
paid in. KeyBalances now skips a key whose own plan has no balance
source, so a mixed provider's Coding Plan key gets no stray card.
SiliconFlow: /v1/user/info answers 410 (code 20092) since 2026-08-14 and
its release notes list no replacement through 2026-10-21. The reason was
already read but shown as the generic line, with the last balance kept.
It is now a typed error (siliconFlowRetired): no kept balance, the card
says the API is gone in the user's language (en, zh, zh-TW, ja, de) and
its "Open the console" button opens cloud.siliconflow.cn (or .com).
Run at this head, rebased on origin/main bc10a6198: on mote, go test
./internal/provider (ok, full package), ./internal/tui (ok), the
budget tests in ./internal/gui (ok); ./internal/gui and ./internal/cli
are red only in TestMainWindowCorners (#3949) and
TestEveryRouteHasACommandOrIsNamed (#5026), the same on main. go vet:
GOOS=windows provider and gui, GOOS=linux provider (ok); gui for linux
needs cgo, not run. gofmt -l clean. GUI on mote at 9335e23d3: the 126
files matching balance|quota|usage|i18n|glm, 1819 of 1856; the reds are
the Usage page's (usage-agents-hide #3414, usage-fold #3415,
usage-ledger #5048), and in WSL the six of them plus
siliconflow-balance and i18n-keys, chromium and webkit, give 32 red at
this head and 35 at bc10a6198 itself, the same tests. siliconflow-balance
20 of 20 (en, zh, zh-TW, ja, de; 900 and 420 wide).
Broken by hand, each red then green: no Zhipu source (TestZhipuBalance,
TestZhipuAndSiliconFlowBalanceCards), no SiliconFlow SeeAt (the cards
test), no per-key plan check (the cards test), the never-paid-in rule
("anthropic, never paid in: <nil>"), the GUI mapping
(siliconflow-balance.test.cjs 0 of 20).
Not tried: a funded Zhipu account (only a never-paid-in one answered, so
the funded fixture is that reply with amounts filled in); a real
SiliconFlow key (the 410 shape is the one TestSiliconFlowRetiredBalanceQuery already held); the credit
line (creditBalance) isn't read; a provider whose own plan is the Coding
Plan with a pay-as-you-go key beside it still gets no balance for that
key. The account report is undocumented and may change.
dallascao on Discord: generating images in Codex and revising them again
and again, magpie answered 413 "request body is over magpie's gateway
limit of 512 MB (decoded); the provider was not asked" on
127.0.0.1:3425/backend-api/codex/responses, while Codex signed in to
OpenAI directly went on. The count was right: Codex keeps each image it
generated in the conversation (a function_call_output input_image, a
~3 MB PNG as ~4 MB base64; codex-rs ext/image-generation to_response_item,
and history keeps image_generation_call results), and over HTTP sends the
conversation whole every turn, so ~130 images is 512 MB decoded. To
OpenAI directly Codex uses its WebSocket and sends a delta.
- Codex's own path (codexBackend, the Codex relay, the Responses
WebSocket's read limit, keyLimited on CodexPath) reads to
codexBodyLimit: a sixteenth of the machine's memory (memLimit, else
proc.MemTotal), 512 MB at least, 2 GB at most. 16 GB: 1024 MB,
24 GB: 1536 MB, 32 GB+: 2048 MB, 8 GB or unknown: 512 MB as before.
It is still the bomb guard: nothing decodes past it, and the zstd
decoder keeps its window bound.
- A turn for a magpie model ("provider/model") on that path is held to
the 512 MB of every other route once its model is read: it is
translated, at several times its size. Its 413 says one of Codex's own
models takes up to codexBodyLimit; writeError's /compact hint stays.
- provider.codexNamesBad read tools/input/tool_choice with
GetManyBytes, which copied the whole input (the body's size: 300 MB of
a 300 MB turn in the alloc profile). It reads in place now.
Cost at the largest input (mote, a relayed gpt-5.5 turn of random
~3 MB images, heap objects sampled every 5ms, load ~350): 300 MB took
4.7s, 600 MB 7.7s, 1000 MB 11.9s, peak heap 1.5 to 2.1 GB past the
body's own bytes. The rest of the cost is io.ReadAll growing the decoded
body and fillJSONIn/exchangeOf; bodyRoom still runs a body bigger than
its room alone.
Run at the pushed head (mote): gofmt -l clean; GOOS=linux and
GOOS=windows go vet ./internal/gateway ./internal/provider ok;
go test -timeout 45m ./internal/provider ok, ./internal/gateway ok but
TestCompactionOverByteCapEveryTime, red in the full package run only
(#4862, filed before this; passes alone 3 of 3 here).
TestRequestBodyTooLarge/codex now sends codexBodyLimit+1.
- TestCodexGeneratedImagesPastOldLimit (16 GB machine fixture, a 516 MB
turn of generated images in Codex's shape): reaches the fake ChatGPT
backend whole in ~6s; the same turn for x/gpt-5 is 413 naming
"one of Codex's own models takes up to 1024 MB".
- TestCodexBodyLimitFromMemory: 2/8/16/24/64 GiB and unknown memory.
Broken by hand: codexBackend reading with limit 0 (the old code) makes
TestCodexGeneratedImagesPastOldLimit red with the reporter's 413; the
magpie-model check turned off makes it red (404 from routing, not 413).
Not tried: the reporter's own session or a real Codex image-generation
run through magpie; a turn past 1 GB on a 16 GB machine; the WebSocket's
raised read limit has no test of its own.
steven_4422 on Discord asked for the 5h and 7d account use in Claude
Code. magpie has had `magpie statusline` since #1997 (kensenzhao), but
it was found only in docs/reference.md and needed a hand-written
settings.json entry naming a `magpie` the app doesn't put on PATH.
Claude Code's row now has a "status line" square beside ultracode (the
same toggle, now a table, TOGGLES in app.js), and `magpie claude
statusline on|off` in the CLI. On writes settings.json's statusLine as
{type: command, command: "<this magpie's full path> statusline"},
quoted for a POSIX shell (Git Bash on Windows, forward slashes).
The command reads the gateway's kept windows with a 1s timeout and
prints nothing when it can't, as before.
- A status line of the user's own is never written over: the square
isn't offered while one is there, on is refused, and off and
Disconnect leave it byte for byte. Ours is a single plain command
whose program is magpie/magpie-* and first argument statusline, so a
hand-written one from the reference counts and a compound (&&, |, ;,
$(...)) is the user's.
- An unreadable settings.json is not written over.
- Disconnect takes magpie's status line out with the rest.
- Quiet: Claude Code reruns a changed statusLine command in its open
sessions, so no restart notice.
- Not offered for a WSL distro, and a distro's settings.json isn't read
for the options (a stopped one would start, #3896). A stopped
distro's fields fall back to magpie's models as options, so without a
case in wsl.go its square would have listed models
(TestWSLClaudeNoStatusLine).
Run on mote (go1.26.8, load ~400):
- at f33e6d112 (rebased on 3088872e6): go test -count=1
./internal/agent ./internal/cli ./internal/gui. Red:
TestWSLColdPlaceOpensNothing (mine: Options read a distro's
settings.json; fixed), TestCoreScriptBudget (5 bytes over after the
rebase; a comment trimmed, no raise), TestEveryRouteHasACommandOrIsNamed
(#5026, from 0872bc2a0 on main), TestMainWindowCorners/macOS_26_SDK
(#3949, macOS 27). go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: ok.
- GUI at f33e6d112: every agent-*, claude-*, i18n*, field* and tweak*
file, both engines: 1294 of 1296. agent-stale-copies (webkit ja 980,
#1949) and claude-subagent-tag (webkit ja 1100, filed #5040) timed out
under load; at d85b4e49b both files and claude-statusline.test.cjs
(en, zh, zh-TW, ja, de at 900 and 400 wide) alone: 130 of 130.
- at d85b4e49b (the fixes above): go test ./internal/agent ok;
TestCoreScriptBudget ok.
- rebased on f37742e14 (a key's spend cap took the core to 21 bytes
under its budget; this change's 207 bytes are paid for by foldSame's
comment cut, no raise), at the pushed head: go test ./internal/agent
ok (318s); TestCoreScriptBudget ok (1,533,597 of 1,533,802);
claude-statusline, i18n-keys and claude-effort GUI files, both
engines: 46 of 46.
- gofmt -l clean.
Broken by hand, each red then restored:
- the user's-own guard off: TestClaudeStatusLineLeavesTheUsers
- the Unwire call taken out: TestClaudeStatusLineGoesOnDisconnect
- the file wiped before the write: TestClaudeStatusLineUnreadable
- the compound check off: TestClaudeStatusCommand
- the WSL asleep case off: TestWSLClaudeNoStatusLine
- the here check after the read: TestWSLColdPlaceOpensNothing
- the statusline entry out of TOGGLES: claude-statusline 15/15 red
Not tried: a real Claude Code session showing it (and its hot
reload); Windows Git Bash and PowerShell with a real path; the Linux
AppImage path; WSL is not offered at all.
A third-party model in Codex (DeepSeek, MiniMax, ...) had its web
searches made by asking gpt-6-luna on the Codex account to search
through /responses. A ChatGPT account now searches by the ChatGPT
backend's /alpha/search, the request Codex's web.run sends by itself
with no model turn (codex-rs ext/web-search): one search_query, the
account's small model in "model", allowed_callers ["direct"], and
external_web_access from the client's web_search tool (#5018: Codex's
"cached" sends false; live by default). The output's pages are read by
their 80-dash rule and ref_id; the private-use citation marks are dropped.
Measured on a real Plus account (2026-11-03, token not refreshed): 151
alpha/search calls left the 5h window at the same percent, ~1.5-2.2s
each; 51 searches by gpt-6-luna took 0% -> 1% of it, 7-15s each,
~9-17k tokens in (40 of them: 414,585 in, 10,313 out). The backend
answered the same for any "model" (deepseek-v4 too) and any
max_output_tokens.
- Automatic (and searchInTurn) picks the backend's search for a ChatGPT
account; Settings > Web search offers "<id>/@search" as "its web
search". "<id>" and "<id>/<model>" saved before still search by that
model, so a user's pick is unchanged.
- When the backend's search fails, the account's small model searches
(codexSearchBy).
- Codex web.run's own search for a non-ChatGPT model (alphaSearchHere)
and a Responses request's web_search tool pass their mode on.
Run at this head (rebased on origin/main), on mote:
- go test ./internal/gateway/... ./internal/gui/ ./internal/agent/
-timeout 45m: gateway and agent ok; gui red only on
TestMainWindowCorners/macOS_26_SDK (#3949, macOS 27 on mote).
After the rebase: the gateway's search tests again ok.
- searcher-pick.test.cjs: 22/22, chromium + webkit, en/zh (+ the label
is in zh, zh-TW, ja, de).
- gofmt -l clean; GOOS=linux go vet gateway, provider; GOOS=windows go
vet gateway, gui.
- Whole GUI suite on the Linux box (wsl-run): not finished when pushed;
its reds so far are WebKit pages this doesn't touch (add-provider,
API key palette, Routing headers, click-scroll, Codex resets).
Broken by hand, each red: the Automatic switch (TestCodexSearchesWith
ItsCheapModel, TestChatGPTAccountSearchesByItsWebSearch), the
responses.go mode (TestResponsesWebSearchModeKept), the body's mode,
the fallback, and the picker option (searcher-pick).
Not tried: a real search through magpie in a sandbox (the request shape
was tried by hand against the backend); an account out of its
allowance (does alpha/search still answer?); the model fallback still
searches live when Codex asked cached.
Suggested by lucy_85908 on Discord.
xiaoq6285 on Discord (magpie 0.1.2798, the Windows Codex app, one
ChatGPT Plus account, Codex on its own model joined beside the sign-in):
at the five-hour limit the app showed an error and had to be restarted,
then its account menu showed only "magpie" with no quota; at the reset
it restarted by itself and the account came back.
Cause. When the active account was held (used up, no credits), Sync's
own-model takeover made magpie Codex's provider on codex/<model>
whenever magpie's catalog listed that model on any Codex account -- the
same used-up one included. With one account and no fallback every turn
it took over is refused on that account anyway, while the takeover:
- has account/read answer no account, so the menu drops the user, Plus
and the usage meter until the reset;
- changes the route twice (into it, back at the reset), and
KeepCodexAppOnItsProvider ends the app's app-server each time, which
ChatGPT desktop 26.1027.x shows as "ChatGPT 遇到了问题" and relaunches
(#4550, still open, the app's own reaction to an ended app-server).
Separately, magpie's [model_providers.magpie] requires_openai_auth
follows the account out and back (openaiAuth), and codexAppRoute
counted it even when that table was not Codex's model_provider, so
staying beside the sign-in would still have ended the app-server at
the limit and at the reset.
Change.
- provider.CodexServesWhileOut(model): the Codex subscription has
fallbacks for codex/<model> (FallbackModels), or another ChatGPT
account is not known held and not lapsed.
- Sync's own-model takeover runs only when that holds. Otherwise Codex
stays on its sign-in: the app keeps the account, its quota and reset,
and shows its own limit message. With a fallback set it moves as
before (affa979d5 serves the fallback through the gateway too).
- codexAppRoute counts magpie.requires_openai_auth only while
model_provider is magpie; the table is still written as before.
- docs/subsystems/agent-wiring.md says both.
Tests.
- TestCodexOwnModelOneSpentAccountStaysOnItsSignIn (new): one account,
no fallback, held: config stays on the sign-in, codexAppRoute and
AppOut unchanged across two Syncs and the reset.
- TestCodexServesWhileOut (new): one account none; another not known
out yes; every account out none; a codex fallback yes.
- TestCodexOwnModelGoesThroughMagpieWhileUsedUp and
TestCodexOwnModelOutThenKeptOnChatGPT now set a codex fallback, the
case where the takeover still serves something.
Broken by hand: the CodexServesWhileOut gate taken out -> the new agent
test red (Codex moved to model_provider = "magpie", codex/gpt-a);
codexAppRoute counting requires_openai_auth always -> red (route
changed with model_provider empty). Each put back, green.
Run on mote at this head (rebased on e41ef6288), -tags nogui -timeout 45m:
- internal/agent ok (381s), internal/provider ok (254s);
- internal/cli FAIL in TestEveryRouteHasACommandOrIsNamed alone: GET
/api/context/reply has no command, from 0872bc2a0, filed as #5026,
nothing of this change;
- gofmt -l clean; go vet of both packages, GOOS=linux go vet -tags
nogui ./... and GOOS=windows go vet ./... ok.
- internal/gateway ok (1152s) at the earlier base 3088872e6, not run
again after the rebase (it imports provider; this change adds a
function there and changes nothing it calls).
Not tried: the real Windows Codex app signed in to a used-up Plus
account (the Windows box's app is not signed in; #4550's crash was not
reproduced there); a real codex app-server against a fake 429 upstream.
Users with a fallback or a second account still get the takeover and
its two app-server restarts, which #4550 tracks.
sparkling_lemur_62868 on Discord: a team's OpenAI key holds granted
credits that other docker services spend from too, and they want magpie
to stop at a share of it. Their workaround was two magpies behind a
gateway-key limit.
What changed
- provider: KeySpendCaps on a provider, keyed by the key's fingerprint
(key_spend.go): USD over a local calendar day, a local calendar month,
or in all since it was set. Since is kept while the cap stays one in
all. SetKeySpendCap and ParseSpendCap refuse an amount outside
0 < usd <= 1,000,000 and an unknown period, and leave the saved cap
as it was. Subscriptions are refused, since an account has its own
usage-window cap.
- usage: KeySpent(keyID, start) is what magpie's own calls on the key
cost at the Usage page's prices. Turned-away calls and app-reported
ones are left out. It reads usage.jsonl once per key and start, keeps
the sum for 5 minutes, and Append counts each new call into it
(spentNew). A read that a write races is read again.
- gateway: perKeyEvery bars a key at its cap (spendHeld) as a usage cap
holds an account. The next key serves, then the fallbacks. With none,
the reply is 429 "spend cap reached: ..." naming each key, what it
spent of which cap, and how to go on. Retry-After is when the soonest
period renews; a cap in all gives none. A spend hold is not a usage
cap: Stop at the caps and strictKeep don't end at it (capHeldOnly).
The trace's barred row carries the cap, the spend and the period.
- GUI: a pill on each key's row in the provider editor, for example
"$7.50 of $20.00 today". It opens the app's menu (No spend cap,
Per day..., Per month..., In all...) and then takes the amount in
place, as the lane-limit pill does. A key at its cap gets a line
under its row: "At its spend cap · back in ...". Every string is in
all five languages. The pill and the line are in keyspend.js, which
app.js imports when it draws a key's row, so the core's script
budget is not raised. /api/providers' keyList carries spend, and
POST provider/keyspendcap sets it.
- CLI: magpie provider spend-cap <id> [key [usd [day|month|total]|off]]
lists each key's spend and sets or removes a cap.
- docs: providers-accounts.md and gateway-routing.md.
Caveats, also in the tooltips:
- What counts is magpie's priced usage, not OpenAI's bill.
- A model with no known price counts $0.
- Requests already under way when the cap is reached still finish, so
a key can go a little past it.
Run on mote at the pre-rebase head (3e3196222 + this change):
- go test -count=1 -timeout 45m for internal/provider, usage, cli, gui
and gateway: provider, usage and gateway ok. Three reds, none from
this change:
- cli TestEveryRouteHasACommandOrIsNamed: GET /api/context/reply,
red on main, #5026.
- gui TestMainWindowCorners/macOS_26_SDK: macOS 27, #3949.
- gui TestCoreScriptBudget: from this change. Fixed by moving the
pill into keyspend.js, then ok on a rerun.
- go vet: plain, GOOS=linux -tags nogui and GOOS=windows -tags nogui,
all clean. gofmt -l is clean.
- GUI, both engines: key-spend-cap.test.cjs passed 20 of 20 before
the keyspend.js move, and all of its tests passed again after it.
It covers en, zh, zh-TW, ja and de at 900 and 400px, a refused
amount, the set, change and remove posts, and checks for no native
select, no border stripe and no sideways scroll.
- Also run in both engines: i18n-keys, old-webkit, lane-limit,
account-cap, key-row-chips-fit, key-weight-fit, key-nourl,
provider-many-keys, key-switch, key-plan and key-rest-date.
- key-replace's webkit 420px is red at base 3e3196222 too
(#4126; base failed 2 of 3 en runs, this change 3 of 3).
- key-rest-date's webkit zh-TW, ja and de tests time out at
--test-concurrency=4 with three other files beside it, at base
too (base 5 reds, this change 7). Run alone at concurrency 2, it
passes 10 of 10 at base and with this change (#4691).
After the rebase onto 9c51f7fdb, at the pushed head:
- go build ./... and go vet on the five packages: clean.
- go test of the spend tests, TestCoreScriptBudget and the gui
package's word tests: ok.
- i18n-keys and key-spend-cap in both engines: 24 of 24.
Broken by hand, each red and then restored:
- spentNew taken out of Append: TestKeySpentCountsTheKeysCalls red
("after a new call key a spent 3, want 7").
- spendHeld never barring: TestKeySpendCapPassesTheKeyOver red (the
capped key reached the upstream).
- capHeldOnly keeping spend holds: TestKeySpendCapPassesTheKeyOver red
(Stop at the caps answered 429 instead of using the fallback).
Not tried:
- a real OpenAI key or real spend;
- the real app window;
- Windows and Linux test runs (vet only);
- the whole GUI suite: mote was running two other sessions' full GUI
suites at load 250 to 400.
xybio on Discord (Claude Pro, Claude Code through magpie, likely in auto
mode) saw it twice: right after the 5-hour window reset, one message took
the window from 100% to 0%. Their Usage page for the day (claude-opus-5-5):
- 62 requests and 17M tokens, almost all of it cache (input 102,
output 31.3K);
- a 29.4% cache hit rate, so about 12M tokens were written to the cache,
around 290K for each of the 41 that succeeded.
That is the whole conversation written again on almost every request.
The cause is in the bridge. With server review on, which it is for a Claude
account (AutoModeReviewed), every request carries Claude Code's
`safeguards`. The interactive mode's Claude Code reads
CLAUDE_CODE_EXTRA_BODY only as it starts, so setSafeguards restarted the run
whenever the field differed in any byte. A new run is told the whole
conversation, and that writes it all to the cache again.
The field's classifier_context differs on nearly every request. That is in
Claude Code's own code (2.1.316, Jmr):
- prior_turn_context grows with each tool round's tool_use_ids;
- git_state.status follows every edit;
- system_reminders, artifacts, text_provenance and the shed list vary too.
So every tool round and every turn of one message started a fresh run
(4 turns gave 4 runs in the new test on the old code), each paying a full
cache write of the history.
Change: in an interactive run, setSafeguards compares safeguardsKept forms.
That form leaves out the parts Claude Code itself names as variable and
sheds over its 256KB budget:
- prior_turn_context, system_reminders, artifacts, text_provenance, shed;
- Chrome's tabs;
- git_state except cwd, root, branch and default_branch.
When only those changed, the run goes on with the context it started with.
A change to the rules, permission or auto mode, folders, or the
repository and branch still restarts it. A field that isn't the expected
JSON is compared whole. The -p path is unchanged: it takes every change in
place through apply_flag_settings. The cost is that the server classifier
sees those varying parts as they were when the run started. This is noted
in docs/subsystems/claude-subscription-bridge.md.
Run at the pushed head (52d69934f, on origin/main 9335e23d3), on mote:
- go test -tags nogui -run 'TestClaudeTUI|TestClaudeBridgeSafeguard|
TestClaude.*Safeguard|AutoMode' ./internal/gateway: ok.
- gofmt -l internal/gateway: clean.
Run at 4ff686b49, the same tree before the rebase (the rebase brought in
only 9335e23d3, outside these files):
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway: ok.
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway: one red,
TestClosedBeforeSentEveryTimeSaysWhy (a bare EOF on the Codex
closed-before-sent path, which this change doesn't touch). It passed
30 of 30 alone. Filed as #5031.
Broken by hand:
- The comparison off (always restart):
TestClaudeTUISafeguardsVaryingPartsKeepTheRun is red, "4 turns ...
started 4 runs, want 1".
- The comparison always passing: the same test is red, "a changed rule
went on in 1 runs", and so is TestClaudeTUISafeguardsInEnv.
Not tried:
- A real Claude account in auto mode through the interactive bridge, and
the real 5h meter before and after.
- Whether xybio's windows also fell in the earlier cache regressions
(v0.1.2677 to v0.1.2799). The local-classifier path, where each check is
a one-off run that re-writes its transcript, is not changed here.
chengming0v0 on Discord (v0.1.2806, Claude Desktop): the models of an
API-key provider read "mythos-magpie-0167851852", "mythos-magpie-3494120245"
and the like in Desktop's model menu, beside rows named properly
("DeepSeek V4.1 Flash 1017 · 寄吧鲁东", "GPT-6.1 Sol · ag:zdgit").
Cause: since ae060550b (v0.1.2770), while a model is picked for one of
Desktop's tiers, magpie writes its profile's inferenceModels so Claude
Code gets behavesAs. Desktop 4.4212 skips /v1/models discovery while that
list has no bare tier word as a name (adminListObviatesDiscovery in
index.chunk-m4oMImJ-.js, discoveryEnabled unset), and pzn then names each
entry labelOverride ?? catalog name ?? discovered name ?? ypn(id), which
for mythos-magpie-<n> and anthropic/magpie-<n> is the id itself. Only the
rows listed by their [1m] id (DesktopLongest) got a labelOverride, which is
why the user's 1M models kept their names, and why one GPT model of theirs
showed its name once its window was set from 400K to 1M.
Change: DesktopInferenceModels gives every entry the display_name
/v1/models gives its row as labelOverride, a catalog-named Claude model
(magpie-<n>.anthropic.<model>) too, whose description naming the provider
is lost with discovery. A list magpie wrote before is rewritten on the next
Sync (its hash is magpie's); Desktop reads it as it starts, so it needs a
restart (the Agents row offers one). agent-wiring.md updated.
Reproduced with the reporter's shape: an API-key provider whose models
have reasoning levels (listed as mythos-magpie-<n>), a GPT model at 400K
and one at 1M under DesktopLongest, one picked for a tier, in the tests'
sandbox HOME. TestDesktopInferenceModelsNamed (new) is red on the old
desktop_list.go for every entry but the 1M one ("mythos-magpie-3254679763
is labelled <nil>, /v1/models names it \"gpt-6.1-sol · 寄吧鲁东\"", 5
entries), and
TestClaudeDesktopModelsList's new check, on the profile magpie writes, is
red on it ("named by its id: … name:anthropic/magpie-4604110569"); both
green with the change.
Run on mote, rebased on 3e3196222: gofmt -l clean; GOOS=linux and
GOOS=windows go vet ./internal/gateway ./internal/agent ok; go test
-count=1 -timeout 45m ./internal/gateway ./internal/agent ./internal/gui:
gateway ok, agent ok, gui red on TestMainWindowCorners/macOS_26_SDK only
(#3949, open, unrelated). After that run the new test gained the 400K/1M
pair; -run 'TestDesktopInferenceModels|TestClaudeDesktop' over gateway and
agent ok at the pushed tree.
Not tried: a real Claude Desktop 4.4212 with the written profile (read
from its app.asar only); the reporter's own Desktop version is unknown.
A provider's fixed Headers can't say a value that changes from request
to request or from client to client. 3jRzfF52Qx on X asked for the
agent's own header values to reach the vendor. Each provider now has a
comma-separated list of request headers, saved as `passHeaders`. When the
agent's request carries one of them, its value goes to that provider as
the agent sent it.
- Where it is: the editor's "Request headers to pass" (zh 透传请求头),
under Advanced, right after Reply headers.
- The agent's value stands over a fixed Headers value of the same name.
When the agent sends none, the fixed one goes.
- Never passed on, listed or not (provider.RequestHeaderPassable):
- magpie's key: Authorization, X-Api-Key, X-Goog-Api-Key, Api-Key;
- cookies and sign-ins: Cookie, Set-Cookie(2), WWW-Authenticate,
Authentication-Info, Proxy-*;
- the connection's own fields: Host, Connection, Keep-Alive, TE,
Trailer, Transfer-Encoding, Upgrade, Expect;
- what magpie writes for the body: Content-*, Accept,
Accept-Encoding;
- Origin, Sec-* and X-Magpie-*.
Save refuses such a name with a reason (RequestHeadersOK), and so does
the editor, before the save. The editor's list is held to Go's by
TestReplyHeadersNeverAsTheProvidersAre. A name written into
providers.json by hand is dropped on read.
- Only that provider gets them. forwardOnce, which every chat,
responses, messages, count_tokens, group-member, fallback and plugin
try goes through, puts the agent's headers in the try's context under
the try's provider id (WithClientHeaders). Provider.Sign passes only
what that id lists, before an account signs, so a signed-in account's
own signing still wins. A plugin's fetch gets them in req.Header.
- Wire headers are still masked when read (5ec237568), so a passed
token header shows masked in a call's log.
Run on mote at the tree rebased on origin/main 06944e065:
- gofmt -l: clean.
- go vet: darwin (provider, gateway, gui), GOOS=linux -tags nogui
./..., and GOOS=windows ./...: ok.
- go test -timeout 45m ./internal/provider ./internal/gateway
./internal/gui: provider and gateway ok. In gui, TestCoreScriptBudget
and the i18n tests are ok and only TestMainWindowCorners/macOS_26_SDK
is red, as on main on macOS 27 (#3949).
- The core budget is not raised. This change's words, and the comments
on extra body and the never lists, were cut first. After the rebase
onto 63dc359fb it was 438 bytes over again, so three provider-editor
comments (User-Agent, balance token, plan access keys) were cut to a
line each. The core is 1,533,554 bytes, 248 under 1,533,802.
- At this head (rebased on origin/main 63dc359fb): go test -run
Budget|I18n|ReplyHeaders ./internal/gui is ok. The new provider and
gateway tests are ok. node --test pass-headers, reply-headers,
i18n-keys, header-session-hint, balance-fix and extra-body: 162 of
162 ok.
- node --test, Chromium and WebKit: pass-headers (en/zh/zh-TW/ja/de),
reply-headers, i18n-keys, provider-detect-models, header-session-hint
and extra-body: 46 of 46 ok.
- Before the budget cut, against the same base: every GUI file that
opens the provider editor and saves (45 files plus i18n-keys) had 739
of 758 ok. These were red, and red the same on a fresh origin/main
06944e065 copy: models-works-only (#4391), provider-picks-stay
(#4397) and remote-magpie (#4398). Also red: one WebKit sub-pixel
miss in provider-detect-models (#4964), which passed on main and at
this head.
New tests:
- TestRequestHeadersList: cleaning and refusals.
- TestSignPassesClientHeaders: the agent's value over the fixed one,
never magpie's key even when listed by hand, nothing for another id,
and the fixed value when nothing was sent.
- TestPassHeadersReachTheProvider: messages relayed and translated,
chat, a chat stream, responses and count_tokens.
- TestPassHeadersOnlyToTheirProvider: a fallback that lists nothing gets
nothing, the log shows the passed headers masked, and in a group the
member that lists them gets them while the one before it, which lists
nothing, doesn't.
Broken by hand, each red, then put back:
- forwardOnce without WithClientHeaders: both gateway tests red.
- RequestHeaderPassable ignoring the never list: TestRequestHeadersList
red, and TestSignPassesClientHeaders red on X-Api-Key=magpie-key
passed on.
- Sign not skipping a fixed header the agent sent: the provider test,
and the gateway test on every route, red on X-Route=route-fixed.
Not covered: embeddings, images, video and the Codex backend relay,
which don't go through forwardOnce.
Not tried:
- a real vendor or a real plugin provider with the setting;
- Windows and Linux test runs (vet only);
- a gateway test with Authorization listed by hand, which normalize
drops on read. Sign's own check is covered by
TestSignPassesClientHeaders.
Requested by 3jRzfF52Qx on X.
maxleebeta on Discord (#feedback): WorkBuddy answered 429
{"type":"rate_limit_error","message":"WorkBuddy: 您的使用量已超出频率限制,将在
2026-11-03 23:57:19 UTC+8 重置,您也可以切换其他模型继续使用。"} while the
provider's card said 1,934/2,350 credits left (82%), and nothing on the
Providers page said the account was held back.
Routing already handled the refusal: resetsWhen reads the time (UTC+8, the
space before 重置 included), failure() gives failQuota, and since it says
切换其他模型 the rest is that model's alone (restID), by "resets", till
15:57:19 UTC; the account's other models are still asked (#1669). What
was missing was the page: a key's rest showed on its row, an account's
never did.
- gateway.RestsUnder(prefix) lists the rests in force under a key prefix
(provider@ for a subscription's accounts, provider@user/model for a
model's), with Key and the rest's note (Model, By, Error).
- providerJSON.accountRests gives them by user in lower case, the model
filled in from the key when the note has none; provider.KeyRest gains
By, Model and Error.
- app.js: the account row in the provider editor gets a line per rest
(accountRestLines): "<model> resting · 429 quota used up · back at
<time>" or "Resting · …" for the whole account, the vendor's words
beside it (shown whole when it names a time magpie couldn't read, so
an unknown format still says why), and Try now (gateway/unrest by the
rest's key). The key row's rest line is now the same helper
(restLineOf), so app.js grows ~800 bytes, under the core budget.
- New strings in zh, zh-TW, ja and de. docs/subsystems/gateway-routing.md
says where the Providers page reads them.
Not changed: the "-sg" maxleebeta saw in pi is WorkBuddy AI's own model
id (deepseek-v4.1-flash-sg, the paid Singapore id beside the free
deepseek-v4.1-flash); pi's footer and model picker show ids by design,
and the name magpie writes for it is the vendor's ("Deepseek-V4.1-Flash",
"(SG)" added by the plugin only where two ids share a name). Neither
magpie nor the plugin appends "-sg"; the CN build has no -sg ids.
Run (mote, through mote-run):
- go test ./internal/gateway ./internal/gui ./internal/provider at f0df4bb2b
(base 06944e065): gateway ok (737s), provider ok, gui ok except
TestMainWindowCorners/macOS_26_SDK, red on macOS 27 as on main (#3949).
- Rebased on 889767b7b: TestCoreScriptBudget, TestI18n*,
TestAccountRestsInProviderState and the written-reset tests ok;
gofmt -l clean. GOOS=linux and GOOS=windows go vet -tags nogui ok at
f0df4bb2b, before the rebase. Then rebased once more onto 8ee172ca0,
which changes only gateway search files; not re-run there.
- internal/gui/tests/account-rest.test.cjs: chromium and webkit, en, zh,
zh-TW, ja, de, at 900 and 360px, ok. rest-try-now.test.cjs's 15 webkit
reds fail the same on origin/main 06944e065 (#2564, #4127).
- Broken by hand: TestRateLimitedModelListedUnderAccount red with
RestsUnder returning nothing, TestAccountRestsInProviderState red
without accountRests, account-rest.test.cjs red without
accountRestLines.
Not tried: a real WorkBuddy account hitting this 429, so the line has
not been seen on a live gateway; the whole GUI suite (mote under another
session's suite). The line shows in the provider editor's account rows,
not on the collapsed provider row.
uk.jent (Discord, #feedback): MiniMax Code's plugin (0.1.7) served as
Anthropic Messages to Grok Build 1.0.74. The first token took minutes
(5-6 at worst), then hundreds of characters came at once, and every
thinking block said "Thought for 0.0s".
Cause: eventStream decided a reply was a stream by its Content-Type
alone, unless the type was empty or text/plain. A stream sent under
any other type (application/octet-stream, say) was read as a whole
reply. On the Messages passthrough, sigFieldTidy, anthropicTextCalls
and the other tidies hold a whole reply until it ends, so the agent got
the turn only at its end, every block at once. On Chat and Responses
(translated) the same reply failed "did not stream". Under
application/json, notAnAPIReply turned it into a 502 ("isn't JSON").
The plugin itself passes MiniMax's body through untouched, and the host
streams it chunk by chunk, so neither is the cause.
Fix:
- eventStream reads the body's first bytes under any Content-Type that
isn't text/event-stream. A body that begins as an event stream
(event:, data:, a ":" comment) is one, and its Content-Type is set to
text/event-stream for the agent. A JSON or binary body never begins
that way.
- notAnAPIReply lets a JSON-labelled body that begins as an event
stream through (eventsStart, shared with eventStream).
- docs/subsystems/gateway-routing.md says the rule.
Test: TestPluginThinkingStreamsAsItComes. The fake MiniMax plugin is
put in front of a vendor that sends its first thinking and then waits
until the agent has heard it (or gives up after 10s). It covers
messages, messages with tools (as Grok Build sends them), chat and
responses, each under text/event-stream, application/json, text/plain,
no type and application/octet-stream.
Run on mote:
- On origin/main d73f2254d: gofmt -l internal/gateway clean; go vet
-tags nogui ./internal/gateway with GOOS=linux and GOOS=windows ok;
go test -tags nogui -timeout 45m ./internal/gateway ./internal/plugin:
internal/gateway ok (742s), internal/plugin ok (136s).
- Rebased on origin/main 441a2b6b1, which brought the #4775 upload
changes into internal/gateway: gofmt and both vets again ok; go test
-run 'TestPluginThinkingStreamsAsItComes|NotAnAPIReply|
APIReplyUntouched|Upload|Unrouted|Streamless|PluginStream|QuietWhole|
Thinking|Signed|Passthrough|Continuation' ./internal/gateway: ok
(108s). The whole package was not re-run at this head.
Broken by hand:
- With eventStream at the old code, the octet-stream cases go red in
all four shapes: messages "reached the agent only once the vendor
had finished"; chat and responses "FakeCo did not stream".
- The application/json cases go red with eventStream alone fixed and
notAnAPIReply at the old code ("the thought never reached the agent",
a 502 after 90s).
- text/event-stream, text/plain and no type pass on the old code.
Not tried:
- a real MiniMax Code account or a capture of the mavis endpoint's real
reply headers. There is none here, so the cause is the class that
fits the symptom, not MiniMax's literal bytes.
- a real Grok Build run.
- a stream that comes compressed (Content-Encoding).
Found reviewing magpie-community/plugins#658 (AStudio's and Agnes Code's
sign-ins wait up to 5 minutes for the vendor's desktop app).
Cancel didn't end a plugin sign-in. The window's Cancel (and the sign-in's
timeout) ended plugin.Finish's context, but "callback" was not a
cancellable call, so the host never heard: the plugin's wait went on, and
a session file written after Cancel still saved the account. Now
authorize, callback and apiKey are cancellable as gatewayRequest is
(host.go `cancellable`): magpie writes `abort`, host.js (`signInSteps`)
drops whatever the plugin answers after it, so nothing is saved, and
counts the call done at once. The plugin's wait is told too: every fetch
it makes for the sign-in carries the sign-in's signal
(`whileSigningIn`), and magpie's hook passes the signal as
callback(code, { signal }) / authorize(inputs, { signal }), which OpenCode
doesn't, so a plugin can stop polling a file. A plugin that ignores the
signal keeps running until its own deadline, but its answer is dropped.
An oauth method's authorize that returned { type: "failed", error } (no
callback) was stored and its missing callback called, so the user saw
"s.a.callback is not a function". host.js now answers that, or any result
with no callback, as the sign-in's failure, and plugin.Authorize returns
ErrFailed with the plugin's reason, for auto and code methods; an api
method's authorize already did. The GUI's start shows it as its failure,
`magpie plugin login` prints it.
Docs: provider-plugins.md, and the plugin guide (en, zh, ja) on failing
from authorize and the signal.
Not changed: #3083's timeout field, #4678's model/usage task lifetime.
Tests (testdata/signinend, no network; the vendor is testenv.FakeVendor):
TestCancelledSignInSavesNothing, TestCancelledSignInEndsThePluginsWait,
TestCancelledSignInEndsItsFetch, TestSignInFailsWithThePluginsReason
(internal/plugin), TestCancelledPluginSignInSavesNothing
(internal/provider, through StartPluginSignIn/CancelSignIn).
Run on mote (macOS 27), at this change on d73f2254d (the new tests and vet of both packages again after the rebase on 897e88d7e, which touches neither):
- go test -count=1 -timeout 45m ./internal/plugin/ ./internal/provider/:
ok (134s, 145s); the new tests -v: all PASS.
- ./internal/cli ok; ./internal/gui FAIL only in
TestMainWindowCorners/macOS_26_SDK, #3949 (macOS 27 on mote; this
change touches no GUI code).
- GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: ok;
gofmt -l: nothing.
- GUI (Chromium + WebKit): plugin-signin, plugin-signin-no-url,
plugin-signin-opened (en, zh, zh-TW, ja, de), plugin-signin-scrolls,
plugin-keyless-signin, plugin-moved-signin, signin-paste-plugin,
signin-close, i18n-keys: 108/108.
Red on the old code (origin/main's host.js, host.go, providers.go): all
four plugin tests (an account saved after Cancel; the plugin's wait and
its fetch not ended, timed out; methods 2/3/4 said "s.a.callback is not
a function"), and TestCancelledPluginSignInSavesNothing.
Broken by hand: host.go's `cancellable` back to gatewayRequest only, all
three cancel tests red; the whileSigningIn line out of the fetch wrapper,
TestCancelledSignInEndsItsFetch red.
Not tried: the real AStudio and Agnes Code plugins (plugins#658) against
this host; the site's plugin guide isn't deployed by this commit.
Cause: with wuuli's upload credit, a request's charged time stands
still while its body earns at least as fast as it is read. When little
was left, checkMost re-armed most's timer at that sliver, and again
every time it fired, for as long as the body kept coming. In the #4775
review, a hold frozen 100µs short of unroutedMost was looked at 6731
times in a second.
Change: checkMost waits at least unroutedRecheck (1s, or an eighth of
unroutedMost when a test shortens it) before it looks again. A hold is
answered at most that much late. Masking, the 30s unknown-work guard,
the 60s socket idle deadline, the decoded cap and the trickle's 408
are unchanged.
Test: TestUnroutedMostRecheckIsNoSpin freezes a hold's charged time a
sliver short of unroutedMost and counts the timer's looks in a second.
It allows 30.
Run, via mote-run (macOS arm64, Go 1.26.8), at this tree before the
rebase (base affa979d5):
- gofmt -l: clean. go vet ./...; GOOS=linux go vet -tags nogui ./...;
GOOS=windows go vet ./...: all exit 0.
- go test -tags nogui -race -count=5 of the ten upload and body tests
(the patches' four, this series' five, TrickledBodyAnswered408): ok
(102.5s).
- go test -tags nogui -timeout 45m ./internal/gateway/...: one red
(771.9s), TestCodexPoolSaysTheClientsVersion. That is #4807 (another
test's Codex identity reaching it), fixed on main by 17f2387e1, which
this tree's base predated.
- After the rebase onto f3335dd1b (which brings 17f2387e1), at
698362aaf (this tree, before this message was amended):
go test -tags nogui -timeout 45m ./internal/gateway/...: ok (775.7s).
- go test -run TestUnrouted at each of the three commits: ok.
Broken by hand, each with its test (this series and the patches):
- Reset(left) without the floor: NoSpin went red (6731 looks).
- origin/main's unrouted.go with only the two names the tests need:
wuuli's TestUnroutedProgressingUploadOutlastsMost went red with 408
at 1s (identity, chunked, gzip, zstd), and so did
TestUnroutedUploadTimeIsBounded (5 of 6 cases). Leng's
TestUnroutedUploadAllowanceHasCeiling charged 11m against 3m.
TestUnroutedUploadCreditKeepsIdleDeadline passed, as a guard that
holds on main too should.
Not tried: a real slow link or proxy, the reporter's own conversation,
and running on Linux or Windows (vet only).
Thanks to wuuli (Xulin Wu) and lengjingxu (Leng on X, who reported it
again) for the patches this series builds on.
Co-authored-by: Xulin Wu <wuxulin@bytedance.com>
Co-authored-by: Leng <Lengjingxu@gmail.com>
Review tests for wuuli's and Leng's upload credit, guarding the two
ways an earned allowance could hold a request too long.
Banking: a body sent at once earns far more than it took to read
(2 MiB earns 64s at 32 KiB/s). TestUnroutedFastUploadBanksNothing
holds a request after such a body with a lock routing needs. It is
answered 504 at unroutedMost, and the credit buys the later internal
hold nothing (`d -= min(spent, earned)`).
Empty encoded streams: empty gzip members (a 60 KB extra field, no
content) or zstd skippable frames keep the wire busy, decode to
nothing, never reach the 512 MiB decoded cap, and earn upload time
forty times faster than they are read. TestUnroutedEmptyEncodedStreamIsBounded
sends one chunked over a raw conn through Front. It is answered 408 at
unroutedMost plus unroutedUploadGrace: the cap ends it, not the rate.
Go 1.26.8's gzip.Reader loops over members without recursion (read on
mote), so no stack grows with the member count.
unroutedUploadGrace becomes a var so the test can scale it, as
unroutedMost already is. Its value is unchanged (8m).
Run, via mote-run (macOS arm64, Go 1.26.8, -tags nogui):
- go test -run TestUnrouted ./internal/gateway/: ok at this stage.
- The full verification is in this series' last commit.
Broken by hand:
- `d -= earned`: FastUploadBanksNothing went red, unanswered at 20s.
- No clamp on bytes read: EmptyEncodedStreamIsBounded went red in
gzip and zstd, unanswered at 30s, and Leng's
TestUnroutedUploadAllowanceHasCeiling went red (1m and 11m charged).
Not tried: a real client sending such a stream, and a slow real link.
Co-authored-by: Xulin Wu <wuxulin@bytedance.com>
Co-authored-by: Leng <Lengjingxu@gmail.com>
Cause: bodyArriving (#4511) counted a body as still arriving between
two reads only when the request said its Content-Length. A chunked
body, which every encoded upload from an agent can be, was judged by
the read alone. When most's timer fired between two of its reads, the
request was answered 504 "without routing it to any provider", as a
hold of magpie's own, though its body was still coming. A decoder
spends its time between reads too: in the #4775 review, a stream of
empty gzip members got the 504 in 2 of 10 runs.
Change: waitedBody records that a read met its end or an error
(bodyEnded). A chunked body counts as arriving between reads until
then. A body read whole, an empty one, and one not yet begun (the wait
for body room) still count as magpie's hold. Every watched route reads
the body through request_bounds' io.ReadAll, so a read reaches EOF or
an error.
Tests:
- TestUnroutedBodyArrivingBetweenReads now expects a chunked body to
count as arriving between reads, and not once its end is read.
- TestUnroutedChunkedBodyReadWholeHeld504 (identity, gzip and zstd,
sent chunked) guards the other side: a hold after the whole body has
been read is still 504.
Run, via mote-run (macOS arm64, Go 1.26.8, -tags nogui):
- go test -run TestUnrouted ./internal/gateway/: ok. 24 tests at this
stage on 07b6834fe (wuuli's and Leng's patches).
- The full verification is in this series' last commit.
Broken by hand:
- No bodyEnded store: ChunkedBodyReadWholeHeld504 went red in all three
encodings, answering 408 "its body was still arriving".
- The old `d <= 0` condition: BodyArrivingBetweenReads went red, with
"a chunked body between two reads ... did not count as arriving".
Not tried: a real slow link or proxy, and the reporter's conversation.
Bound upload credit to eight additional minutes so progressing compressed streams cannot keep pre-routing requests alive indefinitely. Clamp wire bytes before multiplication to avoid duration overflow. Keep the progressing-upload fix by Xulin Wu in its original authored commit.
Latest main 9d08993c already classifies an unfinished body as 408, but
still ends a large upload at the two-minute unrouted budget. Credit
actual body-read time at one second per 32 KiB received on the wire,
never more than the time spent reading. Fast uploads cannot bank time
for later internal holds. The idle deadline, unknown-work budget, body
room and size cap remain; a trickle still exhausts the base allowance.
The 408 suggests checking the link/proxy or compacting before retrying.
Red: TestUnroutedProgressingUploadOutlastsMost failed on unchanged main
with HTTP 408 at the scaled 1s hold. Restoring main's budget calculation
via Go overlay with final tests makes all four TLS upload cases fail
with 408 and TestUnroutedUploadTimeIsBounded fail its numeric assertions.
Green: declared/chunked/gzip/zstd TLS tests through Front, idle protection,
rate boundaries and existing unrouted/request-body tests pass (28.267s).
Same selection -race -count=20 passes (547.523s).
Verified on macOS arm64, Go 1.26.8, Bun 1.4.3, temp HOME and pinned Go
caches. gofmt -l and git diff --check clean; native/Linux nogui/Windows
vet and builds pass. Final go test -tags nogui -timeout 45m ./... passes:
87 packages (32 cached), 18 without tests, wall 1152.1s; gateway 734.881s,
plugin 122.229s, claudebridge 3.813s. Individual skips not enumerated.
First full suite had 85 passing packages, gateway 743.006s, and two reds.
The known Bun SOCKS assertion (#2207) is fixed by the preceding unchanged
skygunner patch acb2249e (original a93c613a); its -race -count=20 and all
three vets pass locally. A callback helper timeout is filed as #4782:
its isolated -race -count=20 passes (3.586s) and final suite passes, but
the delayed stage is unresolved, not claimed fixed. Existing macOS C
compiler deprecation/enum warnings remain.
No live gateway, account, or original conversation used. No GUI assets
changed; Playwright not run. Linux/Windows were cross-built/vetted, not
runtime-tested. The original network throughput cause remains unknown.
wangbinyq on Discord: with the request archive on, clicking a block of
the context window card still said "只保留最近 10 个请求的原文", since the
card read only the last 10 bodies magpie keeps in memory.
What changed:
- /api/context/text tries memory first, then the request archive's copy
when the route names one (Route.Archive, the route found in the trace
or in the history file of the card's ?day=, HistoryRoute looks a day
either side). gateway.ArchivedPromptText parses it as PromptText does
and masks it through maskedCopy, as the body in memory is; it is
marked from "archive" and the card says so.
- New /api/context/reply: the reply to the request, from the Recent
calls (Server.ReplyBody) or the archive's Response. gateway.ReplyPieces
reads it into thinking/assistant/call pieces (conversationOutput, split
out of conversationTurn) after redact.ScrubJSON, and masks every piece
through maskedCopy. The card's text view has a Reply button beside
Close that shows it and goes back to the part.
- What is shown is what the archive stores, masked as the memory copy
would be, nothing more. A body or reply that can't be masked shows
nothing (404 "unread"); one the archive cut short isn't parsed ("cut");
one it names and doesn't have says so ("missing"), and one with no
archive copy keeps the old "only the last 10" line ("off"). A failed
bucket read is an error, not "gone".
- The archive read is capped at archiveReadMost and the last copy read is
kept 5 minutes, so the items opened one by one read it once.
- ctxtext.js takes the route (id and time) instead of the id; context.js
passes it (its one-line change paid for by a comment cut, core budget
not raised). New strings in zh, zh-TW, ja and de.
- docs/subsystems/gateway-routing.md (Prompt) and gui-shell.md.
Run on f3335dd1b (main has since d73f2254d, textcalls_anthropic.go and
its test only, none of these files), on mote (macOS 27):
- go test -run 'TestArchivedPromptText|TestReplyPieces|TestPromptText|
TestConversation|TestContext|TestCoreScriptBudget' ./internal/gateway
./internal/gui: ok.
- Whole ./internal/gui and ./internal/gateway (before the last rebase,
same change): ok except TestMainWindowCorners/macOS_26_SDK (#3949) and
TestCodexPoolSaysTheClientsVersion (#4807, fixed on main by 17f2387e1
since).
- GOOS=linux go vet -tags nogui and GOOS=windows go vet of both: ok;
gofmt -l clean.
- GUI, both engines, every language, 1100 and 420 wide: every file that
reaches the context card (context-text, context-map, context-window,
context-map-live, context-scroll-end, context-scripts, context-tune,
ctx-route, compact-one-value, routing-ctx-*, routing-context-fold,
routing-live-patch, routing-return-cost) plus i18n-keys: 514 of 518.
The 4 reds are context-map's webkit 420px "two tiles overlap", red the
same on origin/main f3335dd1b run alone (5 of 10 webkit there), #3488.
- The whole GUI suite is running on the Linux box (wsl-run) as this is
pushed; mote had another session's full suite on it.
Broken by hand (each went red):
- maskReplyPieces skipped: TestReplyPiecesAreMasked (phone unmasked).
- ArchivedPromptText's masking skipped: TestArchivedPromptTextIsMasked
and TestContextTextFromTheArchive (phone in the 200 body).
- ctxtext.js's "missing" reason dropped: context-text.test.cjs, 10 of 10
chromium.
Not tried: a real archived request in the running app, the bucket
(WebDAV) archive with a real server, and a reply cut short by the
archive's size in a real call.