Commit Graph
180 Commits
Author SHA1 Message Date
yetone d1f8d8aae7 agent: Cherry Studio adds magpie through its providers link (plugins#865)
Cherry Studio (CherryHQ) shows on the Agents page, and with
`magpie cherrystudio`, on macOS, Windows and Linux. Its row is the link
its main process takes, cherrystudio://providers/api-keys?v=1&data=, with
the gateway at <gw>/v1 as an OpenAI-compatible provider named magpie and
the named key agentKeyAt("cherrystudio"). Cherry Studio asks the user to
confirm it. magpie writes nothing into its store. "Added" is read
untouched from its 2.x database (Data/cherrystudio.sqlite, user_provider),
in the default userData and every one boot-config.json moved it to. A
database or boot-config that can't be read, or a 1.x userData (Local
Storage, no database), is unknown. The data is standard base64, because
Cherry Studio swaps raw + and / before parsing and back after. /api/open
lets that link through. aionui's database status is generalized into
dbStatus{has} so both apps share it. Icon: Cherry Studio's own logo, not
cherryin-color (a different product).

Run (mote, at this change on origin/main c66cdbea9; then rebased on
0f04dca6e and run again: vet of agent/gui/cli, Windows vet of agent/gui,
and the Cherry, AionUi, gateway-key and import-link tests, ok):
- gofmt -l clean; go vet ./internal/agent ./internal/gui ./internal/cli;
  GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...
- go test -tags nogui -count=1 ./internal/agent ./internal/gui
  ./internal/cli: agent and cli ok; gui ok but TestCoreScriptBudget, red the
  same on a clean c66cdbea9 (#4526, 1533856 > 1533802)
- node --test import-row.test.cjs i18n-keys.test.cjs: import-row 20/20,
  chromium and webkit, en/zh/zh-TW/ja/de, and 420px wide; i18n-keys red
  only on "a plugin's words are its own", the same on clean c66cdbea9
  (#5332, #5426, #5482). No new strings.
- TestCherryStudioLinkParsedAs2_1_10 runs the link through 2.1.10's own
  parser (copied into testdata) and the renderer's zod checks, with
  gateways whose base64 spells + and /.
- Real try on mote (macOS 27.2, arm64): released Cherry Studio 2.1.10 in a
  sandbox HOME and --user-data-dir, with a sandbox magpie of this tree on
  127.0.0.1:3561 and a fake upstream. `magpie cherrystudio add` opened the
  dialog with base URL http://127.0.0.1:3561/v1 and the key
  magpie-cherrystudio. Add saved it, turned off as every Cherry provider
  is. `magpie cherrystudio` then said added, read while the app ran (WAL).
  Sync models listed fake/fake-1 from the gateway, and adding it turned
  the provider on. A chat got the fake upstream's reply, and magpie usage
  counted it as Cherry Studio's. A link sent while the first-run welcome
  page was up showed no dialog; after "set up later" it did.

Broken by hand, each red, then restored:
- URL-safe base64: TestCherryStudioLinkParsedAs2_1_10 (baseUrl decoded as
  /x~>/v1 and /xy\x7f?/v1)
- no closing quote/slash on the address match: TestCherryStudioHas
  (another port's provider counted)
- the /api/open prefix dropped: TestCherryStudioImportRow
- Cherry Studio dropped from /api/open's app case:
  TestImportLinkNothingOpens

Not tried: a real run on Windows or Linux (detection is unit tests
only); Cherry Studio 1.x, which reads as unknown; a real vendor upstream
(the try used a fake). Full suite not run at push.

Reported-by: mysterysqwq
2026-11-08 19:09:21 +08:00
yetone a210b3bd5f agents: a reply limit typed by hand into Pi or OpenCode is kept
sayagoodbyeplz on Discord set Pi's maxTokens for WorkBuddy's
deepseek-v4.1-flash to 128000 in models.json, and magpie's next sync
wrote models.dev's 384000 back. magpie writes its models block whole,
so a hand edit inside it was never kept.

output_kept.go records, in the stash, per file and model, every reply
limit magpie has wanted there (the last 8). A value in the file that is
none of them is the user's, and the next sync keeps it. Pi's
providers.magpie.models[].maxTokens and OpenCode's
provider.magpie.models.<id>.limit.output go through it. A Max output the
user sets in magpie (Model settings, Advanced, or `magpie model output`)
is still written over the hand edit, since that is their word in magpie.
With no record (a model new to the file, an unreadable stash) the value
is magpie's, as before. The record keeps every wanted value, not only
the last one written, because the same block is also built for Drift
and never written.

Other agents that write a reply limit are not covered yet: #5693.

Run (mote, at this tree):
- go test ./internal/agent/ (whole package): ok, again at the rebased
  head on a5c97cd83 (333s); on WSL, -tags nogui, the same run is ok but
  for TestGrokInstalled, red there from Windows binfmt interop (#3548)
- TestPiKeepsAMaxTokensTypedByHand, TestOpenCodeKeepsALimitOutputTypedByHand
  (new): models.dev's value is followed while nothing is typed, a hand
  128000 stays through syncs and a models.dev change, the user's magpie
  Max output wins, and taking it away gives models.dev's again
- go vet on darwin (mote), linux (-tags nogui) and windows (WSL)
- WSL magpie-desktop, -tags nogui: go test -run 'Output|Kept|Pi|OpenCode'
  ./internal/agent/: ok
Broken by hand: with the piOutputsKept and openCodeOutputsKept calls
taken out, both tests fail ("written over: 300000" / "384000").
Not tried: a real Pi or OpenCode session reading the kept value.
Full suite not run at push.

Reported-by: sayagoodbyeplz (Discord)
2026-11-08 19:05:37 +08:00
yetone 32fc5809e1 agents: OpenMausBot gets magpie as an engine of its own, written as its own Claude endpoints are (a user on X)
A user on X asked for OpenMausBot (github.com/milind-soni/OpenMausBot,
read at 516ca75; released 0.1.145). Its bots run on engines from
`instances` in ~/.openmausbot/config.json ($OMB_DATA_DIR,
server/config.ts:713). Without this, a Claude bot reached magpie only
through ~/.claude/settings.json, and its picker listed Claude's static
models alone: OpenMausBot doesn't read the model from env
(readClaudeModelCatalog, claude.ts:296-316).

- openmausbot.go writes `instances.magpie` in the shape of OpenMausBot's
  own "Claude endpoint" (newClaudeEndpoint, claude-endpoints.ts:91-139):
  - driver claudeAgent, access custom
  - config.configDir is <data>/providers/magpie. Given that,
    OpenMausBot starts Claude Code with that CLAUDE_CONFIG_DIR and
    strips account keys the engine doesn't set (claudeEnvironment,
    claude.ts:111-136, 158-179), so the engine owns its routing.
  - requireApiKey
  - ANTHROPIC_BASE_URL, AUTH_TOKEN, API_KEY and MODEL point at the
    gateway
  - endpointModels holds magpie's models, kept to the ids
    CLAUDE_MODEL_ID accepts. One bad id makes OpenMausBot refuse the
    whole engine (claude.ts:636).
- A non-empty `instances` is the whole fleet (config.ts:1173). With
  none saved, magpie writes DEFAULT_FLEET (instance-fleets.ts) beside
  magpie, stashed as openmausbot.fleet. Off takes the fleet out again
  if the user hasn't changed it.
- What stays the user's: the engine's name, a model they picked from
  the list, their other env and an inherited `cli`.
- Check reports the base URL drifting away from the gateway.
- OpenMausBot reads config.json once at start (index.ts:780), and an
  engine edited in it writes back the fleet it holds
  (routes/instances.ts:132, config.ts:997-1012). So Set is refused
  while it runs (errOMBRunning), and the notice asks to quit it first,
  since Windows can't tell.
- ListOnly, ListsModels, OMB_DATA_DIR in agentenv. The icon is
  OpenMausBot's build/icon.svg (Apache-2.0).
- i18n in zh, zh-TW, ja and de. Docs: reference, agent-wiring, both
  READMEs.
- Codex bots use ~/.codex (codex.ts:373-386), which the Codex wiring
  already covers.
- The agent package's TestMain holds ombRunning false. An OpenMausBot
  open on the test machine refused every test that turns magpie on for
  each agent: my own sandbox OpenMausBot on mote turned
  TestSyncKeepsAnAddressOnAnotherMachine, TestListOnlyAgentsReadConnected
  and TestReverseProxyIsStillMagpie red. With a process named
  openmausbot running, they now pass. LiveAgent's, OpenPencil's and
  NewMax's running checks have the same hole and are left to #5587.

Run (all on mote):
- gofmt -l: clean
- go vet ./... on darwin, GOOS=linux -tags nogui and GOOS=windows: ok
- go build for the same three targets: ok
- go test -tags nogui ./... -timeout 45m at e1453a168 (this change on
  origin/main 30ae0e3f9): 88 packages ok, none failed. Rebased after
  it onto e932cd258, which changes internal/library and adds one GUI
  test only. At the pushed head: go vet of internal/agent and
  internal/library, and go test of internal/agent, agentenv and
  appdir, all ok.
- GUI: the 71 files this change reaches, in chromium and webkit, every
  language they cover: agent-*, agents-*, i18n-*, icon-*, gui-de,
  gui-ja, gui-zh-tw, about-notices, deprecation-notice, header-relang,
  market-icon-corners. 1145 of 1146 pass. The one red is i18n-keys'
  "a plugin's words are its own" for plugins' "Use the library's",
  "No session ID" and "View routing", the same on main and filed
  (#5332, #5426, #5482). The whole GUI suite was started too and
  stopped at 369 ok, 0 failed: at ~5h on mote it runs after this push.

Real OpenMausBot: 0.1.145's arm64 app was run on mote, its own server
(ELECTRON_RUN_AS_NODE, Resources/server/index.js) with HOME and
OMB_DATA_DIR in a sandbox, on a free port, against a config.json
magpie's Set wrote. /api/instances listed 28 engines, among them
`magpie`: access custom, claudeEndpoint at http://127.0.0.1:3425, and
models relay/glm-4.6 and relay/gpt-5.5 in its picker, with the first as
default. It read "unavailable: `claude` CLI not found" only because the
sandbox PATH had no claude. The file was left as magpie wrote it.

Broken by hand:
- The fleet not written: TestOpenMausBotEngine red.
- The model-id filter taken out: TestOpenMausBotEngine and
  TestOpenMausBotKeepsTheUsers red ("relay/glm 4.6 (beta)"). Green
  before a bad id was added to the fixture, so one was added.

Not tried:
- A bot turn through Claude Code to a gateway. No claude CLI or
  account on mote.
- The desktop app's window, Linux and Windows builds.
- An OpenMausBot running while magpie writes. The refusal is
  unit-tested only.
2026-11-07 13:13:36 +08:00
yetone 49f207c784 agents: DS Bot, wired in the DSH home it runs on
DS Bot (github.com/Fei2411/DS-Bot, Apache-2.0, dsbot.app) is a DSH plugin
and an Electron app built on it. The app ships its own DSH (0.2.2-rc.1 in
0.3.0) and runs it with DSH_HOME at a data folder of its own, booting the
profile ds-bot, and never reads ~/.dsh: magpie's dsh row didn't reach it.

It is a row of its own now, ds-bot (dsbot.go), wired by dsh's code on its
folder (dshOn, split out of dshAt): magpie's routes and start in
profiles/ds-bot/cordis.patch.yml, the key in that folder's .env and
.credentials.yaml. The folder is $DS_BOT_HOME, else locations.json's
dataDir in the app's userData ($DS_BOT_SHELL_DATA, else <config>/DS Bot,
or the legacy DeepSeek Bot), else ~/.ds-bot, as the app's first-run.mjs and
legacy.mjs choose it. A locations.json that can't be read or names no
folder is unknown: nothing is read or written. The routes there list the
models shown for DS Bot on the Agents page (dshListFor), and the serving
round fills a profile the app makes there as it does ~/.dsh's
(dshHomesRounds). Found by DS Bot.app (io.github.fei2411.dsbot) or its
Windows per-user install (guid from its electron-builder.yml). Three
notices, translated into zh, zh-TW, ja and de. DS_BOT_HOME and
DS_BOT_SHELL_DATA are in agentenv's sandbox list.

Run:
- go test ./internal/agent/ ./internal/agentenv/ ./internal/gui/
  ./internal/cli/ ./internal/appdir/ on mote: ok but
  internal/gui TestMainWindowCorners/macOS_26_SDK, red on mote's macOS 27
  whatever the change (#3949).
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./... on mote: ok. gofmt -l: clean.
- node --test i18n-keys, i18n-en-no-cjk, agent-notice-lang (chromium), and
  agent-notice-lang in webkit: all pass but i18n-keys "a plugin's words
  are its own", red on main for three plugin words (#5332, #5426, #5482).
- Real DS Bot 0.3.0 (DS-Bot-0.3.0-mac-arm64.zip) on mote, all in a sandbox
  HOME with DS_BOT_HOME, DS_BOT_SHELL_DATA and DS_BOT_WORKSPACE under it:
  a magpie built from this tree (nogui), MAGPIE_ADDR 127.0.0.1:3572, a
  fake OpenAI upstream on 3571 added as a provider. `magpie ds-bot
  magpie/fake/m1` before the app was ever opened wrote the profile; the
  app's first start kept it (agent-default-model still magpie's) and added
  its own files beside it. Its Chief Bot offered "Magpie: m1 · fake, m2 ·
  fake"; picking m1 and sending "ping" over CDP went through magpie to the
  fake (POST /v1/chat/completions model m1, stream) and "pong from fake"
  showed. `magpie ds-bot default` then took every magpie entry out and the
  .env with it. Only my own pids (app, serve, fake) were stopped.

Broken by hand, each red, then put back:
- dsbot's desktopApps entry out: TestDsBotWired (not detected).
- dshListFor always "dsh": TestDsBotOwnModels.
- dshHomesRounds without DS Bot's home: TestDsBotProfileMadeWhileServing.
- a bad locations.json taken for ~/.ds-bot: TestDsBotDataFolder.
On the old code the tests don't build (no ds-bot row at all).

Not tried: the Windows app (install path and registry guid read from its
electron-builder.yml, not from an installed copy); Linux (its AppImage and
deb aren't looked for; the data folder its first start makes finds it);
a real vendor behind magpie; a default Bot model set in DS Bot (the notice
says it wins, per its models.js). Not done: usage gives DS Bot no
User-Agent of its own (its DSH's requests likely count as dsh's), and the
Sessions page doesn't read its data folder's sessions.

Reported-by: rnhung
2026-11-07 05:43:04 +08:00
yetone 37c1bc043b agent: a group whose members all serve Responses, one best there, is asked on Responses
zyh6036 on X: several subscriptions that all serve the Responses API were
asked on Chat once they were put in a routing group. Pi, OmO, omp, StepCode,
droid, dsh, Hermes, Grok CLI and the live agents ask each model on the one
API catalog.Model.APIs names, and a group had Responses only when every
member's Native was Responses (allResponses, #1594). A relay that serves
Chat and Responses, best on Chat (no Base URL API given, not OpenAI's own
host), counts as Chat there, so one such member put the whole group on
Chat, and the gateway then translated Chat to Responses for the ChatGPT,
Copilot GPT or Responses-relay members. Found groups (auto-<slug>) hit this
without the user doing anything: a new relay that also lists gpt-5.5 moved
auto/gpt-5.5 from openai-responses to Chat (pi_api_test shows it).

provider.GroupAPI now gives Responses when one member is best on Responses
and every other takes a Responses request as it is (Responses among the
APIs it relays), or translates every request anyway (a Claude Code
subscription). So no member is translated that Chat would have relayed,
and the ones best on Responses are relayed, not translated from Chat. The
gateway already relays a /v1/responses request to each member that serves
it (usable), so nothing changes there.

Mixed groups: a member that Responses doesn't reach (a Chat-only key, a
Messages-only Claude) keeps the group on Chat, where that member is
relayed; picking Responses there would translate it on every turn. A
Messages-only group stays on Chat as before (#1594's reason: a Claude
member's thinking is known by its own model id, not the group's).

An agent plugin's connect is told a group's native_endpoints now
(provider.GroupEndpoints: the APIs every member relays), where it had
none. /v1/models still leaves them out for a group:
TestRemoteMagpieNativeAPI holds that a remote magpie sends a group's
request on in the client's API for the other side to pick per member.

No setting added: the group's API follows from its members.

Run (mote, through mote-run):
- go test ./... -timeout 45m at 65780f04f on 49c9491b7, under the shared
  lock: every package ok except three reds, all filed and not in this
  change's path: internal/gateway TestBurstTellsNoSpeed/
  responses_from_chat_burst (passes 3 of 3 alone; #2719, commented),
  internal/gui TestMainWindowCorners/macOS_26_SDK (#3949), internal/provider
  TestRenewLoginsKeepsClaudeReading (red alone too; #5481, on main).
- After rebasing on fcc0daa23: go test ./internal/agent ./internal/catalog,
  ./internal/provider -run 'TestGroupAPI|TestNative|Group',
  ./internal/gateway -run 'Group|RemoteMagpie'; go vet ./...,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...; gofmt -l
  empty.
- Broken by hand: GroupAPI put back to "every member best on Responses":
  TestGroupAPI red (one best there plus one serving it too; the same
  second), TestPiModelsAskedOnTheirNativeAPI red (group/subs, and
  auto/gpt-5.5 once a Chat-first relay serves gpt-5.5).
- New: TestGroupAPI (provider), TestGroupOfResponsesServersRelaysOnResponses
  (gateway: the Chat-first member is asked on /responses, relayed).

Not tried: the reporter's own providers (not known: which subscriptions,
which agent); a real Pi or dsh run against a real mixed-API group; the GUI
(unchanged).
2026-11-06 19:07:15 +08:00
yetone 6bc5702cd4 agent: magpie's OpenCode provider sets setCacheKey, so OpenCode sends its session's prompt_cache_key (#5468)
mariamatrix (#5468) and mahiro233 on Discord: magpie writes OpenCode's
magpie provider with @ai-sdk/openai-compatible and only baseURL/apiKey, so
OpenCode sends no prompt_cache_key and an upstream that caches by it misses.
Checked against OpenCode's source and real runs (sandbox HOME on mote, a
recording Chat server):
- 2.2.5: v1/config/migrate.ts maps options.setCacheKey to
  compatibility.supportsPromptCacheKey, and openai-chat.ts sends
  prompt_cache_key only then. Without it: no key; with it:
  "prompt_cache_key":"ses_…" on the turn and the title request. A config
  with magpie's provider under providers, compatibility.supportsPromptCacheKey
  true, sends it too; without, none.
- 1.19.5: setCacheKey true sends camelCase promptCacheKey (the previous
  commit sends it on as prompt_cache_key).
- 2.0.25: ignores the option; the run answers as before, no error.

Now:
- the "opencode" shape's options have setCacheKey: true. Every writer of
  provider.magpie goes through it and openCodeKept: OpenCode, its
  OPENCODE_CONFIG_DIR copies, MiMo Code, DevEco, Air's OpenCode and
  OpenChamber's.
- openCodeNative writes it as OpenCode 2 does: compatibility
  .supportsPromptCacheKey, not a setting.
- a setCacheKey the file has already under provider.magpie.options, or a
  supportsPromptCacheKey under providers.magpie.compatibility, is the
  user's (false too) and stays, through a sync and a pick.
Kilo has no wiring in magpie; no other agent's config has this option.
TestAirProviderWritesKeepCustomFields compared every option as a string;
it now compares a bool as its JSON.

Run on mote: go test ./internal/agent (full package) ok; go test -run
'OpenCode|CacheKey|Air|OpenChamber|Deveco|Mimo|KeepTheir' ./internal/agent
./internal/gateway ok; go vet on darwin, GOOS=linux, GOOS=windows; go
build ./... (darwin, windows); gofmt clean.
Broken by hand, each failing TestOpenCodeSetsCacheKey: no setCacheKey in
the shape ("no setCacheKey"); no keep under provider ("the user's false not
kept"); no keep under providers (same); no move out of settings
("setCacheKey in OpenCode 2's settings").
Not tried: a config written by a running magpie fed to a real OpenCode
(the real runs used configs of the same shape, written by hand); a real
upstream's cache hit rate before and after.

Reported-by: mariamatrix
Reported-by: mahiro233
2026-11-06 15:02:53 +08:00
ggbdpq e7948e2484 agent: a routing group with a Claude member tells Pi its cache keeps five minutes (#5037)
Pi's cacheWarming weighs a model by its promptCache and stops with
"cache lifetime unavailable" without one. magpie declared it only where
piPromptCache saw the entry's own api — anthropic-messages for a Claude,
openai-responses for a GPT — and a routing group has no api of its own
(a Messages-only group stays on Chat, allResponses), so auto/claude-*
went out with none and Pi never warmed the group's cache, while the
cache itself was there: on the Chat path the gateway marks its own
translation to a Claude member ephemeral for five minutes (addedMark).

So the group now derives the field from its members: one asked on
Anthropic's Messages by its own provider, and the entry declares the
five minutes the gateway's own marks keep. long stays out — the gateway
marks an hour only where a session's turns are often far apart, so it
isn't always true — and a subscription's Claude (asked through Claude
Code, which caches on its own) still declares none, as before. An
all-Responses group keeps what it had: its entry's own api answers.

Reviewed and ported: every line read against origin/main 1b0340fdb.
The added branch runs only for a native entry with no api, and only
when GroupFinder knows the id as a group; a Claude subscription member
answers Native "" and adds nothing, so its group stays as before. On
mote (mote-run): with agents.go put back to origin/main,
TestPiGroupPromptCache FAILs with "group/auto: promptCache <nil>, want
{short: 300}"; with the change, ok, and the rest of TestPi* ok. go vet
(darwin, linux, windows, -tags nogui): ok; gofmt -l clean.
The three packages (provider, agent, gateway) with all three ports: ok.
Not tried: a real Pi run warming a group's cache. A group whose
Anthropic-protocol member is not a Claude (a vendor's Messages
endpoint) also declares five minutes; the gateway marks those
requests ephemeral too.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
Generated-by: GLM-5.3-Flash (ZCode)
2026-11-05 18:31:17 +08:00
yetone 4f624241f7 codex: the ChatGPT app left on "hit a snag" after an app-server restart is reopened when idle (#4550)
ysm119 on Discord: each Restart of Codex in magpie left the ChatGPT
desktop app on "ChatGPT 遇到了问题 / 请重试" till it was quit and opened
again. magpie ends the app's own app-server cleanly (code 0); a
signed-in ChatGPT 26.1021 then fails "Hosted AppServerManager identity
is not ready" on the one it starts, logs fatal_error_broadcasted and
shows the page. That is the app's bug; magpie now follows it up.

- provider/codex_app_crash.go: for 60s after every end magpie makes
  (the watcher's step, RestartCodexApp, RestartSwitchedCodexApp) the
  app's logs are read for a whole fatal_error_broadcasted line stamped
  after the end. On one, with no request through magpie since or in
  flight and no Codex turn opened since, the app is quit and opened
  once. Otherwise it is left as it is and logged. Where it can't be
  reopened (Linux, an app that didn't quit) the Agents row says
  "The Codex app hit an error · quit it and open it again" (appSnag)
  until the app-servers seen then are gone or the app is closed.
  Unreadable logs reopen nothing.
- agent/codex_app_crash.go: the logs as the app's file logger writes
  them (macOS ~/Library/Logs/com.openai.codex, Windows
  %LOCALAPPDATA%\Codex\Logs and the Store package's LocalCache, Linux
  $XDG_STATE_HOME/codex/logs; YYYY/MM/DD folders, tail-read, half
  lines dropped). The relaunch is the Agents row's: on macOS
  ChatGPT.app found by its bundle id, quit as ⌘Q does and opened once
  it has ended, never forced; on Windows codexAppReopen.
- GUI line in en, zh, zh-TW, ja, de; docs/subsystems/agent-wiring.md.

Run on mote (macOS) at this head on origin/main 08982805e:
- go vet ./internal/agent ./internal/provider ./internal/gui (darwin
  and GOOS=windows), GOOS=linux go vet ./internal/agent
  ./internal/provider; go build ./...; gofmt -l clean.
- go test ./internal/provider ok; go test -run
  'TestCodexApp|Restart|Reopen' ./internal/agent ok.
- go test ./internal/gui: red only in TestMainWindowCorners (#3949) and
  TestPanelHiddenByWailsMarksPageOutOfSight (#5322), AppKit window tests
  red on mote's macOS 27 and filed before this change.
- win-run and wsl-run: go test -run TestCodexApp ./internal/agent
  ./internal/provider ok (the macOS relaunch test skips on Windows, as
  TestWorkBuddySidecarOutlivesQuitOnMac does, #4115).
- node --test codex-app-snag, codex-app-out, codex-app-back, i18n-keys,
  i18n-en-no-cjk: chromium and webkit, every language, 980 and 440px.
  i18n-keys' "a plugin's words are its own" stays red for "View routing"
  (#5327/#5332, red on main since 73c98ebc2); this change added a word
  there and took it out again.
- Core script budget: under it, not raised.

Broken by hand, each red then restored:
- codexAppCrashStep's call removed: 4 provider tests red.
- the watch not armed in RestartSwitchedCodexApp:
  TestCodexAppRestartsWatchForTheErrorPage red; in RestartCodexApp:
  TestCodexAppRowRestartWatchesForTheErrorPage red.
- the turn and request checks off: TestCodexAppInUseAfterItsErrorPageIsLeft red.
- the snag not set: TestCodexAppSnagSaidTillTheAppRestarts red.
- the stamp's >= since check dropped, or a half-written last line kept:
  TestCodexAppCrashedReadsItsOwnLogs red.
- a wrong Store package path: TestCodexAppCrashedReadsEachSystemsFolder red.

Not tried: a real signed-in ChatGPT app reaching the identity-not-ready
page, and a real quit and reopen of the user's ChatGPT.app (the relaunch
is tested with faked process listing, quit and open in a sandbox HOME).
The log line and folders are read from ChatGPT 26.1021's
file-based-logger and the reporters' logs; a later app that renames
them reopens nothing, as before this change.
2026-11-05 17:24:53 +08:00
yetone dabb5722f8 claude: Claude Code routed through magpie stays signed in where the user put it when that account is spent
oreoft on Discord has two Claude accounts: A, the main one, whose sign-in
carries their claude.ai connectors (MCP), and B, a quota account. A's
allowance was used up. They set A first and signed in, B second, and
"跑着跑着" B came first again and became Claude Code's sign-in, and the
MCP broke. They set it back more than ten times.

Cause: the used-up switch (#208). KeepOnAnAccountWithRoom looks at
Claude Code's sign-in every minute or five; A is spent, so NextLogin
returns B and SwitchWhenSpent rewrites Claude Code's live credential to
B. The GUI's list puts the account in use first (loginsInOrder), so B
"moves to first". Each time the user signed A in again, the next look
moved it back.

Decision: when Claude Code's settings send its requests to magpie's
gateway (ANTHROPIC_BASE_URL is the gateway, whether it signs in with
magpie's key or keeps its claude.ai sign-in), NextLogin never moves its
sign-in off a spent account. The gateway already routes every request
to an account with room (it skips spent ones on its own), so moving the
sign-in served nothing and only took away what the user signed in as.
This keeps the user's choice and needs no setting.

Still switching, unchanged:
- not routed (Claude Code asks Anthropic as its own sign-in): the switch
  is the only thing that keeps it working (#208);
- "Only switch Claude Code's sign-in" (SwitchOnly): the gateway serves
  none of those accounts, so switching is all magpie is asked to do;
- the move back to the first account / the kept account
  (returnsToFirst, KeepLoginAs), which go toward the user's choice;
- `magpie accounts switch claude next` and the GUI's own switch.
- Codex is left as it is: the Codex app stops sending once its own
  account is out, so it needs the sign-in moved.

ClaudeThroughMagpie is a provider hook the agent package sets
(claudeRouted, the same check claudeIn's "routed" uses), like
CodexAppRoute.

Run (all on mote via mote-run):
- new TestClaudeRoutedThroughMagpieKeepsItsSignIn (sandbox HOME: A
  spent, B with room; routed: three looks, no switch, credential still
  A's; SwitchOnly: switches to B; not routed: switches to B) with
  TestClaudeSwitchedWhenSpent, TestClaudeSwitchOnly*, TestKeepLoginAs*,
  TestNextLogin*, TestClaudeSwitch*, TestNextInOrder, TestCodexDrain*:
  ok. New TestClaudeThroughMagpieReadsItsSettings (agent): ok.
- gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; go build; GOOS=linux go build -tags nogui;
  GOOS=windows go build: ok.
Broken by hand: with the NextLogin gate turned off ("if false && ..."),
TestClaudeRoutedThroughMagpieKeepsItsSignIn FAILs at line 80, "Claude
Code routed through magpie was signed in to b@example.com".
Not tried: real Claude accounts and a real Claude Code with claude.ai
connectors; Windows and Linux boxes. Full suite runs after the push.
A sign-in already moved to B stays on B until the user switches back
once.
2026-11-05 06:43:51 +08:00
yetone c03dee7e3e agent: LiveAgent, magpie's models in its model picker (xiaoxiaofei. on Discord)
xiaoxiaofei. asked for LiveAgent (Stack-Cairn/LiveAgent, v2). LiveAgent 2
is a Tauri app that runs its models through K-brain, a Go backend it
starts as `k-brain backend -data-dir <root>`; every provider lives in
<root>/config.json (JSONC, Pi's provider shape). Root: $LIVEAGENT_HOME,
else $K_BRAIN_HOME, else the folder ~/.liveagent/data-dir.json points to,
else ~/.liveagent, on every OS (LiveAgent's data_home.rs and
kbrain_backend.rs, K-brain's internal/config and internal/storage).

Connect adds providers.magpie: type claude_code + api anthropic-messages
(what LiveAgent's own settings write for an Anthropic-compatible
provider), baseUrl the gateway root (K-brain appends /v1 and posts
/messages with X-Api-Key), the key naming LiveAgent, activeModels null,
modelOrder in magpie's order, models sorted by id with display name,
window, output limit and input [text, image]. K-brain decodes with
unknown fields refused, so only its fields are written. A default or
compact model still K-brain's endpoint-less demo model1 becomes magpie's
first; the user's own pick stays. Through a sync the user's name, the
models they turned off, their order, K-brain's metadata and a model's
own displayName stay; a new model is on and last; nothing to change
writes nothing. A file K-brain wouldn't read as providers (not an
object, providers not an object, top-level models, a bare provider) is
left alone. Disconnect takes the entry out, puts picks back to K-brain's
default, gives a file left with no provider K-brain's demo back (its CLI
restores config.json.bak, which could hold magpie's, from a file with
none), and removes a file holding only what magpie made. LiveAgent's
backend holds the settings and writes them whole on any change, so a
change is refused while liveagent or k-brain runs (macOS/Linux; the
notice says to quit it first, in every language). Logo: the app's own
64px icon (src-tauri/icons/64x64.png, MIT) in an SVG.

Run on mote at this tree:
- gofmt -l clean; go vet ./internal/agent ./internal/agentenv for darwin,
  linux (nogui) and windows
- go test -tags nogui ./internal/agent -run 'LiveAgent|GatewayKey|ListsModels'
  ok; ./internal/agentenv ok; ./internal/gui: only TestCoreScriptBudget
  red, which is red on its base too (app.js untouched here; #5139)
- GUI icon-tile, i18n-keys, agent-notice-lang, gui-zh-tw, gui-ja, gui-de:
  Chromium 27/27, WebKit 27/27
Broken by hand on mote, each red: the user's activeModels not kept
(TestLiveAgentProvider "activeModels after sync [], want [...]"); the
demo provider not put back (TestLiveAgentMakesItsFile "emptied file");
the demo default not replaced (TestLiveAgentProvider, TestLiveAgentMakesItsFile).

Real use on mote (sandbox HOME and LIVEAGENT_HOME, this magpie on
127.0.0.1:3562, a fake Anthropic upstream on 3561, LiveAgent 2.0.5's
bundled k-brain from the release dmg):
- k-brain backend's first start wrote config.json as {}; magpie
  liveagent magpie then wrote providers.magpie and the default pick
- `k-brain run "Reply with exactly: pong"` (K-brain's CLI, same config
  and routing code) answered "pong"; the upstream saw POST /v1/messages
  from magpie
- the backend LiveAgent starts listed magpie's model in /v1/models with
  it as the default, and its /v1/text/generate answered "pong" through
  magpie
- with k-brain running, connect/disconnect were refused with the notice;
  after it quit, disconnect removed the file magpie made
Not tried: LiveAgent's window itself (its model picker was not opened;
the backend's API it reads was); LiveAgent on Linux or Windows; a real
vendor reply (fake upstream).
2026-11-04 18:41:13 +08:00
yetone d8b3749ef7 agents: Copilot CLI reaches magpie's models through its providers.json (BYOK)
tony9759 on Discord asked for Copilot CLI to be wired to magpie, since its
docs say it takes a custom model provider URL.

What Copilot does (1.0.105, @github/copilot-darwin-arm64's cli-main.js,
`copilot help providers` / `help environment`; GitHub docs
docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/use-byok-models):
env BYOK (COPILOT_PROVIDER_BASE_URL, _TYPE openai|azure|anthropic, _API_KEY,
_WIRE_API completions|responses) and a providers.json at
$COPILOT_PROVIDERS_CONFIG, else <COPILOT_HOME or ~/.copilot>/providers.json:
{providers:[{name,type,baseUrl,apiKey}], models:[{id,provider,name,
maxPromptTokens,maxOutputTokens,...}]}, picked as <provider>/<id> in
settings.json "model". Neither needs a GitHub sign-in. The multi-provider
file is marked experimental in the SDK types. The version BYOK started in is
not verified (github/gh-aw#25014 says 1.0.19; GitHub's changelog of
2026-04-07 announces it).

magpie writes the persistent file, not the environment: provider "magpie"
(openai chat completions, the gateway's /v1, the agent-named key) and one
models entry per catalog model, then model = magpie/<ref>. Only entries
naming magpie are magpie's; the user's providers, models and other keys stay
through connect, Sync and Disconnect (which also restores the model they were
on); a file that does not parse is never written over. COPILOT_HOME and
COPILOT_PROVIDERS_CONFIG are honoured (the latter added to agentenv.Vars).
Copilot's own models stay in the field's list.

Run at this head (a4fb75bfd's tree on 47b7ba303, mote): go test -timeout 45m
-count=1 ./internal/agent ./internal/agentenv ok; gofmt -l clean; GOOS=linux
and GOOS=windows go vet ./internal/agent ./internal/agentenv ok. Before the
rebase also ./internal/gui (only TestMainWindowCorners, red on origin/main
47b7ba303 too, #3949) and ./internal/library ok. TestModelReadersShareTheList
caught a first draft ranging over magpieModels; it uses sharedModels.
Real e2e: magpie's own Pick wrote the files into a sandbox COPILOT_HOME, the
real copilot 1.0.105 binary (no GitHub account) ran `-p "say hi"` against a
fake OpenAI server and sent POST /v1/chat/completions, model deepseek/pro,
Bearer magpie-copilot. The interactive TUI was also started earlier on a hand-written
providers.json and answered from it.
Broken by hand, each red: user providers dropped on write, Disconnect's
unwrite a no-op, an unparseable file treated as empty, Sync a no-op.

Not tried: a real magpie gateway behind it (the fake stood in), Copilot's
`anthropic`/`responses` wire types, Windows/WSL Copilot, an org with
forceLoginOrgs, tools/streaming against a real vendor model, the GUI suite
(no Agents-row layout change).
2026-11-04 05:13:45 +08:00
JoeyWu-tech d3de7e8f3e agent: a provider of the user's own at magpie's gateway, under OpenCode 2's providers, stays theirs (#3915)
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).
2026-11-03 20:38:11 +08:00
JoeyWu-techandyetone 0ed9891de0 agent: magpie's provider under OpenCode 2's providers is kept current (#3883)
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>
2026-11-03 20:38:11 +08:00
yetone f37742e14d agent: a used-up ChatGPT account magpie can't serve past leaves the Codex app on its sign-in (xiaoq6285)
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.
2026-11-03 15:46:42 +08:00
yetone 5573f79231 agent: an agent's own models say they go direct, and a pick of one asks before 接入 goes off (maxleebeta)
maxleebeta in #feedback: Pi 1.5.0 connected to magpie; picking one of
Pi's own OpenCode Go models (opencode-go/<model>) turned 「接入」 off at
once, with nothing said, while magpie's models kept it on.

The cause: the pick writes defaultProvider opencode-go, so Pi asks
OpenCode Go itself and magpie is no longer in its config, and Wired()
is rightly false. What was missing is that the model said so. Options
from ownProvider (every ownOptions agent: Pi, OpenCode, Crush, Goose,
Cline, Hermes, Morph, OpenChamber, Qoder, StepCode, plugged agents, the
WSL twins) and ompOwnOptions carried no Direct, unlike Claude Code's
and Codex's own models. So the picker neither tagged them "direct, not
via magpie" nor asked before a pick took the agent off magpie. Each
now carries Direct = its vendor's name. The GUI already does the rest
(pathTag, the leave-ask, direct options listed after magpie's).

Tests:
- internal/agent TestOwnModelsSayTheyGoDirect: Pi, OpenCode, Crush and
  omp, signed in to OpenCode Go, each give every opencode-go/ option
  Direct "OpenCode Go"; magpie's options have none. Picking one writes
  defaultProvider opencode-go.
- internal/gui/tests/agent-own-direct.test.cjs: the tags, magpie's
  first, the ask (Cancel keeps 接入 on, nothing written), magpie's other
  model not asked, confirmed → written and off. Run in chromium and
  webkit × en/zh/zh-TW/ja/de × 980/420.

Run at this head (rebased on 2c2d2a5e5, mote):
- gofmt -l clean
- CGO_ENABLED=0 GOOS=linux go vet -tags nogui and GOOS=windows go vet
  of ./internal/agent ./internal/gui: ok
- go test ./internal/agent (TestOwnModelsSayTheyGoDirect, Codex
  Own/Pi/Omp/Crush/OpenCode runs): ok
- GUI agent-own-direct, agent-leave-magpie, agent-own-path,
  agent-own-providers, claude-default-off, pi-default-note: 56/56
  pass, both engines

Before the rebase (base 4cd01c964), go test of ./internal/agent and its
importers (backup, cli, davsync, gui, library, profile, stats, tui,
uninstall): all ok except internal/gui's
TestMainWindowCorners/macOS_26_SDK, which is #3949 (red on mote's
macOS 27). This change doesn't touch it.

Broken by hand:
- Without Direct in agents.go/omp.go, the Go test goes red for all
  four agents.
- With `direct` stripped from the GUI fixture, the GUI test goes red.

Not tried: a real Pi 1.5.0 signed in to OpenCode Go.
2026-11-03 10:08:44 +08:00
yetone 5f0a84a003 agent: Air in JetBrains IDEs gets magpie's Magpie agent in ~/.jetbrains/acp.json (Jumy on Discord)
Jumy asked for the "air-plugin" new in IntelliJ IDEA 2026.3 (Settings ›
AI › Air). magpie's air agent wrote the Air app's acp.json, in
~/Library/Application Support/JetBrains/Air, which the IDE plugin never
reads: the plugin (com.intellij.air, air-plugin-262.8665.521-mac-arm64
from JetBrains Marketplace) loads its custom ACP agents in
AcpConfigurationLoader (intellij.air.backend.acp.runtime) from
user.home/.jetbrains/acp.json on every system, the file AI Assistant's
custom agents use too; AgentServerConfig takes command, args, env,
use_idea_mcp and use_custom_mcp. The standalone app (Air-262.1037.14,
Fleet-based) reads acp.json from its own configs folder
(genericAcpConfigPath), so the two are separate files.

Air's own agents have no base URL: JetBrains AI, the agent's own login,
or an Anthropic, OpenAI, Gemini or OpenRouter key under AI › Air ›
Accounts. So the IDE gets the same route as the app: a new air-ide agent
("Air (JetBrains IDEs)", aliases air-plugin, air-in-ides) writes a
Magpie entry (opencode acp, OPENCODE_CONFIG naming magpie-opencode.json
beside acp.json) and nothing else; the user's agents and
default_mcp_settings stay, and disconnecting takes out that entry and
that file. air and air-ide share airAt. air-ide shows for an IDE config
folder of 2026.2 or later (the plugin is bundled from 2026.3), or with
its entry already in acp.json. Notice in en, zh, zh-TW, ja, de; README,
reference and agent-wiring rows.

Run at this head (rebased on ed978e560), on mote:
- go test -tags nogui ./internal/agent ./internal/gui: ok.
  ./internal/cli: TestEveryRouteHasACommandOrIsNamed red, the
  checkin-account route, #4826, not this change.
- go vet darwin, GOOS=linux, GOOS=windows (agent, gui); gofmt -l clean.
- -run Air on Windows (win-run) and Linux (wsl-run): ok.
- GUI i18n-keys, agent-notice-lang, about-notices, agents-last-known in
  chromium and webkit: all pass.
Broken by hand: air-ide on the app's folder fails
TestAirIDEAddsMagpieAgent; a version check of > in place of >= fails
TestAirIDEDetectedByIDEVersion on GoLand2026.2.
Not tried: a real IntelliJ IDEA 2026.3 with the plugin listing Magpie
(the plugin's watcher should pick up acp.json; JetBrains' docs say to
restart the IDE, which the notice says); opencode acp itself was checked
under the app's entry in 5a0559d37, the entry is the same here.
2026-11-02 19:00:29 +08:00
yetone a8d6a861a4 agent: Pi's codemode gets magpie's decision and image models (extensions/magpie.ts)
wangbinyq on Discord (#feedback) asked for magpie's System One and image
models in Pi's config, since Pi's codemode can call classifier and image
models (models.classify, models.generateImages; Pi docs/models.md "Use
classifier models").

Pi's models.json can't hold them: its model entries have no type, so
every one is a chat model (ModelDefinitionSchema, modelFromJson in
provider-composer.ts, Pi 1.4.0 / c9f4c7b9f). A custom provider's
classifier and image models come from an extension alone
(docs/custom-provider.md, "Register mixed-operation models"). So while
models.json has providers.magpie, magpie now writes
extensions/magpie.ts in Pi's agent folder, which Pi loads by itself:

- provider magpie-systemone: provider.OfferedDeciders, labelled as
  /v1/models labels them, on Pi's own typesafe-system-one client
  (builtinProviders' typesafe .classify), which posts the TypeSafe
  System One body to the gateway's /v1/systemone. Text input only.
- provider magpie-images: gateway.ImageModels (new; mediaModels with
  labels, the Settings > Images default first, none while it is off),
  drawn by POST /v1/images/generations with the input's images as data
  URLs, b64_json back as image blocks.

Separate ids because an extension's models replace those models.json
gives the same provider id: registered as "magpie", Pi 1.4.0 listed no
chat models at all ("No models available").

The file is rewritten at each Sync and on a pick, and removed with
providers.magpie (pick of none, Disconnect, a Sync that finds it gone).
A magpie.ts whose first line isn't magpie's mark is the user's and is
never written over or removed. Pi only, not OmO or Prime Agent. On a Pi
older than its classifier models the extension returns without
registering anything. Codemode itself is not turned on: that is the
user's defaultTools.

Run at the pushed head (on mote):
- At e7185daeb plus this change: go build ./..., go vet (darwin, GOOS=linux,
  GOOS=windows) of agent and gateway, gofmt -l clean; go test -timeout 45m
  of agent, backup, cli, davsync, gateway, gui, library, profile, stats,
  tui, uninstall. All ok but three reds that are the same on origin/main
  1747559d0 and filed: cli TestEveryRouteHasACommandOrIsNamed (#4826), gui
  TestMainWindowCorners/macOS_26_SDK (#3949), gateway
  TestCodexPoolSaysTheClientsVersion (full-run only, passes alone, #4807).
- Rebased on 1aca55909: go build ./..., go vet linux/windows of agent and
  gateway, go test ./internal/agent/ ok (181s), gateway -run
  'Image|Media|Draw|Decide|SystemOne' ok.

Real Pi in a sandbox HOME on mote (npm @earendil-works/pi-coding-agent),
against a fake gateway, with the extension magpie generated
(piExtensionFor from the test fixture):
- 1.4.0: `pi -p --tools +codemode`, the script listed
  magpie-systemone/mixed/typesafe/jev and magpie-images/art/gpt-image-2
  (in=text,image); classify answered {approved: bool 0.93}; a drawing
  with an image input came back as image/png. The fake logged
  /v1/systemone {model: mixed/typesafe/jev, noul question} and
  /v1/images/generations {model: art/gpt-image-2, images: [data URL]},
  both with Bearer magpie; the chat model from models.json still ran.
- 0.87.1 and 1.0.0: start and chat with the file in place, no error.

Broken by hand: the user's-own check removed -> LeavesTheUsersOwn red
(file written over, then removed); the Pi-only gate removed ->
PiOnly red; the extension write made a no-op -> ListsDecisionAndImage
Models and FollowsSync red.

Not tried: a real magpie gateway with real decision or image vendors
behind it (the fake answers in TypeSafe's wire shape, as magpie's
/v1/systemone does); classifier image input (left off); a WSL Pi. A
change of decision or image models reaches the file at the agent's next
Sync (a catalog change) or pick; whether a Settings > Images change
alone starts a Sync was not checked.
2026-11-02 15:43:43 +08:00
yetone 611ce90d15 agent: OpenBot, magpie's models in its model picker (jiezhengj)
OpenBot (nightly-labs/openbot, openbot.run, v0.58.0) is a new row on the
Agents page. jiezhengj on Discord asked for it: today they type magpie's
address into OpenBot by hand and add each model one at a time.

OpenBot lists the user's own OpenAI-compatible endpoints from
openbot-custom-providers-v1.json in its userData folder:
~/Library/Application Support/OpenBot, %APPDATA%\OpenBot, or
~/.config/OpenBot. Connecting adds an entry with id "magpie" pointing at
the gateway's /v1 and holding the models picked for OpenBot, with
secret null. OpenBot seals an entry's key in safeStorage, which magpie
doesn't open, so the entry has no key. OpenBot hands it to OpenCode
keyless, and the gateway accepts it as a request from this computer.

What the entry keeps to:
- OpenBot's decoders drop the whole list over one bad entry. So the entry
  has at most 64 models, only ids OpenBot accepts as magpie/<id>, and a
  context window only inside 1,024 to 100,000,000.
- The user's other entries stay. The name, harness and secret they give
  magpie's entry in OpenBot stay too.
- A sync with nothing to change doesn't write.
- A file whose version isn't the number 1, or whose providers isn't a
  list, is one OpenBot refuses itself, so magpie leaves it alone.
- Disconnect takes out magpie's entry, and the file too when only the
  version and an empty list are left.

OpenBot reads the file at start, so while it runs, a notice says to
restart it. The notice is in every language.

OpenBot is detected by its userData folder, OpenBot.app
(app.openbot.desktop), or OpenBot.exe under %LOCALAPPDATA%\Programs or
%ProgramFiles%. Docs updated: agent-wiring.md, reference.md, and both
READMEs.

Run at the pushed head, on mote:
- gofmt -l: clean.
- go vet -tags nogui for internal/agent and internal/gui, and for ./...
  with GOOS=linux and GOOS=windows: ok.
- go test -tags nogui -count=1 -timeout 45m on internal/agent and every
  package that imports it (., backup, cli, davsync, gui, library,
  profile, stats, tui, uninstall, plugins/...): ok.
- GUI: agent-notice-lang, i18n-keys, header-relang and about-notices in
  Chromium and WebKit: 58 of 58 pass.

After rebasing on d20caffae (appdir, i18n.js and gui changed on main), these were run again: gofmt; linux and windows vet of agent, gui and appdir; go test of the same three: ok. The four GUI files plus checkin-now-account: 80 of 80 pass.

Real OpenBot 0.58.0: the arm64 zip, sha512 checked against
latest-mac.yml, notarized by Akudama GmbH. It ran on mote under a
sandbox HOME with --user-data-dir and --use-mock-keychain, on a file
that magpie's own openBotWire wrote.
- OpenBot started without setting the file aside.
- Asked over CDP, window.openbot.customProviders.list() returned magpie's
  entry with all three models and harness opencode.
- Saving another endpoint in OpenBot wrote magpie's entry back unchanged.
- The notice's pgrep pattern matched the running OpenBot.

Broken by hand, each red:
- the 64 cap
- the id filter
- the version check
- keeping the user's name, secret and harness
- writing version 1 into a new file
- the notice's Running check

One break stayed green: dropping openBotWire's own no-change check.
edit.SetJSON already skips a write that changes nothing, so the test
holds at that layer.

Not tried:
- a chat through OpenBot to the gateway. OpenBot's onboarding and its
  OpenCode download were not gone through, so no request reached magpie.
- OpenBot's MCP servers. They live in its SQLite database, which magpie
  doesn't write; magpie's /mcp/magpie/... servers are added by hand.
- Windows. Its install folder is read from electron-builder's defaults,
  not from a real install.
- Linux and the AppImage.
- A request from OpenBot is counted under OpenCode's name, since
  OpenCode sends it.
2026-11-02 05:37:32 +08:00
yetone 7c712847b7 agent: Antigravity's desktop app is a row, wired through its gateway setting (ryougi_hachi on X)
Antigravity (Google's desktop app, 2.15 and later; not Antigravity IDE)
takes a gateway from ~/.antigravity/settings.json: Google's Antigravity
Enterprise Gateway, documented at
docs.cloud.google.com/gemini/enterprise/docs/ai-developer-tools/connect-enterprise-gateway.
magpie writes gateway {enabled, url: magpie's, apiKey: magpie-antigravity,
wireProtocol: openai} and models.defaultModelId, and takes out models.list
(it would narrow the picker). The user's gateway, default model and list
are stashed and put back on disconnect or when a model of their own is
picked; caCertPath and the rest of the file are untouched. Sync keeps what
the user added to magpie's block, and so does a set again (a moved port,
Reconnect). Check speaks when admin_settings.json or AGY_LLM_GATEWAY_URL
wins over the file, and when the block's url or key is no longer magpie's
(wiringOff), so drift and a port move see it. AGY_LLM_GATEWAY_URL joins
agentenv.Vars, cleared in every sandbox. Found by its bundle
(com.google.antigravity, 2.15+) or the file its backend writes
(~/.gemini/antigravity/agyhub_summaries_proto.pb); ~/.antigravity alone is
the IDE's and agy's too. The notices are translated (zh, zh-TW, ja, de).
`magpie antigravity` now names the app; agy stays `magpie agy` /
`antigravity-cli`.

Run (worktree base 647323409, on mote):
- Real app backend in a sandbox HOME: Antigravity.app 2.28.2's
  language_server (hub), wired by this branch's magpie built from the
  worktree (`magpie antigravity magpie/rec/pro`, MAGPIE_ADDR on a port of
  its own, a recording upstream as a custom provider).
  GetCascadeModelConfigData listed rec/pro from magpie's /v1/models; a
  cascade ("Say hi") went app -> magpie -> upstream as
  /v1/chat/completions (stream, 12 tools) and its answer came back into
  the trajectory. `magpie usage` counted both calls to Antigravity.
  `magpie antigravity default` gave back the user's genai gateway, model
  and list byte for byte (JSON-equal).
- Before that the same file was checked with the real agy CLI 1.4.12.
- go vet (darwin, GOOS=linux, GOOS=windows) for internal/agent; gofmt.
- go test -tags nogui -count=1 ./internal/agent ./internal/agentenv
  ./internal/gui ./internal/usage ./internal/cli: all ok at this tree.
  The first run was red in four guard tests (TestFolderVarsAreListed,
  TestDriftUnwiredEveryAgent/antigravity, TestReverseProxyIsStillMagpie,
  TestPortMovesEveryAgent): Check had no wiringOff and the variable
  wasn't listed. Both fixed here.
- GUI (node --test, Chromium + WebKit): i18n-keys, agent-notice-lang,
  about-notices, 46 of 46 ok.

Broken by hand: renamed the gateway's stash key and dropped the
models.list deletion: TestAntigravityGateway, TestAntigravityGatewayFromNothing
and TestAntigravityOwnModelBack each went red; the desktopApps entry
missing made TestAntigravityDetected red; writing magpie's block whole on a set
again made TestAntigravitySync red (the user's customHeaders lost). The new tests are red on the
old code (no such agent).

Not tried: the Electron window itself (the backend was driven over its
RPCs, headless); the app on Windows or Linux (its install paths there
aren't known; the backend's file finds it); whether Google sign-in comes
back on its own after disconnect; the full ./... suite, because another
session's full suite was running on mote.
2026-11-01 16:49:55 +08:00
yetone cdfdb62c69 agent: a model field's list is joined with the catalog once while neither changed
Each agent's model field returned append(its own models,
viaMagpieShared(...)...), a copy of the whole catalog's options for
each field of each agent on every poll: Picks was 94.7 MB of 496 MB
over forty polls of the Agents page with real accounts. withVia keeps
the joined list per agent and prefix while the own models read the same
(sameOption, field by field) and the catalog's list is the very one
kept (same array), and joins it again when either changed. The list is
read only and clipped, as viaMagpieShared's is; every caller of a
field's Options reads it, Picks clones it before it drops anything.
The 52 `return append(own, viaMagpieShared(...)...)` sites call it.
omp's and Reasonix's planner edit the joined list after the append, and
Grok's writes Same into its copy, so they keep their own copies.

TestWithViaKeepsTheJoinedList: the same own models give the same array,
own models changed in a value or only an icon are joined anew, a
provider saved since is listed, and nothing joined is the catalog's own
list. TestSameOptionReadsEveryField sets each field of Option alone and
fails when sameOption doesn't see it. Broken by hand: never answering
from the kept list ("the same own models joined the catalog again"),
and FastFor left out of sameOption ("sameOption doesn't read
Option.FastFor").

Run on mote: both tests alone 3 of 3; internal/agent, internal/tui and
internal/cli ok; internal/gui red only on TestSettingsSaveKeepsWhatItDoesNotSend
(#4514) and TestMainWindowCorners (#3949); gofmt, vet and GOOS=windows
and linux vet clean. Real accounts in a sandbox HOME, forty polls:
Picks 94.7 MB -> 51.2 MB, state 190.8 MB -> 154.0 MB, state and drift
replies byte for byte the same as before. Footprint peak 136 MB.
2026-11-01 07:54:54 +08:00
ggbdpq 2c33db2499 agent: VS Code 1.139's versioned layout hides the launcher's marker
Tony-ooo's retest (magpie 0.1.2322, VS Code 1.144.0 on Windows): the
false positive of #3269 is back — bin\copilot-shim on PATH, no ~\.copilot,
and magpie ls still lists Copilot CLI. The marker check 6f435677c reads
six product.json places around the launcher (its folder and two above,
directly or under resources\app), and all six are absent: VS Code 1.139's
versioned Windows layout (win32VersionedUpdate) keeps the app's payload
in a folder named for the build's commit — the short hash, ten lowercase
hex digits, 2c33b50b16 for 1.144.0 — with resources\app under it and bin
beside it (microsoft/vscode#343045), so product.json is at
<install>\2c33b50b16\resources\app\product.json, one level under the
deepest place the walk reaches.

The walk now also takes a build folder a commit's short hash names: a
child of any of the three folders whose name is ten lowercase hex digits
and that keeps resources\app\product.json there. A folder of the user's
is not named as a commit's short hash is, so the cap keeps its meaning —
nothing wider than the same three folders is read, and a product.json
further up still says nothing of an editor.

vscodeCodeBinary is left alone: it reads product.json to tell WHICH build
a code launcher belongs to, and when it reads none, keeping the PATH
fallback is that function's own documented behavior; #3269's judge only
asks whether an editor keeps the folder at all.

Run:
- TestCopilotLauncherBesideTheBuildsHashFolderIsNotTheCLI (new): red on
  fb29cd30f ("VS Code 1.144's copilot launcher is taken for the Copilot
  CLI"; "the CLI looked for is .../bin/copilot-shim/copilot, the
  launcher"), green now.
- The name guard alone is the mutation: commitHashName made to take
  every name turns the same test's last case red ("a folder beside bin
  that is no build's hash counts as an editor's install").
- TestCopilotLauncherFromAnEditorIsNotTheCLI: green (1.143's layout, a
  Mac's app, bin itself, the CLI where a user's installs put it, npm's
  global under a far product.json, a link on PATH).
- go test -tags nogui ./internal/agent: green but TestMothX, which fails
  the same on the untouched tree (this Mac's PATH has a real mothx).
- gofmt -l internal/agent clean; go vet darwin, GOOS=linux -tags nogui,
  GOOS=windows; go build darwin, GOOS=linux -tags nogui, GOOS=windows.

Not tried: a real Windows 1.144.0 install — this was written on a Mac;
the layout is read from microsoft/vscode#343045 and from Tony-ooo's
paths on disk.

Reviewed and landed as one batch of 12 commits (gua's #4593, #3269,
#3881, #2887, #3289, #2718, #2855, Edward4226's #2718 key-path
sibling, and four review follow-ups). Run for the batch, whose last
commit's tree is 5d58a75f3:
- Full suite before the rebase (base d307aa648, wsl-run magpie-desktop,
  go test -tags nogui -count=1 -timeout 45m ./...): 81 packages ok. Reds,
  all with issues and none in code this batch touches: internal/agent
  TestInstalledVersion, TestGrokInstalled, TestOmpDetectedWithPiDir
  (#4033, #3548, #3141); gateway TestUnroutedHeldReportSaved (#4300);
  gui TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestColdTurnsTaken (#4510); provider
  TestClaudeAccountServesModelsListedSinceItsFetch (#3174). Run alone at
  origin/main 573b21f4b, TestGrokInstalled, TestOmpDetectedWithPiDir
  and TestSettingsSaveKeepsWhatItDoesNotSend are red there too. The
  other four pass there alone.
- After the rebase onto origin/main 573b21f4b, at this tree:
  internal/usage, update, gateway and provider ok. In internal/agent,
  the #4033/#3141 install-detection reds plus TestCopilotFolderFrom-
  AnIDEPluginIsNotTheCLI and TestZedAppPath. Those two are flaky the
  same way at origin/main (-count=10 alone: 4 and 5 of 10 red) and are
  already listed in #4033. The #3269 tests (TestCopilotLauncher*) pass
  5 of 5.
- Rebased onto origin/main ef63ef4a2. The #2855 commit met 0b9727ec9
  (#2974) in responses.go: the streamed item's done now takes both, the
  upstream's own id (thinkUp) and the made-over item; and in
  gateway-routing.md main's paragraph is kept with #2855's clause. That
  matches gua's latest head (range-diff: context only). At tree d7c76c6fa:
  internal/gateway, provider, usage, redact and update ok; vet
  GOOS=linux -tags nogui ./internal/..., darwin and GOOS=windows for
  gateway and provider.
- Rebased last onto origin/main d8f7d089f (5 commits: internal/agent
  and GUI files only). At tree 0d4bfd8c8, the pushed one: internal/agent's
  TestCopilotLauncher*, TestClaude*, TestOwn* and TestVSCode* ok, -count=3;
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI red once there, as it is at
  main (#4033). Vet of internal/agent: darwin, linux and windows.
- gofmt -l clean. On mote: go vet darwin, GOOS=linux -tags nogui and
  GOOS=windows.
- Broken by hand, each turning its guard red: the lift gate
  (TestReadingKeepsARefusalsRest, TestAutoVisionKeepsOffARefusedAccount);
  the named-time condition (TestNamedQuotaTimeReplacesAGuess); the
  filter-chain hop (WholeReply/glm-5.3-flash); Edward's aAt
  (TestKeyAllowanceElapsedResetStartsAgain); and the old
  magpieMadeReasoning, which panics in TestMadeReasoningSaysItsTextOnce/
  no_summary. Every new test of gua's is red at base d307aa648.
Not tried: real OpenAI, DeepSeek, GLM or ChatGPT accounts; a real VS Code
1.144 install on Windows; a GUI run (no GUI files are touched).

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 07:06:19 +08:00
yetone 68ebd1ec4a agent: a provider's options an agent reaches on its own are kept
Goose's model field asked ownOptions each poll, for the picker and again
for Drift, and each provider's models were made into options anew
(catalog.Provider, options, group, its icon): ownOptionsFrom was 21.2 MB
of forty polls with real accounts. For agents without a registry of
their own (native == nil), each provider's options are now kept in
ownBuilt per provider.StampNow (a minute at most) and copied into the
caller's list; Pi's and omp's, which read their own registries, are
built as before (ownProvider is the old loop body).

TestOwnOptionsKept: a catalog of 200 OpenAI models; asking again takes a
fifth or less of the allocations building does, a caller's write doesn't
reach what is kept, and a model the catalog lists since is offered.

Run on mote at c1457f2ee plus this commit and the next one (Goose's own
options kept), together:
- gofmt; go vet darwin, windows, linux: ok
- TestClaudeViaMagpieKept and TestOwnOptionsKept alone 3/3 ok
- go test ./internal/agent -timeout 45m: ok (267.7s)
- real accounts, sandbox HOME, network blocked, 40 polls, both commits
  against c1457f2ee: state and drift answers byte for byte the same;
  footprint peak 134 MB, RSS at end 177 MB
- broken by hand (ownOptionsFrom builds each time): red, "took 211
  allocations, building them 202"
- ownOptionsFrom 21.2 -> 7.0 MB, gooseIn.func10 28.9 -> 16.0 MB; Picks
  134 -> 118 MB with the commit before

Not run: the GUI suite (no GUI file changed), Windows and Linux test runs.

Picked onto ef63ef4a2 (with ef63ef4a2, Codex's subagent models kept, and gateway, redact and GUI commits; none in internal/agent); not run again there.
2026-11-01 06:53:25 +08:00
ggbdpq 1cf66e4b17 agent: a tool asked on Responses says strict: false, its optional parameters stay optional (#3055)
What changed: OpenAI's Responses API takes a function tool whose strict
is left out as a strict-mode one and normalizes its schema, where every
property is required, so a tool's optional parameters came back filled
(#3055, ArakawaHenri). pi-ai (dsh's llm-pi-ai, Pi and its kin) says
strict: false on an ordinary tool only when the model's compat says
supportsStrictMode, which it takes as false where the compat is left
out. magpie now says it: every model of a dsh route whose api stands as
openai-responses carries compat.supportsStrictMode, by the api the route
has now (the one the user picked in dsh's Models page kept), not by its
name, beside the keys they set there (dshKeepCompat); and piModelJSON
says it for a model best served on Responses, which Pi's and StepCode's
models.json carry (Pencil's entries stay on Chat throughout). omp's
models.yml is left alone: omp turns a models.yml away over a field its
schema doesn't name (16.3.5 over a max), so the compat needs an omp
version of its own pinned first. docs/subsystems/agent-wiring.md says
so.

Run: new TestDshTellsAResponsesToolsStrictIsOff and
TestPiTellsAResponsesToolsStrictIsOff fail without the change (the
first with "a model asked on Responses isn't told strict is off:
Compat:<nil>", the second with "resp/gpt-5.5 is asked on Responses and
isn't told strict is off") and pass with it; removing only the dsh case
turns the first red and only it, removing only the piModelJSON compat
line turns the second red and only it. go test ./internal/agent/
(TestMothX fails the same with both files back at the baseline here, so
not from this change), gofmt -l on the changed files (nothing), go vet
./..., GOOS=linux GOARCH=amd64 go vet -tags nogui ./...,
GOOS=windows GOARCH=amd64 go vet ./..., go build . (darwin arm64),
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -tags nogui .,
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -tags nogui .,
GOOS=windows GOARCH=amd64 go build -o /dev/null .

Landed (yetone). Broken by hand on mote: with the dsh case and
piModelJSON's compat line taken out, both new tests are red ("a model
asked on Responses isn't told strict is off: … Compat:<nil>",
"resp/gpt-5.5 is asked on Responses and isn't told strict is off").
Run at the pushed head: go test ./... -timeout 45m on mote with this branch on 41b5c0f19: 83 packages ok. internal/gui is red on TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners (#3949), both red alone at 41b5c0f19 too, and on TestColdTurnsTaken (#4510). internal/update is red on TestRelaunchOpenTriedAgain (#3881). The last two pass alone at 41b5c0f19 and here. Rebased on f856d381a: agent, gateway, plugin, provider and sessions ok, gui red on #4514 and #3949 only, gofmt -l clean, go vet ok for linux (nogui), windows and darwin. Rebased on bb478f0e5: agent and gateway ok, gui the same. The last rebase, onto 573b21f4b, brings in only internal/gui/providers*.go and internal/provider/models.go, which this branch doesn't touch.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 06:21:39 +08:00
yetone 93879515a0 agent: QwenPaw, each of its agents' active_model one of magpie's (pkh1585 on Discord)
pkh1585 asked for QwenPaw (AgentScope, github.com/agentscope-ai/QwenPaw)
on Discord. Read in its source, 2.2.2.post1, as data:

- Its folder is QWENPAW_WORKING_DIR, else ~/.copaw when that exists (the
  old name), else ~/.qwenpaw; WORKING_DIR/.env is loaded without
  overriding the environment. config.json's agents.profiles lists the
  agents, each with a workspace_dir whose agent.json holds active_model
  {provider_id, model}, read again on each message.
- Providers are no plain config: SECRET_DIR (QWENPAW_SECRET_DIR, else
  "<WORKING_DIR>.secret") holds providers/{builtin,custom}/<id>.json,
  read once at start. A plain api_key there is encrypted to "ENC:" at
  start, so that is the place QwenPaw itself keeps keys.

What magpie does now:

- `magpie qwenpaw <model>` and the GUI: a row per QwenPaw agent
  (qwenpaw#<id>, the default one as plain qwenpaw), skipping agents whose
  backend is ACP (another CLI runs those) and agents turned off.
- Connecting writes providers/custom/magpie.json (mode 600, the gateway's
  /v1 and the magpie-qwenpaw key, magpie's models as extra_models with
  their window, output and tool use) and sets that agent's active_model
  to {magpie, <provider>/<model>}. The old active_model is stashed as it
  was and put back verbatim on disconnect, absent and null included.
  The provider file is removed only when no QwenPaw agent still uses it.
- A sync after QwenPaw re-saved the provider (encrypted key, discovered
  models, its own defaults) keeps what QwenPaw wrote and changes only
  what magpie owns, so a second connect leaves the file as it is.
- The notice says QwenPaw reads providers at start-up: restart it once
  after connecting and after magpie's models change. New text in every
  locale.
- appdir: QWENPAW_WORKING_DIR and QWENPAW_SECRET_DIR take ~/ as QwenPaw's
  expanduser does; agentenv clears them in tests.
- README (en, zh), docs/reference.md, agent-wiring.md, the site's agent
  list and start pages (en, zh, ja), icon.

Run:
- internal/agent's QwenPaw tests (Connect, AgentsAreRows, SyncKeeps-
  WhatQwenPawChanged, Check, NotStartedYet, Folders, OwnModelAfter-
  Magpies, SyncAfterQwenPawSaved, NullModelRestored) on mote, and the
  all-agent tests (applied, rewire, lan_kept, proxy_kept, spelled) with
  a QwenPaw fixture.
- Broken by hand, each red: always rewriting the key
  (SyncKeepsWhatQwenPawChanged), removing the provider while another
  agent uses it (AgentsAreRows), no backend filter (AgentsAreRows lists
  qwenpaw#coder), dropping the keep of QwenPaw's own fields
  (SyncAfterQwenPawSaved), IsObject for Exists (NullModelRestored).
- Real QwenPaw 2.2.2.post1 (Python 3.12 via uv) in a sandbox HOME on
  the Linux box (WSL magpie-desktop), magpie on 3741, a fake OpenAI
  upstream on 3742: first start wrote config.json and agent.json;
  `magpie provider add fake …`, `magpie serve`, `magpie qwenpaw
  magpie/fake/echo-1`; after a restart QwenPaw encrypted the key (ENC:)
  and `qwenpaw agents chat` answered "PAWPAW-OK from the fake upstream",
  its log "built agent … model=magpie/fake/echo-1"; the upstream saw
  /v1/chat/completions model echo-1 streamed, magpie's usage.jsonl
  agent qwenpaw status 200. A second connect and `magpie models` left
  the provider file unchanged. `magpie qwenpaw default` took
  active_model back out (the only diff in agent.json) and removed the
  provider; QwenPaw started clean after.
- gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows -tags nogui.
- Full suite on mote (go test -tags nogui -count=1 -timeout 45m ./...)
  at 9554883db on d714c4216: 84 packages ok, internal/gui red on
  TestSettingsSaveKeepsWhatItDoesNotSend only (SearchAll from
  b09349d17, red on main, #4514). Rebased onto 15066f84f (an appdir
  change among the four new commits): appdir, agentenv, agent,
  filememo, gateway ok again, gui the same #4514 red; vet darwin,
  linux and windows of agent, appdir, agentenv ok. Rebased again onto
  dd7442f28 (edit, provider and agent changes): edit, provider, agent,
  appdir, agentenv ok, vet linux and windows of agent ok. Rebased onto
  6a23d9d75 (606743831's registry-following agent variables, which
  QWENPAW_WORKING_DIR and QWENPAW_SECRET_DIR now follow as agentenv
  vars): appdir, edit, agentenv, agent ok, vet linux and windows ok.
  Rebased onto 61b536d78 (provider's model lists): agent, appdir ok.
- GUI on mote, the files this reaches (i18n-keys, gui-de, gui-ja,
  gui-zh-tw, agent-connect, agent-layout, agent-notice-lang, brand,
  builtins, desktop-lang, header-relang, icon-tile, icon-url):
  Chromium 103/104, WebKit 59/60, the one red each gui-ja's ja for
  removing an agent's only account (a7b47d57e, #4580). The whole GUI
  suite wasn't run: mote had three other sessions' whole GUI suites
  running (load ~130) and WSL one more.

Not tried: Windows, the macOS desktop app, QwenPaw in WSL wired from
Windows magpie, the ACP backend, QwenPaw's web console after connecting,
a real legacy ~/.copaw.
2026-11-01 05:00:36 +08:00
yetone dd7442f283 agent: a look at the via-magpie options shares the kept list
viaMagpie handed every caller its own copy of the options list it keeps
per stamp, and a window poll asks for it from most agents' fields and
pickers. In a real-account sandbox (abr.sh, 20 polls of drift, state and
providers on v0.1.2463) those copies were 33.7 MB of slices.Clone, plus
~8 MB more on the way, of the 713 MB the polls allocated.

viaMagpieShared returns the kept list itself, clipped, so an append
makes the caller's own array. The 58 callers that only read it, or
append onto it, now take it; viaMagpie (a copy) stays for the ones that
change it.

TestKeptListSharedWithoutACopy checks that 20 shared looks return the
kept array, and that an append onto a shared look and a write into
get's copy leave the kept list as it was.

Run on mote at this tree:
- gofmt, go vet (darwin, GOOS=windows, GOOS=linux with gateway),
  go build ./...: ok.
- Broken by hand (shared returns slices.Clone): the test is red, "a
  shared look copies the kept list".
- go test -count=1 ./internal/agent: ok (480s).

Not run: internal/gateway and internal/gui packages on this tree.
2026-11-01 04:25:59 +08:00
ggbdpq cdd470ce9f agent: opencode.json lists magpie's models in the order the user set
The models of magpie's provider in opencode.json were a
map[string]any, whose keys encoding/json marshals sorted: the order the
user dragged to on the Agents page reached magpieModels and died at the
last step, the file listing the models A to Z (#4575). A pure
re-ordering wasn't even written — syncJSONInOrder's sameOrder compared
two alphabetical lists and found them alike. The variants under each
model kept their order since #713 (orderedJSON); the models keep theirs
the same way now, and openCodeKept looks a model up in the ordered
block to put a variant of the user's on it.

Every config in OpenCode's shape moves with the one fix: OpenCode,
OpenChamber, Air, MiMo Code and DevEco Code (openCodeLike and the
openCodeKept calls in air.go and openchamber.go). Pi, Crush and Codex
list models in arrays and were never touched.

Run: TestOpenCodeModelsInOrder in internal/agent (written first) fails
on the unmodified code — the fresh block lands alphabetical and a
dragged order is never written — and passes with the fix. The
models-as-map assertions in TestInferredGroupImagesReachAgentCatalogs,
TestMiMoCodeCatalogNarrowedSeparately and
TestGroupModelsCarryTheirFirstMembersPrice read the ordered block now.
go test -tags nogui -count=1 ./internal/agent ok (150s) but for
TestMothX, which fails the same on unmodified main cac655c14 on this
machine (mothx_test.go:154) — pre-existing, not this fix's. gofmt
clean; go vet -tags nogui clean on darwin, linux and windows; go build
-tags nogui ./... ok on the three.

Generated-by: GLM-5.3-Flash (ZCode)

Broken by hand: with the agents.go hunks reverted,
TestOpenCodeModelsInOrder is red (written: [aaa/m1 relay/glm-4.6]).
Not changed: Cline's models.json is built from a map too (cline.go
clineModelsAt and clineKept). Filed as #4594.
2026-11-01 02:45:01 +08:00
yetone 02ff0e908f agent: the Codex app's route opens config.toml to see it can be read, not reads it whole
codexAppRoute runs every 3s for as long as magpie does (the Codex app's
app-server watcher). It read the whole of Codex's config.toml with
os.ReadFile only to learn the file could be read; the keys it uses come
from filememo, which parses the file once per change. Codex keeps every
project's trust level in that file, and the owner's is 1.5 MB, so this
was 1.55 GB of the 33 GB a live magpie allocated in 53 minutes (heap
profile: KeepCodexAppOnItsProvider → codexAppStep → os.ReadFile). It is
now opened and closed: a file that can't be opened is still an unknown
route, a missing one still a known one.

Run on mote:
- TestCodexAppRouteReadsNoWholeConfig (new): a 1.6 MB config, 10 looks
  allocate under 1 MB; a config with mode 0 gives no route.
- Broken by hand: ReadFile put back, red (14.4 MB for 10 looks); the
  unreadable check dropped, red.
- go test -run CodexAppRoute ./internal/agent: ok.
- go test -count=1 -timeout 45m ./internal/agent ok (185.3s), at this tree rebased on 4a7d1c63a; gofmt -l clean; go vet ./internal/agent for darwin, linux and windows ok
2026-11-01 00:32:35 +08:00
yetone 73a12e8bf6 wsl: a distro's agent folder that is a link is opened where it leads (#4502)
On Windows, adding a skill or switching RTK on for an agent in WSL failed
with `mkdir \\wsl.localhost\<distro>\root\.codex: Cannot create a file
when that file already exists` (linusxiong). In the distro ~/.codex is a
link to /mnt/c/Users/<user>/.codex. Through \\wsl.localhost Windows can't
follow a link the distro has: a mkdir of it says it exists, and nothing
below it can be made, written, read or listed. ggbdpq found and explained
the link (thanks); their patch, which takes that EEXIST as "there", wasn't
used: the writes below the link fail next (its test passed because a
symlink here is followed).

The fix, for every agent folder and every writer through \\wsl.localhost:
- The WSL probe asks `readlink -f` in the distro where each agent folder,
  its skills folder and the folders beside them lead (wslLinkPaths ->
  distro.Links; a $HOME that is itself through a link is left alone), and
  which drive each Windows mount is (win:/mnt/c C: -> distro.Drives).
- distro.open opens a path at or below a link where it leads: on a Windows
  drive, the drive's own path (C:\Users\<user>\.codex); elsewhere in the
  distro, through \\wsl.localhost again. native spells it back through
  the link, so the agent is told its own path.
- A link readlink couldn't resolve is never guessed at: distro.open
  errors, and the agent is unreached (Agent.Unreached: its notice says
  why; every field Set and Sync returns it).
- Writers: the agents' own files (place.join/place.open, every
  filepath.Join(at.home, ...) in internal/agent), the library's WSL
  targets (wslOpen/wslOpened; one "wsl" problem per agent and nothing
  written), RTK (rtkAt, rtkInstall checks agent.WSLOpen before its mkdir),
  the Sessions page's WSL reads (sessions.WSLHome.Open) and the Copilot
  CLI sign-in read (provider.CopilotWSLHomes -> CopilotWSLDirs).
- Not changed: magpie's image MCP server opens arbitrary paths an agent
  in WSL gives it the same way; filed as #4578. Links deeper than the
  probed paths (other than <agent dir>/skills) aren't resolved. A distro
  probed by an older magpie has no Links until probed again (each run).

Run:
- Real Windows box (xiaomi-gpu, distro magpie-desktop, sandbox
  /tmp/x4502/home with .codex -> /mnt/c/Users/yeton/runs/x4502-target/.codex,
  .claude -> /tmp/x4502/data/claude, .pi -> a missing folder), a throwaway
  Windows test running the real probe with that HOME: probe said
  link:.codex /mnt/c/..., link:.claude /tmp/x4502/data/claude, link:.pi,
  win:/mnt/c C:, win:/mnt/d D:. The old way, MkdirAll(\\wsl.localhost\
  magpie-desktop\tmp\x4502\home\.codex\skills\pdf) = "Cannot create a file
  when that file already exists" (the report's error). distro.open wrote
  SKILL.md to C:\Users\yeton\runs\x4502-target\.codex\skills\pdf and to
  \\wsl.localhost\magpie-desktop\tmp\x4502\data\claude\skills\pdf, both
  read back with cat in the distro through the links; .pi said "~/.pi in
  WSL magpie-desktop is a link magpie couldn't follow". Sandbox and target
  removed after.
- New tests with a fake distro whose ~/.codex and ~/.claude are links to
  /mnt/c/... that don't exist here, so, as through \\wsl.localhost,
  nothing below them can be made: TestWSLFolderIsALinkToC,
  TestWSLFolderLinkUnresolved, TestRTKWSLFolderIsALink,
  TestRTKWSLFolderLinkUnresolved (library); TestWSLProbeLinks (runs the
  probe script), TestWSLOpenThroughLinks, TestWSLAgentFolderIsALink
  (config and a Claude session read on C:), TestWSLAgentFolderLinkUnresolved
  (agent).
- Broken by hand: the library tests on the base (with a no-op
  FakeWSLDrives) fail with "mkdir .../home/me/.codex: file exists", the
  report's error; with ggbdpq's patch applied they still fail (the skill
  mkdir, and RTK's hook not written).
- mote: go build ./...; go vet of agent, library, sessions, provider for
  darwin, GOOS=windows (and linux for agent, library); gofmt -l clean;
  go test -timeout 45m ./internal/agent ./internal/library
  ./internal/sessions ./internal/provider: all ok.
- Windows (win-run): the same four packages. The new tests pass (the
  RTK ones skip: the fake distro runs sh). 32 tests are red, all already
  red at the base c63c2136b run on the same box, and filed (#4115, #2808:
  Hermes profiles, Codex keychain, Agy, desktop entries, ...); the Hermes
  ones fail alike on base and branch with -count=3.

- Rebased on origin/main 3ecc02b78 (it changed internal/agent): at this
  head on mote, go build ./..., go vet of the four packages for darwin,
  windows and linux, gofmt -l, go test ./internal/agent ./internal/library:
  ok.

Not tried: the full ./... suite; the GUI (no GUI change; the unreached
notice uses the existing Notice); a real Codex/Claude Code run against
the moved files in the distro.
2026-10-31 21:29:22 +08:00
yetone 70d50254cb codex: a change to the model list alone no longer ends the Codex app's app-server
The Codex app crashed and relaunched every few minutes (indekkusu141209
on X, #4550: 08:06, 08:12, 08:26).

Cause. KeepCodexAppOnItsProvider ends the app's app-server whenever
codexAppRoute changes. Since ca8a6f346 (lucis0116 on X) the route held a
hash of the bytes in the catalog that model_catalog_json names. The
ChatGPT app takes an ended app-server as a crash. Those bytes change far
more often than where requests go:

- Each model's default_reasoning_level follows config.toml's
  model_reasoning_effort (codexcat.ModelDefault, Creat.wu on Discord).
- The Codex app writes that key on every effort pick, and on a switch to
  a model with other levels. So does magpie's settle() when a pick moves
  the effort.
- The next SyncCatalog, set off by things like a plugin token refresh or
  a providers.json save, rewrote the catalog. 3s later the route had
  changed, and the app-server was ended once idle.

The route doc's own promise, "nothing the Codex app writes itself is in
route", was broken through the catalog.

The repro was in a sandbox HOME, not the live ~/.codex. A throwaway
gateway test diffed CodexDesktopCatalog's bytes:
- Two passes with nothing changed: same bytes.
- A model pick: same bytes.
- models_cache.json refetched with a new fetched_at/etag: same bytes.
- model_reasoning_effort low -> high: different bytes.
The new agent tests below show the same for magpie-models.json, and the
old route moved with it.

Change. The route is where requests go, and only that:
model_provider, openai_base_url, magpie's base_url and
requires_openai_auth, and AppOut. model_catalog_json and the catalog's
content are out, and codexCatalogTag (codex_app_route.go) is gone. A
list-only change (a provider renamed, a model added, an effort picked)
restarts nothing. The app reads the new list at its next launch. The
Agents row already shows a Codex app on an older list, with its Restart
(StaleCopies). Its digest compares slugs and visibility, so an effort
pick doesn't flag it. No new UI.

The effort in the catalog is kept. It is the Creat.wu fix, and with the
restart decoupled, a rewrite of a file the app reads only at start costs
nothing.

Trade-off: a provider renamed or a model added in magpie shows in a
running Codex app only after it is reopened, or after the Agents row's
Restart. Before this commit that happened on its own, which was
lucis0116's ask.

Siblings, all read:
- RestartCodexApp (Agents row), RestartSwitchedCodexApp (switch notice,
  46aa7e6b8) and RestartCodexAppWhenIdle (uninstall) are user-started or
  a real route change. None reads the catalog. Unchanged.
- KeepCodexDaemonCurrent restarts the CLI's managed daemon only with no
  codex session on it, on the slug digest. That is not the desktop app.
  Unchanged.
- No other agent hashes its catalog into a restart.
- zhangjian94cn's fix/4243-codex-lifecycle-boundary takes away all of
  magpie's restarts. That goes further than this commit, and no code was
  taken from it. #4243 (aresxu8866-hue) asked for the catalog to count
  only when it is magpie's, which this commit supersedes.

Tests:
- TestCodexEffortPickKeepsTheAppRunning (new): the reporter's case. An
  effort saved as the app saves it, then SyncCatalog. The catalog
  changes and the route does not.
- TestCodexAppRouteIgnoresARename replaces
  TestCodexAppRouteFollowsTheCatalog, whose guarantee is now reversed.
- Broken by hand: both new tests run on the old codexAppRoute are red
  ("an effort picked in the Codex app changed its route", "a provider
  renamed changed the Codex app's route"). Green with the change.

Run at this head (5b0bb1349's tree, rebased on e90a635a9), on mote:
- go test -tags nogui -count=1 -timeout 45m ./internal/agent
  ./internal/provider: ok, ok. The same before the rebase.
- gofmt -l .: nothing.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
  go vet ./..., go build ./...: ok. That run was before the rebase; vet
  on agent and provider was run again after it.

Not run: the full go test ./... suite. Another session's full suite held
mote, and the owner's rule is to ship without holding for it; it follows
after the push. Not tried: a real ChatGPT/Codex desktop app. Nothing on
the ChatGPT side was changed or measured (the MCP handshake ggbdpq
traced). docs/subsystems/agent-wiring.md was updated.
2026-10-31 19:39:38 +08:00
yetoneandggbdpq 6f435677c3 agent: VS Code's bundled copilot launcher is not the Copilot CLI (#3269)
Tony-ooo's Windows (magpie 0.1.1320): VS Code 1.143 ships a copilot
launcher of its own in <install>\bin\copilot-shim and puts it on the
user's PATH, while the CLI was never installed and ~\.copilot doesn't
exist. magpie ls and magpie agents still said Copilot CLI was installed,
and it showed up as a Library target; renaming the shim folder away made
the row go.

Detected's last resort took any command of the agent's Bin name that
binAt found, and cliBin (what CLI magpie offers to update) took the same
launcher. An Agent may now turn away a command found for its Bin
(binNot, binsOwn). Copilot CLI turns away one an editor keeps, told by
the product.json beside the editor's program (editorLauncher, as
vscodeCodeBinary tells an install). Ported from ggbdpq's patch on the
issue.

Changed from the patch:
- editorLauncher resolves a symlink first and looks in bin's own folder
  and the two above it only. The patch walked up to the root, so a
  product.json in any folder above (a home, a checkout of an editor's
  source) turned away a real CLI under it.
- BinPath and cliHeld (gone.go) go through binsOwn too. BinPath returned
  the shim, and cliHeld counted it as the CLI holding ~/.copilot.
- The windows-tagged test is dropped: it wrote into a folder of the real
  registry PATH and passed without the fix.

Run at the pushed head (parent 3e5aa1151):
- mote: gofmt -l clean; go vet ./internal/agent for darwin, linux and
  windows; go test ./internal/agent -count=1 -timeout 45m: ok (371.2s)
- Windows box (win-run, Go 1.26.8): TestCopilotLauncherFromAnEditorIsNotTheCLI
  passes (the symlink row is skipped there), run at this change on
  a808c31a7. The whole internal/agent package there has the same 14
  reds with and without this change: TestCopilotFolderFromAnIDEPluginIsNotTheCLI and the others
  are in #1827, #1388 and #4115 (TestT3CodeCodexInstance added there).

Broken by hand:
- the patch's unbounded walk without EvalSymlinks: the "product.json
  four levels up" and "a link to the shim" rows go red.
- binNot: nil: 6 rows go red (detected, cliBin, BinPath for the shim in
  each layout).

Not tried: VS Code 1.143 itself on the Windows box, or the reporter's
magpie ls. If the shim comes first on PATH and a real CLI later, Detected
still says not installed; cliBin falls back to proc.FindTool, Detected
doesn't.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-31 10:07:24 +08:00
yetone fa5e86cf2b agents: Kimi Code and Kimi Code Desktop requests show their own name and icon, not the raw id and the cube (jiabubu)
jiabubu on Discord (magpie 0.1.2245, Windows, Kimi Code 2.4.1, Kimi Code
Desktop 1.2.1.0): the Routing page's request list drew Kimi Code's
requests as the grey cube and "kimi-code-cli", and Kimi Code Desktop's as
the cube and "kimi-code-desktop".

The request list, Usage and Sessions already take a client's name and
icon from one table, /api/state's clients (agent.Clients). The drift was
in usage.AgentOf: Kimi Code 2.x sends "kimi-code-cli/…", which matched
neither the kimi agent's "kimicli" prefix nor its "kimi-code" alias, and
Kimi Code Desktop ("kimi-code-desktop/…", its bundle's clientName) had
no entry at all, so both kept their raw product names.

- kimi's UA list takes kimi-code-cli.
- Kimi Code Desktop is a client of its own (agents.go's others). It runs
  Kimi Code's engine on ~/.kimi-code, so it is set up through Kimi
  Code's row. Its icon is the app's own: the 128px entry of build/icon.ico
  in KimiCode-1.2.1-win-x64.exe, the installer winget's
  MoonshotAI.KimiCodeDesktop 1.2.1 points to on code.kimi.com (sha256
  75111cb6…c312, as the manifest says). Nothing was drawn by hand.
- app.js's pngIcons names it (comment shortened, app.js 5 bytes smaller,
  budget untouched); app.css's tile rule names it, as icon-tile measures
  it solid to its edges.
- Old records re-resolve through AgentOf, so earlier kimi-code-cli
  requests read as Kimi Code too.

Guard: TestEveryClientHasNameAndIcon checks that every client has a
name and an icon file app.js's icon() really loads (a PNG only if
pngIcons names it), and that the ids the gateway records by more than a
User-Agent (claude-desktop, claude-science, cursor-local, codex, magpie)
and kimi / kimi-code-desktop are all clients. The cube is allowed only
for the six clients with no logo yet (ante, pencil, openpencil, newmax,
kirocrew, raft), filed as #4487. routing-client-icons.test.cjs draws the
request list from a history fixture and checks names, data-icon, and that
the desktop PNG loads.

Run (mote unless said):
- Red on the old code: TestAgentOf (got "kimi-code-cli" want "kimi"),
  TestEveryClientHasNameAndIcon (kimi-code-desktop not among the
  clients); routing-client-icons in Chromium on the old app.js
  (0/2, the desktop row is the cube).
- Broken by hand: pngIcons without the entry makes the guard fail ("a PNG
  app.js's pngIcons doesn't name, so it is drawn as the cube").
- go test ./internal/agent ./internal/usage ./internal/usageapi: ok.
  ./internal/gui: ok except the ten real-window AppKit tests killed at
  their deadline on mote (#4125, #2645). ok with those skipped, after
  the rebase.
- go vet (darwin), GOOS=linux -tags nogui and GOOS=windows vet of
  internal/agent and internal/gui: ok. gofmt -l: nothing.
- routing-client-icons: Chromium 2/2 on mote, WebKit 2/2 on Linux
  (wsl-run; WebKit launch hangs on mote, #4125).
- routing-*, i18n-keys, icon-tile, mono-icon-redraw and
  models-add-and-icons in Chromium on mote and WebKit on Linux: i18n-keys
  green. icon-tile caught the missing tile entry (fixed here). The other
  Routing reds are still being compared against a fresh origin/main copy
  in both engines (running at push time). Any that turns out to be ours
  gets a follow-up commit.

Not tried: a real Kimi Code 2.4.1 or Kimi Code Desktop 1.2.1 against
magpie (the UA strings come from their bundles: appName kimi-code-cli,
clientName kimi-code-desktop). Only the Windows installer's icon was
read; the macOS app's wasn't compared. Full Go suite to follow the tag.
2026-10-31 04:12:17 +08:00
yetone d99e213f5b codex: an account switch restarts nothing while Codex's provider takes no ChatGPT account
danzi002 on Discord: with requires_openai_auth = false on Codex's provider,
switching the Codex account in magpie still restarted the Codex app's
app-server and said the app and daemon were left on the old account.

Codex's provider with no requires_openai_auth = true goes by no ChatGPT
account: codex-rs ModelProviderInfo::account_state answers no account, and
resolve_provider_auth sends the table's key, never auth.json. So which
account auth.json holds is nothing a running Codex uses.

- provider.CodexNoAccount (set to agent.codexNoAccount): the config's top
  model_provider is not openai, has a [model_providers] table, and the table
  doesn't say requires_openai_auth = true. A profile, the built-in provider,
  no table or an unreadable config count as false (may use the account).
- codexAppStep forgets a switch (and a spent switch) while it holds, so the
  app-server is left running; a route change still restarts it.
- CodexAppStale / CodexDaemonStale say nothing, and `magpie accounts`'
  switch line says nothing needs restarting.
- Kept: route-change restarts (model_provider, openai_base_url,
  model_catalog_json, base_url, catalog hash: read only as the app-server
  starts) and the daemon's model-list restarts; and switch restarts when
  magpie writes requires_openai_auth = true (ChatGPT sign-in with room).

Run (mote-run; full suite at this change on e0ad48641):
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., go build for darwin/linux(nogui)/windows: ok.
- go test -tags nogui -timeout 45m ./...: 81 packages ok, no FAIL.
- New tests: TestCodexNoAccountSwitchRestartsNothing (provider),
  TestCodexNoAccountFollowsRequiresOpenAIAuth and
  TestCodexNoAccountOfEachConfig (agent).
- Broken by hand: codexNoAccount returning false in provider made
  TestCodexNoAccountSwitchRestartsNothing red (ended the app-servers);
  agent's codexNoAccount returning false made both agent tests red.
- Real codex-cli 0.165.0 in a sandbox CODEX_HOME with a provider table at
  requires_openai_auth = false: app-server account/read and getAuthStatus
  answered no account before and after auth.json was switched from a@x to
  b@x, and `codex exec` against a loopback capture server sent
  `Authorization: Bearer <the table's key>` with no chatgpt-account-id for
  both accounts.

After rebasing onto origin/main (2 commits: gateway desktop probe,
usage purposes): go vet ./... and go test of internal/agent, provider,
cli, usage and gateway at the pushed head: ok.

Not tried: the real Codex desktop app (macOS or the Windows MSIX) through
a switch; a daemon with live sessions through a switch; the GUI suite
(no GUI asset changed; the switch notice reads CodexAppStale).
2026-10-30 21:01:09 +08:00
yetone 2f5a3f1c0b agent: Pi's models.json keeps a Gemini model on Chat, as Raft runs Pi's SDK on it with a fetch of its own (yunfei9958 on X)
Since 7eb7fa540 (#3282, v0.1.2042) a model served on Gemini's API,
an Antigravity sign-in's gemini-3.8-flash among them, was written into
Pi's models.json as api "google-generative-ai" at the gateway's /v1beta.
Raft (slock, @botiverse/raft-daemon 1.0.17) runs Pi's SDK, pi-ai 0.83.0,
on Pi's own agent folder (PI_CODING_AGENT_DIR, else ~/.pi/agent:
ModelRuntime.create's modelsPath) and gives every request its own fetch
(installProviderHttpClient). pi-ai's Google adapter throws before
sending when a fetch is given ("Custom fetch is not supported by the
Google Generative AI adapter", api/google-generative-ai.js; the same in
pi-ai 1.4.0), so every Gemini model failed in Raft.

Per-request fetch is a feature of Pi's SDK, so the file Pi's folder holds
can't count on google-generative-ai. piAsked now drops the Gemini API for
"pi" as it did for StepCode, whose rule moves there from stepcodeProvider:
the model stays on the provider's openai-completions, which the gateway
translates, as before v0.1.2042. piOffered reads the same entry, so Pi
offers the levels Chat has. OmO's and Prime Agent's folders are their own
and keep google-generative-ai. A sync rewrites magpie's model list, so
files written since v0.1.2042 are corrected without the user editing them.

Run (mote, at this tree on origin/main 8f0d21a00):
- go test -tags nogui ./internal/agent -run
  'TestPiGoogle|TestPiFolder|TestPrimeAgent|TestStepcode|TestStepCode|TestAside'
  -count=1: ok.
- Broken by hand (piAsked back to StepCode alone):
  TestPiGooglePluginModels/pi and TestPiFolderKeepsGeminiOnChatForRaft red.
- Raft's pi-ai 0.83.0 from npm, a request with a fetch of its own (as
  Raft's daemon gives) against a local fake gateway: the old entry
  (google-generative-ai, /v1beta) ends "Custom fetch is not supported by
  the Google Generative AI adapter", the reporter's error; the new one
  (openai-completions, /v1) reaches /v1/chat/completions and gets the
  reply.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build, GOOS=linux go build -tags nogui,
  GOOS=windows go build: ok.
- Full suite (go test -tags nogui ./... -timeout 45m): started on mote
  at this tree; pushed before it ends, per the owner's ship-at-once rule.
  Its result goes on the commit's thread when it ends.

Not tried: the real Raft app (it needs a slock account), and a real
Antigravity account through it. Aside also runs Pi's SDK, on a folder
of its own; its source isn't public, so whether it passes a fetch is
not known, and it keeps google-generative-ai.
2026-10-30 17:30:23 +08:00
yetone 0911a65e7d agent: a catalog sync leaves a magpie provider the user wrote alone while the agent isn't connected
yyddbds on Discord: in Xiaomi MiMo they added a custom provider pointing
at magpie and picked a few models by hand. MiMo's switch on the Agents
page was off, yet after an update the provider held every one of
magpie's models. SyncCatalog runs at each start and update and on every
catalog change, and MiMo Code's Sync (openCodeLike) brought any
provider.magpie block up to the catalog whether magpie wrote it or not.
magpie's default went over a list the user set.

An Agent whose Sync does nothing but keep a block of magpie's name up
to the catalog is now ListOnly, and SyncCatalog runs it only while the
agent is Wired, which is what the Agents page's switch shows. The same
sync was in every sibling, so ListOnly is on all of them: openCodeLike
(OpenCode, MiMo Code and their WSL forms), piLikeKeyed (Pi and forks),
Goose, Crush, Air, AtomCode, Command Code, Droid, Fx, jcode, Kimi,
MiniMax, Mothx, omp, OpenChamber, OpenClaw, OpenPencil, Penguin, Qwen
Code and T3 Code. Left out on purpose: Codex, Claude, Grok and Hermes,
whose Syncs also repair while not connected (Hermes keeps its bots'
magpie provider current) and have their own gates.

Trade-off: a list magpie wrote while connected doesn't follow the
catalog while the agent runs a model of its own (switch off); it does
again once a model of magpie's is picked. Users whose list was already
written over: magpie keeps no copy of the old list, so it stays full;
from this release on it is left alone, and they trim it once by hand
(or connect the agent in magpie and use its model list's Pick).

Tests: TestCatalogSyncLeavesAHandWrittenMagpieBlock (MiMo, Pi and Crush
with a hand-written magpie block stay byte for byte; connected, MiMo's
list follows the catalog; disconnected and written by hand again, left
alone; a magpie model picked in MiMo, followed again).
TestListOnlyAgentsReadConnected: every ListOnly agent magpie connects
reads as Wired (n >= 15), so none of them loses catalog updates.
Fixtures of TestSyncCatalogRewritesAgentLists,
TestModelNameAndLevelsReachAgentFiles, TestSuffixModesReachAgentFiles
and TestPiKeepsTheirKeysInMagpiesProvider, and internal/cli's
TestSaveAnswersBeforeTheAgentsSync (its Pi settings were {}), now have
Pi connected (settings.json defaultProvider magpie), as a block magpie
wrote implies.
docs/subsystems/agent-wiring.md says the rule.

Run (mote, sandbox HOME via the tests' syncHome/codexHome):
- old code + the new test: red (MiMo, Pi, Crush written over; after
  Disconnect written over).
- broken by hand: ListOnly dropped from openCodeLike: red on MiMo
  (lines 52, 82); the Wired gate in SyncCatalog replaced with true: red
  on all three.
- go test -tags nogui -count=1 ./internal/agent: ok.
- gofmt -l clean; go vet ./... for darwin, GOOS=linux and GOOS=windows:
  ok.
- full suite, go test -tags nogui -count=1 -timeout 45m ./... at base
  3bebc3839 (logs kept in the worktree): every package ok but
  internal/cli (TestSaveAnswersBeforeTheAgentsSync, mine, fixture fixed
  above, then ok alone) and internal/gateway: TestAntigravityTurned*,
  TestAntigravityTurnsCodexsGPT5ThreadAwayOnce and
  TestCodexSpentGrokFailingIsTold, red the same on a fresh origin/main
  b26fa0903 copy, filed as #4362.
- rebased on e8d42c02d: vet (darwin, linux, windows) of internal/agent and
  internal/cli, and go test of internal/agent, internal/cli,
  internal/library and internal/gui: all ok. Pushed on 764a032f6,
  whose three commits since touch gateway, usage, provider and chat only.

Not tried: the real Xiaomi MiMo desktop app (the fixture is the OpenCode
shape MiMo Code writes; whether the reporter's provider id is literally
"magpie" is unconfirmed: a provider of another id was never touched).
Lists already written over are not restored.
2026-10-30 14:25:38 +08:00
yetone cc81ad4ea1 codex: a Windows Codex app that starts no app-server after a switch is reopened (蛋仔 on Discord)
After magpie switched Codex's account, the Windows Codex app answered
every send with "Codex app-server process is not available" until it
was quit and opened again. The report said the app doesn't reconnect
after a clean exit. That is half right. The app (MSIX OpenAI.Codex
26.1021, an Electron ChatGPT.exe that spawns codex.exe app-server over
stdio) does start another, but only once the old one's stdout reaches
EOF and its exit has fired. On Windows a child of the app-server (an MCP
server, a tool command) inherits that pipe handle. A child left running
keeps the pipe open, so the app never sees the close, starts none, and
its send() throws. Reproduced on the Windows box with the real codex.exe
0.164 app-server plus an MCP server: stdout ended only when the MCP
server did, and at once when the tree was ended.

magpie took "the old pid is gone" as done in each place it restarts the
app-server. None of them checked that a new one came:
- codexAppStep (the switch watcher) now records the pids it ended and
  waits codexAppBackWait (30s) for another app-server. If none comes and
  the app still runs (CodexAppOpen), it quits and opens the app as the
  Agents row's Restart does (CodexAppReopen: restartWin by the
  OpenAI.Codex_2p2nqsd0c76g0!App AUMID, Windows only). Where it can't,
  the row says to (CodexAppStuck).
- RestartCodexApp (macOS Restart), RestartCodexAppWhenIdle (uninstall)
  and the switch notice's Restart (RestartSwitchedCodexApp, 46aa7e6b8)
  wait for a new app-server too, and reopen or say so the same way.
  RestartSwitchedCodexApp's own 20s codexAppBackWait went into the
  shared 30s one.
- recheckLeft no longer clears the "still on the old account" record
  while the app is open with no app-server.
- A turn stuck open when quota ran out mid-task (蛋仔's follow-up) held
  the restart for up to codexTurnWindow (30m), since an open turn in
  Codex's sessions meant "a task runs". A switch off a used-up account
  (SwitchWhenSpent) now marks it spent (codexAppSpentSwitch). After such
  a switch, a turn that has written no session file and sent nothing
  through magpie for codexTurnStuckAfter (2m) counts as stuck, and the
  app-server is restarted past it. Its next request would be refused on
  that account anyway. A tool still running in that turn is ended with
  it. A switch for any other reason waits for the turn as before.
macOS is never reopened unasked (a reopen opens a new window,
yoshi037070, 10-27). WSL needs nothing: WSL Codex has no desktop app, and
the Windows app's app-server runs on the Windows side.

Run (at this head unless said):
- mote: go test -timeout 45m ./... at 4cf444bc4, this change on
  origin/main 807048470. It was rebased on dca3e2d71 after (5 commits,
  none in codex_app*/codex_switch/codex_daemon), and the -run below was
  run again at the pushed head. Result: every package ok except gateway and gui, whose reds aren't this
  change's (it touches neither package). gateway: TestAntigravityTurn*
  x4 and TestCodexSpentGrokFailingIsTold, red the same on origin/main
  46aa7e6b8 (#4362), and TestUnroutedUnknownHoldAnsweredSooner, which
  passes alone 3 of 3 at this head (filed #4377). gui:
  TestMainWindowCorners (#3949).
- mote: provider and agent -run 'CodexApp|CodexDaemon|RestartCodex|
  RestartSwitched|CodexSwitched|CodexSessionsQuiet|Switch' ok; gofmt -l clean; GOOS=windows, linux,
  darwin go vet ./internal/agent ./internal/provider ok.
- win-run, the same -run: everything of mine passes. Two tests are red,
  TestCodexDaemonEnvIsTheTerminals and TestWorkBuddyRestartOnMac, the
  same on origin/main (#4115).
- Broken by hand, each red, then restored: the step's no-app-server
  branch, RestartCodexApp's not-back check, uninstall's reopen,
  recheckLeft's open check (4 provider tests); RestartSwitchedCodexApp
  without the reopen (TestRestartSwitchedCodexApp "reopened 0"); the
  codexWinApp matcher widened to \WindowsApps\OpenAI.
  (TestCodexAppReopenedOnWindows). The stuck-turn bypass taken out
  ("a turn stuck on the used-up account: ended []"), the spent mark not
  set (TestCodexSwitchedWhenUsedUp), and the bypass without its spent
  and quiet checks ("a turn open after a switch not for spend: ended
  [60]").
- Real Codex app on Windows (xiaomi-gpu, OpenAI.Codex 26.1021.3705.0,
  from a throwaway test, not committed, run as a scheduled task in the
  console session):
  - RestartCodexAppWhenIdle ended the real app-server, and the app
    started another within ~0.6s. codexAppBack saw it (left false).
  - codexAppReopen quit ChatGPT.exe 43832 and opened the app by its
    AUMID in 3.7s (main now 70060). A new app-server came 9.6s after.

Not tried:
- The stuck state itself in the real app: an MCP child really holding
  the app-server's stdout inside the Codex app. It was reproduced with
  codex.exe outside the app, and the reopen was run on a working app.
- A signed-in real account switch on Windows.
- The quota-mid-task hang with a real used-up account. Why the app sat
  on the turn wasn't reproduced. A plain usage_limit_reached refusal
  closes the turn (task_complete, as dd9828f2b found), so this covers a
  turn that stays open, whatever holds it.
- Whether a reopen loses an unsent draft.
- The macOS path with a real stuck app (it says to quit and reopen;
  nothing is reopened there).
2026-10-30 13:42:48 +08:00
yetone 7946256933 agents: omp, OpenCode and Crush get each model's price, and a group of mixed prices is priced at its first member (taotao7 on Discord)
taotao7 (#help, msg 1565576524193857678): omp on magpie's group/* models
counted every call at 0. omp's custom provider prices a call by the cost
in models.yml alone (omp 18.9.1: pi-catalog src/models.ts
calculateUsageCost, USD per 1M tokens; models-config-schema-bundle.ts
cost {input, output, cacheRead, cacheWrite}). magpie wrote no cost into
omp's models.yml for any model; an ordinary id still got one from omp's
bundled reference match, a group/* id matched none. And a group whose
members cost differently had no price in magpie's agent list at all
(EntryPricer prices only one-price groups), so Pi had none either.

- provider.AgentPricer: as EntryPricer, but a mixed-price group is priced
  at the member it sends to first (a manual group's pick, else the first
  not switched off); a fast or unpriced first member leaves it unpriced.
  Chosen over "the member it routes to most" because that needs usage
  history and would rewrite agents' files as traffic shifts; the first is
  what an In order / Manual group sends to while it answers. Read at each
  Sync, so it follows the members. The gateway's /v1/models keeps
  EntryPricer.
- omp: models.yml model entries carry cost.
- Siblings: Pi, mothx, alma, penguin, plugged already wrote m.Price and
  now get group prices too. OpenCode got no cost at all: now cost
  {input, output, cache_read, cache_write} (OpenCode 2.0.25). Crush:
  cost_per_1m_in/out/in_cached(write)/out_cached(read) (Crush 0.39.3).
- docs/subsystems/agent-wiring.md says so.

Run (mote): TestGroupModelsCarryTheirFirstMembersPrice ok; full
go test -timeout 45m ./... at load ~150-210 from other work: agent and
provider ok, 77 ok; reds TestTOMLBigFileParsesInLinearTime (#4109) and
the Antigravity turned-away tests + TestCodexSpentGrokFailingIsTold
(#4362), both filed against main. GOOS=linux/windows go vet of agent and
provider ok. Real omp 18.9.1 in a sandbox HOME: `omp models list --json`
reads group/mix with cost {1,2,0.1,1.25}, pricingStatus fixed.
Broken by hand: route.go back on EntryPricer -> red (group/mix cost
nil); omp's Cost line dropped -> red (a/cheap cost nil).
Not tried: a real omp turn through the gateway showing the cost; OpenCode
and Crush showing a session's cost in their UIs (keys read from their
binaries' strings only).
2026-10-30 13:25:55 +08:00
yetoneandskygunner 7eb7fa5407 agent: Pi, OmO and Prime Agent ask a Gemini model on google-generative-ai at the gateway's /v1beta (#3282)
A model served on Google's Gemini API (a custom provider's gemini=, a
Google sign-in's Code Assist, a plugin model declaring @ai-sdk/google)
was written into Pi's models.json with no api, so it inherited the
provider's openai-completions and the gateway translated Chat to Gemini.
magpieModels now gives such a model the Gemini API when no Chat,
Responses or Messages API was chosen for it, and piModelJSON writes it as
api "google-generative-ai" with baseUrl <gateway>/v1beta. A model whose
user picked Chat for it, routing groups and Pencil stay as they were.
Sync rewrites magpie's own model list, so files written before get it.

The patch is skygunner's (279e9bd1 on fix/pi-google-api in their fork).
Changed here:
- StepCode keeps such a model on Chat. Step-Code at 90a57820 registers
  only anthropic-messages, openai-completions and openai-responses
  (packages/providers/src/compat.ts BUILTIN_APIS); its docs list
  google-generative-ai but nothing streams it, so the patch would have
  broken every Gemini model there.
- On google-generative-ai, pi-ai's resolveGoogleThinkingLevel maps a level
  through thinkingLevelMap and throws on anything but minimal, low,
  medium or high, so a level the model names otherwise (xhigh, max) is
  set to null there and Pi doesn't offer it.

Checked against each client's source: pi-ai 1.4.0 and OmO's senpi-ai
2026.10.27-1 set apiVersion "" when baseUrl is given ("baseUrl already
includes version path"); Prime Agent's pa-ai providers/google.rs takes a
model baseUrl in place of host and version, and pa-core models/custom.rs
reads a per-model api and baseUrl.

Run (mote, at this tree rebased on 96a703a59, then again on adc618bbf):
- go test -tags nogui ./internal/agent -count=1 -timeout 45m: ok (385s).
- go test -tags nogui ./internal/gateway -count=1 -timeout 45m: ok (744s,
  load ~20 from other sessions). A first run of both packages together
  exited 1 after agent's ok; its log was deleted from the shared
  scratchpad by another session before the red could be read, so it is
  unnamed. The rerun of gateway alone at the same tree passed.
- Rebased on adc618bbf (#3279's plugin text filter, fake plugin
  changes): internal/agent -timeout 45m ok (252s); internal/gateway
  -run 'TestPlugin|TestCustomGemini' ok (43s).
- Pushed on fa2332976: the three commits since adc618bbf (fc43c69e5,
  750bd1bb6, fa2332976) change gateway code this change doesn't touch;
  not run again on them.
- Red without the fix (origin/main with these tests): TestPiModelsAsked-
  OnTheirNativeAPI (gem/ and hybrid/gemini-3-flash api <nil>),
  TestPiGooglePluginModels for pi, omo, prime-agent, and
  TestPiGoogleThinkingLevelsAreGeminis. TestPluginProvider's new /v1beta
  part passes there too: it guards that the plugin's sign-in and fetch
  still serve the route, which already worked.
- Broken by hand: with the null-out of non-Gemini levels turned off and
  the StepCode exception removed, TestPiGoogleThinkingLevelsAreGeminis
  (xhigh, max kept) and TestPiGooglePluginModels/stepcode go red.
- Real Pi 1.4.0 (@earendil-works/pi-coding-agent) in a sandbox HOME on
  mote: a custom provider gemini=http://127.0.0.1:18761/v1beta (a local
  fake), magpie serve on 127.0.0.1:18762, `magpie pi
  magpie/gemfake/gemini-3-flash`. models.json had the model at
  google-generative-ai, <gw>/v1beta; `pi -p "say hi"` printed the fake's
  reply, its session recorded api google-generative-ai, and the fake got
  /v1beta/models/gemini-3-flash:streamGenerateContent?alt=sse.

Not tried: a real Google account or plugin sign-in, real OmO and Prime
Agent binaries (checked by their source only), Windows and Linux.

Co-authored-by: skygunner <84759+skygunner@users.noreply.github.com>
2026-10-29 18:34:21 +08:00
yetone adc618bbf9 codex: a Codex switched off in magpie still has its held ChatGPT account read, so the Codex app sends magpie's models (sherlock_23333 on X)
sherlock_23333 on X: once the ChatGPT account Codex is signed in to ran
out, the Codex app's Send stayed greyed even on a magpie model, through
restarts and reconnects.

The gate is the Codex app's own (ChatGPT.app 26.1021, composer gM):
Send is blocked while its authMethod is chatgpt and its own /wham/usage
says rate_limit.allowed false with no credits. magpie's one lever is
the takeover (codex.out): magpie becomes Codex's provider without
requires_openai_auth, so the app-server reports no ChatGPT account and
the gate lifts. That runs only when provider.CodexUsedUp says the
account is held, and CodexUsedUp read LoginUsage, which returns nothing
for a provider switched off or removed in magpie (leftAlone). So a user
who turned Codex off in magpie once its allowance ran out never got the
takeover, and one already taken over was put back on the held account.

Now, with Codex left alone, CodexUsedUp reads the active account alone
(codexHoldReading) while Codex takes magpie's models beside its sign-in
or magpie is its provider for the held account (Agent.HoldMatters, via
the new provider.CodexHoldMatters hook). At most once a minute (the
loginReading cache), with the token as Codex keeps it, never renewed or
written (codexTokenAsKept); the Usage page still shows nothing of it.
Codex's prompts and base_instructions are untouched.

Run at f41b63232 + this change, on mote via mote-run:
gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
GOOS=windows go vet ./...; go build ./... all ok.
go test -count=1 -timeout 45m ./internal/provider ./internal/agent: ok
(219s, 340s).
Rebased on 9f25de56c (a Cursor mover min and a GUI test), then at 9f25de56c +
this change: go vet and go test -count=1 -timeout 45m of
./internal/provider ./internal/agent again: ok (178s, 273s).
8c63c5b78 (plugin speech models; no file in common) landed on main
after that run and this is rebased onto it; the two packages were not
run again with it.

Broken by hand: without the leftAlone branch in CodexUsedUp,
TestCodexHoldReadLeftAlone fails ("switched off: CodexUsedUp = false on
a held account"); with the left-alone token read sent back through
codexToken, it fails with the expired sign-in refreshed once.

Not tried: the reporter's own config (whether their Codex was off in
magpie is inferred, not confirmed); the real Codex app against a held
account; internal/gateway's suite (no gateway code changed); Linux and
Windows test runs (vet only).
2026-10-29 18:20:50 +08:00
yetone 9474eaf9cb sessions: Raft's Pi agents' sessions are listed as Raft's, with their prompts, calls and delete
Raft (slock's raft-computer) runs its agents on Pi and keeps each one's
Pi SDK session files in that agent's folder: <slock>/agents/<id>/
.pi-sessions/<ts>_<id>.jsonl, or .builtin-sessions/ for its built-in
runtime. <slock> is $SLOCK_HOME or ~/.slock (%USERPROFILE%\.slock on
Windows, the distro's ~/.slock under WSL). Read from raft-computer
1.0.14's PiDriver (buildPiSessionDir), BuiltInDriver and
resolveSlockHome, and a read-only listing of ~/.slock here.
runtime-sessions/ holds handoff notes, no sessions, and is not read.

- The Sessions page lists them as Raft's (agent "raft", in agent.Clients'
  others), titled and opened with their prompts as Pi's are.
- Their calls count on the Usage page as Raft's; calls through magpie
  stay the gateway's, as Pi's do.
- Raft's Pi uses the user's own ~/.pi/agent, so a request it sends
  through magpie reaches the gateway as Pi's under the same session id.
  sessions.GatewayKeys gives a Raft session both "raft|ID" and "pi|ID",
  so the gateway's copy is not listed twice nor counted twice (Merge,
  stats, NativeIDs, the GUI's Via).
- Delete and restore work as Pi's: the one file goes to the trash, and a
  folder beside it is left (the agent's workspace is not the session's).
  A session written in the last minutes is refused as active.
- No resume command, no carry and no trace export: Raft starts its own
  agents, and nothing outside it can resume one.
- SLOCK_HOME is passed through agentenv like the other agents' homes.

Run (at 958ad9f10 on e61e10535):
- mote (macOS): -run 'Raft|TestPi|TestDirs|TestVars|TestFolderVars' in
  sessions and agentenv: ok, and red for each break below. A full
  go test ./... was started there; at load ~300 from other sessions'
  suites it printed only magpie and internal/access (ok) before mote
  stopped answering (host down), so no full macOS record exists.
- mote (macOS), rebased on 5d24bc6cc: go test -count=1 ./internal/sessions/
  ./internal/agentenv/: ok (sessions 495s, agentenv 1.1s). agent and gui
  were not run in full on macOS.
- mote: GOOS=windows go vet of sessions, agent, agentenv, gui; GOOS=linux
  go vet of sessions, agent, agentenv: ok.
- Windows (win-run): agentenv ok; -run 'Raft|TestPi|TestDirs' in
  sessions ok. The full sessions package hit its 30m timeout after
  TestOneListing's red (#4114) and the Agy reds (#4115, #4177). agent
  and gui reds (Hermes, WorkBuddy, Lody, Qoder/Copilot plugin folders,
  Codex keychain, ClaudeDesktop language, Aside, InstallWithoutNode,
  DesktopExec, AionUi, ImportStatus, UpdateThatWontStart,
  GatewayHeldByAContainer, GatewaySessionHistoryAndCalendar): each run
  again at origin/main c1660481c on Windows and red there too, except
  TestHermesProfilesFollowMagpieModel which passed there alone; it is
  #1388's Hermes model rewrite, which this change does not reach.
- Linux (wsl-run): sessions ok, agentenv ok. agent's TestInstalledVersion,
  TestGrokInstalled, TestCursorFolderFromTheEditorIsNotTheCLI and
  TestOmpDetectedWithPiDir are red at origin/main c1660481c too (#4033,
  #3548). gui does not build there (no gtk4/webkitgtk-6.0 in the distro).

Broken by hand, each red, then restored: Raft's listing removed; the
"pi|ID" key dropped from GatewayKeys; the folder-beside check reverted to
Pi's absence; $SLOCK_HOME ignored; Raft's calls left out of piCallFiles;
NativeIDs without Raft; stats' native keys without "pi|ID".

Not tried: with real Raft. No agent on this machine has run on Pi, so
the fixtures are Pi 1.1.0's own files (testdata/pi-calls, testdata/pi)
placed in Raft's folders. The GUI was not run in a browser: no JS
changed, Raft's name and icon come from agent.Clients. Raft's icon is the
generic one.
2026-10-29 15:29:30 +08:00
yetone 3c6b7d585f agent: OpenClaw is wired up like the other agents
arthur041691 (Discord #help) runs OpenClaw for WhatsApp and asked for it in
Agents. Connecting writes magpie as a custom provider of OpenClaw's own, in
openclaw.json, and makes the picked model agents.defaults.model's primary.

What is written, from OpenClaw's source at 5bab0c14 (npm 2026.10.8, dc2523e):
- the file: OPENCLAW_CONFIG_PATH, else $OPENCLAW_STATE_DIR/openclaw.json,
  else ~/.openclaw-<profile> for a named OPENCLAW_PROFILE, else
  ~/.openclaw; ~ is OPENCLAW_HOME when set (src/config/paths.ts,
  src/config/state-dir.ts, src/cli/profile-utils.ts). OPENCLAW_PROFILE is
  a name, not a path (agentenv.NotPaths); the other three expand a
  leading ~, as resolveUserPath does (appdir.usable).
- models.providers.magpie: baseUrl (the gateway's /v1), apiKey (the
  OpenClaw-named gateway key), api "openai-completions", and every model
  magpie serves with id, name, input, reasoning and contextWindow
  (src/config/zod-schema.core.ts, docs/gateway/config-tools/custom-providers.md).
  A user's own keys on a model entry (headers, maxTokens…) stay on Sync.
- agents.defaults.model keeps its shape (string or {primary, fallbacks});
  agents.defaults.models gets the ref's {} entry as `openclaw models set`
  adds it (src/commands/models/shared.ts), only when that map exists; a
  non-empty modelPolicy.allow gets "magpie/*" when nothing there lets
  magpie's models in (src/agents/model-selection-normalize.ts).
- Model changes are hot-reloaded (docs/gateway/configuration/hot-reload.md);
  a chat that already has a model keeps it (docs/concepts/models.md), so
  the notice says to send /model default there. Translated in every
  language.
- The file is written through temp-and-rename; a new one is 0600 in a
  0700 folder, as OpenClaw makes it (src/config/io.write.ts). A file that
  isn't JSON after comments are blanked (JSON5's bare keys) is left alone
  with an error, never read as empty.
- Disconnect puts back the model there was, removes magpie's provider,
  its {} entries, the allow entry and any object magpie made, and the
  file itself if magpie made it.

Icon: a mask drawn from OpenClaw's ui/public/favicon.svg (MIT).

Run, on mote at this tree:
- go test -tags nogui ./internal/agent -run OpenClaw plus the every-agent
  tests (drift, port move, sync on another machine, reverse proxy, LAN,
  pinned key per writer, notices translated), ./internal/appdir,
  ./internal/agentenv: ok.
- Broken by hand, each red then green again: no stash restore
  (TestOpenClaw, Shapes, AllowList), user keys dropped
  (SyncKeepsTheirs), no allow entry (AllowList), no JSON5 guard
  (JSON5LeftAlone), profile ignored (Paths), OPENCLAW_PROFILE back as a
  path variable (Paths).
- Real OpenClaw 2026.10.8 from npm, Node 24.22.2, sandbox HOME on mote:
  onboard --non-interactive made the file (its bytes are the test
  fixture); magpie's code connected it; `openclaw config validate` ok;
  `openclaw models list` shows magpie/kimi/k2 as default; `openclaw agent
  --local` sent POST /v1/chat/completions with Bearer magpie-openclaw and
  model kimi/k2 to a fake gateway on 3425 and showed its reply; no
  agents/*/models.json override was written; Disconnect gave the file
  back byte for byte and it validates.
- GUI: i18n-keys, agent-notice-lang, icon-tile, about-notices,
  agent-connect (Chromium and WebKit): 53/53.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok.
- Full suite, go test -tags nogui -timeout 45m ./... at fe05f0a72 + this
  change: 76 packages ok; internal/provider red on
  TestClaudeAccountServesModelsListedSinceItsFetch only, green alone
  -count=5: the known #3174 (untouched here).
- Rebased on b2d005bf3 (grok.go, i18n.js changed there): internal/agent,
  appdir, agentenv, gui and the five GUI files above again, all ok.

Not tried: per-agent model overrides (agents.list[].model), a config
split with $include, a chat already pinned to a model, Windows and Linux
OpenClaw installs, a real WhatsApp channel.
2026-10-29 05:06:50 +08:00
yetone 72ca3d593b codex: magpie as Codex's provider keeps the Codex app's ChatGPT account while it has room, so its Work chats and projects stay
Qyburn3 on X: with magpie taking Codex over, the Codex app's "Work"
sessions don't load while the model still answers; turned off, they
come back.

Cause: [model_providers.magpie] had no requires_openai_auth, so Codex's
app-server answers account/read and getAuthStatus with no account and no
token whenever magpie is Codex's provider (magpie API, or the codex.out
takeover). ChatGPT.app 26.1021 then switches to an identity of no
account: onboarding again with no name, ChatGPT mode's projects and
chats ("Work") empty, no avatar, no Chrome control (#1824).

Now putProvider writes requires_openai_auth = true while Codex has a
ChatGPT sign-in with room (openaiAuth: codexChatGPTKnown and not
codexUsedUp), and takes it out otherwise:
- API key alone: left out. With it Codex drops image_gen (captured: 11
  tools without, 10 with), and there is no account to keep.
- No sign-in: left out (the app would ask for a sign-in).
- A sign-in the Codex app holds (codex.out, or magpie API while used
  up): left out, since the app's composer gate (authMethod chatgpt +
  allowed false, #540) would grey Send for magpie's models again. The
  takeover's note now names "its ChatGPT chats and projects" among what
  is off till the reset, beside Keep on ChatGPT.
- An unknown sign-in read leaves the table as it is.
Sync rewrites the key on any table that disagrees (authStale), an older
magpie's included, and the key joins codexAppRoute, so the Codex app's
app-server is restarted onto its account with nothing for the user to
do. The magpie API note no longer says Chrome control needs ChatGPT (en,
zh, zh-TW, ja, de); agent-wiring.md says why.

Real app (mote, ChatGPT.app 26.1021 with its codex 0.164.0-alpha.11,
sandbox CODEX_HOME, copied real ChatGPT auth, auth.json unchanged after):
- native config: the account's projects and recent chats listed.
- magpie table without the key: onboarding, "ChatGPT Work" with no
  projects, no chats. app-server: account null, authMethod null.
- magpie table with requires_openai_auth = true (the keys this commit
  writes): every project and chat back; account/read chatgpt pro,
  getAuthStatus authMethod chatgpt with a token.
- Model requests to a capturing server, with and without the key:
  Bearer is magpie's experimental_bearer_token, no ChatGPT-Account-ID,
  15 tools both ways with a ChatGPT sign-in (image_gen kept).

Tests: TestCodexMagpieProviderKeepsChatGPTAccount (ChatGPT + magpie API,
used up and back; taken over and the reset; an older magpie's table from
live config bytes; API key and no sign-in, fresh and after ChatGPT) and
TestCodexAppRouteFollowsOpenAIAuth. Broken by hand: on the old codex.go
5 of 7 subtests red; without the Sync re-derive 3 red; with the key kept
while used up 2 red; agents.go without the route key, the route test red.

Run (mote-run, at this tree on origin/main 157d575c3; the build and the
agent run again after the rebase onto e5e2aa58e, ok; 5a85a9836 after it touches redact only,
no agent
or GUI file, ok): gofmt -l clean;
go build ./...; go vet linux (-tags nogui) and windows ./..., darwin
./internal/agent; go test -tags nogui -run 'Codex|Agents|Sync|Disconnect|Route'
./internal/agent ok; GUI codex-signin-always, codex-app-out, i18n-keys
and the i18n files, Chromium and WebKit, 96/96.
Not run before the push: the full go test ./... (mote had three other
sessions' full suites at load ~100); it runs after, and any red gets an
issue. Not tried: the used-up case on the real app with the key (the
composer gate is from #540's reading of 26.1013), Windows and Linux
Codex apps.
2026-10-29 01:18:59 +08:00
yetone f25871cddc agent: the Codex app's route is read from one look at Codex's config (#1665)
KeepCodexAppOnItsProvider asks codexAppRoute every 3s for as long as
magpie runs, and it read config.toml's keys one getter at a time, each a
look at the disk: 42 looks in 25s on Windows, where an antivirus works on
each. It now holds what it read (filememo.Hold) for the call, so each
tick looks once, and its keys come from one version of the file.

Measured on xiaomi-gpu (Windows 11), an empty sandbox HOME, magpie web
--gateway, second start, 27s, counting looks with an uncommitted build,
with the warm-up's hold (fcbbb8e47) in both: codexAppRoute's looks 42 to
8, all looks 483 to 448.

Run (mote): gofmt -l internal/agent clean; go vet ./internal/agent for
darwin, windows and linux (-tags nogui) clean; go test -count=1
./internal/agent ./internal/provider ok. Not tested by its own test:
nothing in codexAppRoute lets a test write between its getters.
2026-10-28 13:57:48 +08:00
yetone f6ed2c99bc effort: a vendor's light and extra_high are low and xhigh, in dsh, Pi and the gateway
nianshou5 (Discord) runs Trae's DeepSeek V4.1 Flash through the Our Free
Model plugin (github:mu-zi-lee/magpie-our-free-model). Its variants are
Trae's own names, light, high and extra_high, and dsh offered only
default and high: dshModelLevels (and Pi's piThinkingLevels) matched a
model's efforts to pi-ai's level names only, so light and extra_high
were dropped. The gateway dropped them too: effortOf read "light" as no
effort, and NearestEffort fitted an agent's low or xhigh to the plugin's
high.

catalog.EffortAliases names light as low and extra_high as xhigh
(EffortLevel). NearestEffort places a model's levels by the level they
name and returns the model's own word; the gateway's effortOf reads an
alias as its level. dsh's reasoningEfforts and Pi's thinkingLevelMap map
dsh's low/xhigh to the model's own word (modelEffort), which llm-pi-ai
sends on the wire as written (resolveModelReasoning in dsh-llm-pi-ai
reads each value as "the spelling dispatch sends"). Levels a user kept
are untouched: only the names a model lists are mapped.

Tests: TestDshOffersTraeNamedLevels (agent), TestNearestEffortTakesVendorWords
(catalog), TestPluginThinkingOff's new fake-trae subtests (gateway, a
real plugin host with the fake plugin listing light/high/extra_high).
Broken by hand: modelEffort without the alias, dsh levels [high] (the
report's picker); NearestEffort without EffortLevel, low/xhigh sent as
high; effortOf without the alias, light/extra_high sent as nothing.

Run on mote at this tree (base e4ccf67b1): go build, GOOS=linux and
GOOS=windows go vet -tags nogui ./... ok; go test -tags nogui -timeout 45m
./... : 73 packages ok, three red that are red the same on origin/main
7f32f0ec9 run alone: internal/agent TestWSLColdPlaceOpensNothing (#3924),
internal/tui TestTUIFetchesSubscriptionModels (#3919), internal/provider
synctest crash in TestUnreadLoginsWriteErrorsKeepCredentials (#3632), so
the rest of internal/provider didn't run. No GUI file changed.
Rebased on 7f32f0ec9 (one agent file changed there): go build ./...,
internal/catalog whole and gateway/agent -run Effort|Dsh|Pi|ThinkingOff|Level
ok at this head.

Not tried: a real dsh session against the user's plugin (no Our Free
Model account here); dsh's parsing of a non-pi-ai wire value was read
from its source, not run.
2026-10-28 04:34:45 +08:00
yetone 6d24d4f4ea agent: a hung wsl.exe no longer holds every Windows command 20s
On a Windows box whose wsl.exe hangs (`wsl -l` there never answered),
every magpie command took ~20s, `magpie version` too. A goroutine dump
taken 8s in showed start-up's moves (RenameLegacy, then the Cursor and
Antigravity effort moves) walking All(), whose WSL agents list the
distros: `wsl -l -q` waited out its 10s timeout, then `wsl -l --running
-q` waited out another. `magpie providers` waited too, through Copilot's
sign-in looked for in each distro's home.

- Start-up's moves look at this machine's agents only (local()). They
  came before WSL agents (the dial rename 09-23, the effort moves 09-28,
  the day WSL Codex came), so a distro has nothing for them.
- A listing that failed isn't followed by the running list: no distro
  was listed, so none runs. That was a second timeout under wsl's lock,
  which the GUI waits on.
- A listing that hung (failed after 5s or more) is remembered in
  wsl-hung beside magpie's settings for 10 minutes: a new process
  doesn't list again in that time, and a listing that answers removes
  it. A process that runs on (the GUI) lists again each minute as
  before.

Real run on the Windows box (10.0.0.132), wsl.exe hung, sandbox
USERPROFILE, old build (main c89284ae6) against this one:
  version    20.17s -> 0.12s
  agents     20.29s -> 0.24s
  providers  20.21s -> 10.16s the first time (it records the hang),
             0.14s after
wsl-hung was written at the first run's hang.

Tests: TestStartUpMovesAskNoWSL (start-up's moves ask wsl.exe nothing,
All() still has the distro's agents), TestWSLListFailsAsksNoRunning,
TestWSLHangRememberedAcrossProcesses. The first two are red on the old
code; the third goes red with the hang check turned off by hand.

Run at this head (base b10f43e89): gofmt; GOOS=linux/windows/darwin go vet
-tags nogui ./internal/agent ./internal/cli; go test -count=1 -tags nogui
./internal/agent ./internal/cli: cli ok (38s), agent ok but one test:
TestWSLColdPlaceOpensNothing is red on main already (#3924, from
34d38ed66's Hermes profiles), with or without this change.

Not tried: a real WSL that answers slowly but under 10s; it lists as
before.
2026-10-28 00:36:15 +08:00
yetone ca8a6f346a agent: a renamed routing group moves its agents, and the Codex app reloads a changed catalog
lucis0116 on X: renaming a provider or a group in magpie didn't reach
every agent.

Display names already reached the agents' files: store and SaveGroup
drop the catalog, and SyncCatalog writes the new "<model> · <name>" and
"<group> · routing group" labels into Codex's model_catalog_json, Claude
Code's picker, OpenCode and Pi (checked in a sandbox HOME). Two gaps
were left:

- A routing group given another id (Routing page, `magpie groups
  rename`, TUI) left every agent on group/<old>, which magpie no longer
  has. The CLI even said "agents set to group/from need group/to now".
  agent.RenameGroup now moves each agent field on group/<old> to
  group/<new>, spelled as the agent spells it. It goes through
  renameRefs, the move RenameProvider already made, now shared by both,
  then SyncCatalog. The GUI, CLI and TUI call it in place of
  provider.RenameGroup.
- The Codex app's own app-server reads model_catalog_json only as it
  starts, and KeepCodexAppOnItsProvider restarts it only when
  codexAppRoute changes. The route named the catalog's path, not what
  the file holds, so a renamed provider or group, or a model added,
  stayed on the old list until the user quit the app. The route now
  carries a hash of the catalog's bytes (codexCatalogTag, read again
  only when the file's size or time changes). The restart goes through
  the existing idle gate: no Codex request in flight, 10s idle, no turn
  open. A write of the same bytes is no change.

Run, in a sandbox HOME only:
- TestRenameGroupMovesTheAgentsOnIt (new): Codex, Claude Code, OpenCode
  and Pi on group/smart, renamed to clever: each said moved and each
  file on group/clever, none naming group/smart.
- TestCodexAppRouteFollowsTheCatalog (new): the route changes when a
  renamed provider rewrites the catalog, and stays put when the same
  bytes are written again.
- Broken by hand: RenameGroup's match turned off makes the first test
  red (no agent moved, every file on group/smart). The catalog line
  dropped from codexAppRoute makes the second red ("a provider renamed
  left the Codex app's route as it was").
- At aded9beea (base ad3833512): go test -tags nogui -timeout 45m
  ./internal/agent ./internal/cli ./internal/gui ./internal/tui
  ./internal/provider -count=1: cli, gui and tui ok. agent red on
  TestFolderVarsAreListed (#3884, red on main since e4552cca9) and
  TestCodexDisconnectStaysWithAccountsOn/login=api, which passed 3 of 3
  alone and isn't on this path (filed #3891). provider crashed in
  TestUnreadLoginsWriteErrorsKeepCredentials with "close of synctest
  channel from outside bubble" in filememo.Forget (#3632, open on main).
- Rebased on 56de2d192 (a312bf3e3 adds a switched account's app-server
  to the same stale set; no overlap): go test -tags nogui -count=1
  ./internal/agent -run 'Rename|CodexApp|Sync|Group|Codex|Hermes' ok
  at this head; ./internal/provider -run
  'CodexApp|Group' ok at a312bf3e3 + this change. The disk was full (other sessions' suites), so the
  whole of each package wasn't run again at this head.
- GUI: group-id-dots, group-morph, agent-model-groups and i18n-keys,
  32 of 32. No GUI script changed, and the GUI tests answer the API in
  memory.
- gofmt -l clean. go vet -tags nogui on agent, cli, gui and tui for
  darwin, linux and windows: ok.

Not covered:
- Claude Desktop reads the gateway's model list only as it starts. It
  still needs its Restart button (AppBehind) after a rename, as after
  any other catalog change.
- Pi, omp and StepCode enabledModels: RenameRefs renames magpie/<old>/
  provider entries only. A group's magpie/group/<old> entry goes as
  scope-gone, and the pick of group/<new> is added again. Not checked
  entry by entry.
- Codex signed in beside magpie (models_cache.json aged by the catalog
  tag) was not run again here.
- No real Codex app restart was watched. The reporter's agent isn't
  named.
2026-10-27 18:22:29 +08:00
yetone df83749218 codex: Disconnect and Connect restart the Codex app's own app-server, so the app stops sending to magpie without a restart
JiangLiuer222 on X: after Disconnect the Codex app kept sending to
127.0.0.1:3425, now and then. The app's app-server reads config.toml only
as it starts, so one started while Codex was connected kept the gateway's
base URL until the user quit the app.

Now the gateway's watcher (KeepCodexAppOnItsProvider, from 8b0132b3d)
ends the app's own app-server whenever what it reads at start and magpie
writes changes: model_provider, openai_base_url, model_catalog_json, the
magpie table's base_url and the used-up takeover (codexAppRoute, through
the provider.CodexAppRoute hook, which replaces CodexAppOnMagpie). Same
guards as before: never while a Codex request is in flight or ended in
the last 10s, never with a turn open, only on magpie's Codex home, a
clean exit. At its first look only a used-up account's app-servers are
ended, as before.

Also checked: after Disconnect nothing writes the base URL back. Failover
and the stale-model rewire skip a disconnected Codex, and the takeover
paths in Sync need Codex joined or on magpie.

Run at this tree (on origin/main 32ea16c5a), private GOCACHE, sandbox HOME:
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
  (internal/agent, internal/provider); go build darwin, windows, linux
  nogui.
- go test -count=1 -run Codex ./internal/provider ./internal/agent: ok
  (at 47175a68f); -run CodexApp again at 32ea16c5a: ok.
- Broken by hand: comparing only the takeover flag (the old condition)
  made TestCodexAppServerRestartedOnDisconnect red ("disconnected, idle:
  ended [], want [60]").
- Real app: ChatGPT.app 26.1013 under a sandbox HOME (CFFIXED_USER_HOME),
  this build's magpie serve on 3492, Codex connected to a custom
  provider by magpie codex fakeai/fake-1. magpie codex default: the
  app's app-server 76497 ended within 5s, the app started 77343 and
  logged "Codex CLI process exited classifiedAsExpected=true code=0";
  window kept. Connect again: 77343 -> 79138. The owner's own app-server
  (1902, HOME=~) was untouched.

Not tried: Windows and Linux real apps, a turn running during the
switch (unit-tested only), a signed-in sandbox app (it was signed out,
so no turn was sent to see the new route used).
2026-10-27 16:33:29 +08:00
yetone 8b0132b3d2 codex: the Codex app sends again on every system as soon as magpie takes a used-up ChatGPT account over, and gets it back at the reset
Ethereal499 and Isdavexxx on X, MasterYi on Discord, #540. The Codex app greys
Send for every model, magpie's too, while the ChatGPT account it is signed in
to is used up. Its composer's gate (ChatGPT.app 26.1013) reads authMethod
"chatgpt" plus rate limit allowed=false, and it asks account/read only when its
app-server starts. ef37b6fb7 (v0.1.1381) could fail in practice:
- (a) The reopen was macOS-only, ran once per time out, only from the GUI
  process. A Windows or Linux user, a magpie without its window, or a second
  time out stayed greyed.
- Switch-back: the app stayed on magpie (authMethod null, no cloud tasks or
  Log out) after the reset. Nothing restarted it.
- (c) Detection lag: the account was read every 5 minutes.
- The notice sat on the Providers page, not on Codex's Agents row.

Now:
- The gateway process (`provider.KeepCodexAppOnItsProvider`, every 3s, on
  every OS) ends the Codex app's own app-server each time `Agent.AppOut`
  flips, both ways. The app starts another at once and reads account/read
  afresh. Its window, threads and drafts stay.
- It never ends an app-server while a Codex request is in flight through
  magpie or ended in the last 10s (`Server.CodexBusy`, Codex's requests only),
  or while a session under the Codex home has a turn open (`codexTurnOpen`).
- It ends only the app's own app-server. That one runs on stdio; one another
  program starts with `--listen` is left alone (Miyi Helper runs one on this
  Mac). It must also run on magpie's Codex home (`proc.EnvOf`: ps -E on macOS,
  /proc on Linux; Windows can't tell).
- The exit is clean (`proc.End`: SIGTERM, or TerminateProcess with code 0 on
  Windows). The app shows any other exit as a crash.
- A listing that fails is taken up again at the next look. One that outlives
  3 ends, or is denied, makes the row say to quit and reopen.
- The active account is read every minute while it is held or a window is at
  90% or more (`codexLookEvery`).
- Codex's Agents row says "On magpie until <reset> · ChatGPT allowance used
  up". Hovering it, or opening the row, says what is off until then (cloud
  tasks, the usage meter, Log out) and that it all comes back on its own. In
  en, zh, zh-TW, ja and de.
- Removed: gui's keepCodexAppSending/codexAppOut, provider's episode
  bookkeeping, and the Providers-page notice.

Not changed, by design:
- A Codex own model that no magpie account serves stays as it is: magpie
  can't serve that turn.
- Account discovery off and "Only switch Codex's sign-in" (login=chatgpt) are
  the user's own choices, and are left alone.

Full suite green at cff1a9686 (on origin/main 6ce0f14b9), below. At
4541b3e97 (rebased on 430e3050d, which touched gateway.go, app.js and
i18n.js beside this) ran: gofmt -l, go build ./..., go vet on darwin,
linux (-tags nogui ./...) and windows; go test -run Codex ./internal/provider
./internal/agent ok; GUI codex-app-out (22 ok) and codex-app-stale (20 ok),
chromium and webkit. Pushed rebased on b92cb2f59 (two more commits,
neither in these files), built, not rerun.

Run at this commit (cff1a9686, on origin/main 6ce0f14b9), with a private
GOCACHE (another session ran go clean -cache mid-run):
- gofmt -l: clean. go build ./...: ok.
- go vet: darwin (touched packages); GOOS=linux -tags nogui ./...;
  GOOS=windows (touched packages).
- go test -count=1 -timeout 45m: internal/proc, internal/provider,
  internal/agent, internal/gateway, internal/gui all ok, skipping four
  tests red on main without this change, each already filed:
  TestUnreadLoginsWriteErrorsKeepCredentials (#3632, a synctest crash
  since 091153bf) and TestFetchAsksOneListOnceForTwoBasesOfIt,
  TestFetchUnionsProtocolListsWithoutChat, TestFetchAsksASharedBaseOnce
  (#3854, since 6eb510f78). All three of the latter fail the same at
  origin/main 6ce0f14b9 and at 353519f55 without this commit.
- GUI at cff1a9686, chromium and webkit, 231 cases ok: codex-app-out (5 languages, 980 and 440px),
  i18n-keys, gui-de/ja/zh-tw, codex-app-stale, codex-accounts-via,
  agent-stale-copies, agent-app-restart, agent-failover, agent-connect,
  agent-layout, agent-expand-steady, agent-connected-unfolded,
  agent-notice-lang and codex-signin-always.
- Windows box (cross-built test binaries): proc and provider's Codex app
  tests pass. TestEndExitsClean passes there and goes red with exit code 1.
- Broken by hand, each went red:
  - Codex-only busy: TestCodexBusy.
  - The 90% cadence: TestCodexLookEvery.
  - The retry after a failed listing: TestCodexAppServerUnknown.
  - The turn guard: TestCodexAppServerRestartedEachWay.
  - The --listen exclusion: TestCodexAppOwnServer.
  - Code 0 on Windows: TestEndExitsClean.
  - The row's notice: codex-app-out.test.cjs, 4 of 4.
- Real app: ChatGPT.app 26.1013 in a sandbox HOME/CODEX_HOME, with this
  build serving on 3492/3493. Codex was put on magpie as Sync does for a held
  account (model_provider = "magpie", codex.out in stash.json). OpenAI's usage
  reading to the app was never faked.
  - The first listing ran out at load ~200, so the timeout is now 30s. The
    next look ended the app-server, and the app started another 12s later.
    Its profile went from "Pro · Usage · Log out" to "magpie" with no reopen,
    and /api/state carried appOut.
  - Undoing it ended the app-server again, and the profile came back to Pro,
    Usage and Log out.
  - The owner's own ChatGPT app (its app-server on ~/.codex) was never
    touched.
- One webkit codex-app-out run at load 291 had one red subtest, name lost.
  It passed 3 of 3 alone and in two full webkit runs.

Not tried:
- The Windows Store app (not installed on the box), and a real Codex app
  on Linux.
- A real used-up account.
- A turn running in the real app while the switch happens (unit-tested
  only).
2026-10-27 15:57:41 +08:00
yetone e7173958e9 agent: NewMax, magpie's models in its model picker (jwaitq on Discord)
jwaitq asked in #general (10-27) for NewMax (newmax.cc), an Electron app
built on the Claude Agent SDK. NewMax keeps its settings in
~/.newmax/newmax.db ($NEWMAX_USER_DATA_DIR wins), a SQLite table
settings(key, value) whose "app" row is JSON.stringify of every setting.
Connect adds one Anthropic-format provider, id magpie-gateway, with
magpie's gateway root (NewMax adds /v1/messages itself), its key and up to
20 models (NewMax's MAX_MODELS), appends it to providerOrder and, when
the user had kept NewMax's default, picks it. The row is edited by
splicing raw JSON in one immediate transaction, so every other byte the
user has stays as written. Disconnect removes the entry and its order id,
puts providerId/model back to "default" when they were magpie's, and
deletes the row when magpie made it. NewMax holds settings in memory and
writes the whole row on any change, so magpie refuses to write while
NewMax runs (macOS/Linux, matched on the program, not on a folder named
newmax) and says why in every language.

Run:
- go test -tags nogui -count=1 -timeout 45m ./internal/agent
  ./internal/agentenv ./internal/appdir ./internal/sessions at this head
  (rebased on 5e3dd1d52): ok
- gofmt -l clean; go vet darwin, linux (nogui) and windows on the touched
  packages
- GUI i18n-keys and agent-notice-lang, Chromium and WebKit: 15/15 each
Broken by hand, each red: user entry's name/off overwritten
(TestNewMaxProvider), running check removed (TestNewMaxLeavesAlone), row
kept after off (TestNewMaxMakesItsRow), pick left on magpie
(TestNewMaxProvider), no model cap (TestNewMaxModelCap), the first
process pattern that matched a shell in a newmax folder
(TestNewMaxProcess).

Real use: NewMax 1.1.22 (macOS dmg) in a sandbox HOME and
NEWMAX_USER_DATA_DIR, with this magpie on a sandbox port. Connect was
refused while NewMax ran; after quitting it wrote the row; on relaunch
NewMax's picker listed and picked magpie's models, its ClaudeProxy sent
to magpie's /v1/messages, and "Reply with exactly: pong" came back
"pong" through magpie to a fake Anthropic upstream. NewMax's own 58KB
row afterwards (47 providers) kept magpie's entry as written; disconnect
then removed only that entry, its order id and the pick
(live/deepseek/deepseek-flash -> default), every other byte the same.

Not tried: NewMax on Linux or Windows (Windows has no running check, as
pgrep isn't there); a real vendor reply through NewMax (the sandbox used
a fake upstream).
2026-10-27 11:03:41 +08:00
yetone 3fd7e16983 agent: PenguinHarness is installed from the Agents page and served by magpie with nothing to set up
rankyurky asked on Discord #feedback for PenguinHarness (npm
@prismshadow/penguin-cli, command penguin). Every value comes from
Penguin's own source (0.2.17):

- Config: $PENGUIN_HOME (else ~/.penguin/data, every OS) /
  $PENGUIN_PROJECT_ID (else default_project) /.project_config.toml.
  magpie writes [providers.magpie] (base_url, client_type, api_key),
  one [[models]] entry per magpie model (context_window, vision,
  max_tokens, [models.pricing] in usd_per_mtok) and default_model in
  Penguin's own inline spelling. Penguin's server reads the file again
  when its mtime changes, so no restart; a default naming no entry is
  refused by Penguin, so Check fails when one is missing.
- A file magpie creates is 0600 in a 0700 folder, as Penguin keeps it.
  Disconnect restores the user's own default_model (or none), drops a
  magpie vision model, and removes the file when magpie made it.
  Penguin's own entries, providers and command_policy rules are kept.
- A sync that changes nothing writes nothing (bytes and mtime kept), so
  Penguin's watcher isn't woken.
- Install: curl -fsSL https://penguin.ooo/install.sh | sh, or
  irm https://penguin.ooo/install.ps1 | iex on Windows; update: npm, or
  penguin update --yes for the tarball, except on Windows where
  update.ts refuses it.
- WSL: a penguin kind with no restart notice; the WSL test now expects
  an empty Notice for a kind with no restart.
- agentenv: PENGUIN_HOME, PENGUIN_PROJECT_ID; the project id is in
  NotPaths, or appdir dropped a value like "work" as a relative path.
- edit.SetTOMLArrayTables: replaces every [[name]] entry with key =
  value (with child tables) by blocks, or removes them; blank lines
  between replaced entries go with them, and an unchanged result isn't
  written.
- GUI: penguin-color.svg icon; README (en, zh-CN), docs/reference.md
  and docs/subsystems/agent-wiring.md.

Run (worktree at ca9b5048e, GOMODCACHE/GOCACHE pinned):
- go test -tags nogui -timeout 45m ./internal/agent ./internal/edit
  ./internal/agentenv ./internal/appdir ./internal/usage: all ok but
  TestWSLMoreAgentsPick (penguin has no restart notice), fixed in the
  test; rerun -run 'TestWSL|TestPenguin|TestEveryAgent|TestFolderVars|
  TestEveryNotice' ok.
- internal/gui: TestCoreScriptBudget, TestAssetTypesHoldAgainstTheRegistry,
  icon and i18n guards ok; no budget raised.
- GUI Playwright, chromium and webkit: i18n-keys, getting-started,
  agent-cli-missing, agent-update-all, gui-ja, gui-de, gui-zh-tw:
  123 tests, 123 pass. The icon renders in colour in both engines.
- gofmt -l internal/ clean; go vet -tags nogui ./... with GOOS linux,
  windows and darwin clean.
- Real Penguin 0.2.17 (npm, Node 25) in a sandbox HOME against a sandbox
  magpie serve and a fake upstream: penguin run -m "Say PONG" answered
  "PONG from fake" through magpie (usage agent "penguin",
  /v1/responses -> /v1/chat/completions); switching the model in magpie
  took effect with no Penguin restart; a no-op sync kept bytes and
  mtime; magpie penguin default restored the user's custom/my-own and
  left no magpie line; with no prior file it was created 0600 and
  removed on disconnect. The fixture is the file Penguin itself wrote.

- Rebased on origin/main d9a8148d7 and run again there: internal/agent -run
  'TestPenguin|TestWSL|TestEveryAgent|TestFolderVars|TestEveryNotice|
  TestSync', internal/edit, internal/agentenv and the internal/gui
  guards ok; gofmt clean.

Broken by hand, each went red: the no-op skip (mtime test), the 0600
create, the inline default_model spelling, the own-default restore,
removing magpie's file, dropping the vision model, the NotPaths entry,
and both SetTOMLArrayTables fixes (blank-line growth, unchanged write).

Not tried: the full ./... suite (machine load ~190-200, as asked); a
Windows or WSL real binary; Penguin's desktop app; a real vendor key
through Penguin. Penguin sends the openai SDK's User-Agent, so the
agent is named from its key, not its UA.
2026-10-27 01:38:45 +08:00
yetone b30734f964 sessions: Antigravity CLI (agy) conversations are listed, with title, folder, tokens and resume (RickyWei, #1718)
agy's conversations were on no Sessions page: internal/sessions had no
lister for them, only the calls reader of #2097. Now each
~/.gemini/antigravity-cli/brain/<id>/.system_generated/logs/transcript_full.jsonl
is a session (agy.go). Its steps give the start and last times, the first
prompt (taken out of agy's <USER_REQUEST> wrapper), prompts, replies, tool
calls, and tokens under the model "agy", since no step names one. A step
written again replaces its tokens, read on or read whole. The title and
folder come from the conversation's conversation_summaries.db row:
title, and workspace_uris through agyFolder, which turns file:///C:/... and
file:///c%3A/... into C:\... and a host into \\host\share on Windows. agy
writes the title after the transcript, so the row is the file's rev. The
database is read again only when it or its -wal changed, and a failed read
keeps the rows read before. A row with conversations/<id>.db and no
transcript (#1718's case) is listed from the row alone, with no tokens and
no conversation to open. Resume is "agy --conversation <id>". When agy is
set to use magpie, it is the agent's launch command (gateway variables and
--model, the PowerShell form on Windows) with --conversation after it,
through sessions.AgyStart, which package agent sets. The transcript (user
text, thinking, text, tool calls, tool results) can be opened and searched.

Format read from real files: agy 1.3.5 and 1.4.7 in a sandbox HOME
against a fake Gemini endpoint, with plain replies, a read_file tool call
with thinking, invalid tool calls, and a conversation picked up again with
--conversation from another folder. testdata/agy-sessions is three of
those conversations with paths rewritten to /work.

Resume tried for real in the sandbox: `agy --conversation <id> -p again`
from another folder appended steps 2-4 to the same transcript and kept the
row's folder. Interactive `agy --conversation <id>` (in tmux) showed the
earlier turns.

Run at this tree, rebased on origin/main:
- gofmt -l internal clean
- go vet: darwin; GOOS=linux -tags nogui; GOOS=windows
- GOOS=windows go build ./...; GOOS=linux go build -tags nogui ./...
- go test -count=1 ./internal/sessions ./internal/gui ./internal/agent: ok
  before the row-only change. After it, sessions ok, and gui had one red,
  TestMainWindowCorners killed at its 40s deadline at load ~300 (#1936).
  It passes alone (47s).
- GUI (playwright 1.62.0, chromium and webkit, en and zh): i18n-keys,
  gui-de, gui-ja, gui-zh-tw, session-terminal, sessions-bar-names,
  sessions-manage, sessions-talk, sessions-toolbar: 49 of 49. No GUI asset
  changed. Tab names come from the agent registry.

Fails without the change (broken by hand, each one red):
- agyFiles out of allFiles: TestAgySessions, TestAgyTitleLater, TestAgyTranscript
- agy out of refresh's DBRevision check: TestAgyTitleLater
- no dropUse of a rewritten step: TestAgyGrows (4510 input, want 3010)
- AgyStart ignored: TestAgySessions (wired resume)
- drive letter not handled: TestAgyFolder
- agy out of HasTranscript: TestAgySessions, TestAgyTranscript
- the row-only listing off: TestAgyRowOnly; readable() off: TestAgyRowOnly

Not tried: agy on Windows. The Windows box (10.0.0.132) didn't answer
ssh, so the Windows paths are covered by unit tests only (agyFolder,
the Set-Location resume form). A wired resume through magpie's real
gateway was not tried. Not done: subagents (parent_conversation_id),
which I never saw agy write. The model name, which is only in
conversations/<id>.db's protobuf (#3147). Deleting an agy session from magpie. agy in WSL: #3595.

Side effect: agy's self-updater ran in the sandbox and replaced the
live ~/.local/bin/agy, 1.3.5 -> 1.4.7.
2026-10-25 18:24:20 +08:00