Commit Graph
6050 Commits
Author SHA1 Message Date
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 d20caffae1 release: notes written again on magpie-releases are copied here each hour
GrayRabbit on Discord (11-02): the "更新内容" dialog in Chinese listed
v0.1.2634 on as raw English commit subjects. magpie-releases' release
runs got "Insufficient Balance" from DeepSeek for both the changelog
and its Chinese since v0.1.2634, so those releases went out with the
commit list and no <!-- lang:zh --> part, as v0.1.1233 to 1242 did
(#2122). magpie-releases b90a82b now writes such notes again each hour
(notes.yml) once DeepSeek answers.

- notes-mirror.yml, hourly at :53 and by hand: a release here still
  without the zh marker gets magpie-releases' notes of the same tag
  once those have it, with the mirror's footer. The app reads
  magpie-releases through usemagpie.ai, so this is the GitHub page.
- release.yml's notice on #2260 names insufficient_balance_error as a
  DeepSeek top-up and says the notes are written again by themselves.

v0.1.2634 to 2644's notes were written by hand from their commits, in
English and Chinese, on both repos' releases.

Run: actionlint 1.7.7 (mote) on notes-mirror.yml and release.yml:
nothing but release.yml's existing unknown runner labels. No Go or GUI
code changed.
Not tried: notes-mirror.yml on GitHub's runners before this push.
2026-11-02 05:22:19 +08:00
yetone e87140242b settings: Check in now for one account, its switch left as it is (xiaowu_95660)
xiaowu_95660 (Discord #general) asked for a way to check in one account
right now where its daily check-in switch is, without turning the switch.

- provider: a checkiner can be held to one account (`only`), and
  CheckInAccount(ctx, by, key) runs the same claim path once for it, for
  WorkBuddy, Trae, MiniMax, Qoder and every plugin with a check-in.
  CheckinOff is not read or written.
- gui: POST /api/usage/checkin-account {By, Key}. Settings' daily check-in
  group (built-ins and plugins) gets a "Check in now" row under its
  accounts. One account checks in at once; several open the app menu to
  pick one. The line says done, already checked in, not eligible,
  inactive, captcha, own-app or the failure. Only quotas reload, so
  Settings isn't redrawn under the button.
- The row and press live in the lazy checkinnow.js (core budget unchanged,
  three check-in comments cut). Once loaded it draws at once, so a redraw
  by the switch doesn't shorten the page for a moment.
- Strings in zh, zh-TW, ja, de. provider-plugins.md says how it works.

Run at befdfa72b (on origin/main d89f03aa9; 4ffd5b96d, the Cursor min line, landed after), on mote:
- gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet of
  internal/provider and internal/gui ok.
- go test ./internal/provider ok. go test ./internal/gui: only
  TestMainWindowCorners/macOS_26_SDK red, the same at base de7953e3b
  (#3949, macOS 27 box).
- GUI, chromium and webkit, every language, narrow widths: checkin-now-
  account (new), checkin-account, plugin-checkin, checkin-reason,
  checkin-reason-once, checkin-early-done, usage-checkin,
  qoder-checkin-recheck, settings-groups, settings-lines-wrap,
  click-scroll, old-webkit, i18n-keys: 252 of 252 ok.
- Earlier at the pre-rebase head: warm-now webkit 440 en/ja/de click
  timeouts (#4322) and segs-press-redraw (#4566) red, both the same at the
  base.

Broken by hand: without the `only` branch in reaches(),
TestCheckinOneAccountNow goes red (every account is claimed). Loading
checkinnow.js after every redraw made checkin-account's "the switch moved
the page" red on webkit 420 zh/zh-TW/ja; fixed as above.

Not tried: the whole GUI suite (another session's full suite was running
on mote); a press against a real account (no real claim was made).
2026-11-02 05:22:12 +08:00
yetone 9f1734645a appdir: exports go to the Downloads folder the system keeps, not home/Downloads
1Shin on Discord (#feedback, 11-02): an export (Settings' backup, a
request saved from the archive, a session as Markdown, the usage file)
joined $HOME/Downloads, which is wrong when Downloads was moved: Windows'
known folder (to another drive or OneDrive) or the XDG one on Linux
(~/下载 on a Chinese desktop).

appdir.UserFolder(kind) asks the system: SHGetKnownFolderPath
(FOLDERID_Downloads/Desktop/Documents, KF_FLAG_DONT_VERIFY) on Windows,
used when magpie's home is the profile Windows keeps it for (a home given
of its own, as a test's, keeps home\Downloads); $XDG_CONFIG_HOME/
user-dirs.dirs on Linux and the BSDs, read as xdg-user-dir does ("$HOME/x"
or "/x", quoted, backslash escapes, the last line wins); ~/Downloads on a
Mac. A failed lookup is home/kind, as before. gui's downloads() tries it,
then home/Downloads, then home. appdir's sharedFolder (a data folder
beside magpie there isn't portable data) adds the system's folders to
home's, and Cursor's AppImage is looked for in the system's Downloads too.
update's isDownloadFolder already asked Windows for its known folders and
is unchanged.

Run at this head (rebased on origin/main):
- mote (macOS): gofmt -l clean; go vet ./internal/appdir ./internal/gui
  ./internal/agent; GOOS=windows go vet of those and ./internal/update;
  GOOS=linux go vet -tags nogui of the three; go test ./internal/appdir ok,
  -run "Backup|Export|Archive" ./internal/gui ok, -run
  "Cursor|Desktop|Sandbox" ./internal/agent ok.
- wsl-run (Ubuntu 24.04): appdir's UserFolder/SharedFolder/ResolveDownloads
  tests and gui's TestExportGoesToTheSystemsDownloads,
  TestBackupLibraryRoundTrip and the session exports pass. Against the real
  xdg-user-dir in a sandbox HOME, "$HOME/下载", "/mnt/d/My Downloads" and
  "$HOME/a \"b\"" read the same; "$HOME/" gives home without the trailing
  slash.
- win-run (Windows 11): the appdir tests pass, and
  TestKnownFolderIsExplorers checks the known folder against Explorer's
  User Shell Folders value (read only). Windows expands that value's
  %USERPROFILE% once a process, with the first call's environment, so the
  check runs in a child of its own. The real profile gives
  C:\Users\yeton\Downloads, Desktop and Documents.

Broken by hand: no user-dirs.dirs read, or no profile check on Windows:
TestUserFolderXDG, XDGLines, XDGConfigHome and TestUserFolderWindows go
red. gui's downloads() without the system's folder:
TestExportGoesToTheSystemsDownloads red in WSL (saved in ~/Downloads, want
~/下载).

Not tried: a Downloads really redirected on Windows (to D:\ or OneDrive).
Moving it means writing the user's own User Shell Folders on the test box,
so the redirect is a faked known folder in TestUserFolderWindows only. Not
run: the GUI suite (no GUI file changed) and a full go test ./....
2026-11-02 05:19:45 +08:00
yetone 4ffd5b96dc provider: the Cursor move asks for plugin 0.2.36 (plugins#550)
Cursor plugin 0.2.36 (magpie-community/plugins@24cd0b9, on npm, checked
with npm view --prefer-online): a stateless Run whose step sent its calls
and then only heartbeats, with no tool count, hands the calls that came
to the caller 60 s after Cursor's last non-heartbeat frame instead of
waiting 240 s to go quiet. Windsland52's fifth wire trace: a native
stall pushed the retry onto the stateless path, where two calls and no
count cost another 4 minutes. keepMovedCurrent updates moved users.

Run at this head (mote): go test ./internal/provider -run
"Mover|Moved|Migrat|Retir|Plugin|Min": ok. GOOS=linux and GOOS=windows
go vet ./internal/provider: ok. gofmt -l: clean. The plugin's own run is
in its commit (bun test packages/cursor: 380 pass).
Not tried: a real Cursor account on the plugin.
2026-11-02 05:12:52 +08:00
yetone d89f03aa92 settings: trayNoNumber is a key magpie settings sets, and GET /api/quit is the window's own (#4793, #4794)
da275848b saved trayNoNumber without naming it in settingsapi.Keys, and
8826a15ea added GET /api/quit without naming it in the CLI parity table,
so TestKeysAreWhatTheSaveWrites, TestSettingsCLISetsWhatTheWindowSaves
and TestEveryRouteHasACommandOrIsNamed have been red on main since.
/api/quit only reads which agents the window's Quit question names, so
it is the window's own (W), with nothing to do in a terminal.

Run at a8e98e1ab plus this, on mote: go test -tags nogui -count=1
./internal/settingsapi ./internal/cli ./internal/settings: ok. The same
three tests were red at 6b3a6d42c without it.
2026-11-02 04:51:42 +08:00
yetone 3f393a4fae redact: a user name is not masked where code has the same word as a name (Tomyu_2034 on X)
Tomyu_2034 on X: "magpie 里面的 masking 很容易把参数变量名当成 user name
给 mask 掉". No sample was given, so the class was measured: with "User
name in home folders" and "User and computer names" on, two finders took
names in code for the user's.

- Known values (known.go). A user name the home rule found once
  (/Users/developer/…) is known from then on when it is 8 bytes or more,
  and standsAlone's default bound is a letter or a digit only, so it was
  masked wherever the word stood between anything else: def
  run(developer, developer_dir), developer_mode = True, const developer
  = 1, {"developer": true}, -    developer_count := 0 in a diff, a tool
  call's old_string. A user name such as developer or workspace1 is a
  word code has too.
- The "User:" line rule (more.go). Its unquoted value was any
  login-shaped word, so user = current_user, user: UserInfo, login =
  loginName, username = target_name, a Go struct's "\tUser  UserProfile"
  and a TS interface's "user: CurrentUser" went as made-up names.

nameAlone now decides a known USERNAME: it is the user's name as a word
of its own in text (a path's part, name@host, --author=name, ls -l's
owner, uid=501(name), prose, a quoted string, chown name:staff), and
code's where it is joined to another part (_ $ a letter or digit beside
it, or a . or - with one past it), declared (const/let/var/def/func/
class/return/import…), assigned or called (name =, name(, name[,
name :=, x = name), a JSON key ("name":), or a parameter ((name, ,name)
name: str, name string), but for id's 501(name)). Nothing is exempted
by a key's name: a tool call's arguments are read by the same rule as
any text, and a quoted value in them is masked as before. The "User:"
rule leaves an unquoted value made of two or more words (split at _ .
and camel humps) one of which says it holds a user (identParts: user,
name, login, current, target, info, obj, id…); a quoted one, and a
login of words of its own (deploy_bot, john_doe), are masked still.

The boundary costs this: prose that puts the name alone in a list
"(developer, alice)" or before "=" now goes as written; such text reads
as code to this rule. A name under 8 bytes was never matched as known,
so for those only the "User:" half changes anything.

Tests (identname_test.go), with "developer" (a common word) and
"rinakato" (a handle), known from a working directory first:
- TestUserNameInCodeIsNoUserName: a Python and a JS file read, a JSON
  file, Go code, a diff and an edit tool call's arguments go as written;
  a home path, --author=, ls -l, uid=501(), prose, a quoted string, a
  JSON value, chown and a bash tool call's ~name go as the made-up name.
- TestUserLineInCodeIsNoUserName: seven code lines unmasked; User:
  deploy_bot, USER=rinak, user: "current_user", ssh config's User and
  user = john_doe masked.

Broken by hand: with more.go and known.go as on main both tests are red
(12 and 7 failures); with standsAlone's USERNAME case returning true,
TestUserNameInCodeIsNoUserName alone is red.

Run at this head (on origin/main 89ffc58f5; nothing since touches
internal/redact or the doc), on mote:
- gofmt -l clean; go vet ./internal/redact ./internal/masking, and
  GOOS=linux -tags nogui and GOOS=windows go vet ./internal/redact: clean.
- go test ./internal/redact ./internal/masking ./internal/otlp
  ./internal/pii ./internal/sessions ./internal/settings: ok.
- go test ./internal/gateway -run '(?i)mask|redact|privacy|personal|
  standin|restore': ok.
- go test ./internal/gui: TestMainWindowCorners/macOS_26_SDK red, the
  AppKit title bar on mote's macOS 27 (#3949, open); nothing else.

Not tried: the full internal/gateway package and go test ./... (the
gateway takes ~45 min; pushed at once per the owner's ship rule); the
local model's PERSON finds, which already leave snake_case and
lower-case words (modelTakes, programWords); the home rule's
"/home/<segment>" in a web route ('/home/dashboard'), which reads as a
home folder and is unchanged; a real request with the reporter's code.
2026-11-02 04:49:42 +08:00
yetone a8e98e1abb gateway: a Claude Code run that exits mid-reply is a failure, not a 200 (#4822)
A Claude subscription run whose Claude Code exited after its reply began,
with no message_stop nor a result (only the message_start, or part of the
text), closed its segment as if the reply had ended. The client was
answered 200 with nothing or the words so far, and the agent took it as a
finished turn.

- readOutput: at the end of Claude Code's output, a reply begun on the
  open segment (KStart, tracked in emit as unended until a KStop or
  KError) ends with a KError, 502, "Claude Code exited before it ended
  its reply" and the end of its stderr. -p and the interactive mode share
  this path.
- relay, not streamed: any error is a status, words said before it too
  (was: a 200 with the partial reply), as a translated reply cut short is
  (errEndedShort). The try's usage is kept as before (d2a83de61).
- Streamed with nothing sent yet: the head's KError is a status, as
  before, so the spare answers by the existing failover rules, and the
  cut try keeps its handed_on usage row. Streamed after text: the
  protocol's error event (Anthropic `error`, chat's error chunk with no
  [DONE], Responses' response.failed), no end event, no other run.
- A reply that ended with message_stop, or whose stop was told, is
  unchanged.
- The tests' fake Claude Code (claudeSubscriptionFirstSays) answers
  control requests, so it runs in the interactive mode too.

TestClaudeSubscriptionRunExitedMidReplyFails: message_start then exit and
text then exit, on /v1/messages, /v1/chat/completions and /v1/responses,
streamed and not, -p and interactive (24 cases): the spare's answer and
the cut try's handed_on row (900 cache write) where nothing was sent, the
error event and no end where text was streamed.

Run, at this tree on origin/main 89ffc58f5:
- mote: go test -run TestClaudeSubscriptionRunExitedMidReplyFails
  ./internal/gateway ok (24/24); go vet -tags nogui ./internal/gateway
  for darwin, linux and windows ok; gofmt -l clean.
- mote: go test -tags nogui -timeout 45m ./internal/gateway
  ./internal/claudetui: claudetui ok; gateway red on
  TestCodexPoolSaysTheClientsVersion alone (#4807, another test's Codex
  identity, open and passes alone; this change doesn't touch Codex).
- Full suite (go test -tags nogui -timeout 45m ./..., Linux, wsl-run)
  was still running at push time; internal/agent's install-detection
  reds there are #4033. Its result goes on #4822.
Broken by hand: with claude_subscription.go at origin/main, all 24 cases
red (200, runs "own", partial or empty reply). With the relay change
alone reverted, the 6 text/not-streamed cases red (200 partial).
Not tried: a real Claude Code whose upstream cuts the stream and exits
mid-reply. A non-streamed reply cut after text now goes on to the spare
account, which is billed for the conversation again (the client gets a
whole answer instead of a cut one, as for translated providers).
2026-11-02 04:38:57 +08:00
yetoneand胡峻果 89ffc58f5b gui: a card's Refresh says the read's failure, and Claude Code's first-run screens say what to do (#4817, uiuing)
From uiuing's branch (1eeb8928b, 66818dbf6), adapted. A usage card's
Refresh showed nothing when the read came back as a card with an
error: only a thrown request reached status. quotaRefresh now says the
refreshed card's error through quotaError, for a single account and
for a provider whose cards were replaced (the one kept in quotas).
quotaError reads the helper's new "stays on its first-run screens" and
an older magpie's "shows its first-run notes" as "Finish Claude Code's
first-run setup, then refresh", in en, zh, zh-TW, ja and de. Comments in
quotaError and quotaRefresh were cut so the core scripts stay in their
budget (1,533,732 of 1,533,802; main was at 1,533,780), with no raise.

Run at the pushed head, on mote: node --test of claude-quota-onboarding,
quota-refresh-order, usage-card-refresh, usage-refresh,
usage-refresh-flight, account-refresh, editor-quota-quiet,
usage-no-reading, usage-remote-cards, tray-usages, glm-quota-error,
claude-usage-asked, allowance-open-read, api-key-usage,
key-balance-card, copilot-signed-out-account, signin-again, plugin-git
and i18n-keys (chromium and webkit, every language each file runs, 440px
where it sets it): 287 of 287.
go test -run 'Budget|I18n|Lang' ./internal/gui ok.
go test -run "Claude|TUI" ./internal/gateway ok. The full
./internal/gateway (-timeout 45m, before the rebase onto 6b3a6d42c) is ok but for
TestCodexPoolSaysTheClientsVersion, #4807 (another test's Codex
identity reaches it in a full run); nothing Claude or GUI.

Broken by hand: without the new status line, 13 of the 31 tests in
claude-quota-onboarding and quota-refresh-order go red (all ten
engine/language cases and three VM ones).

Not tried: the real app's card against a real signed-in Claude Code
that stays on its notes.

Co-authored-by: 胡峻果 <uiuing@foxmail.com>
2026-11-02 04:19:23 +08:00
yetone af4ff747bc claudetui: Claude Code's first-run screens are gone through as a person would, not the run's end (#4817, steven_4422 on Discord)
With "runs as" Interactive, a Claude Code whose onboarding was never
finished (no hasCompletedOnboarding in the state file: steven_4422's
every request 502'd, uiuing's /usage read in #4817) stopped on the
"Security notes" screen, and 88a0262bf ended the run there. A person
presses Enter. The helper now does the same:

- "Choose the text style": Enter (as before, now after the settle);
- "Security notes: ... Press Enter to continue": Enter;
- "Use Claude Code's terminal setup? ... Esc to skip" (shown for
  TERM_PROGRAM Apple_Terminal or vscode): Esc, so no one's terminal
  settings are changed.

Each key waits until its screen has stayed drawn trustSettle (300ms),
as the trust dialog's does, and each screen gets onboardTries (3)
presses; one that is still shown after that ends the run with "stays on
its first-run screens, its onboarding not done; run Claude Code once in
a terminal and go through them", plus the screen. Claude Code then
records the onboarding done itself (hasCompletedOnboarding,
lastOnboardingVersion); magpie writes nothing in the user's
.claude.json. There is no -p fallback: with On nothing runs as -p (the
owner's 11-01 call, e5f66f8a6).

Run at the pushed head, on mote: go test ./internal/claudetui ok;
gofmt -l clean; go vet darwin, linux, windows ok. wsl-run claudetui ok
(at the pre-rebase base). win-run claudetui: TestShimGoesThroughOnboarding
and TestShimNeverPrints pass; TestShimFirstMessageWaitsForTools (#4810)
and TestShimReadsUsage (#4820, filed for this) fail the same at
origin/main eb3b9376e on Windows. go test -run "Claude|TUI" ./internal/gateway ok;
the full package ok but for #4807's TestCodexPoolSaysTheClientsVersion.

Real Claude Code 2.1.316 (npm darwin-arm64) on mote, through a built
magpie's claude-tui-helper, in fresh sandbox HOMEs with a fake
CLAUDE_CODE_OAUTH_TOKEN and ANTHROPIC_BASE_URL at a closed port, for
TERM_PROGRAM unset, Apple_Terminal and vscode: the first run got
through theme, notes (and terminal setup) and trust to init in 5-6s,
the second in 2s; .claude.json then had hasCompletedOnboarding true and
lastOnboardingVersion 2.1.316, settings.json theme dark.

Broken by hand: no Enter on the notes, both TestShimGoesThroughOnboarding
subtests red; Enter instead of Esc on terminal setup, "the user's
terminal was set up" red. Taking the settle out still passes (the fake
redraws and is answered again), so the settle is not guarded.

Not tried: a real signed-in account (no token was provided), so no
request past init; real Claude Code on Windows or WSL; iTerm or other
TERM_PROGRAMs whose onboarding may show other screens.
2026-11-02 04:19:23 +08:00
yetone 62ffc40169 gateway: a waiting request goes to an account back from rest (01huadalang)
01huadalang on Discord (11-01): three ZCode accounts, three requests at
once each. The first two got a 405 and rested, so every request went to
the third, and those over its three waited in its lane. Once the first two
were back, the waiting ones stayed on the third, behind its long turns,
until its requests were cut by hand. Same under Smart, In turn and Stays
off.

Cause: a request that queued in a lane (lanes.take) waited only for that
lane's turn. Nothing looked again when another lane gave a slot back or a
rest ended. With ZCode's maxAccounts 2, the third took a seat while the
first two rested and was a reserve again once they were back, but the
requests already waiting for it stayed. laneMate also gave way to a mate
resting, because ready() checks only lane and RPM room.

Change:
- lanes.take takes a move func. While waiting (lanes.await), it looks
  again when any lane gives a slot back, when a rest is lifted (Unrest,
  UnrestAll signal lanes.freed), when the soonest rest among the others
  ends, and at least every 5s (laneRecheck). waitMate finds the first
  candidate after it in the planned order (then those probeOne left out
  for resting) of the same provider, or any member of a group, that has
  a free slot with no queue (tryTake), minute room, isn't resting, didn't
  give way, and isn't a reserve as keepAtOnce stands now. The request
  then leaves its queue (errMoved) and serve runs that candidate with the
  slot already taken for it. A fallback provider is never one. Strict
  stays leave no other candidate, so nothing changes there.
- laneMate skips resting mates.
- docs/subsystems/gateway-routing.md Limits row says so.

Tests:
- TestWaitingRequestGoesToAccountBackFromRest: 3 keys, cap 3, MaxAccounts
  2, k1 and k2 resting (405), 9 requests. 3 go to k3, 6 wait for it, and
  none reach the resting two. Then the rests are lifted (Unrest) or run
  out (300ms), and the six go to k1 and k2 while k3's three are still
  out (9 at once). Run under Smart and Rotate, with Stays default and
  off.
- TestWaitingRequestTakesSlotGivenBackElsewhere: 2 keys, cap 1. A third
  request waiting for one key goes to the other when that one's request
  ends, under default, order, rotate and usage routing.
- TestFullMemberGivesWay updated. c, waiting for first, now goes to second
  once second's b ends. d (first's fallback is second) still waits for
  first.

Run on mote (mote-run), rebased on e65bc8473:
- go test -count=1 -timeout 45m ./internal/gateway: every test ok
  except TestCodexPoolSaysTheClientsVersion (608s; #4807, below)
- go vet ./internal/gateway, GOOS=linux (-tags nogui), GOOS=windows: ok
- gofmt -l: clean
- go test -race -count=10 on the three tests above: ok
- That red is #4807, also the only red in an earlier full run (it passes alone,
  here and on origin/main e65bc8473; another test's Codex version reaches
  it).

Rebased again on 6b3a6d42c (VS Code agent host, gateway.go): at this
head, vet for darwin, linux and windows ok, gofmt clean, and go test -run
'Lane|Waiting|FullMember|AtOnce|VSCode|Vscode|AgentHost|Concurrency|
Queue|Rest|Probe|Affinity' ./internal/gateway ok (44s).

Broken by hand:
- On origin/main's code, the new tests and the updated
  TestFullMemberGivesWay are red. The rest test fails at "six waiting for
  k3" because laneMate handed requests to the resting keys.
- With waitMate's move ignored (if ok && false), every case is red at
  "the waiting ones at k1 and k2", and so is TestWaitingRequestTakesSlot-
  GivenBackElsewhere.
- With the rest's end ignored for the recheck timer (only laneRecheck),
  the four "ran out" cases are red.
- Two test races were found under -race and fixed in the test: the rest
  was timed from before the nine were sent, and the concurrency count was
  read before the ninth reached the fake vendor.

Not tried: real ZCode accounts or the ZCode plugin. The plugin's own 405
handling and maxAccounts are as before. Not run on Windows or Linux
machines; vet only.
2026-11-02 04:17:24 +08:00
yetone 6b3a6d42c0 agent: VS Code's Agents window (vscode_agent_host) counts as VS Code, its turns as Codex's
justruman on Discord (#general, 11-01): VS Code's Agents window showed
in Usage as a raw "vscode_agent_host" row, 23 calls, 7 failed, beside
the "VS Code" row.

Why: VS Code's agent host runs `codex app-server` with clientInfo
{name: "vscode_agent_host"} (microsoft/vscode main at 8fb6054,
src/vs/platform/agentHost/node/codex/codexAgent.ts CLIENT_INFO; it
bundles @openai/codex 0.163.0). Codex sends that name as its
originator and at the head of its User-Agent, and it reads the user's
~/.codex config, so with Codex connected to magpie its turns come here
under VS Code's name. No agent's UA list had it.

- Usage: vscode_agent_host is in VS Code's UA list
  (vscodeAgentHostUA), so those calls are VS Code's. Records are named
  again at read time (ReportedAs -> AgentOf), so calls already logged
  under the raw name fold into VS Code too. Insiders' and VSCodium's
  agent host send the same name and are counted as VS Code (Stable):
  nothing in the request tells them apart.
- Routing: fromCodex also takes vscode_agent_host (hostedCodex), so
  every Codex rule holds for those turns. The one that fails without
  it: one of Codex's own models asked there, which no account in
  magpie serves, was answered 404 "magpie knows no model" instead of
  going on Codex's sign-in (codexOwnOffMagpie). Also now applied:
  spawn_agent's model list, compaction told in the stream on a byte
  cap/overflow, Codex's headers to a keyed Codex-only relay.
- A test asked as Codex keeps only Codex's own names (codexNamed) as
  Codex's shape: the agent host's headers never become it.
- VS Code's Copilot-proxied names (vscode_codex, vscode_claude_code) go
  to GitHub, not magpie, and are not matched.
- docs/subsystems/gateway-routing.md says so.

Run on mote at this change rebased on origin/main 16ce5ed23; the
one commit since, e65bc8473 (#4802), changes internal/plugin and GUI
files only: gofmt -l empty; go vet ./internal/agent ./internal/gateway
./internal/usage for darwin, GOOS=linux -tags nogui and GOOS=windows
ok; go test -count=1 -timeout 45m on the three packages: agent ok,
usage ok, gateway ok except TestCodexPoolSaysTheClientsVersion
(#4807, filed at origin/main 79f83798f before this change; it sends
codex_cli_rs, which this change leaves as it was, and passes alone
at this head and at its base).

Broken by hand, each red: without hostedCodex in fromCodex,
TestVSCodeAgentHostIsCodex, TestVSCodeAgentHostOwnModelGoesOnSignIn
(404 "magpie knows no model \"gpt-6.1-sol\"") and
TestVSCodeAgentHostNotCodexTestShape (relay sent magpie/dev); with
SawClient ungated, TestVSCodeAgentHostNotCodexTestShape (as Codex sent
vscode_agent_host, 403); without the UA list entry, TestVSCodeAgentHostUA.

Not tried: a real VS Code Agents window against magpie (no VS Code on
this machine or mote). The UA and originator are from VS Code's and
Codex's source, not captured bytes, and the terminal part of the UA is
a guess (it isn't matched). The reporter's 7 failures weren't seen:
the 404 above is the failure class the source shows, not one confirmed
in their log. Other checks keyed on agent == "codex" (Codex memory
calls, image drawing on Codex's own models, title links, CodexBusy)
don't apply to these turns, since they are counted as VS Code.
2026-11-02 04:04:47 +08:00
yetone e65bc84731 plugins: a git plugin updated past the commit the look found waits no more (#4802)
matrix0487 (Discord, #4802): github:faithleysath/magpie-oh-my-aihub, unpinned.
The look at 14:38:55 wrote {version: fdaa691, latest: 3b411a5}; the repository
moved on to ba898e7 twenty seconds later, and Update installed ba898e7. The
dot, "Update all (1)" and the row's New commits stayed until the next hourly
look, and every Update after said only "is up to date".

Cause (checked against the source, as the reporter traced it):
- PendingUpdates kept a git entry until the commit installed was the
  recorded latest (GitBehind is installed != head, not "behind"), so a commit
  newer than latest kept it forever. The npm branch compares versions in
  order and was right.
- Upgrade, Update and add never touched plugin-updates.json; only the next
  CheckUpdates/CheckNow rewrote it.
- The page kept /api/plugins/git's old head (3b411a5) in its heads map, and
  merge() put it over the plugins' own fresher head after the update, so the
  row's New commits and Update all stayed even with the file right.

Changes:
- waitsNoMore (shared by PendingUpdates and the new settleWaiting): a git
  entry also waits no more once the commit installed is not the one the look
  saw installed (Version).
- settleWaiting rewrites plugin-updates.json without what waits no more,
  after add (every install, npm Upgrade, Update's pinned path), a git
  Upgrade, Update (Update all) and InstallMissing. Checked time is kept.
- reinstall's #2954 "left it at X" error now needs the commit to have stayed:
  a moved install that can't ask the repository again (rate limit, offline)
  isn't reported as stuck on the look's older head.
- plugins.js: an action on a plugin (Update all: on every one) drops the
  page's cached head for it, so the plugins' own head is drawn; a git Update whose
  commit moved says "{name} updated to {commit}" (zh, zh-TW, ja, de), and
  the Up to date chip's tooltip prefers the row's head over the check's.

Siblings: npm (version order already right; now also rewritten on file),
a commit pin (dropped once at the pin: test case), Update all (same flow as
Upgrade: test case), the toast (above). CheckNow/CheckUpdates rewrite the
file as before.

Tests (reporter's literal fdaa691 / 3b411a5 / ba898e7):
- TestGitWaitingGoneOnceUpdatedPastTheLook: installed ba898e7, 3b411a5, another
  commit, still fdaa691 (waits), and a pinned spec.
- TestSettleWaitingRewritesTheRecord: git + npm entries gone from the file.
- TestGitUpdatePastTheLookWaitsNoMore: fake bun + fake GitHub; look, push,
  then Upgrade / Update / Upgrade with GitHub down after; nothing waits on
  file or in PendingUpdates, and the update isn't an error.
- plugin-git.test.cjs: the repository moves on after Check for updates;
  Update installs ba898e7, no New commits, no Update all, toast names it.

Run at the pushed head (rebased on 99d9016fd), on mote:
- After the last rebase onto 16ce5ed23 (quotaall.js, i18n.js): internal/gui
  TestCoreScriptBudget ok, i18n-keys and plugin-git in both engines 10 of 10.
- gofmt -l internal/plugin internal/gui: empty. go vet darwin, linux
  (nogui) and windows on internal/plugin, gui, provider: ok (at d2a83de61;
  only plugins.js changed after).
- go test internal/plugin, internal/provider: ok. internal/gui
  TestCoreScriptBudget: ok, 1,533,780 of 1,533,802 with no room added (the
  JS's comments cut to one).
- go test internal/gui and internal/cli at d2a83de61: ok except
  TestMainWindowCorners (#3949), TestSettingsCLISetsWhatTheWindowSaves
  (#4793) and TestEveryRouteHasACommandOrIsNamed (#4794), main's own.
- node --test plugin-git, plugin-update-button, plugin-updates,
  plugin-check-updates, plugin-card-update, i18n-keys (chromium + webkit,
  every language they cover): 54 of 56; the 2 are plugin-card-update webkit
  waiting 5s for the card's Update button before any click, red 2 of 3
  alone at this head and 2 of 3 alone at origin/main 99d9016fd (#3079).
- Before the rebase, every plugin-*.test.cjs + i18n-keys +
  account-plugin-user: 956 of 960, the 4 being plugin-move-unserved's "Try
  again takes the models unticked", equally red at de7953e3b (#4410).

Broken by hand (on mote, then restored):
- all three Go parts removed: all three new Go tests red (the reporter's
  ba898e7 case keeps Waiting; the file keeps both entries; Upgrade/Update
  keep it waiting, and the GitHub-down Upgrade errors "left it at ...").
- plugins.js without the heads line: plugin-git red in both engines (New
  commits still shown, 6 of 6 red).
- only settleWaiting a no-op: TestSettleWaitingRewritesTheRecord and the
  on-file check of all three TestGitUpdatePastTheLookWaitsNoMore cases red.

Not tried: the reporter's real repository or a real bun against GitHub (the
fake bun and fake GitHub API stand in); the Windows and Linux apps.
2026-11-02 03:54:00 +08:00
yetone 16ce5ed232 usage: an account whose longer window is used up adds no headroom to the all-accounts sum (#4791)
hayden4608 (Discord) and handong66 (#4791) have four Codex accounts. Three
show 5 hours 100% left with 7 days 0% left, and one shows 5 hours 0% left
with 7 days 22% left. The All accounts strip read "5 hours 75% left", but
none of those three can spend its 5 hours until its week starts again.
The right figure is 0%.

mergeQuotas (quotaall.js) is the one place that sums windows across
accounts. It feeds the Usage page's strip, the tray panel's strip and the
Routing groups' line. The native menu-bar tray, the TUI, the CLI and
/v1/magpie/quotas show one account at a time and are unchanged. The GUI's
JSON doesn't carry Aside, Model or the matches, so the call is made in Go.
provider.WithHeldWindows marks a window heldBy another window of the same
account when that other window:
- stops the account for every model, by routing's rule: not aside, no
  model, no matches, used >= 100, reset not passed, and not Codex credits
  that go on; and
- starts again after this one (by reset times, else by span).
So 7 days used up holds 5 hours, but 5 hours used up doesn't hold a week
with 22% left. /api/usage/quotas and its refresh apply it. mergeQuotas
counts a held share window as 100 used and a held counted one as its
limit, and the strip's tooltip says how many were counted that way
(en/zh/zh-TW/ja/de). The account cards still show the vendor's own figure.

Run on mote (macOS) at this head's parent tree:
- go vet for darwin, linux (nogui) and windows: ok; gofmt -l: none.
- go test -count=1 ./internal/provider ./internal/gui, before the
  quota_span leftOut line and an i18n comment fix. The provider package's
  only red was TestQuotaSpanCarriesEveryWindowField, which wanted heldBy
  named, and it is now named. internal/gui's only red was
  TestMainWindowCorners/macOS_26_SDK, which is #3949.
- GUI, chromium and webkit, every language, 440px and 360px: quota-*,
  usage-* (all-accounts, merge, accounts, fold, refresh and more),
  panel-usage/quota/switch-accounts/balance-order, routing-quota-left,
  routing-group, tray-usage, i18n-keys, gui-de/ja/zh-tw, old-webkit:
  704 of 707. The reds were i18n-keys (a quoted "All accounts" in
  window_held.go's comment, fixed here) and usage-fold's "17
  subscriptions and 29 accounts" in both engines, which is #4790 and is
  red at origin/main too (see below).
At the pushed head, rebased on eb3b9376e, on mote: gofmt none, vet ok.
internal/provider ok. internal/gui is red only on TestMainWindowCorners
(#3949). GUI usage-merge, usage-all-accounts, i18n-keys and usage-fold,
both engines: 44 of 46. The 2 reds are usage-fold's 29 accounts, which
fail the same at origin/main eb3b9376e on mote (noted on #4790).

Broken by hand, each red, then restored (cmp):
- Go, no HeldBy set: both TestHeldWindows tests red (a, b, c not held).
- Go, outlasts always true: red on d and on "a week that starts again
  first".
- JS, held forced false: usage-merge plus all 5 languages of
  usage-all-accounts red in chromium, showing the reporter's
  "5 hours · 75% left".

Not tried: real accounts. The issue names no provider; Codex is assumed
from the cards' 5 hours / 7 days. Not done: marking a card as held by its
week, the reporter's optional second ask. Not written: a handler-level
test that /api/usage/quotas carries heldBy. Not run on Linux or Windows.
2026-11-02 03:46:01 +08:00
yetone 99d9016fd9 provider: Devin's mover min is 0.1.32, so a system notice mid-conversation keeps its place (plugins #599)
devin 0.1.32 (plugins 17525a7, leosocy) sends a role:"system" notice
that comes partway through a conversation as a user prompt, in its
place and with its cache mark. Before, the notice was lost. A notice
that arrives while tool calls are still waiting for results goes after
those results. keepMovedCurrent now updates every moved Devin user to it.

npm has 0.1.32: npm view --prefer-online @magpie-community/opencode-devin-auth version.
Run on mote at this tree: gofmt clean; go vet ./internal/provider on
darwin, linux (nogui) and windows; go test -count=1 ./internal/provider ok.
In the plugins repo, at 647039a merged with main: bun test packages/devin
182 pass, and 4 of the new tests fail on the old index.mjs.
Not tried: a real Devin account.
2026-11-02 03:44:34 +08:00
yetone eb3b9376ea plugin load: a model listed by another id gets its plugin's load (axelburks)
axelburks on Discord: a plugin reports a model's load through
input.magpie.load by its own model id. A model the user lists in magpie
under another id (Listed as, settings' ModelIDs) showed no load on the
Providers page, and with Busy models last on it was never judged busy;
models whose id wasn't changed worked. The reporter's reading was right:
plugin.ModelLoad keeps the load by the plugin's id and both callers asked
it by the listed one.

Both call sites of plugin.ModelLoad (grep: there are only two) now map the
listed id back through Provider.OwnModelID first:
- internal/gui/providers.go providerInfoWith (models[].load), which
  already computed OwnModelID for models[].vendor; it is now read once
  and used for both.
- internal/gateway/fallback.go busyOf (restLast's busy ordering and the
  trace's busy).
A listed id whose own id is a model@size (grok -> grok-4.7@256k) still
falls back to the model's load inside ModelLoad. The provider-plugins
subsystem page says the lookup is by the plugin's own id.

Tests:
- internal/gui TestModelLoadListedAsAnotherID: a plugin provider with
  fast -> big and grok -> grok-4.7@256k listed, loads noted for big,
  grok-4.7 and small; models[].load must be 87.4 / 60 / 12 for fast /
  grok / small and absent for quiet.
- internal/gateway TestBusyModelListedAsAnotherID: busyOf at 80 judges
  fast, grok and big busy, and an unreported model not.

Run at the pushed head on mote (mote-run):
- at base de7953e3b with this change: gofmt -l clean; go vet of
  internal/gui, gateway, plugin for darwin, GOOS=linux (-tags nogui) and
  GOOS=windows: ok. go test -count=1 -timeout 45m ./internal/gui
  ./internal/gateway ./internal/plugin: plugin ok; gui red only on
  TestMainWindowCorners/macOS_26_SDK (#3949, macOS 27 corners) and
  gateway red only on TestCodexPoolSaysTheClientsVersion (#4807, another
  test's Codex identity in a full package run); both filed, neither
  touches loads. internal/gui/tests/model-load.test.cjs (Chromium and
  WebKit, every language, narrow and wide): 82 of 82 pass.
- at the pushed head 7a804cf03 (rebased; the rebase changed none of the
  touched files): vet for the three OSes ok, and go test -run
  "Load|Busy|ListedAs" of internal/gui, gateway and plugin: ok.

Broken by hand: with both call sites put back to m.ID / c.model, both new
tests fail ("fast: no load, want 87.4", "grok: no load, want 60";
"fast: load 0 busy false", "grok: load 0 busy false"); restored, both pass.

Not tried: a real plugin reporting loads in the running app with a
renamed model (the reporter's in-house vendor plugin isn't available
here); model-load.test.cjs fakes the API, so it checks the badge's
drawing, not this lookup. No full go test ./... (another session's full
suite was running on mote).
2026-11-02 03:40:03 +08:00
yetone d2a83de612 gateway: a try billed before it failed and handed on keeps its usage row
A Claude subscription run that fails after Anthropic's message_start
(an overload, a dropped connection, a cut stream Claude Code gave up on)
is a 502 so another account can take over. That account is a new Claude
Code told the whole conversation, and writes it to its own cache again.
The first try's usage was dropped twice over: relay threw away the reply
start's usage on that path, and serve wrote a usage row only for the
request's last try (and for refusals). The Usage page counted the second
account's tokens alone, with "2 tries" on the row as the only sign that
the conversation went out twice (hhxk233 and Kayrainforest on X).

- relay keeps the usage of the head's KStart/KUsage events on a failure
  before content (streamed), and the collector's usage (not streamed).
- serve writes a handed_on row for any failed try that billed something
  and handed the request on, to another account or member or the same
  one again. The row is written when the next try begins. The refusal
  and turned-away paths keep their own row, and a failure that billed
  nothing still has none. Totals count a handed_on row's tokens, not a
  request, as for refusals. The Usage page already shows such a row as
  "<status> · handed on" with its tooltip in every language.

No same-account double send was found: a fake Claude Code breaking its
stream in nine ways (error before or after message_start, a 529 or 500
result, a cut then an error or an exit, text then an error or an exit),
streamed and not, starts one run per account at most. A failure before
content goes on to the spare once. A failure after text ends the
request with no other run.

Run, at this tree on origin/main de7953e3b:
- mote: go test ./internal/gateway -run 'TestClaudeSubscriptionFailedTryKeepsItsTokens|TestClaudeSubscriptionRefusal|TestClaudeSubscriptionBigRefusal' ok;
  -run 'Retried|SearchInstead|HandedOn|Refus|Loop' ok (25.5s); gofmt -l clean.
- The full suite (go test -tags nogui -timeout 45m ./..., Linux, wsl-run)
  was still running at push time. mote had other sessions' suites the
  whole hour. Its result goes in a follow-up if it shows a red.
Broken by hand: with the failedRow() call commented out, the new test is
red ("handed-on rows: []", both stream modes). With relay's change alone
missing, it was red the same way.
Not tried: real Claude Code against a mock Anthropic that cuts the
stream. Claude Code's own stream-to-non-stream fallback (strings in
2.1.316) resends inside one run. magpie's ledger can't see that, and it
happens the same without magpie.
2026-11-02 03:38:42 +08:00
yetone de7953e3b8 browser: browser_evaluate calls an async()=> function and awaits it
The check that tells a function from an expression wanted a space after
async, so `async()=>{…}` was evaluated as an expression: the function
itself came back, serialized as {}, and its body never ran. And a
parameter list could hold parentheses, so `(async()=>{…})()` counted as
a function and its promise was called ("is not a function"). async may
now touch its parameters, and a parameter list holds no parentheses.
The extension goes to 0.1.2.

Found driving X through magpie-browser from Claude Code.

Run on mote (Chrome for Testing 1234):
- MAGPIE_BROWSER_CHROME=… go test ./internal/gateway -run
  'TestBrowser.*InARealBrowser' -count=1: ok (46.5s). Five new evaluate
  cases: async()=>, async () =>, async function, an async IIFE and
  Promise.resolve, each answering "awaited".
- Broken by hand: with origin/main's background.js the test is red at
  the first case (async()=>… doesn't say "awaited").
- go test ./internal/browserext: ok. gofmt -l: clean.
Not run: the full suite; not tried in Edge or Firefox.
2026-11-02 02:15:47 +08:00
yetone ccd746e039 claude: /usage is read in the interactive mode, typed in it, not through -p
With the interactive mode on, the plan's allowance (the Claude account's
usage card) was still read by `claude -p /usage`, the one -p run left
beside a request. Claude Code 2.1.316's -p /usage also tells only the
session's cost, no window. Now claudeUsage, with claudeTUIOn, runs the
interactive mode's helper (claudeUsageTUI) and gives it a line
{"type":"command","command":"/usage"}. The helper types /usage, waits for
the panel to settle (a "N% used" and a second without change, or three
seconds of anything else, 20s at most), closes it with Esc, and tells
what was drawn as -p's lines say it (usageText: "Current session: 0% used
· resets 5am (Asia/Shanghai)"), so parseClaudeUsage reads it unchanged.
No model is asked. The helper types no other command. The machine
reasons a request is refused for (no shim, OS, missing, off) refuse the
read the same way. Turned off, -p runs it as before.

Run (mote, at this tree on origin/main a25d3d081):
- gofmt clean; go vet internal/gateway and internal/claudetui for darwin,
  windows, and linux with -tags nogui: ok.
- go test -run 'Usage|Claude|Command' ./internal/gateway
  ./internal/claudetui ./internal/provider: ok (59.9s, 4.1s, 25.2s).
- New tests: TestShimReadsUsage, which uses the bytes Claude Code 2.1.316
  drew for the panel (testdata/usage-2.1.316.bin), TestShimRunsNoOtherCommand,
  TestUsageText and TestClaudeUsageTUIOn.

Real run (this Mac, sandbox HOME, Claude Code 2.1.316, the test account):
the built helper with claudeTUIUsageArgs and the /usage line answered in
6.1s with local_command "usage" and "Current session: 0% used · resets
5am (Asia/Shanghai)" / "Current week (all models): 98% used · resets Nov
4 at 6am (Asia/Shanghai)". Exit 0.

Broken by hand: with claudeUsage's claudeTUIOn branch off,
TestClaudeUsageTUIOn read "Total cost: $0.0000" from -p and went red.
With usageText's reset dropped, TestShimReadsUsage and TestUsageText went
red.

Not tried: a plan with overages on, or a Team/Enterprise plan's panel;
both are read through the overages line and the "no window" fallback
only. Not run on Windows or in WSL. No GUI file changed. Not run: the
full gateway suite.
2026-11-02 00:39:54 +08:00
yetone a25d3d0815 claude: a JSON schema is answered in the interactive mode, through an answer tool
With the interactive mode on, a request with a JSON schema was refused
with a 400 since v0.1.2592: interactive Claude Code takes --json-schema and does nothing
with it, its StructuredOutput tool being -p's alone. It now runs in the
interactive mode like any other request.

- serveClaudeSubscription compiles the schema (santhosh-tekuri/jsonschema
  v6.0.3, draft-07 unless it says otherwise, as -p reads one; a $ref
  outside the schema is refused, never fetched) and adds an answer tool,
  StructuredOutput or a numbered name apart from the client's tools, with
  the schema as its input schema, through the bridge's MCP server. A
  schema that can't be compiled is a 400 before any run.
- mcpCall checks each call against the schema: one that doesn't fit is
  told why (isError) to be made again, as -p's is; one that fits is kept.
- At the turn's result the kept input is the reply's structured output.
  A turn that ended with no call is told once to call the tool, and
  fails "no answer fitting the schema" if it still doesn't. Neither the
  call nor the words around it reach the client.
- claudePrint no longer lists the schema. The two refusal tests
  (TestClaudeTUIOnRefusesPrint, TestClaudeTUIRefusalIsNoAccountsFault)
  now use the case that is still refused before any run: an image by
  its URL that can't be downloaded (127.0.0.1, which magpie never
  fetches).
- The provider editor's card no longer says -p takes "a JSON schema"
  the interactive mode can't (en, zh-CN, zh-TW, ja, de).
- docs/subsystems/claude-subscription-bridge.md: the refusal list, and
  how a schema is answered.

Run:
- A real run, haiku, the test account in a sandbox HOME, real Claude
  Code 2.1.316 through the helper with --json-schema and a stdio MCP
  server named magpie serving the answer tool and its description: the
  result's structured_output was null (the premise), and the model
  called mcp__magpie__StructuredOutput at once with
  {"color":"Sky blue","hex":"#87CEEB"}, which fits the schema's
  pattern. 7.2s, one turn. Not run: the whole gateway path with a real
  account (the unit tests drive it with Claude Code's real transcript
  rows).
- mote, at this tree (base 14e351378, origin/main just fetched): gofmt,
  go vet (darwin, windows, linux -tags nogui), go mod verify ok;
  go test ./internal/gateway ./internal/claudetui: claudetui ok, gateway
  red in TestCodexPoolSaysTheClientsVersion only, which is #4807 (red in
  a full package run on mote, another test's Codex identity reaches it);
  alone at this tree -count=3 ok. claude-mode 44/44 and i18n-keys 4/4 in
  chromium and webkit.
- Broken by hand: answer() taking every call without checking it made
  TestClaudeTUISchemaAnswer red ("a call that doesn't fit was told
  Answer received.").
2026-11-02 00:35:21 +08:00
yetone 14e3513780 claude: Claude Code in WSL runs interactively when Windows can't read its transcripts
With the interactive mode on, Claude Code in WSL was refused with a 502
in two cases: the distro user's own folder unreadable from Windows
(\\wsl$ needs the 9P redirector, which a session over ssh hasn't;
"wslread") and a distro whose home the probe didn't find ("wsl-home").
Both now run interactively: the helper reads the transcript inside the
distro.

- claudetui/wslread.go: before Claude Code starts, a shell run through
  wsl.exe notes how much of $HOME/.claude/projects/*/<sid>.jsonl is
  there (a resumed session's earlier turns), says "ready", then tail -F's
  the rest; the helper copies it to a file of its own and tails that as
  any transcript. When Claude Code ends it waits for the copy to stop
  growing (settle), then closes the shell's stdin, which ends it.
- claudetui.WSL gets Distro (Projects omitempty); the gateway's tuiWSL
  sets it when Windows can't read the folder or the home is unknown.
- the wslread and wsl-home refusals are gone (claudeTUI, claudeWhy,
  claudeNotTUIWhy); the GUI's "wsl-home" reason and its 4 strings too.
- docs/subsystems/claude-subscription-bridge.md says how it is read.

Run, at origin/main ff65ebd14 plus this change (the reader through real
wsl.exe and the break-by-hand at 546cdbde6):
- WSL (magpie-desktop, go1.26.8): go vet -tags nogui, GOOS=windows vet,
  GOOS=darwin CGO_ENABLED=0 vet of claudetui ok; go test ./internal/claudetui
  ok; go test -run 'Claude|WSL' ./internal/gateway ok (51s);
  claude-mode.test.cjs chromium + webkit 44/44; i18n-keys 4/4.
- Windows 11 (xiaomi-gpu): go vet ok; go test ./internal/claudetui ok
  but TestShimFirstMessageWaitsForTools, red the same at main 2739626c3
  (bee3ea675's test, #4810);
  go test -run 'Claude|WSL' ./internal/gateway ok with
  TestClaudeAsRootEnv skipped: it is red the same at main 546cdbde6 on
  Windows (#2425, a root test where magpie is never root), at 546cdbde6.
- the reader through the real wsl.exe into magpie-desktop (a temporary
  test, not committed): ready in 93ms, the line already in the file left
  out, two lines written after copied, stopped in 9ms, no tail left in
  the distro.

Broken by hand: tuiWSL not setting Distro: TestClaudeTUIWSL red ("its
own folder, unread": Distro empty).

Not tried: a real Claude Code turn in WSL over ssh (real runs stay on
this Mac); mote (its disk is full); the full go test ./... .
2026-11-02 00:12:40 +08:00
yetone 2739626c38 provider: the ZCode mover's min is 0.1.41, nothing to claim is asked again in half an hour (plugins#600)
zcode 0.1.41 (magpie-community/plugins#600) gives a daily claim that
found no gift plan an `until` half an hour out, so magpie asks again
through the day and a plan ZCode drops into its feed later (the weekend
plan from 19:00 Beijing) is still claimed. keepMovedCurrent now updates
every moved user's plugin to it.

npm view @magpie-community/opencode-zcode-auth version --prefer-online
--registry https://registry.npmjs.org: 0.1.41, checked when this landed.

Run on mote (mote-run) at base ff65ebd14 with this change: gofmt -l
internal/provider (clean); go vet ./... for darwin, GOOS=windows, and
GOOS=linux -tags nogui (all ok); go test ./internal/provider/ -timeout
45m (ok, 103.8s).

Not tried: a real ZCode account's move. No real account was moved.
2026-11-02 00:05:39 +08:00
yetone ff65ebd142 provider: Zed's plugin is 0.1.14 at least: a Gemini model's efforts are keyed lowercase and its thinking level goes to Zed uppercase (plugins#215)
Zed's /models now lists a Gemini model's supported_effort_levels
uppercase (LOW/MEDIUM/HIGH), so the plugin keyed its variants LOW and
magpie's pi profile, which maps efforts by key, marked every thinking
level unsupported for zed/gemini-* (Yezike-yyy on plugins#215). And a
thinking level reached Zed lowercase, which its serde enum refuses:
400 "unknown variant `low`, expected one of `MINIMAL`, `LOW`,
`MEDIUM`, `HIGH`" (iron-water, plugins#215). zed 0.1.14
(magpie-community/plugins 3618bf9, from ump45nose's #587) keys the
variants lowercase whatever case /models uses and uppercases the level
only on the wire. The mover's min is raised to it, so keepMovedCurrent
updates every moved user.

npm view @magpie-community/opencode-zed-auth version --prefer-online:
0.1.14 at landing.

Run on mote at 59fdab0af (origin/main after rebase) plus this change: go test ./internal/provider/
-timeout 45m ok (104s); go vet ./... on darwin and GOOS=windows ok;
GOOS=linux go vet -tags nogui ./... ok (without nogui, Wails' cgo
Linux files don't build from macOS); gofmt -l clean.
Broken by hand: nothing here (a one-value change); the plugin's own
tests were broken by hand in 3618bf9.
Not tried: a real Zed account (none here) and a real move to 0.1.14.
2026-11-01 23:55:43 +08:00
yetone 59fdab0af7 gateway: a caller's folder the user hasn't trusted runs in magpie's, not a 502 (lwjef on X)
lwjef (X, 2116867007799030000): a cwd Claude Code hasn't trusted hangs
the interactive-mode bridge (paseo chat).

Cause: in the user's own account the helper leaves the trust question
to the user (no MAGPIE_CLAUDE_TUI_TRUST) and ends at once saying so. Up
to 11-01 that run became -p; since e5f66f8a6 nothing runs as -p, so the
turn got a 502 (endedBefore, "Claude Code asks whether to trust the
folder"). A Claude Code client such as paseo's asks again with backoff
on a 5xx, so the chat looked hung. The real Claude Code 2.1.309 in an
untrusted folder (sandbox HOME, copied account) ends the helper in 1.3s
with that line.

Fix: startTrusted runs startRun, and when the helper ended over the
trust question (its stderr read to the end, saidOnEnd) in the caller's
folder under the user's own account, remembers that folder for 10
minutes (passedOver) and starts the run once more in magpie's own folder,
told the caller's (envElsewhere), as a caller on another computer is.
Only one retry: a second refusal is returned as before. The saved-session
retry in start goes through startTrusted too.

Run (mote, at this tree):
- go test -run 'Claude|MCP|Bridge' ./internal/gateway: ok
- TestClaudeTUIUntrustedFolderAnswered: ok

Broken by hand: saidOnEnd returning false made the new test red (502
"exited before it answered magpie's initialize request ... trust the
folder"); passedOver turned off made it red with the same 502 after one
retry. An earlier draft that retried through start itself looped forever
with passedOver off; the retry is bounded to one since.

Not tried: a real gateway turn from paseo; the real helper and Claude
Code were run on each side of the retry (untrusted folder ends at once;
a trusted magpie folder answers), not through a live gateway. A user who
trusts the folder within 10 minutes still runs in magpie's folder until
then.

At the pushed head's tree, on origin/main 79f83798f (which has 2b52302dc,
crosscn's 400KB fix), on mote: gofmt -l is clean, and go vet
./internal/... is ok for darwin, windows and linux. go test -timeout 45m
./internal/claudetui ./internal/claudebridge is ok. ./internal/gateway is
ok except TestCodexPoolSaysTheClientsVersion, which fails the same way in
a gateway run at origin/main 79f83798f itself and passes alone at both
(#4807, filed here). The conflict with main's tuiRefusal and replay change
in start() was resolved by keeping main's req.told and calling
startTrusted. Before the rebase, the three packages were ok on
magpie-desktop (Linux) too.
2026-11-01 23:47:47 +08:00
yetone bee3ea6753 claudetui: the first message waits for Claude Code to list magpie's tools (MinhuWang on X)
MinhuWang (X, 2116836405548916907): in the interactive mode the first
message can go before MCP has loaded, and then has none of pi's tools.

Cause: the helper's ready() took the drawn "❯ " prompt as ready. Claude
Code connects its MCP servers beside the prompt, so a message pasted at
once was answered with no mcp__magpie__ tools. Reproduced with the real
Claude Code 2.1.309 (sandbox HOME, a copy of the owner's account): an MCP
server held 8s before answering initialize got "NOTOOL" for "what is the
secret word, use your tool".

Fix: startRun gives claude-mcp-helper a third argument, a `listed` file in
the run's temp folder, which RunMCP writes after it has answered
tools/list. The helper finds that path in the run's --mcp-config
(mcpListed) and ready() waits for it as well as the prompt, inside the
same ReadyWait (45s); past it the run ends saying the tools weren't
listed. Runs without that server (warm-up, model test) don't wait.

Run (mote, at this tree):
- go test ./internal/claudetui ./internal/claudebridge: ok
- go test -run 'Claude|MCP|Bridge' ./internal/gateway: ok
- real Claude Code 2.1.309 here, a sandbox HOME with a copy of the
  account's credentials, the new helper and the real claude-mcp-helper
  behind an 8s sleep: initialize answered at 12.7s, the first turn called
  mcp__magpie__pi_secret and answered "The secret word is PELICAN".
  Without the sleep: answered at 2.1s, same answer. 2.1.309 sends
  server/discover before initialize; the helper's method-not-found answer
  is taken and initialize follows.

Broken by hand: toolsListed returning true made
TestShimFirstMessageWaitsForTools red ("echo: hello (without magpie's
tools)"); RunMCP not writing the file made TestToolsListedFileWritten
red.

Not tried: Claude Code in WSL (the path is the gateway's Windows temp
path, handed to magpie.exe as the callback path is); a Claude Code that
lists tools only on its first request (2.1.309 lists them at start),
which would now wait 45s and fail saying so instead of answering
without tools; the full gateway suite (run after the next commits).
2026-11-01 23:26:57 +08:00
yetone 79f83798fd kiro: the mover installs 0.1.25, which shows bonus credits on the Usage card (plugins#602)
kiro 0.1.25 is on registry.npmjs.org (npm view --registry
https://registry.npmjs.org: 0.1.25, shasum
00882472feb467e0ecb59da3c364bda423c5f12f). It is plugins#602
(GiantGKL), squash-merged as 6053811 in magpie-community/plugins:
bonus credits (a first upgrade's 500 trial credits, a promotion's)
show as aside windows of their own, with when they lapse, and a month
used up while a bonus has credits left is shown only too, since Kiro
spends the plan's credits first. keepMovedCurrent brings every moved
Kiro user to it.

Run on mote:
- at 276c806db + this change: gofmt -l, go vet ./..., GOOS=linux go
  vet -tags nogui ./..., GOOS=windows go vet ./..., go build ok;
  go test -tags nogui -timeout 45m ./...: 85 packages ok, and 3 reds,
  all on main already and filed: TestKeysAreWhatTheSaveWrites and
  TestSettingsCLISetsWhatTheWindowSaves (#4793, since da275848b's
  trayNoNumber), TestEveryRouteHasACommandOrIsNamed (#4794, since
  8826a15ea's /api/quit).
- rebased on 8569f39f6 (internal/provider changed: Zed's min), at
  this head: gofmt ok, go vet of internal/provider for darwin, linux
  and windows ok, go test -count=1 ./internal/provider ok (104s,
  TestKiroMoverHasTheTooLongFix holds with 0.1.25), internal/cli and
  internal/settingsapi the same three reds.

Not tried: a real Kiro account moved to 0.1.25 through magpie; the
plugin's own suite and its tests broken by hand are on plugins#602.
2026-11-01 23:11:28 +08:00
yetone 8569f39f6c agent: Claude Code's /model hides its own lineup while magpie's list is narrowed
yyhhyyyyyy on Discord picked only a routing group's models for Claude Code
on the Agents page, and Claude Code's /model still listed a model they had
not picked. Real Claude Code 2.1.316 in a sandbox HOME, with the settings
magpie writes, lists: Default, the group (as Custom Opus), Claude Code's
built-in "Fable 5.1" row, then the group as Sonnet and Haiku, then
magpie's modelPicker rows. The Fable row is Claude Code's own lineup.
magpie leaves ANTHROPIC_DEFAULT_FABLE_MODEL unset for a main model that
isn't a Fable (#2090), so Claude Code shows its own Fable there. The
gateway's /v1/models already follows the picks (CatalogFor), and Claude
Code's gateway discovery is off unless
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY is set. Neither of those is
where the row comes from.

Claude Code's documented modelPicker.replaceBuiltInOptions hides the
lineup and leaves Default and magpie's rows. In the same sandbox, the
same settings with the flag set list exactly those rows. magpie already
set the flag while "Show Claude Code's own models" is off (#4548). It now
also sets it while Claude Code's list leaves out some of magpie's
catalog: only the picked models, some taken out one by one, or a
visibility of families (claudeNarrowed, CatalogFor's hidden list). A
change to the picks already rewrites settings.json through
catalog.Touched and Sync.

The user's own values:
- A user's ANTHROPIC_CUSTOM_MODEL_OPTION, in the settings env or the
  shell, keeps the lineup. The flag would hide that row too.
- availableModels was not used. It also hid the Fable row in the
  sandbox, but it is the user's key, it blocks --model, and it is meant
  for enforcement.

Run at this head (rebased on origin/main 2503520f8), on mote:
- gofmt -l: clean.
- go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: ok.
- go test -tags nogui -timeout 45m ./...: internal/agent ok, along with
  84 packages. Three packages are red, all on main and filed:
  - internal/settingsapi TestKeysAreWhatTheSaveWrites and
    internal/cli TestSettingsCLISetsWhatTheWindowSaves (trayNoNumber,
    #4793);
  - internal/cli TestEveryRouteHasACommandOrIsNamed (/api/quit, #4794);
  - internal/gui TestRestartHandsTheGatewayOver (#4167, #4107).

Broken by hand:
- On the old claude.go, TestClaudePickerNarrowedListReplacesLineup fails:
  "glm-5 taken out: ... replaceBuiltInOptions=false".
- With the custom-option guard forced off, it fails on the user's
  ANTHROPIC_CUSTOM_MODEL_OPTION step.

Not tried:
- A real magpie writing settings.json for the real Claude Code. The
  sandbox used hand-written settings of the same shape, with the base URL
  on an unused port and no sign-in.
- Claude Code in WSL. claude@wsl takes the same writePicker path.

No GUI file is touched, so no GUI run.
2026-11-01 23:00:10 +08:00
yetone 2f4c088dce usage: Warm up on a Codex or Claude account's card whose 5 hours haven't started
01huadalang on Discord looked for a way to start one account's 5-hour
countdown on the Usage page, not in Settings. A Codex or Claude account
card whose 5-hour window isn't running now has a Warm up (预热) button on
its account line. It sends the request Settings › Warm-up's Warm up now
sends (POST /api/warm-now {agent, user}), to that account alone: for a
ChatGPT account the scheduled warm-up's one "hi" with the account's own
sign-in, on its cheapest model at low effort (warmModel); for a Claude
account Claude Code's own run on haiku (WarmClaudeVia), so magpie sends
nothing that imitates Claude Code. No new server code.

When it shows: the account is one magpie is signed in to (codexUsers /
claudeUsers), its read has no error, and its 5-hour window is idle as the
scheduled warm-up tells it (idle in codex_warmup.go): nothing used and the
reset a whole window away (within warmSlack), or the reset gone by. A
Claude account never used has no window read and shows it too, as
claudeWindowsExpected fills in; a Codex account with no 5-hour window
doesn't. While the request is out the button is disabled (busy), so a
second press sends nothing; once it went, the account's button stays away
for warmSlack (10 minutes), the time a just-started window still reads as
idle, and the quotas are read again (the server marks the account stale).
Refused, the vendor's reason goes in the status line and the button
comes back. Words in en, zh, zh-TW, ja, de (the tooltip is new; the
button and status lines reuse Warm up now's).

Run (at the head before the last rebase onto 09d5dfb87, which changed no GUI asset or internal/gui file, unless said):
- quota-warm.test.cjs (new), on mote: 20 of 20 pass, Chromium and
  WebKit, en/zh/zh-TW/ja/de, 1100px and 390px. On origin/main with only
  the test copied in, 10 of 10 Chromium cases are red (no button.acct-warm).
- Broken by hand: the 10-minute hold taken out (now - busy < 600e3 ->
  false): red 2 of 2 (the button comes back after the warm-up).
- go test ./internal/gui/... ./internal/provider on mote (before the last
  rebase onto df03aeb35, which touched none of these files): provider ok;
  gui red only in TestMainWindowCorners/macOS_26_SDK, #3949 (macOS 27).
- 25 GUI files near the change on WSL (account-mask, privacy-hides-accounts,
  quota-*, usage-fold/-pack/-accounts/-keys/-card-refresh, warm-now,
  codex-auto-reset, tray-cell-click, panel-usage, i18n-keys, gui-de/-ja/
  -zh-tw ...): i18n-keys caught a comment saying Library's "Not running",
  fixed. The other reds are the same on origin/main 85e37162e run the
  same way: usage-fold "most on one screen", tray-cell-click and
  codex-auto-reset webkit de (filed #4790), warm-now 440px (#4322).
- The whole GUI suite was started at this head on mote (concurrency 3,
  another session's suite beside it); it was not finished at push. One
  red by then, account-eye chromium zh-TW (opacity '' read before the
  styles), which passes 15 of 15 alone on WSL; its fixture's windows are
  used, so no Warm up is drawn there.

Not tried:
- A real account's warm-up from this button. The request is Warm up
  now's, whose own commit (1801c96bf) didn't try a real account either;
  a Codex sign-in copied into a sandbox can rotate the live refresh token,
  and a Claude one lives in the Keychain.
- The tray panel's Allowances, which draws the same account line.
2026-11-01 22:50:45 +08:00
yetone 09d5dfb87b gateway: aliased and magpieAliasAsked read one alias parser (#4667)
magpieAliasAsked copied aliased's four prefixes; a fifth form added to
one would leave the other behind. Both now read aliasDigits.

Run: targeted alias/member/desktop/science tests, gofmt, vet x3 (mote).
2026-11-01 22:44:23 +08:00
ggbdpq 3d64d6c52f gateway: a reply to one of magpie's own aliases keeps the vendor's model name (#4667)
leizh007: with Claude Code Desktop served through magpie, ccusage counted
the model as "magpie-2213244526.anthropic…" from the 11-01 release on;
before it said the subscription's own "opus-5-5".

The asked-name rule (9bb1efdde) names a reply after the model the agent
asked for whenever the request went out under another name. Claude
Desktop's effort-picker aliases (fb1575730) made Desktop's Code tab ask by
such a name: magpie-<n>.anthropic.claude-opus-5-5, mythos-magpie-<n>,
anthropic/magpie-<n>, Claude Science's claude-magpie-<n>. The vendor is
asked under the model's own name, the reply came back under it, and the
rule wrote the alias over it — into Claude Code's usage records, where
ccusage counts each model by the reply's name. An alias is magpie's
deployment name, not a model id any vendor knows.

Now a request that came in under one of those aliases is served the
vendor's own name, as every reply was before the asked-name rule. The
recognition is the alias shape alone (magpieAliasAsked), not a catalog
lookup: a session saved on an old alias is served all the same, and its
reply keeps the vendor's name too. MemberModel and X-Magpie-Response-Model:
member are untouched — an explicit ask for magpie's id still says it. The
usage ledger still records the catalog id asked for and the vendor's name
as served.

Run (this head on dfe868a1e, upstream/main):
- go test -tags nogui -count=1 ./internal/gateway: ok (573s). The new
  TestReplyToMagpieAliasKeepsVendorName (10 subtests: the four alias forms
  and [1m], streamed and not) was red before the fix — every subtest had
  the reply naming the alias — and TestReplyNamesAskedModel,
  TestReplyNamesMember, TestGeminiReplyNamesAskedModel, TestMemberLine,
  TestMemberLines stay green.
- Ablation (product files back at the parent, test kept): 11 failures,
  all "the reply names <alias>, want the vendor's opus-5-5".
- go test -tags nogui -race -count=1 on the member and alias tests: ok.
- gofmt -l clean; go vet -tags nogui ./internal/gateway clean;
  GOOS=linux and GOOS=windows vet clean.
- Builds: darwin arm64 (cgo warnings in internal/gui pre-existing),
  linux and windows with -tags nogui, the Makefile's own cross-compile
  form (Makefile line 105).

Sibling faces checked: the alias constants are constructed only in
desktop.go and science.go; aliased() serves resolution (unprefixed) and
GUI display, both of which need the catalog, unchanged; the memberWriter
is the one writer of reply names and this gate covers it; the Responses
WebSocket path never carries a Desktop alias (Codex-side ids).

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:44:23 +08:00
yetone 567b648bd8 gateway: test #4445 on the reporter's route, Codex's ChatGPT backend path
The reporter's turn came to magpie's /backend-api/codex/responses, with
the Model Map plugin naming remote-magpie/codex/gpt-6.1-sol; the patch's
test asked on /v1/responses only. TestRemoteMagpieCodexModelKeepsLiteOnCodexPath
asks the same Lite request on CodexPath.

Run (mote, at this tree, -tags nogui):
- go test -run TestRemoteMagpie ./internal/gateway: ok
- with additional_tools.go and gateway.go put back as on origin/main, the
  new test is red with the report's 400 ("Office:
  X-OpenAI-Internal-Codex-Responses-Lite requires `reasoning.context` to
  be `all_turns`."), as is the patch's own /v1 test.
2026-11-01 22:44:23 +08:00
ggbdpq 1ff928139d gateway: a remote magpie's codex model gets Codex's Responses Lite as it was sent (#4445)
What changed: a Codex Desktop turn on one of its own Lite models (gpt-6.1-sol)
routed through Model Map to a Remote Magpie provider answered 400 "Remote
magpie: Codex: X-OpenAI-Internal-Codex-Responses-Lite requires
`reasoning.context` to be `all_turns`". liteKept treats a Remote Magpie like
any plain Responses upstream, so passthrough ran fromLite (the additional_tools
item lifted into tools, reasoning.context taken off) and forwardOnce dropped
the Lite header. The remote serves codex/<model> through its ChatGPT account,
which passes on what it got, and the ChatGPT backend refuses a request for one
of its Lite models without reasoning context "all_turns" (#534): the request
arrived stripped of exactly what that model demands. Had it gone as Codex sent
it, the remote's account path keeps the Lite shape (liteKept true there) and
its answer is 200, as the reporter's codex=as-sent workaround showed.

liteKept now also keeps the shape, with the model it is asked for: a Remote
Magpie's codex model, named codex/<model> — the ChatGPT account's namespace in
every magpie's catalog, so the remote lists one only when that account is there
to serve it. Its other models still get what Codex sends a model that isn't
Lite (#350), header and reasoning context included in the lift (#350, TangForX).

Run: go test -tags nogui -run 'TestRemoteMagpieCodexModelKeepsLite|
TestRemoteMagpieOtherModelLeavesLite' ./internal/gateway/ — the first failed
with the 400 above before the change and passes after; the second keeps the
old behavior. go test -tags nogui ./internal/gateway/ passes.

Fixes #4445

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:44:23 +08:00
ggbdpq 6de04a26e2 gateway: a Codex memory call on its own bare name follows the session when a provider serves a model under that name too (#4765)
raphael-y7: with magpie as Codex's model provider, the conversation on
orbis/gpt-6.1-sol, Codex's memory consolidation — its own background
request on its own default consolidation model, asked by its bare name
gpt-5.6-terra — went to workbuddy-ai, the only provider of magpie's with
a model under that name, and the account it landed on refused it: 400
"model [gpt-5.6-terra] is not allowed for user type
[personal_free_user]", three tries, 8.5s, and the memory was never
written. The bare name resolved, so codexMemoryStandIn (#742) left the
call where it stood; a model of Codex's own asked by its bare name is
not a pick of whichever provider has one under that name.

Now a memory call whose bare name resolves still follows the
conversation's model, as it does on the ChatGPT backend's path
(codexFollowTo), when Codex's config names no model for its memories:
codexMemoryStandIn asks codexMemorySession first and only falls through
to the name's own resolution when there is none to follow. What keeps
going as the name resolves: any other call, a model Codex's config
names (the user's own pick, a full id or a bare name), a config magpie
can't read, and a conversation magpie has no model of (on Codex's own,
or nothing answered yet).

What this doesn't change: the three tries on a capability refusal, and
the model catalog's exposure of a model an account can't serve — the
reporter's other two suggestions, both a bigger cut; the auto-review's
codex-auto-review and the app's title, description and summary calls,
whose as-Codex-sent default is deliberate (codexTitlesTo, codexSideTo;
shruru counts a provider serving a luna-named model picking titles up
as a feature, #4590).

TestCodexMemoryOnACollidingBareNameFollowsTheSession: a provider with a
model under gpt-5.6-terra, the conversation on another provider's — the
memory call followed the conversation and the named provider got
nothing (red before: it got the memory); the config's pick and a plain
turn on the name still go to it. Run (darwin arm64, -tags nogui):

- go test -tags nogui -run 'TestCodexMemoryOnACollidingBareNameFollowsTheSession|TestCodexMemoryCallsGoWhereItsTurnsGo|TestCodexMemoryStandInFollowsTheSwitch|TestCodexMemoriesFollowTheSession|TestCodexSideCallsKeepTheConfigsModel|TestCodexSideCallsBeforeTheFirstTurnFollowTheSwitch|TestCodexOwnModelOnMagpieThreadGoesOnSignIn' ./internal/gateway: ok (the new test was red before the fix, with the report's routing)

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:44:23 +08:00
yetone 206efc90c8 gateway: a Codex side call with no setting still goes on Codex's sign-in (#4590 review)
e99e75dab took every side call on one of Codex's own models (title,
description, summary, prediction) off Codex's ChatGPT sign-in. With no
setting naming a model, codexTitlesTo and its siblings hand back the
bare model Codex asked for, which magpie serves nothing for: a user
signed in to ChatGPT whose titles worked through the sign-in got
"magpie knows no model \"gpt-6.1-sol\"" 404 for every title,
description, summary and prediction. A thread's summary has no setting
at all, so it always went that way.

Now only a side call whose setting names where it goes (CodexTitles,
CodexDescriptions, CodexPredictions: a model or "off") stays off the
sign-in (codexSideSet); without one it goes on the sign-in as before.

Run (mote, at this tree, -tags nogui):
- TestCodexSideCallOnOwnModelUnsetGoesOnSignIn (new: signed in, no
  setting, each of the four kinds): red on e99e75dab, the 404 above for
  all four; green now.
- go test -run 'TestCodexSideCallOnOwnModel|TestCodexOwnModelOnMagpieThread|
  TestCodexTitlesSetting|TestCodexTitleOnMagpieProvider|
  TestCodexDescriptionsSetting|TestCodexDescriptionFallbackOnMagpie|
  TestCodexPrediction|TestCodexSummar' ./internal/gateway: ok
- broken by hand: codexSideSet always false turns gua's
  TestCodexSideCallOnOwnModelNotPutOnSignIn red (the reporter's 404);
  always true turns the new test red.
2026-11-01 22:44:23 +08:00
ggbdpq 50e8da4c34 gateway: Codex side calls on its own models stay with magpie, not its sign-in (#4590)
shruru: with magpie as Codex's model provider, picking any model in the
Codex titles setting never took: the thread's title stayed the first
message's truncation, and a request for gpt-5.6-luna, Codex's own title
model, to /v1/responses was answered 404 "is one of Codex's own models...
open ~/.codex/auth.json: no such file or directory".

A thread started while magpie was Codex's provider sends to magpie's /v1
(model_providers.magpie's base_url is magpie's /v1), and since
4586307de a request there on one of Codex's own models is put on Codex's
ChatGPT sign-in, or answered 404 when no sign-in can be had — before
handle ever asks codexTitlesTo where the settings send a title. Codex's
hidden side calls (a thread's title, description, summary, a composer
prediction) on its own models were swept up in that: magpie has its own
answer for each (codexTitlesTo and its siblings, further down handle),
so with no ChatGPT account anywhere the title request died at the sign-in
check and Codex fell back to naming the thread after its first message,
whatever the settings said.

Now codexOwnOffMagpie leaves side calls where they stand; a plain turn on
one of Codex's own models goes on the sign-in as 4586307de says.

Tests (internal/gateway/codex_own_v1_test.go): shruru's machine — Codex
never signed in (no auth.json), gpt-5.6-luna in its models cache, no
ChatGPT account in magpie, titles and descriptions set to a magpie model;
a thread_title and a thread_description request to /v1/responses on
gpt-5.6-luna: was 404 "one of Codex's own models...", now 200 with the
{"title"} / {"description"} the settings' model wrote.

Run (darwin arm64, -tags nogui):
- go test -tags nogui -run 'TestCodexSideCallOnOwnModelNotPutOnSignIn|TestCodexOwnModelOnMagpieThread|TestCodexTitlesSetting|TestCodexTitleOnMagpieProvider|TestCodexDescriptionsSetting|TestCodexDescriptionFallbackOnMagpie' ./internal/gateway: ok
  (the new test was red before the fix, with the reporter's 404 verbatim)

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:44:23 +08:00
yetone 37d7913c20 claude: the interactive mode is given an earlier conversation as a transcript
A conversation no run has (a run lost to an update, a client's own
history) was told to a new Claude Code in its interactive mode as one
first message, pasted. #4778's 229 messages and 3 images that way were
refused; #4780's 56 messages and 25 images were pasted one by one until
the paste timed out, and the request got a 502 or an empty reply.

Now, when the conversation has a reply that calls no tool,
replaySession writes it as Claude Code's own transcript: a session file
in the project folder Claude Code reads, a user line holding the
conversation before that reply (as renderClaudePrompt tells it, images
as image blocks, client cache marks out) and an assistant line holding
the reply's words. The run starts with --resume on it, as a saved
session's run does, and is typed only the turns after the reply. If
Claude Code can't go on from it, start tries once more told whole
(req.told). -p (interactive mode off), WSL (no session folder) and a
conversation with no such reply are told whole as before. The file goes
in the folder of the work path with its links followed: the first try
wrote it beside the unresolved /var/folders path on a Mac, and the
replay test was red on mote for it.

Real run (this Mac, sandbox HOME and CLAUDE_CONFIG_DIR, one of the
owner's real Claude accounts by CLAUDE_CODE_OAUTH_TOKEN, real Claude Code
2.1.316 through magpie claude-tui-helper, -p stream-json in, the
interactive mode under it, --model haiku): the transcript was made by
replaySession itself (a throwaway test on mote, not committed) from 6
earlier messages with 3 images (red, blue, green 64x64 PNGs) and a
455KB file whose line 004321 names a fruit, 464,798 bytes; the work
folder was reached through a symlink. Typed only "Name the colours of
images A, B and C, and the secret fruit named in line 004321 of the
file. One line." Answer in 8.4s: "A: red, B: blue, C: green; secret
fruit in line 004321: PAPAYA." Claude Code appended to the same session
file (504,788 bytes after).

Run (mote, at this tree, rebased on 85e37162e): go vet ./internal/gateway, GOOS=windows and
GOOS=linux -tags nogui go vet; go test -run
"TUI|Claude|Resume|Interactive|Refusal|Replay|Fallback|Branch"
./internal/gateway ok. gofmt -l clean.

Broken by hand: with replaySession returning nil,
TestClaudeTUIReplayGoesInATranscript is red ("the run wasn't given a
transcript to go on from"). TestClaudeTUISafeguardsInEnv now expects the
new run of changed safeguards to be given the whole conversation
through the transcript, not typed it, and
TestClaudeTUIBranchOfPrintRunIsToldWhole (049848c5e) accepts a branch of
a -p run's session given the whole conversation as a transcript of its
own, never the -p session (it was red at the rebased head before).

Not tried: the full gateway path (a real magpie serve with the
subscription) end to end; the request was driven at the helper with the
transcript replaySession wrote. Not changed: #4780's ask that an empty
200 not count as an answer and that the specific reason reach the
client; WSL still tells the conversation whole. Part of #4778 and #4780.
2026-11-01 22:43:52 +08:00
yetone 949000a36a claude: a request the interactive mode refuses is a 400 no account rests for
A request Claude Code's interactive mode can't take (a JSON schema, a
branch of a -p run's session, WSL Claude Code whose home wasn't found)
was refused with a 502. The fallback asked every account of the
subscription in turn and rested some for it: #4778 saw 15 tries across 3
accounts. The refusal is the same on every account, so it is now a 400
(tuiRefusal), which the fallback neither retries nor rests an account
for.

The message is reworded so that "Models" no longer stands just before
the error's "invalid_request_error": "Settings › Models › Replies
runs every request as -p\",\"type\":\"invalid_request_error" matched
provider.ModelUnserved, which made the 400 retryable again.

Run (mote, at this tree): go vet ./internal/gateway, GOOS=windows and
GOOS=linux -tags nogui go vet; go test -run
"TUI|Claude|Resume|Interactive|Refusal|Fallback" ./internal/gateway ok.
gofmt -l clean.

Broken by hand: with the 400 mapping taken out,
TestClaudeTUIRefusalIsNoAccountsFault is red (502); with the old wording
it was red on WSL (retryable true through ModelUnserved).

Not tried: a refusal against real accounts. Not changed: a run that
starts and fails (tuiNoStart) is still a 502, retried on the next
account. Part of #4778.
2026-11-01 22:43:52 +08:00
yetone df03aeb351 provider: Zed's plugin is 0.1.13 at least: a Gemini request's tool-calling mode goes in lowercase (#4657)
Zed's cloud refused every tool-bearing Gemini turn of the Zed plugin with
400 "unknown variant `AUTO`, expected one of `auto`, `any`, `none`"
(atticuskk). magpie-community/plugins f4e2ac3 (zed 0.1.13, co-authored
with ggbdpq, who found the cause) lowercases the mode in the plugin,
where the request is fitted to Zed's wire; the mover's min makes every
moved user's plugin that version.

Checked: npm view @magpie-community/opencode-zed-auth@0.1.13 version
--prefer-online -> 0.1.13. Plugin run (mote): bun test in packages/zed
54 pass; the lowercase line off -> 3 red. gofmt -l clean.
Not tried: a live request to cloud.zed.dev.
2026-11-01 22:32:41 +08:00
yetone 97e66bce26 library: an uninstalled Kiro CLI is listed to take back what it was given (#4769)
b4c67477f lists Kiro CLI in apps only while kiro-cli is found. held, which
lists an uninstalled agent on the rows of what magpie gave it so that can
be unticked and taken out of its folder (TestGoneAgentListedToTakeOut),
walks apps and agent.All, so once kiro-cli was uninstalled magpie's
entries stayed in ~/.kiro/settings/mcp.json, ~/.kiro/skills and the
steering file with no row to take them out.

Kiro CLI is now always in apps, with Bin the found path or "kiro-cli":
Detected (binAt) still decides whether it is a target, so ~/.kiro alone
(Kiro Crew, the Kiro IDE) makes nothing a target, as before. Takes tells
an app that isn't installed so, rather than recording it and then giving
it nothing (the #2254 shape); before, an uninstalled Kiro CLI got
"unknown agent".

Run (mote, mote-run -tags nogui):
- go test -count=1 -run 'Kiro|Gone|Takes|Held|Target' ./internal/library: ok
- go test -count=1 ./internal/library (whole package, before this
  change, with b4c67477f): ok 156s
- Broken by hand: apps() back to listing Kiro only when found ->
  TestKiroCLIUninstalledHeld red ("isn't listed as gone: <nil>", Takes
  "unknown agent"); Takes' new check off -> red (Takes returns kiro-cli
  for an uninstalled one).
- gofmt -l: clean.
Not tried: a real kiro-cli uninstall (the user's live ~/.kiro untouched).
2026-11-01 22:32:41 +08:00
ggbdpq eb469c70a9 fix(library): Kiro CLI gets the Library's skills, MCP servers and instructions (#4769)
The library's targets are agent.All plus apps, and apps held Claude
Desktop alone: Kiro CLI, which magpie wires no model into and the Agents
page rightly leaves alone, could be given none of the three, and a user
of it copied skills, servers and instructions into ~/.kiro by hand
(#4769, ump45nose).

Kiro CLI is an app now, found by the kiro-cli program alone — PATH,
~/.local/bin, Kiro CLI.app, where provider.KiroExecutable already
looked — never by ~/.kiro, which Kiro Crew and the Kiro IDE keep too. It
reads ~/.kiro/skills, ~/.kiro/settings/mcp.json and
~/.kiro/steering/AGENTS.md, its global steering's AGENTS.md being always
included (kiro.dev/docs). Its mcp.json has a format of its own: entries
of command/args/env or url/headers, no type written, the user's fields
(disabled, autoApprove, disabledTools, oauth) kept, no SSE named — a url
is streamable HTTP, the docs give no way to say SSE — and a ${NAME} in
headers or env passed through, Kiro expanding those its Mcp Approved Env
Vars approves.

What a kiro-cli in a WSL distro is given, and a project's .kiro, stays
out: apps are this machine's, and per-tool off stays the user's.

Run: go test -tags nogui ./internal/library (ok; TestKiroCLITarget,
TestKiroCLINotByItsFolder and TestKiroMCP new); go vet (darwin, linux,
windows; nogui) and gofmt -l clean on the package; builds for all three
platforms.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:32:41 +08:00
ggbdpq a97653bf3e routing: LeastUsed sends a key with no share behind subs with room, not first (#4535)
A pay-as-you-go key, a prepaid wallet, or an account whose use wasn't
read has Seat.Used read 0, and LeastUsed compared that 0 as if it were a
share of 0%: any subscription that had used more than nothing went after
every such key, so paid balance burned while subscription quota sat
idle. Smart and Pace already keep a seat whose allowance isn't known
behind those whose share was told; LeastUsed now does too: the shareless
go after subscriptions with room and before those running low or spent,
ordered among themselves by what a wallet has left and what magpie sent
a key lately. A learning account still goes first, once, as in Smart
and Pace. Pools of seats that all tell a share, or all tell none, are
ordered as before.

What changed:
- internal/routes/strategies.go: LeastUsed places seats by whether their
  share was told (Known with a use past 0 or a renewal known) before the
  Used comparison; its comment says so.
- internal/routes/routes_test.go: TestLeastUsedSeatsWithNoShare locks a
  key behind subs with room, a wallet behind a told share and before a
  key, keys past low and spent subs, a learning account first, and told
  shares ordered by use as before.

Run:
- go test ./internal/routes/ -count=1 (fails on the parent at
  TestLeastUsedSeatsWithNoShare: [key sub], passes with the fix)
- go vet ./internal/routes/, gofmt clean

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:32:41 +08:00
yetone 2503520f82 codexcat: each Codex model takes official Codex's own instructions for it (#3759, #4008, #4783)
Every magpie model in Codex's catalog (model_catalog_json) carried
gpt-5.2-codex_prompt.md ("You are Codex, based on GPT-5"), so a magpie
GPT-6 model, the auto group's included, ran on a GPT-5.2-era prompt while
official Codex sends GPT-6's own template. magpie still writes no words of
its own into the prompt and leaves the identity line alone: each entry now
takes the text official Codex sends that model, word for word.

- A model's slug (the id's last segment) is matched as Codex 0.166
  matches one (longest prefix of an official slug): first in the entries
  the user's ChatGPT account handed this Codex (models_cache.json), whose
  base_instructions and model_messages go over as sent; then in Codex
  rust-v0.166.0's bundled models.json (instructions_template only, as an
  older Codex may not read 0.166's model_messages), embedded as
  codex_instructions.json.
- Any other model, and a routing group, takes Codex's prompt for a model
  it doesn't know (models-manager/prompt.md, model_info_from_slug), which
  replaces codex_prompt.md: that is what official Codex sends it.
- ownEntry with no base_instructions, and internal/provider's
  codexInstructions fallback, take the same official text.
- testdata holds Codex's models.json and prompt.md at rust-v0.166.0;
  TestBundledIsCodexOwn fails when the embedded copies drift from them.
- GET /v1/codex/models (a remote Codex's model_catalog_url): entries are
  now ~21 KB, so Codex before 0.166's 1 MiB cap holds about 48 of them
  (was ~125). Codex 0.166 reads the catalog whole (models_endpoint.rs
  passes no body limit), and it sends ?client_version=, so the cap now
  applies only to a Codex below 0.166 or one that doesn't say
  (codexReadsWholeCatalog). docs/reference.md says so.
- docs/subsystems/agent-wiring.md: a "Codex instructions" row. The
  Antigravity cloak's comment no longer calls the GPT-5 prompt magpie's.

Run (mote's disk is full, 100% with other sessions' runs, so on WSL
magpie-desktop through wsl-run):
- go test ./internal/codexcat/: ok. go vet -tags nogui ./... and
  GOOS=windows go vet ./...: ok. gofmt -l: clean.
- go test -tags nogui -count=1 -timeout 45m codexcat, provider, agent,
  gui, gateway (every package that imports codexcat): codexcat, provider,
  gui ok. agent: TestGrokInstalled and TestOmpDetectedWithPiDir red, the
  same at origin/main 276c806db on the same box (#3548, #4033: WSL binfmt
  and install detection). gateway: TestCodexCatalogFitsCodexsLimit and
  TestCodexCatalogKeepsTheKeysUsedModelsFirst red from this change (the
  1 MiB cap, fixed above; both ok after, with every TestCodexCatalog*,
  TestCodexListed*, TestCodexApp*), and TestUnroutedHeldReportSaved, red
  only in the full run, ok alone here and at origin/main (#4300).
- Real Codex 0.166.0 (npm) in a sandbox HOME/CODEX_HOME, model_catalog_json
  from this codexcat, against a fake Responses gateway on 127.0.0.1:38611
  capturing each request: 0.166 sends the instructions as the first
  developer message (no top-level instructions). For magpie/gpt-6-astra it
  equals gpt-6-astra's instructions_template in Codex's models.json, byte
  for byte; for magpie/deepseek-v4-pro it equals prompt.md.

- After rebasing on origin/main 9da9bfabd: go vet (linux, windows) of
  codexcat, gateway, provider ok; codexcat ok; -run
  "Codex|Antigravity|Grok" in gateway and provider ok. Then rebased
  onto 546cdbde6 (7 commits in redact, gateway translation and a GUI
  test, none in codexcat or the Codex catalog) and not run again.

Broken by hand:
- The cap held for every client_version: both catalog tests FAIL (47
  listed for 0.166.0, 0.167.0-alpha.1 and 1.0.0).
- Old codex_prompt.md and Prompt everywhere: TestBundledIsCodexOwn,
  TestThirdPartyModelsTakeCodexOwnInstructions (all 7 slugs started "You
  are Codex, based on GPT-5"), TestThirdPartyModelsTakeCachedEntry,
  TestOwnEntryInstructions and TestCodexCatalogKeepsOwnEntries FAIL.
- The same real Codex run on origin/main's codexcat: both models' first
  developer message is the 7.5K GPT-5 prompt, differing from the official
  text at byte 15 (astra) and 8 (deepseek).

Not tried:
- GOOS=darwin go vet (needs mote, full).
- Reading the bundled catalog from the user's installed Codex binary;
  the snapshot is 0.166's, and a Codex release with new templates needs
  testdata and codex_instructions.json refreshed.
- An Antigravity account with Codex's unknown-model prompt ("You are a
  coding agent running in the Codex CLI"): the cloak breaks only the
  GPT-5 identity lines tried before.
- A remote Codex below 0.166 with many models through a gateway key: it
  lists fewer than before; the used ones FitOwn moves into the first 100
  can fall past the 48 that fit.
- A real ChatGPT account's models_cache.json entries (tested with a
  fixture cache).
2026-11-01 22:30:51 +08:00
yetone 546cdbde6b gui tests: claude-mode moves the pointer off the page once the editor is opened (#4638)
The "both modes on hover" tests found the hover card up before their
hover in WebKit. The click that opens the editor leaves the pointer on
the provider row, at (450,110) at 900px and (210,110) at 420px, and the
editor draws its TUI / claude -p switch there: a probe printed the
switch at [306,96,515,121] (en 900) and [171,78,378,126] (en 420), and
the card up in those runs. WebKit sends mouseenter for a pointer that
never moved once something is drawn under it. openEditor now moves the
pointer to (0,0) right after the click, before the editor is read.

Run in WSL (magpie-desktop, Playwright 1.62.0) at origin/main 276c806db:
- before (main): the webkit hover tests red in each run, 1 to 3 of 10
  (ja, de, en, at 900 and 420; which ones changes from run to run);
- after: BROWSER=webkit, the hover tests 3 times, 10/10 each; the whole
  file in chromium and webkit 44/44.

Not tried: mote (its disk is full); the rest of the GUI suite (no other
file uses this openEditor).

Fixes #4638
2026-11-01 22:27:23 +08:00
yetone b4d1c393c1 redact: a Chinese session's words before a missing module are read as cheaply (#4766)
The #4766 fix read the last 64 bytes before the quote, but fell back to
lowering the whole text before it when those bytes were not ASCII. A
session written in Chinese is not ASCII, so it kept the quadratic cost
the fix removed. Lowering is rune by rune with no context, so the last
bytes of the lowered window equal the last bytes of the lowered whole
text; the fallback is dropped. The spaces before the quote are now
trimmed before the window is taken, so more than 64 of them no longer
hide the words.

Run (mote-run, -tags nogui):
- go test ./internal/redact: ok.
- With ggbdpq's model.go: the new Chinese case is red (450560 bytes made,
  8 KiB at most). With main's: red (401408 bytes). With the window taken
  before the trim: the many-spaces case is red.
2026-11-01 22:23:51 +08:00
ggbdpq d3bf8f7394 fix(redact): an error's words for a missing module are read before the quote, not the whole body before it (#4766)
What changed

missingModuleAt said a quoted name is a module an error could not load by
lowering everything before the quote. A session's body holds a place a known
value turns up at for each turn it has been in the history, and knownSpans
asks packageAt at each of them, so every such place paid the body's whole
length again — a 555 KB turn held 1m54s in the masking, past the unrouted
budget, and was answered 504 (#4766). The words stand right before the
quote; what is read of what is before them is the last 64 bytes of it now,
as assignedSecret reads the 64 before the value it judges. A letter a lower
case folds wider than in those bytes reads the whole text before the quote,
as before. Nothing of what is masked changes.

Run

- RED (product file reverted, test kept): TestMissingModuleReadsOnlyTheWordsBeforeTheQuote
  fails with "judging the words made 401440 bytes, 8 KiB at most".
- GREEN: the test passes; go test -tags nogui ./internal/redact/ passes.
- A session that grows turn by turn, Personal on and config-dense as the
  report has it: a 925 KB turn went from 3.8s to 0.76s, a 560 KB turn
  masks in 0.2s; the rest of the cost is the rules' own linear scan.
- go vet on darwin, linux/amd64 and windows/amd64; builds on all three;
  gofmt clean; BenchmarkMaskLongSession unchanged on its shape.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:23:51 +08:00
yetone 7126f7de3e gateway: only the user's "it sees" lifts the small models' shape guess, and a group's ID stays out (#4359)
Review of ggbdpq's aa378a4f6 (the commit before). Its comment says a
group's, auto's or a subscription's agent-written ID stays out whatever
the user said of it, but the code put those guards inside the same
"user said nothing" branch, so a group/ or auto/ ID with a modelImages
entry entered the pool. And any answer lifted the guess, a "takes no
images" too: that says nothing of whether the ID is a vendor's model,
yet let a colon or *-embed/-tts/-free ID into the searcher's small
model pool, which has no image keep to hold it back.

Now the structural guards stand for every model, and only a modelImages
true lifts the colon/word guess.

Run (mote, -tags nogui):
- TestSmallCandsLiftOnlyWhatTheUserSaidSees, new: red on aa378a4f6
  ("pool [cn:text-only cn:sees group/g auto/a], want only cn:sees"),
  green here.
- TestAutoVisionPicksANamespacedIDTheUserSaidSees (ggbdpq's): red with
  search.go at origin/main 85e37162e (AutoVision = ""), green here.
- -run 'TestAutoVision|TestRankSmall|Small|Searcher' ./internal/gateway: ok.
2026-11-01 22:23:51 +08:00
ggbdpq 4932a8bd1c fix(gateway): a model the user said sees is picked though its ID carries a namespace colon (#4359)
What changed

AutoVision never picked a model of a relay whose IDs carry a vendor
namespace (cn:deepseek-v4.1-flash, gateway key 21/cn:…), though the user
had marked every one as taking images in settings.json's modelImages:
smallCands dropped every model whose lowercased ID holds a colon or a
tilde, and the drop came after keep (seesAt) had read the user's answer,
so their word never reached the pick — the pool came out empty and seer()
said no model sees, while naming the model in vision worked.

smallCands now reads the pool's settings once and leaves a model the
user gave an answer about (ImageOverride) in the pool whatever characters
its ID carries: their answer names one of the vendor's models in full,
which is exactly what the colon, the tilde and the nano/lite/image/…
words were guessing at. The shape filters stand for every model they
said nothing of, and the structural ones — a group's, a found group's,
and, on a subscription, what magpie wrote into its agent — stand even
for a model they did name. The searcher's pool reads the same answer:
the filters are one judgment, and a model the user proved real can be
searched with too; a relay is asked to search only where it was before.

Run

- TestAutoVisionPicksANamespacedIDTheUserSaidSees (new) fails on the old
  smallCands with "AutoVision = \"\", want
  relay/cn:deepseek-v4.1-flash, the model the user said sees" and passes
  now; it also holds that with no answer of the user's the model stays
  out, and that their "takes no images" keeps it out.
- go test -tags nogui -count=1 ./internal/gateway/ (whole package).

Fixes #4359

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:23:51 +08:00
ggbdpq 8d7439a1a0 gateway: a translated system turn is folded for a Responses upstream, and a relay's "Upstream request failed" 400 fails a group over (#4632)
Two faults, one turn. Claude Code 2.1.296 and later send their
environment as a message with role "system" inside messages
(Request.envInTurns). The Chat and Anthropic builds fold such a message
into the system prompt (responseInstructions); buildResponses wrote the
role as it came, and a relay whose Responses endpoint fronts the ChatGPT
backend — which takes user, assistant and developer alone — answered
every translated turn 400 "Upstream request failed". That 400 matched
none of the wordings that make a 4xx retryable, so the holdWriter held
it as final and the group's second member never ran: the relay's answer
went to the agent, every turn.

What changed: buildResponses folds a translated request's system and
developer messages the way the Chat and Anthropic builds do, keyed on
the read. A Responses client's own instruction items are kept by the
read (#2532) and go where they stood; so do a codex account's, which
its send says as developer ones in place (codexBody — the fold would
move them out of conversation order, so buildFor marks the account's
requests kept). A translated request's system message is the harness's,
so it is said in the instructions, and one after a reply is told as a
user <system-reminder>, as on every other target. A relay's own word
that the provider behind it turned the request away ("sub2api: Upstream
request failed", type upstream_error — the words the Codex compaction
already reads, #866, #1511) joins the wordings that make a 400 or 422
retryable (retryable) and fail a group over (shapeRefused): the next
member is asked, and nobody rests. A 400 that says nothing of the kind
still ends the route, as a bad request would fail on every member
alike.

Run: TestClaudeSystemTurnSaidInTheInstructionsOnResponses and
TestGroupFailsOverARelaysUpstreamFailed, red at upstream/main 77e853588
and green here; TestUpstreamFailedWordsFailARelayOver's guards (a 401,
403 or 429 with the words, a plain bad request, and an
insufficient_quota beside them keep their reading); the codex account's
own shape (TestCodexAccountUpstream, both clients), the instruction
roles contract (TestResponsesInstructionRolesThroughSearch,
TestResponsesInstructionsOtherAPIsUnchanged), the compaction, group and
retry families, the full gateway package, gofmt, vet on darwin, linux
and windows, and builds of all three (-tags nogui).

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:23:51 +08:00
ggbdpq 65fc2efa44 gateway: a Chat legacy function_call carrying nothing is left out (#4659)
jinccc-ctrl on #4659: with tools declared and the model answering in text
alone, WorkBuddy's stream ended on a frame whose function_call was an
empty object where the contract has null, and OpenMausBot, which checks
every frame's shape, read the empty object for a legacy call and refused
the whole turn ("legacy function_call is unsupported; use structured
tool_calls") — so every text reply a tools-carrying request got was a
turn lost, while clients that merge silently never noticed.

An empty function_call — a name and arguments both empty — says nothing
and runs nowhere, so chatTidy leaves it out, as it leaves out an empty
reasoning_content, an empty tool_calls and a nameless call (#1475). A
null goes as it came, and a call whose name or arguments hold something
is one a client may still be reading: both untouched, as is a name or
arguments of another kind than a string.

Run (darwin/arm64, go test ./internal/gateway/ -tags nogui):

  internal/gateway/function_call_null_test.go:32: an empty function_call
  object went out where the contract has null (#4659) — before the fix;
  after, TestStreamedEmptyFunctionCallLeftOut and
  TestStreamedNamedFunctionCallKept pass, the full gateway package
  passes, and gofmt, go vet, -race on the targeted tests and
  linux/windows/darwin builds are clean.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:23:51 +08:00
yetone 9da9bfabdc gateway: Grok's reasoning goes back to it through a Claude, Chat or Gemini client (jenryai on X)
jenryai uses Grok through Claude Desktop and sees repeats and broken tool
calls that Grok Build doesn't make. Diffing Grok Build 1.0.67's captured
requests against magpie's: Grok Build asks for
include ["reasoning.encrypted_content"] and sends every reasoning item,
encrypted_content and all, before the function_call it led to. Through a
Messages (or Chat, Gemini) client magpie never asked for that reasoning,
and those clients have no place to keep a Responses item. So every step
of a tool loop reached Grok without the reasoning behind its earlier
calls.

Now, for a Grok plugin request from a client that isn't Responses:
- the request asks for reasoning.encrypted_content (askSealedReasoning);
- the sealed reasoning items before a call are kept on disk by hash, the
  same store as Gemini's thought signatures, and the call's id carries
  the key: <id>__rk16__<key> (carryReasoning, on both the whole and the
  streamed paths);
- on the way back afterParse strips the key from the call and its result
  and puts the items in front of that assistant turn (unreasonCalls).
  buildResponses already sends such sealed parts back.
A key magpie no longer has, or an id cut short, goes as before. A
Responses client keeps its own items and is unchanged.

The test fixture testdata/grok_reasoning_then_call.sse is a real Grok
stream (reasoning, then message, then function_call, interleaved).

Run (mote):
- at the base 85e37162e: go vet ./internal/gateway on darwin,
  GOOS=windows and GOOS=linux; go test ./internal/gateway -count=1
  -timeout 45m: ok (969.6s)
- at the pushed head, rebased on 276c806db (which changes host.js, no
  internal/gateway file): go vet ./internal/gateway and go test
  ./internal/gateway -run 'Reasoning|Sealed|Grok|Plugin|Signature'
  -count=1: ok (108.9s). The whole package was not run again there.
- real Grok account (opencode-grok-auth 0.2.3, grok-4.7, effort high)
  through a sandbox magpie built from this tree, Messages client, a
  three-call tool loop (read, read, write the sum), streamed and whole:
  both wrote 462. A mitm capture of each of the 8 upstream requests
  shows the include, and turn N carries N reasoning items
  (encrypted_content 383/179/891 bytes) before their function_calls
  under the plain call ids; every reply was 200.
Broken by hand:
- carryReasoning returning dec unchanged:
  TestGrokReasoningGoesBackThroughOtherAPIs red ("carries 0 items").
- asksSealedReasoning false: TestSealedReasoningAskedOfGrokAlone red
  ("include []" for anthropic, chat, gemini).
Not tried:
- the reporter's broken calls themselves were never reproduced (a real
  10-turn Claude Code run through the live gateway had none); the cause
  is from the diff with Grok Build.
- Claude Desktop itself; a Gemini client end to end (unit-tested only).
- reasoning before a text-only turn is not carried (no call id to ride).
- magpie's own search rounds (search.go) don't know the client's API and
  are left as they were.
No plugin change; the mover's min stays.
2026-11-01 22:21:00 +08:00