Commit Graph
2563 Commits
Author SHA1 Message Date
yetone a0993ed71d gateway keys: a key held to some models can be given a decision group (Kautism on Discord)
Kautism on Discord, after making a group of Clef and Jev models: "group
似乎不能在閘道金鑰上使用?我翻不到。" The key editor's model list comes from
GET /api/caller-keys/models, which is built from provider.Catalog, and
Catalog keeps decision groups out (no agent chats with one). The gateway
already serves a key that names one (serveDecisionGroup's groupGiven at
/v1/systemone), so a key held to some models could only reach a
decision group through All models.

Now the list puts the decision groups after the chat groups, marked
Group and Decides: only those the gateway serves (not hidden, not
switched off, found by FindGroup), and none twice.

Tests:
- TestCallerKeyModelsOfferDecisionGroups: a decision group is listed
  after the chat group; a switched-off one is not. It fails with the
  new block taken out by hand ("groups offered [group/chat], want the
  chat group and the decision group").
- TestGatewayKeyNamingADecisionGroup: a key given only the decision
  group reaches it at /v1/systemone, and a key given another model is
  refused. This is a guard on gateway behaviour that is already there;
  the gateway code is unchanged.

Run (worktree base 223b900b4, rebased onto 169446a1d, which changes
only the tray files):
- mote: go test -count=1 -timeout 45m ./internal/gui/ ./internal/gateway/
  ok (199s, 988s); go vet for darwin, GOOS=linux -tags nogui and
  GOOS=windows: ok; gofmt clean.
- node --test internal/gui/tests/gateway-key-*.test.cjs: 363 pass,
  11 fail. 10 of the fails are gateway-key-arrange's "dragged into
  order" at 420px, both engines and every language, which are #6268.
  On mica, at load ~5, those two files fail the same 10 at this branch
  and at a fresh origin/main 169446a1d. The 11th (limit-off, chromium
  de 420) passed in the rerun of both files.

Not tried: the editor in the real app with the reporter's group.
2026-11-18 03:48:29 +08:00
yetone 169446a1d7 gui: the Mac's menu bar item takes its clicks from the start, so the first click after a restart keeps the panel open (Refeccd on Discord)
Refeccd on Discord: "每次更新后,第一次在菜单栏点击唤起主界面会出现闪退现象
(实际程序未退出,只是隐藏了)" (macOS, automatic updates).

Cause: 182803ea7 made the panel lazily, on its first open, and
trayOwnClicks (mpOwnClicks, the local monitor that sends the item's
action on mouse-down and drops the event) was installed in makePanel.
So the first click after every start went through the button's own
mouse-down tracking: the panel came up, the tracking loop took focus
back, and HideOnFocusLost hid it at once. Later clicks were fine,
because by then the monitor was in. Every update restarts magpie, so
it showed after each one.

Now trayOwnClicks runs right after the tray item is made, in app.go,
before any click can arrive; makePanel no longer installs it (the
monitor is dispatch_once, so nothing is installed twice).

Run (mica):
- go test -count=1 ./internal/gui/: ok (153.7s).
- Quick tests, go vet (darwin, GOOS=windows, GOOS=linux -tags nogui)
  on mote: ok; gofmt -l clean.
- TestTrayOwnsClicksBeforeThePanel is red with the call moved back
  into makePanel (broken by hand), green with the fix.

Not tried: a real tray click after a restart (no click can be driven
over ssh); the reporter's case is reasoned from the code path above.
2026-11-18 03:34:06 +08:00
yetone 223b900b48 library: a skill from GitHub or git syncs as its source, and what a sync leaves out is said (#5715)
JJasonsun (Discord #help, #5715): a skill over a sync's 64 MiB budget was
left out of the server's file while Settings > Sync said the sync worked,
so the other computer silently didn't have it.

A library skill from GitHub or another git repository whose folder is
still what was fetched (editState known and unedited, or Pending) now
goes as its source, as a plugin does (plugin_carry.go): CarriedSkill
gets Fetch, Hash and Commit, and the receiving computer fetches it
itself after Put lets go of the library lock (fetchSkills, through
updateSkills). Its files still go as far as the room the skills carried
as files leave, so a magpie from before this, which ignores Fetch,
writes the skill as it did.

On the receiving side (fromSourceHere): same version is kept; one
changed here is kept and, when the other computer has another version,
said as a problem ("Update replaces them"); another version or a skill
new here is fetched, unless the carried files are already the whole of
it. A skill that can't be fetched stays Pending, shows "Not fetched
yet" on its Library row, and is said as a problem until Update fetches
it (library.Unsettled drops a settled one).

A skill changed here, one from a folder, and one from a link holding a
token (whose link must not be synced) go as their files, as before.

What a sync still leaves out is said: state.LibraryLeft names skills
and plugins whose files were too big (or that this computer never got,
Skill.Missing, carried on as Left so a third computer isn't told it
has them), state.LibraryProblems what the last sync bringing the
library in couldn't put here. Status gives them as libraryLeft and
libraryProblems, and Settings > Sync shows them in red under the
status (askPreviewRows). Strings in every language.

Run at this head (rebased on origin/main 7b552eef3):
- gofmt -l: clean. go vet darwin, GOOS=linux, GOOS=windows: ok.
- mica: go test -count=1 -timeout 45m ./internal/library
  ./internal/davsync ./internal/backup ./internal/gui: ok.
- mote: node --test in Chromium and WebKit of sync-*, i18n-*, gui-zh-tw,
  gui-ja, gui-de, skill-*, library-items, library-all, library-plugins
  and the new sync-library-left (16/16 in both engines). Red, and red
  the same in a fresh origin/main 7b552eef3 worktree, each filed:
  skill-fold-all (#6667), skill-manual (#6668), skill-group-shared
  (#6687), skill-where's zh 900px under concurrency (#5859).
- The first package run at this head had TestSkillCarriedBySource and
  ...NotFetched red: InstallSkills took another test's cached probe of
  owner/repo (SKILL.md only). carrySource now forgets the probes before
  and after; ./internal/library ok again, once more with -shuffle=on.

Broken by hand, each red: bySource always false (5 library tests),
fetchSkills removed (library + davsync), changedHere removed, Missing
not carried on, Unsettled removed, Pending not set in Put, signedIn
check removed from Collect and from Put (TestSkillSignedInLinkGoesAsFiles),
leftOut returning nil, Fetch not excluded from leftOut.

Not tried: a real sync between two computers with a real >64 MiB skill
from GitHub; the tests use a local git repository as the source. A
restore (backup.Restore through the restore and plan paths) carries
skills by source too but doesn't record LibraryLeft/LibraryProblems
yet (said in sync-backup.md).
2026-11-18 03:05:47 +08:00
yetone b2b3d488c1 settings: an SSH server as a saved proxy, and a failed proxy says why
@laiuuui on X (tweet 2122704105005314155) was told to put Gemini behind
a proxy in a supported region. Their VPSes give only SSH (address, port,
password or key), and every http:// proxy they added failed with Go's
words alone.

A saved proxy can now be an SSH server. Settings > Network > Add proxy
has Proxy | SSH; SSH asks for the server, the user and the password, and
Advanced (closed) holds a private key and the trusted host key. magpie
logs in itself with golang.org/x/crypto/ssh (no ssh command) and resolves
the @id to a SOCKS5 server of its own on loopback, which takes only its
own random login and carries each CONNECT as a direct-tcpip channel, as
ssh -D does: lazy login, keepalive@openssh.com every 20s, one re-login
when a channel finds the connection dead.
- Save logs in first: a refused login is said there and nothing is kept.
- The host key is trusted on first use, kept in authorized_keys form and
  shown as its SHA256 fingerprint; another key is refused
  (HostKeyChangedError, both fingerprints said) until Trust a new key.
- The key is a secret like the password: left out of backups and
  syncs without keys, kept on a sync that has none.
- ssh:// typed as a plain address is refused: its login goes with a
  saved proxy.

A failed proxy says why (netproxy.Why: an English template the page
translates in all five languages, Go's words after it): an SSH server
typed as http:// or socks5:// ("is an SSH server, not a proxy: add it as
SSH"), a refused login, keyboard-interactive refused (OpenSSH without
PAM, "unexpected message type 51"), nothing listening, not SSH, TLS on a
plain proxy, 407, timeouts, hangups, and a server that logs in but won't
forward (AllowTcpForwarding no, or macOS 27's sshd, which hangs up on
every forward, OpenSSH's own ssh -W too). A check the user asks for
reads the server's first bytes when Go's text can't tell: Go reads a
real OpenSSH banner ("SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13.20") as an
HTTP status line with a malformed code, and an SSH server's banner can
reach Go's transport before its request goes out
("readLoopPeekFailLocked", found red 1 of 20 on mica, then 40 of 40
green). Each save is tested at once.

app.js keeps one line (api() hands a proxy_why reply to proxies.js,
where proxyWhy now lives); both script budgets are raised by that line's
52/54 bytes, with the reason in core_budget_test.go.

Run (mica, at this head on origin/main 81c666e1c):
- go test -tags nogui ./internal/netproxy/... ./internal/settings/
  ./internal/davsync/ ./internal/gui/ ./internal/provider/
  ./internal/backup/...: ok
- GOOS=linux and GOOS=windows go vet of netproxy, settings, gui; gofmt -l
  internal: clean
- GUI, chromium and webkit, en/zh/zh-TW/ja/de, 1100 and 420px:
  saved-ssh-proxy, saved-proxies, i18n-keys, provider-proxy-missing:
  64/64
- Tests use netproxy/sshtest, an SSH server on loopback that answers
  channels itself; nothing reaches the network.

Broken by hand, each red: accepting any host key
(TestSSHProxyRefusesAChangedHostKey); no login check on the SOCKS end
(TestSSHProxyLocalEndNeedsItsLogin); no SSH banner case and no banner
probe (TestProxyFailureNamesAnSSHServer, its OpenSSH-banner case); no
type-51 case (TestSSHProxySaysWhyItFailed, keyboard-interactive); no
code 2 for a hangup (TestSavedSSHProxyThatWontForward, both cases);
api() not handing proxy_why to proxies.js (saved-ssh-proxy, 20 of 20
cases red: err.why is already a failed move's reason).

Real use: Ubuntu 24.04 OpenSSH_9.6p1 (WSL magpie-desktop, a user sshd
on loopback, key login): the host key was learned, a Cloudflare trace
through the tunnel came back ip=104.194.93.45 loc=US, a wrong password
said "turned the login away", a changed host key said both
fingerprints, and http:// and socks5:// pointed at the sshd both said
"is an SSH server". mote's and mica's sshd (macOS 27, OpenSSH 10.5 and
10.3) log in and refuse every forward, now said as "won't forward
connections".

Not tried: a password login against a real sshd (the user sshd had no
shadow access), a real VPS, and the full go test ./... and full GUI
suite: both mote and mica were running other sessions' GUI suites the
whole time.
2026-11-18 01:01:30 +08:00
yetone 81c666e1c2 gateway: an advisor call Anthropic's server ran is a usage row of its own (#6977)
A Claude Code turn relayed on Messages with its advisor on has the advisor
run at the vendor. The reply's top-level usage is the executor's alone;
each advisor call is an advisor_message entry of usage.iterations, billed
at the advisor model's rates (Anthropic's advisor tool page, "Usage and
billing"). magpie read only the top level, so an Opus advisor beside a
Sonnet executor was in no row and priced nowhere.

aUsage reads iterations, whole and from a stream's message_delta (whose
list is cumulative, so the latest stands for the reply). Each advisor call
becomes its own row (advisorRows, written by appendAdvised at every row of
a try that reached a provider, and on the native route): under the
advisor's model by magpie's id (advisorKeyModel of the request's advisor
tool), Served as the vendor names it, Kind "advisor" (named Advisor in
Usage's filters, already translated), the request's route, agent, account
and session, status 200, counted as its own request as magpie's own
advisor calls already are. The executor's row is unchanged. Routing prices
the calls too, before the request's own usage so the prompt is still read
from the last entry. Iterations with no advisor entry (Copilot) leave
Usage as it was.

The fixture is Anthropic's documented example word for word; no real
reply with an advisor call was captured.

The core script budget is raised by 52, the Advisor entry in the
generated purposes.js (the base had no room; 1 byte less is red). The
kinds are read wherever Usage and Routing draw a row, so there is no page
to move it to.

Run at this commit's tree on f1b0663f1, then on b1f044fc1 (which changed
core scripts only, i18n.js and syncfiles.js, so internal/gui and the GUI
files were run again there):
- mica: gofmt -l (nothing), go vet (darwin), GOOS=linux go vet -tags nogui,
  GOOS=windows go vet for internal/gateway, internal/usage, internal/gui: ok.
- mica: go test -timeout 45m -count=1 ./internal/gateway ./internal/usage
  ./internal/gui: ok (916s, 64s, 161s).
- mote: node --test purpose-filter, routing-purpose-state, usage-big-write,
  usage-ledger-mcp, usage-ledger-search, i18n-keys (Chromium and WebKit):
  74 of 74 pass.
- On b1f044fc1, the pushed base: mica go test -timeout 45m -count=1
  ./internal/gui ok (147s); mote the same six GUI files, 74 of 74 pass.
- Before the rebase, at ae94571d7, the same packages on mote were ok
  except TestCoreScriptBudget, which this commit's budget line answers.

Broken by hand:
- aUsage.usage never setting advised: TestAdvisorIterationsRead red
  ("stream=false: advisor calls <nil>, want one"), TestAdvisorCallHasItsOwnRow
  red in both subtests ("advisor rows: []").
- passthrough without advisedAs: TestAdvisorCallHasItsOwnRow red in both
  subtests, the row named claude-opus-5-5 and not magpie's claude-opus-5.5.

Not tried: a real Anthropic reply with an advisor call (no account with the
advisor beta at hand); Bedrock and Vertex passthrough with an advisor
(they share the sniffer, not run); the Usage page with an advisor row in a
real browser session beyond the GUI files above.

Reported by Refeccd on Discord.
2026-11-18 00:38:36 +08:00
yetone b1f044fc1e library: a Claude plugin goes to another computer whole, its hooks naming that computer's folder (#6685)
A plugin installed from Library > Claude plugins didn't reach the other
computer by sync: the bundle carried its parts as plain items, with
${CLAUDE_PLUGIN_ROOT} already resolved to the first computer's
<library>/plugins/<name>, and neither the plugin record nor its folder.
Hooks there pointed at a path that doesn't exist, Windows' too.

Now Bundle.Plugins carries each plugin's record (name, version, source,
pick, agents, Off, parts taken out by hand) and never its parts:
- A GitHub or git link goes as its source. The receiving computer
  installs it from there, as UpdatePlugin does, after the library's lock
  is let go. Re-installing from the source was chosen because the files
  stay the vendor's and an update keeps working there; a fetch that
  fails keeps the plugin Pending (shown on its row, "Update tries again")
  with a problem, and the next sync or Update tries again.
- A plugin from a local folder, or from a link holding a token (whose
  link must not be synced), goes with its files on the skills' budget,
  executables kept executable, and is installed from them.
- Either way the parts are read again there, so every hook, server and
  skill names that computer's own plugin folder. A plugin the bundle no
  longer has is removed with its folder; Off spreads.
- A bundle from an older magpie has no plugins list: this computer's
  plugins keep their parts over the same-named items it carries.
- An empty list hashes as before, so computers without plugins don't
  see a change; the preview names each plugin, its files as one digest.
- Sibling: a plugin installed from a marketplace under a name other
  than its manifest's named the manifest's folder in its parts.
- The sync settings' text says Claude plugins go with the Library (en,
  zh, zh-TW, ja, de); "Claude plugins" moved into the core i18n.js since
  the core now says it.

Run at this head (54e682dc5's tree on f1b0663f1, mote):
- go test -tags nogui -timeout 45m ./internal/library ./internal/davsync
  ./internal/backup: ok
- gofmt -l: empty; go vet GOOS=darwin (library, davsync, backup, gui),
  GOOS=linux -tags nogui ./..., GOOS=windows ./...: clean
- Windows (win-run, xiaomi-gpu): go test ./internal/library -run
  TestPlugin and ./internal/davsync -run Plugin: ok. The hook there names
  B's C:\...\plugins\kit/bin/done (TestSyncLibraryPlugins first failed
  on Windows for the test's own path form; fixed in the test).
- GUI, Chromium and WebKit, every language the files test:
  library-plugins, library-items, agent-plugin-agents, i18n-keys,
  i18n-en-no-cjk, old-webkit, every sync-*, github-sync, s3-sync,
  auto-backup: 337 pass, 1 fail: webkit en "S3 sync settings", red the
  same at origin/main f1b0663f1 (#2448, #3413, open).

Broken by hand, each red, then restored:
- parts not skipped and Plugins not set in Collect:
  TestPluginCarriedWhole, TestPluginCarriedBySource,
  TestSyncLibraryPlugins
- held.without dropped: TestPluginOldBundleKeepsPlugins
- fetchPlugins dropped: TestPluginCarriedBySource
- marketplace name fix reverted: TestPluginMarketplaceNameIsItsFolder
- empty list not hashed as none: TestNoPluginsHashAsBefore
- TestPluginFromFilesEitherOS guards that a Mac path is files on
  Windows and C:\ on a Mac; it passed without a new check (such paths
  are no git source), so none was added.

Not tried:
- a real two-computer sync through the GUI, Mac to Windows;
- a local marketplace entry's own fields (strict: false) aren't carried,
  so there it is read from its files alone;
- a private git source over ssh on the receiving computer.

Reported by JJasonsun on Discord; issue by JJasonSun (#6685).
2026-11-18 00:24:41 +08:00
yetoneandmdwsk88 0bad752415 claude-desktop: a session on a tier's pick the catalog leaves out for now stays on the pick, not on another session's model (#6748)
Claude Desktop names a Claude model with reasoning levels by magpie's own
id for it (claudeLooking: magpie-<n>.anthropic.claude-opus-5-5), and
aliased read <n> back from the catalog alone. When the model was out of
the catalog for a while, the id stayed as asked, unserved took it for a
model magpie doesn't serve, and desktopMoveTo's gone branch served it on
desktopPicked: the model of the last tool turn of any Desktop session.
Copilot's /models once answered without its three Claude models and the
list was kept for an hour; three sessions on Copilot's Opus 5.5 were
answered by another provider's model for 25 minutes, with Desktop still
saying Opus (desktop-gone in the Routing rows).

- aliased: after the catalog, the models picked for Desktop's tiers
  (DesktopTiers) are matched by <n> too, a later tier's number
  (desktopTierKey) by whichever tier. A pick so read back goes to its
  provider as asked. A routing group's id is skipped (#6719).
- desktopTierTurn: an id of magpie's that still names no model but names
  a Claude model (aliasClaude) goes to the pick for that model's tier
  (desktop-tier), as Claude Code's own id of one does.
- The routing reference states the rule.

Ported from mdwsk88's reference commit 68f39e8ae (branch
desktop-alias-tier-pick on mdwsk88/magpie, patch sha256[:16]
a7b9dee0d26cdcbc, matching the issue). Reviewed line by line; code and
tests taken as written, only the routing doc hunk re-placed onto current
main. Thanks to mdwsk88 (dawei) for the report, the logs and the fix.

Siblings checked: desktopPicked is read by desktopMoveTo (gone, title,
aside branches) and desktopChosen's probe path (served picks only);
aliased is reached through unprefixed and DesktopCatalogID
(internal/agent's Desktop settings), which now also read a pick back.
Left as they were, filed as #6983: an unresolved alias of a model that
is no tier's pick (mythos-magpie-<n>, or a Claude alias whose tier has
no pick) still goes to desktopPicked, and Claude Science's scienceTurn
has the same fallback to sciencePicked.

Run on mica, sandbox HOME with Go's caches pinned, at this head
(rebased on 50c5a52db):
- gofmt -l on the changed Go files: no output.
- go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet on
  ./internal/gateway/ ./internal/masking/: ok.
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway/
  ./internal/masking/: gateway ok (932.6s), masking ok (6.5s).
  (masking reads the routing reference). Same green at the earlier base
  a922e3864 (934s) and 4a1ac8442 (943s).
Red on the old code (origin/main's desktop.go, aliasClaude stubbed to ""
so the tests compile), on mote: TestDesktopAliasOfTierPickLeftOutOfCatalog
(aliased/unprefixed keep the alias), TestDesktopClaudeAliasGoneTakesItsTier
(went to "other/some-model" by "desktop-gone") and
TestDesktopAliasLeftOutRoute (the opus session's turn sent upstream as
"some-model"); all four green with the change.
Broken by hand, each red: group skip removed
(TestDesktopAliasSkipsGroupPick: "a deleted group's alias read as
group/gone"); aliasClaude fallback removed from desktopTierTurn
(TestDesktopClaudeAliasGoneTakesItsTier); later tier's number not read
(TestDesktopAliasOfTierPickLeftOutOfCatalog).

At the pushed head (rebased onto 4b8c5948e: 6c6d3bc84 changes Codex search in
internal/gateway, 4b8c5948e GUI files only), on mica:
- at 7ba7f26e8 (parent ae94571d7): go test -timeout 45m -count=1
  ./internal/gateway/ ./internal/masking/ ok (gateway 1013.2s, masking
  6.6s); go vet ./internal/gateway/ for darwin, linux and windows ok.
- after the rebase: go test -run "Desktop|CodexSearch|WebRun"
  ./internal/gateway/ ok; vet for darwin, linux and windows ok; gofmt -l
  clean.

Not tried: a real Claude Desktop session while Copilot's list lacks its
Claude models (the route test through Server.Handler stands in);
go test ./... and the GUI suite (no GUI file changed; both machines were
running other sessions' full and GUI suites).

Co-authored-by: mdwsk88 <11055210+mdwsk88@users.noreply.github.com>
2026-11-18 00:04:34 +08:00
yetone 6c6d3bc842 gateway: Codex's web.run goes to a relay set to search by itself (YIXIE233 on X)
YIXIE233's GPT relay serves /v1/alpha/search itself, but Codex's web.run
(<base>/alpha/search) only went upstream for ChatGPT accounts; for every
API-key provider magpie ran its own searcher. The per-provider "Searches
the web by itself" switch (search=yes, Advanced > Web search, default
off) already sent Responses' web_search tool and Claude's WebSearch
through as sent; now it covers web.run too.

- relaySearchers resolves the model's provider, or a routing group's
  members in order (the leading candidate decides, as for the request).
  A provider qualifies when it has search on, is an API-key provider
  (not a ChatGPT account, not a plugin) and has a Responses base.
- The search goes to that base's /alpha/search with the provider's key,
  Codex's headers, originator and the agent's User-Agent.
- If the relay fails, magpie searches in its place and the output says
  "X's web search failed (why); magpie searched in its place."
- Settings' "magpie searches for every model" still overrides it.
- GUI help text, every language, names web_search and web.run; the CLI
  help, docs/reference.md and docs/subsystems/gateway-routing.md say so.

Tests: TestCodexWebRunGoesToRelayThatSearches and
TestCodexWebRunInGroupFollowsLeadingMember are red on the old code
(magpie's searcher answered). TestResponsesWebSearchToolToRelayThatSearches
guards the web_search pass-through. provider-search.test.cjs covers en,
zh, zh-TW, ja, de in both engines and at 400px (no sideways scroll).

Run (mica): gofmt clean; go vet, GOOS=linux and GOOS=windows vet ok.
Full go test ./... -timeout 45m before the rebase: 102 packages ok, only
internal/gui TestCoreScriptBudget red (app.js 22 bytes over); fixed by
shortening the English help key (net -2 bytes), budget not raised.
At 64c5e1e0a (on origin/main d4af0ca4f; then rebased over ae94571d7, a Library change, and the gui budget tests rerun ok): internal/gateway,
internal/gui and internal/cli ok; provider-search, i18n-keys and
images-codex-one GUI files 72 pass, 0 fail.
Whole GUI suite (two runs on mica, under other sessions' load): reds in
30 files, none touched by this change. The 26 files run alone on
origin/main d4af0ca4f are red there too (154 tests; filed in #6975,
#6934, #6709); header-centre (#3479) and icon-tile (#6759) are red on
main too. images-codex-one was red only under load and passes alone
at the pushed head.

Not tried: a real relay serving /alpha/search (tests use a local fake);
a plugin-served provider (excluded on purpose).
2026-11-17 23:50:29 +08:00
yetone ae94571d70 library: a project's own instructions, in the file each agent reads
@VictorHong1022 on X asked to manage AGENTS.md per project beside a
project's skills, so the shared instructions keep only general rules.

A project in the Library now has instructions of its own (the
Instructions tab, expand a project; `magpie library project
instructions <dir>`). magpie writes them into the project file each
picked agent reads there, by that agent's own name for it: Claude Code
CLAUDE.md (or .claude/CLAUDE.md when that is the one there), Codex and
pi their override first, Gemini GEMINI.md (or its context.fileName),
Qwen QWEN.md, CodeBuddy CODEBUDDY.md, the rest AGENTS.md. magpie owns
only a marked part (<!-- magpie:begin … --> to <!-- magpie:end -->):
the user's own text around it is kept byte for byte, CRLF included, a
hand edit of magpie's part stays until the project's text changes, a
file magpie made is listed in the repo's .git/info/exclude and removed
when emptied, and an agent's user-wide instructions file is refused.
Worktrees of the project follow it. A first text goes to the agents
the shared instructions are on for, else every agent here that reads a
project file. Problems show as the project's "instructions" problem.

Tested:
- internal/library: 8 new tests (block kept around user text, CRLF,
  hand edit kept, made file excluded and removed, renamed files,
  global file refused, worktrees). Four broken by hand, each red.
- internal/cli: TestLibraryProjectInstructionsCmd; red with the
  default agents dropped.
- GUI: project-instructions.test.cjs, en and zh, chromium and webkit,
  6 of 6. Red when Goose (no project file) was offered, and red when
  the defaults ignored the agents the instructions are on for.
- Real use on mote: the built binary, sandbox HOME and project. add,
  text, agents; CLAUDE.md kept CRLF with the part appended; AGENTS.md
  and GEMINI.md made and excluded; the user-wide CLAUDE.md untouched;
  zed refused; an edited part survived `library sync`; `agents none`
  put CLAUDE.md back byte for byte, removed the made files and
  emptied the exclude block.
- Full Go suite (go test ./... -timeout 45m) on mote: 103 packages ok,
  gofmt clean, go vet darwin, linux (nogui) and windows rc=0, at this
  change on origin/main 873b1f7d5.
- At dbb7230ae (rebased on d4af0ca4f), on mote: gofmt clean; go vet
  darwin, linux (nogui) and windows rc=0; go test internal/library,
  internal/cli, internal/gui and internal/testenv ok; node --test
  site/*.test.mjs 133 of 133. Not the whole Go suite again: of the
  commits that came in, only backup_cmd.go and main.go in internal/cli
  touch a package this change does, and its tests pass.
- The 89 Library GUI files (library-*, lib-*, project-*, skill-proj*,
  i18n-keys) at dbb7230ae on mote, both engines: 1868 of 1876. Red:
  library-open-again's 6 at 1100px, red alone at origin/main 28f27e07b
  too (#6751); library-new-skill's chromium en 420 timed out waiting for
  "taken" under the parallel run and passed alone at this head.
- Rebased again on 28f27e07b (three commits, one internal/cli test):
  go test internal/cli and internal/library ok on mote, and
  docs-index.mjs leaves the generated site files unchanged.
- Site: node docs-index.mjs regenerated llms-full, search and
  docs-index.sums at the rebased head; node --test site/*.test.mjs
  133 of 133.
- Full GUI suite (make test-ui, both engines) on mote at 873b1f7d5's
  rebase, beside other sessions' runs at load up to ~100: 28532 tests,
  1156 red in 133 files, none of them project-instructions. 115 files
  are #6975's, red at origin/main. Run alone at this change and at
  origin/main 8e1534f5f, the other 18 give the same result at both:
  16 green, name-suffix-remote red (#5147), library-env red. Recorded
  on #6975.

Not tried: a real Cursor, Copilot or Gemini session reading the files;
the library tests on Windows or Linux (cross vet only). Cursor and
Copilot read both CLAUDE.md and AGENTS.md, so picking Claude Code and
them together can show them the text twice.
2026-11-17 23:37:54 +08:00
yetone 28f27e07b7 editor: a provider's warm-up or check-in that is on opens its Advanced (ChrisYagao on X)
ChrisYagao on X asked where his warm-up went. Nothing was lost: warm-up
moved from Settings into each provider's editor (11-09), then into that
editor's folded Advanced (11-10), so a warm-up that was on vanished from
sight with no trace of where it went.

Fix: the editor's Advanced opens on its own while that provider's
warm-up (on reset or daily times) or daily check-in is on
(provPrefsOn), unless the reader opened or closed it by hand, the same
rule as Routing's Advanced. renderWarmAtOwn moves into the lazily
loaded autoresetown.js (warmAtOwnPaint), so app.js and the core script
budget each drop by 1,529 bytes. reader.cjs's openProvPrefs waits for
the modal's animations to end before measuring (warm-at-times WebKit
900px measured mid-animation, 0.66px overhang).

Old data: no setting changes and nothing migrates; a warm-up that was
on shows again the first time its editor opens.

What was run:
- warm-advanced.test.cjs (new): red 10/10 on the old app.js
  ("codex, warm up on reset: Advanced open"), green after; chromium and
  webkit, en zh zh-TW ja de.
- At the pushed head (rebased on origin/main), on mica: warm-advanced,
  warm-at-times, warm-at-own, warm-now, quota-warm, plugin-checkin,
  editor-advanced-align, routing-advanced: 160 passed, 0 failed.
- 29 related GUI files (every openProvPrefs user, warm-*, quota-warm,
  plugin-checkin, routing-advanced, editor-advanced-align,
  codex-auto-reset*, reset-providers, search-mix, model-api-preset,
  i18n-keys, segs-press-redraw, settings-groups) alone on mica: 603
  passed, 31 failed; every red is red at origin/main 8e1534f5f too:
  codex-auto-reset-settings webkit de #4790, i18n-keys "a plugin's
  words are its own" #6877, model-api-preset chromium #5838,
  reset-providers 420px #6196, settings-groups "Spend extra usage"
  #6597, segs-press-redraw currencySegs (filed #6990).
- go test ./... -timeout 45m on mote: ok, no FAIL. After the rebase,
  go test ./internal/gui/ (budgets) on mica: ok.
- GOOS=linux go vet -tags nogui ./... ok, GOOS=windows go vet ./... ok,
  gofmt -l clean.

Not tried: the whole GUI suite ran once only, by accident, at an
earlier head before the reader.cjs fix, under load on mica (24,676
passed, 3,151 failed); those reds can't be attributed and are not a
record for this head. Not tried in the real app with ChrisYagao's
settings.
2026-11-17 23:27:42 +08:00
yetoneandmdwsk88 fe41216b01 claude-desktop: Claude Code's WebSearch runs on the model picked for haiku (#6348)
In Claude Desktop's gateway mode, Claude Code's WebSearch call always went
to the session's model (Opus here, 11-19s a search). Claude Code 2.1.321
sends it to its small (haiku-tier) model only when the remote flag
tengu_plum_vx3 is on, and Desktop sets DISABLE_GROWTHBOOK=1 in gateway
mode, so the flag falls back to off. WebFetch's page summaries already run
on the haiku pick (#5534); WebSearch now does too.

- desktopSearchCall knows the call by its shape only: tools is exactly one
  web_search_* server tool named web_search, and tool_choice is
  {"type":"tool","name":"web_search"}. The prompt is never read.
- desktopMoveTo, for a request Claude Code sent in Desktop, puts it on
  DesktopTiers()["haiku"] when that pick is set, served and not already
  the model asked, recorded as desktop-search. It doesn't change the
  session's recorded model (desktopPicked).
- A subagent's search taken by the haiku pick is Claude Code's helper,
  not the subagent's turn: Desktop's subagent model, effort and turn tag
  leave it (desktopSearchHelper; subagentTurnOf takes the agent, so
  terminal Claude Code is unchanged).
- No haiku pick, or one magpie doesn't serve: nothing changes.
- The Routing page says why (desktop-search, en/zh/zh-TW/ja/de), and
  gateway-routing.md has the rule.

Ported from mdwsk88's f68197aa6 (mdwsk88/magpie
desktop-websearch-haiku-tier), reviewed line by line. Changed in the port:
the gateway-routing.md conflict was merged onto main's text (main's
codex-suggestions kept), and the cheap pre-check is bodyHas on
`"tool_choice"` and `web_search_` instead of bytes.Contains, since
desktop.go no longer imports bytes on main (the patch didn't compile
there) and every Desktop request from Claude Code takes this check.
web_search_* is kept as a prefix, so a newer search tool version
(web_search_20260209) is matched as the same call.

Run on mote (go1.26.8). Whole packages last at base 659e8850a (also
fefe3f658, 05d46f42e, 4a1ac8442 before; all ok):
- go test -count=1 -timeout 45m ./internal/gateway/ ./internal/gui/: ok
  (gateway 949s, gui 218s at 659e8850a).
- After rebasing on 50c5a52db (backup, touches internal/gui):
  go test ./internal/gui/ ok, and the focused gateway run below ok.
- Focused -run '^(TestDesktop|TestClaudeDesktop|TestSubagentTurn)': ok.
- Broken by hand, each red: the search rule removed (old routing) ->
  TestDesktopWebSearchHaiku, ...KeepsSessionPick, ...Route fail; the
  Claude Code guard removed -> TestDesktopWebSearchScope fails; the
  subagent helper exemption removed -> TestDesktopSubagentWebSearchIsHelper
  and TestDesktopWebSearchRoute fail.
- node --test routing-moved-why, i18n-keys, i18n-en-no-cjk (chromium and
  webkit): 37/38; the one red is i18n-keys "a plugin's words are its
  own" on ", with an image", red on origin/main and filed as #6877.
- gofmt -l: clean. GOOS=linux go vet (-tags nogui and without) and
  GOOS=windows go vet on ./internal/gateway ./internal/gui: ok.

Not tried: a real Claude Desktop session's WebSearch; the reporter's
routing log will show it landing on the haiku pick.

Co-authored-by: mdwsk88 <11055210+mdwsk88@users.noreply.github.com>
2026-11-17 22:56:55 +08:00
yetone 50c5a52dbd backup: a backup file carries the usage history, and a restore merges it (JasonLeeForOnly on Discord)
JasonLeeForOnly moved magpie to a new server with magpie backup / magpie
restore and lost every call's usage history: a backup file held the setup
only.

- backup.WithUsage puts usage.jsonl's whole lines (gzipped, usage.LogBackup)
  and the quota history (gzipped) in Bundle.Usage. magpie backup and
  Settings -> Sync -> Export add it unless --no-usage / the tick says no.
  Collect never does, so sync, join and automatic backups are unchanged.
- Restore (Parts.Usage, on in All; magpie restore --no-usage and the Import
  tick turn it off) merges: usage.MergeLog appends the lines the log here
  doesn't have, compared byte for byte as a multiset, so restoring the same
  file twice adds nothing and two equal calls both arrive. It reads most
  of the log before the gateway's log lock, the rest under it, and appends
  with O_APPEND in 4MB chunks, after a newline when the log ends in an
  unfinished line. Quota points merge with provider.MergeQuotaHistory.
  A file without usage (older magpie, or --no-usage) restores as before.
- Result.Usage is the calls added; the CLI and the Import form say it.
- Docs: sync-backup.md, reference.md, site sync pages (en, zh, ja) and the
  search index/llms-full.txt rebuilt with node docs-index.mjs.

Not changed: where usage is also shared by sync, the old computer's calls
are in usage-others and, after a restore, in this log too: filed #6987.

Run on mote at this head (26f69e85e rebased on origin/main 4a1ac8442):
- gofmt -l clean; go vet (darwin), GOOS=linux go vet -tags nogui,
  GOOS=windows go vet for backup, usage, cli, gui; GOOS=linux go build
  -tags nogui and GOOS=windows go build of the app.
- go test -count=1 -timeout 45m ./internal/backup/ ./internal/usage/
  ./internal/cli/ ./internal/davsync/ ./internal/provider/ ./internal/gui/:
  all ok.
- GUI (Chromium and WebKit, 5 languages, 1100/420px): sync-*.test.cjs,
  i18n-*.test.cjs, auto-backup.test.cjs: 245 pass, 1 fail, i18n-keys'
  "a plugin's words are its own" over claude_image_budget_test.go, red on
  origin/main and filed as #6877.
- Real use: a built magpie on mote, two sandbox HOMEs, a copy of a real
  105,815-line usage.jsonl (47MB): magpie backup wrote a 9.1MB file in
  1.9s (364 bytes with --no-usage); magpie restore on a home holding the
  last 1000 of those calls added 104,815 in 0.5s, the sorted log then equal
  to the old one; a second restore added 0; the --no-usage file changed
  nothing; magpie usage read the merged log.

Broken by hand, each red: MergeLog without the multiset skip
(TestBackupCarriesUsageHistory); no newline before the
first appended line (TestUsageMergeKeepsLinesWhole); WithUsage not setting
Bundle.Usage (both tests). The Import form's tick check first sat after
the Import click and went red in WebKit; it now runs before the click.

Not tried: the GUI's export and import against a real gateway (the GUI
tests use a fixture API); the full go test ./... and the whole GUI suite,
since mote and mica were each running other sessions' full suites.
2026-11-17 22:41:26 +08:00
yetone 659e8850a2 gateway: a routing group named for a model is listed by that id when the model's own row isn't (小八 on Discord)
v0.1.4377, Settings › Network and sharing › Model ids without the
provider = Only: group/glm-5.2, group/glm-5.3, group/glm-5.3-flash,
group/deepseek-v4.1-flash-1017 and group/sensenova-6.8-flash kept their
prefix while other groups lost it (3126b0bac). Each is a group the user
made, named for a model a provider serves.

Cause: groupBare refused a group's own id whenever any provider entry
(providerEntries, not the shown list) served a model by it, on the
reasoning that the provider's glm-5.2 row would carry the bare id to
the group. That row isn't always shown: a group that lists its members
alone (Group.Unlists), a provider kept for routing groups
(Provider.Unlisted) and an agent's hidden models all keep it out of
/v1/models. Then nothing carried glm-5.2, and the group stayed
group/glm-5.2. The check is gone. bareTarget already requires that a
request for the id reaches this very group (the gateway routes a bare
id GroupFor before Resolve: groupForIn tries a group of that exact id
first), and when the model row is shown its bare id reaches the group
first (BareEntries' reached), so the id is still listed once.

The other way it could stay prefixed, a shown row whose ID is already
"glm-5.2" (ids[id]), isn't real: every provider entry's ID is
provider/model (sharedEntry) and every group's is group/<id>.

Run (mote, mote-run, waited for load under its cores; at
4a1ac8442 + this change, origin/main unchanged since):
- go test -timeout 45m -count=1 ./internal/provider ./internal/gateway:
  ok (158s, 1158s)
- GOOS=linux go vet -tags nogui ./...: ok; GOOS=windows go vet ./...: ok
- gofmt -l on the changed Go files: nothing

Broken by hand: the new TestBareIDsListGroupNamedForAModel (a group
glm-5.2 of b/glm-5.2 and a/glm-5.2, listing its members alone) at the
old bare.go fails "on: [group/glm-5.2 auto/glm-5.2 a/other-a other-a],
want glm-5.2 once". With the fix, under Only glm-5.2 is listed once in
group/glm-5.2's place, GET /v1/models/glm-5.2 answers, and a chat
request for glm-5.2 (and group/glm-5.2) reaches the group's first
member, b, not a as Resolve would.

Not tried: 小八's own providers.json (which of the three ways hides
their model rows is not known; Unlists is the one tested); a real
client against a running magpie; the full ./... suite and the GUI
suite (no GUI file changed); Windows and Linux runs beyond vet.
2026-11-17 22:34:51 +08:00
yetone 3fbade47ab gateway: a found group gone with a provider still goes to its model (canlee886)
canlee886 on X (2122660479411855365): a Codex App thread saved on
group/auto-gpt-6-1-sol failed every turn with 404 "magpie knows no
model", followed by every id magpie has, after azure-fte2-sea's
gpt-6.1-sol went away; other threads were fine, and switching the
thread's model did not help. The user patched the thread over Codex's
app-server RPC.

Cause: a group magpie finds needs two providers serving the model
(autoGroups). When one is removed, or its list no longer has the model,
the group is gone. Reseat moves an agent's config off it, but a Codex
thread keeps the model it was saved with and names it on every turn.
provider.AutoStandIn sent a gone found group's id to its model only
while found groups were off, or when a provider kept out of them took
it away; any other way of losing the group was a hard 404, even with a
provider still serving the very same model.

Fix:
- AutoStandInFor: with found groups on, a found group's id (group/auto-…
  or auto/<model>) that is no group now, and that the user neither
  changed nor removed (no providers.json record), goes to its model from
  a provider that serves it (the agent's own subscription first, then
  one not kept out, then the first). It is the same model, never
  another; a group the user removed stays a 404.
- With no provider serving the model, the request is still 404, but
  unknownModel says the model is gone and to pick another for the
  conversation (Codex: the model menu under the message box), with the
  three nearest ids, not every id (provider.GoneAutoGroup).
- Codex's compaction on the model a thread is leaving
  (model_downshift) already compacts locally when that model 404s
  (2768f04f9); TestCodexLeavingGoneGroupCompactsLocally pins it for a
  gone group.
- docs/subsystems/gateway-routing.md says when a found group can go and
  what a request for it gets.

Siblings: the stand-in is in serve's model resolution, so Claude Code
and every other agent saving the id are covered, as are key limits,
count_tokens, budget and Codex's own-v1 path, which already ask
AutoStandIn.

Run (mica/mote via mica-run/mote-run, at this tree):
- TestFoundGroupGoneGoesToItsModel: red on the old code (404 "magpie
  knows no model ... it has ..." with b still serving gpt-6.1-sol),
  green now. TestAutoGroupSkip's "group/auto-y" case (b's model alone)
  now expects the stand-in b/y; group/auto-nothing still none.
- go test ./internal/provider, ./internal/gateway -run of the
  group/stand-in/Codex compaction tests: ok.
- Full suite at 473de21fa (this change on fefe3f658's parent base) on
  mote, mote-run: gofmt -l nothing; GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go vet ./...: ok. go test -timeout 45m
  -count=1 ./...: 101 packages ok, internal/gateway (1035s), agent,
  provider, gui, cli, budget among them. Two reds, neither touched here:
  internal/plugin's TestHostOnUnstartableBunSaysWhy (62s deadline, #5878)
  and internal/redact, whose tests passed and whose TestMain then hung
  46m in testenv.RemovePrograms on stand-in warm-ups (#5267, SIGQUIT at
  47m); both commented with the output.
- After the rebase onto origin/main (fefe3f658, which changed
  internal/provider/bare.go and internal/gateway), on mica: gofmt -l
  internal nothing; go test ./internal/provider ./internal/gateway: ok
  (149s, 1004s). On mote: ./internal/plugin ./internal/redact alone: ok.
- Rebased again onto 05d46f42e (gateway advisor, agy move; no file
  shared): go vet and go test -run
  "FoundGroup|Gone|AutoGroup|StandIn|Advisor|Unknown|Compact|Group" of
  ./internal/gateway ./internal/provider on mote: ok.

Not tried: the reporter's real Codex App thread and Azure providers;
the fixture removes the model from a provider's list rather than
reproducing why azure-fte2-sea's list lost it.
2026-11-17 22:00:51 +08:00
yetone 05d46f42e5 gui: Claude's menu bar cards can show Anthropic's A\ mark (qingnianxiaozhe on X)
qingnianxiaozhe asked for Anthropic's A\ in the menu bar in place of
Claude's logo. Settings › Usage › Menu bar Claude logo (Mac only, shown
while logos are on and a ticked card is Claude's, under the magpie icon
row) picks Claude's logo
(the default, unchanged) or the A\.

- settings.TrayAnthropicMark, kept per computer through KeepOwn like the
  other menu bar choices; settingsapi.Keys saves it; a change wakes the
  menu bar (onTrayUsage).
- trayAnthropic swaps the icon of cells whose card logo is claude-color
  or a plugin's claudecode-color (trayCell.Logo) for trayAnthropicMark,
  an SVG drawn here (two paths, no other app's bytes), and marks it mono
  so mpGlyph paints it in the bar's text colour. Menu bar logos off
  wins.
- The row's code is trayClaudeRow in traywindows.js (lazy). app.js only
  adds the key to prefsKeep; to stay in TestCoreScriptBudget without a
  raise, renderTrayUsage's no-card branch moved into trayWindowsRow,
  which now hides Windows' figure row itself when no card is ticked.
- en, zh, zh-TW, ja, de strings; docs/subsystems/gui-shell.md bullet.

Tests: TestTrayAnthropicMark (which cells change, input not mutated,
plain cells stay plain), TestTrayAnthropicMarkSVG,
TestTrayAnthropicMarkSaved (POST as the page does, saved and woken once
per change), TestTrayImageAnthropicMark (darwin: renders the real
AppKit image light and dark, the logo rect differs, the rest of the
image is identical), tray-anthropic-mark.test.cjs (five languages, 900
and 400px, Chromium and WebKit: row, two logos, default Claude, A\
posts true, another setting's save keeps it, back to false, no row with
no Claude card / logos off / no card / Win32, no page errors, no
sideways scroll). The GUI test waits for the redraw after a save rather
than a fixed time: a click on a control drawn before the save lands
sends the old value back (any setting, not new here).

Broken by hand: trayAnthropicMark taken out of prefsKeep turns the GUI
test red ("a save of another setting keeps the A\") in all languages;
taken out of settingsapi.Keys turns TestTrayAnthropicMarkSaved red.

Run:
- mica, at 2fa9295ed (this tree less the doc bullet): go test -timeout
  45m -count=1 ./... : 103 ok, exit 0.
- mote, at this head's code: gofmt -l clean; go vet ./...;
  GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./... ok;
  internal/settings, settingsapi, davsync ok; internal/gui -run
  "Tray|CoreScript|Budget|EveryRoute" ok.
- mote GUI, Chromium and WebKit, the 20 files that touch the menu bar
  rows, Settings search or prefs (tray-*, settings-search, side-effort,
  searcher-pick, quota-pace, proto-menu-overflow, classify/image-timeout,
  i18n-*): tray-bird first went red (its row must follow the logos row),
  so the Claude row sits after the magpie icon row. side-effort is 5/5
  red in both engines on origin/main a922e3864 too (#6353).
- After rebasing on a922e3864, at this head: gofmt clean; go vet
  internal/gui, settings; go test -run Tray|CoreScript|Budget|EveryRoute|
  Settings internal/gui, settings, settingsapi ok; tray-anthropic-mark,
  tray-bird, tray-logos, tray-windows, tray-usages, settings-search 51/51
  in Chromium and 51/51 in WebKit.
- i18n-keys: "a plugin's words are its own" red, the same on origin/main
  (routing's ", with an image" in claude_image_budget_test.go), #6877.
- Real AppKit renders of the menu bar image (trayImagePNG, light and
  dark) looked at: "A\ 42%/18%" reads at 14pt.

Not run: the whole GUI suite (mote and mica each had another session's
full GUI suite running); the files above are the ones this can reach. Not tried: a screenshot of the live menu bar of a built app.
2026-11-17 21:50:54 +08:00
yetone d54b7acf43 gateway: Claude Code's dashed advisor id goes upstream as the provider names it
Refeccd (Discord, v0.1.4366): Claude Code with Opus 5.5 as the model and
Fable 5.2 as the advisor, both on one provider; the advisor's turns came
from Opus and Routing showed no Fable request.

Claude Code 2.1.316 (real binary, sandbox HOME, a fake upstream) never
sends a request of its own for the advisor: it is the server tool
{"type":"advisor_20260301","model":"relay/claude-fable-5-2"} inside the
main request, with settings.json's advisorModel as written. magpie writes
a dotted Claude id dashed (ClaudeSpelled), and the gateway took the main
model back to the served id (validateModel) but not the advisor's. On a
provider listing claude-opus-5.5 and claude-fable-5.2 the request went
upstream as model claude-opus-5.5 with advisor claude-fable-5-2, a name
the relay doesn't know.

advisorID now takes the advisor's model to the served id as a request's
own model is (ClaudeUndashed, then unflat and CanonicalRef), and drops
[2m] beside [1m]. Every reader of it goes through it: advisorModel
(passthrough name), advisorKeyModel (key limits), advisorAsked
(advisedHere, advisedInBridge) and readAnthropic's Request.Advisor
(magpie-run advice).

Run (on mica):
- go test -count=1 -timeout 45m ./internal/gateway/: ok at 38babcb13
  (this change on efcf8d9c0), and before at d67ccbd3c and 8e1534f5f
- rebased since onto a922e3864, which adds only internal/library,
  internal/agent/dsh.go and internal/provider/agy_move.go: at this head,
  go test -run Advis ./internal/gateway/ ok, and GOOS=linux and
  GOOS=windows go vet ./internal/gateway/ ./internal/provider/ ok
- gofmt -l internal/gateway: clean
- GOOS=linux and GOOS=windows go vet ./internal/gateway/: ok

Broken by hand: advisorID returning the trimmed id as before makes
TestAdvisorModelAsTheUpstreamNamesIt's new "a dotted id as Claude Code
names it" case red: advisor sent as ["claude-fable-5-2"], want
"claude-fable-5.2", the reporter's shape.

Not tried: the reporter's own relay. magpie still doesn't read
usage.iterations' advisor_message entries, so a passthrough advisor run
at the vendor shows no Fable row in Routing; that is by design of the
server tool, not changed here (#6977).
2026-11-17 21:48:13 +08:00
yetone 3126b0bacd gateway: with model ids without the provider on, a routing group the user made is listed by its own id too (小八 on Discord)
"路由组的外显模型名可以选择去掉 group/ 这个前缀吗": with Settings ›
Network and sharing › Model ids without the provider on, /v1/models
listed a user's routing group only as group/<id>, though the gateway
already takes a request for its bare id (GroupFor). BareEntries skipped
every group row. Now a group the user made adds a row by its own id
(fast beside group/fast; under Only in group/fast's place, through
OnlyBare as before), and GET /v1/models/fast and Ollama's lookup answer
it (BareEntry). Only where the id is the group's alone: not when a
provider serves a model by it (the model's bare id is listed, reaching
the group as the gateway routes it), when it is listed already, when
GroupFor of it reaches another group, for a group magpie found (its
auto/<model> row is already listed under the model's bare id), or for a
group a gateway key can't use.

Agents: unchanged. magpie still writes group/<id> into an agent's
config, as it writes provider/model under Only; the gateway takes either
id, so turning the setting on or off rewrites nothing. The Settings help
text says nothing that is now false, so i18n is unchanged.

Run (mica, mica-run, mote over 18 cores):
- go test -timeout 45m -count=1 ./internal/provider ./internal/gateway:
  ok (152s, 1059s)
- GOOS=linux go vet -tags nogui ./...: ok; GOOS=windows go vet ./...: ok
- gofmt -l on the changed Go files: nothing
- After the rebase onto origin/main: TestBare in internal/gateway again.

Broken by hand: with bare.go at its old version, TestBareIDsListUserGroups
fails "on: [... glm-5.3 only-a only-b], want [...] and then fast once".
With the found-group and already-reached checks taken out of groupBare /
BareEntries, it fails listing "auto-glm-5-3".

Not tried: a real client against a running magpie; the full ./... suite
and the GUI suite (no GUI file changed); Windows and Linux runs beyond vet.
2026-11-17 21:10:26 +08:00
yetone 8e1534f5f9 sessions: read LiveAgent's sessions (#6741)
Usage › Sessions and the Sessions page now list LiveAgent's sessions
with their title, time, model, tokens and cost, and show their
conversation.

- Where: K-brain keeps each session at
  <root>/sessions/<project>/<id>/session.jsonl (older ones right under
  sessions/). sessions/.runs and sessions/.deleted-history are skipped.
- Root: $LIVEAGENT_HOME, then $K_BRAIN_HOME, then
  ~/.liveagent/data-dir.json, then ~/.liveagent. The rule now lives in
  sessions.LiveAgentDirIn, and agent.liveAgentDir calls it, so it has
  one owner.
- Reading: K-brain rewrites the file whole, so it is parsed whole. The
  first line is session_meta (id, title, cwd, running totals).
- Tokens:
  - Each reply's own usage counts on the day it came back.
  - What the totals (model_usage, else usage_in/usage_cached/usage_out)
    hold beyond those replies, such as a compaction's call or a rewound
    reply, counts on the last message's day, together with sub_usage.
  - Cache reads and writes are taken out of prompt_tokens.
- Forks: a fork's copies of its source's messages (seq <= fork_seq) are
  the source's, and count in neither the fork's messages nor its totals.
- Subagents: a subagent's own session (task-<parent>-<task>, task_id
  set) is filed under its parent with its activity, but no tokens,
  because its spend is the parent's sub_usage already.
- Not added:
  - a Calls reader: the gateway's own record of LiveAgent's calls
    carries no session id, so it would count them twice;
  - resume and delete: LiveAgent has no resume command.
- Skills: SkillsManager read (skill://<name>/SKILL.md) and Read of a
  skill path are counted.

Run (mote, mote-run, at d67ccbd3c plus this change before the rebase):
- go test -count=1 -timeout 45m ./internal/sessions ./internal/agent
  ./internal/library ./internal/agentenv ./internal/gui: all ok.
- go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: clean. gofmt -l: clean.
- TestEveryAgentSaysItsSkills has liveagent →
  TestLiveAgentSessions.

Again after the rebase on 3be322fe4 (mote): ./internal/sessions,
./internal/agent, ./internal/library ok; GOOS=linux -tags nogui and
GOOS=windows go vet ./... clean.

Broken by hand (mote), each red:
- Without parserFor's liveagent case: TestLiveAgentSessions (0 listed)
  and TestLiveAgentTranscript.
- Without subtracting a fork's copies: fork1 tokens 600/140/1000 for
  want 400/40.
- Without subtracting the replies already counted: abc123
  3500/550/2000 for want 2500/350/1000.

Fixtures: the issue's literal session_meta, with its placeholders
filled in (12786068 in, 12455808 cached, 103572 out →
330260/103572/12455808). The message, snapshot and compaction lines
follow K-brain's record types as its source writes them.

Not tried: no real LiveAgent install. The files were not written by
LiveAgent itself, and no real session was read. Imported sessions
(ImportHistory) are listed as they are. No GUI file changed, so no
GUI tests were run.
2026-11-17 20:56:30 +08:00
yetone 5622149331 gateway: a relayed Messages request whose tool exchange doesn't pair is mended (miwanzi on Discord)
Claude Desktop through magpie, several conversations at once: a
conversation died with "Invalid request … 400 due to tool use concurrency
issues", which Claude Code shows when the upstream answers 400 with
"messages.N: `tool_use` ids were found without `tool_result` blocks
immediately after" or "unexpected `tool_use_id` found in `tool_result`
blocks", and every later turn carried the same history, so it stayed
stuck. pairToolBlocks mended only a translated request (buildAnthropic);
an Anthropic client's own body relayed to a Messages upstream went as it
came.

toolBlocksPaired (tool_blocks_paired.go) mends it in passthrough's
Anthropic case (an API key, a relay, a plugin's fetch) and before
count_tokens, by pairToolBlocks' rule: a call the next message doesn't
answer gets the synthetic interrupted result (is_error), first in the
user message after it or in one of its own; a result answering no call of
the message before becomes the text it said; a second answer is dropped;
a result after other content of its message goes first. It works on the
raw bytes: a body whose exchange pairs comes back byte for byte (nothing
decoded into maps, nothing marshalled), and a mended body keeps every
message it didn't change, and every other member of one it did, as they
came. A Claude subscription's turn goes through the bridge, which writes
the history as text, so it was never refused for this and isn't touched.

Cause: nothing found in magpie that makes such a history. Salted call ids
(tool_use_ids.go) unsalt id and tool_use_id alike, and a stream cut
mid-reply gets an error event, not a made-up block. A reply cut or failed
after a tool_use block was told (an upstream drop or overload under
parallel load, or the user stopping it while parallel calls run) leaves
the client a call with no result; the mend is what un-sticks it.

Tests (vendor's literal refusal texts through validateExchange):
TestToolBlocksPairedLeavesAPairedBodyAsItCame (Claude Code body with
cache_control, thinking, &, key order: same bytes),
…AnswersACutCall, …OrphanResultBecomesText, …CallsWithNoUserTurnAfter,
…SecondAnswerAndOrder, TestMessagesRelayMendsABrokenToolExchange (relay
to a fake that refuses as Anthropic does: 200; a paired request reaches
it with the client's bytes), TestCountTokensMendsABrokenToolExchange.

Broken by hand:
- the two call sites taken out: the relay and count_tokens tests red with
  "messages.2: `tool_use` ids were found without `tool_result` blocks
  immediately after: toolu_01B".
- toolBlocksPaired decoding and re-marshalling every body: the byte tests
  (unit and relay) red.

largeConversation's Anthropic fixture replaced the last call's answer
with "go on", so its last call went unanswered, which Anthropic refuses;
the mend changed it and TestUpstreamBodiesUnchanged/large-anthropic(-group)
went red. Its user's words now follow the answer, as the Chat fixture's
do since 43001be86, and the two hashes were written again. They come out
the same with the call sites taken out, so that paired large body is
relayed byte for byte with and without the mend.

Run:
- mica (macOS), at 5e4bbf0ce (this change before the rebase onto
  f9492fd8e and before the fixture change): gofmt -l clean, go vet ./...
  ok, GOOS=linux go vet -tags nogui ./... ok. Its GOOS=windows vet and
  gateway tests stopped on "no space left on device" (mote and mica both
  had under 1 GB free, other sessions' files).
- xiaomi-gpu, native Windows, at the rebased head before the fixture
  change: go vet ./... ok.
- WSL magpie-desktop (Linux), rebased on f1a4de736: go vet and
  GOOS=windows go vet ./internal/gateway/ ok, go test -count=1
  -timeout 45m ./internal/gateway/ ok (1097s); the same at the
  f9492fd8e base (1135s).
- At the pushed tree (rebased on 3be322fe4, whose ff28dc6bd changed
  gateway.go away from these lines): go vet ./internal/gateway/ ok and
  -run "ToolBlocksPaired|MendsABrokenToolExchange|
  TestUpstreamBodiesUnchanged|TestMessages|ToolPair|TestAnthropic|Cap|
  Near|Round" ok; the whole package not again. The run before the
  fixture change was red only on the two large-anthropic cases (above);
  its log shows #6339/#6505/#6690's doneHold panic, no test failed for it.

Not tried: a real Claude Desktop or Claude Code conversation against a
real Messages upstream; the miwanzi history itself (not shared). The
full ./... suite was not run, only internal/gateway; the gateway
tests did not run on macOS (no disk on mote or mica).
2026-11-17 20:53:21 +08:00
yetone 3be322fe4c library: a skill brought in from an agent goes back to it when removed (BeiWeiji on X)
BeiWeiji on X (v0.1.4322, zh): a skill imported from "Agent 中已有"
had no way back, only off or Remove, and removed it was gone from the
agents and from "Agent 中已有" too: Remove sent the folder that had been
moved into the library to magpie's backups and took the agents' links
and marked copies away.

ImportSkill now records where the skill was (Skill.Home, this
computer's own; Put keeps it for the same source, a sync never carries
it): the folder moved in (Home.Dir; handOver points it at the shared
~/.agents/skills place) and each agent's entry, a link with its own
text or a byte copy. RemoveSkill/RemoveSkills put it back (putBack):
the library's folder moves back to Home.Dir with what was changed in
the library, or the library's link goes; each agent's link is made
again as it was and each copy copied back. It is in "In your agents"
again and nothing goes to the backups. An entry the user replaced since
is left alone; when Home.Dir is taken the skill is removed as before,
its folder to the backups. This covers every agent with a skills folder
(the record is per agent entry, links and copies alike).

The page: SkillView.back lists those agents, and such a row has Put
back in the trash's place ("放回 {agents}"), whose sheet says where it
goes and sends skills/remove. Other skills keep the trash.

Old imports: a skill brought in before this has no Home record.
Removed, its folder goes to magpie's backups as before, where it can
be moved back by hand (the reporter's already-removed skill is there).

Run (at this change on acc358f07, then rebased on a75a1fffc and on
d67ccbd3c; the commits between touch no library code):
- go test -tags nogui ./internal/library ./internal/gui on mote at
  this head (d67ccbd3c base): ok; go build ./...: ok.
- Full go test -timeout 45m ./... on mica at the acc358f07 base: exit 0,
  every package ok. Not run again after the rebases.
- GOOS=windows go vet and GOOS=linux go vet -tags nogui: ok (whole tree
  at acc358f07; internal/library and internal/gui at this head).
- gofmt -l internal/: clean.
- GUI: skill-put-back.test.cjs (new) in chromium and webkit, en, zh,
  zh-TW, ja, de at 980px and 400px: ok; remove-found-skill ok;
  i18n-keys: only #6877 (", with an image"), red the same at a fresh
  origin/main copy.
- Whole GUI suite (make test-ui) on mica at the acc358f07 base, beside
  another session's suite (load to 200): 28548 tests, 1060 red in 128
  files. Each red file was run at a fresh origin/main a75a1fffc copy:
  118 files (1039 tests) red there too, filed as #6975 (108 already in
  #6934, the rest with their own issues). The other 10 (editor-advanced-
  align, group-new-head, ledger-swipe, library-problems-hide,
  nav-sub-fold, routing-pulse-composited, search-mcp-library,
  signin-closes-sheet, readable-focus, library-env) pass at this change
  run alone on mote, 150 of 150.
Broken by hand: canPutBack forced false; TestRemoveSkills,
TestRemovedImportGoesBackToTheAgents and TestRemovedLinkedImportGoesBack
went red (TestPutBackLeavesTheUsersNewFolder guards the fallback and
passes either way).
Not tried: a real magpie with real agents (tests run in a sandbox
HOME); Windows junctions and WSL-distro links (a WSL distro agent's own
entry is recorded like any other but not tried there); the link tests are skipped on Windows.
2026-11-17 20:48:59 +08:00
yetone 4f94b8a829 grok: context_window is the model's window; Long conversations goes in auto_compact_threshold_percent (@xiancrong on X)
magpie wrote Long conversations' compaction threshold into each
[model."magpie/..."] table's context_window. Grok Build reads
context_window as the model's whole window and compacts at a percent of
it: auto_compact_threshold_percent in [model.<id>], else [session]'s,
else 85 (xai-org/grok-build 559751fd:
xai-grok-shell/src/util/config/resolve/compaction.rs,
DEFAULT_AUTO_COMPACT_THRESHOLD_PERCENT and
resolve_auto_compact_threshold_percent; GROK_AUTO_COMPACT_THRESHOLD_PERCENT
above all). So a 1M model held to 300K compacted at 255K and never had
its real window.

Now context_window is the catalog's whole window, and where magpie has
it compact (grokCompactAt, the old grokWindow rule: the model's or
provider's threshold, else settings.Working, none under Full window)
goes in as auto_compact_threshold_percent of the window written,
rounded down, at least 1 (grokPercent). None leaves Grok's own 85.
- A table an older magpie wrote with the threshold as its window, on
  record in grok:<path>:windows, gets the whole window back.
- A percent the user set in one of magpie's tables stays: what magpie
  gave is stashed in grok:<path>:percents, and one it has no record of
  giving is the user's (grokOwnPercent). A context_window set by hand
  still stays (grokOwnWindow).
- A [session] auto_compact_threshold_percent is the user's for every
  model, so magpie writes no per-model one over it.

Siblings: Codex (codexcat) already writes context_window and
auto_compact_token_limit apart, and Claude Code has
CLAUDE_CODE_MAX_CONTEXT_TOKENS beside CLAUDE_CODE_AUTO_COMPACT_WINDOW.
Grok App (grokapp.go) writes the model's own window. Only Grok Build
had the threshold in its window key.

Run:
- At cfca72eaf (this change on f9492fd8e), on mica (mote was over its
  cores): gofmt -l clean; go vet ./internal/agent ./internal/settings,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok;
  go test -count=1 -timeout 45m ./... ok, go-exit=0.
- At this head, rebased on f1a4de736 (internal/agent changed in
  6abea5f8e): gofmt, vet and go test ./internal/agent
  ./internal/settings ./internal/gui on mica: gofmt clean, vet ok, all three ok (agent 195s, settings 16s, gui 137s).
- Broken by hand: the new tests run against origin/main's grok.go (with
  a shim for grokHadIn) are red: TestGrokWindowIsTheModelsAndCompactsAtThePercent
  (pro 300000, want 1M), TestGrokKeepsTheUsersCompactPercent,
  TestGrokWindowFollowsLongConversations, TestGrokKeepsAWindowSetBeforeTheRecord.
- Real grok 1.0.67 in a sandbox HOME/GROK_HOME: `grok models` and
  `grok inspect` take a table with context_window = 1000000 and
  auto_compact_threshold_percent = 30 with no config warning (a
  misspelt key is reported as "unknown field", so the check sees it).

Not tried: a real Grok conversation running up to the threshold to
watch it compact at 300K.
2026-11-17 20:34:19 +08:00
yetone f8cd4723cc groups: a model its vendor lists without the maker's name joins its found group (tmr11235 on X)
tmr11235 on X (v0.1.4334): the found group auto/kimi-k3.1-pro had
OpenCode Go's and Devin's kimi-k3.1-pro but not Kimi Code's, which they
had to add by hand. Kimi Code lists the model as k3.1-pro (and K3 as k3),
so SameModel merged it by k3-1-pro, a group of its own.

- catalog.Unprefixed: the model a provider's id is when its vendor left
  the maker's name off, by what the provider's own models.dev catalogs
  say of that very id. models.dev gives Kimi Code's k3.1-pro the
  canonical_model_id moonshotai/kimi-k3.1-pro. The canonical alone never
  merges: it gives k3.1-pro-highspeed kimi-k3.1-pro and k3-256k kimi-k3,
  other models. The id must be the canonical's with a maker's name
  (letters) taken off the front, or go on past it to a model models.dev
  knows by that name before the whole id (k3.1-pro-highspeed is
  kimi-k3.1-pro-highspeed; k3-256k stays its own). No K3.1 or K3 takes
  K3.1 Pro.
- provider.mergeKeyIn reads it after the user's same-as and the edition
  twins, so autoGroups, AutoGroupOf (group_share, reseat, dsh compact),
  offSpreadIn and the Providers editor's Same-as placeholder (MergeName)
  all merge alike; spelledIn takes the unprefixed spelling, so Kimi Code
  with Kimi Code China alone is auto/kimi-k3.1-pro.
- Old data: such a model's old group id (auto-k3-1-pro, from Kimi Code
  plus Kimi Code China) is the found group's Former, so an agent set to
  auto/k3.1-pro is still served by it.

Who else names models this way, from the real models.dev cache: Kimi
Code's two plans (k3, k3.1-pro, k3.1-pro-highspeed), MiniMax models at
relays (ofox minimax/m2-her, cloudflare-ai-gateway minimax/m3.1-flash),
vercel's sakana/namazu. A canonical that is a rename rather than a
dropped prefix (kimi-for-coding-highspeed, canonical
kimi-k2.7-code-highspeed) is not merged; that would need the canonical
to be trusted alone, which it can't be (highspeed above).

Tests, red on the old code (Unprefixed's line taken out of mergeKeyIn:
the Kimi Code members missing from all three groups and the relay's
k3.1-pro grouped with Kimi Code's; the spelledIn line out: the pair
listed as group/auto-kimi-k3-1-pro; the Former line out: auto/k3.1-pro
and group/auto-k3-1-pro unserved): TestUnprefixedAs,
TestFoundGroupTakesAModelListedWithoutItsMaker,
TestFoundGroupOfUnprefixedIDsAloneIsTheModels,
TestFoundGroupTakesKimiCodesPreset (both presets).

Not changed: ownEntry still matches on sameModel. No agent's own
subscription (Claude, Codex, Copilot, ChatGPT API, Gemini, Antigravity)
lists a model without its maker, so there is nothing for it to join.

Run at f8787be1f, these two commits on origin/main f9492fd8e (rebased onto origin/main f9492fd8e,
whose found-group window change, mergeName/windowless, this is merged
with: the unprefixed id is looked up first, then put through mergeName;
MergeName takes the provider, and group_window_test calls it so):
- mote: gofmt -l clean; go test -timeout 45m for root, internal/cli,
  internal/gui, internal/provider, internal/catalog, internal/tui,
  internal/agent: all ok; go vet ./..., GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: ok.
- Full Go suite (go test -timeout 45m ./..., log tee'd) in WSL
  magpie-desktop at 074614077, an earlier base of the same two commits:
  99 packages ok, gateway included. Red: root, internal/cli and
  internal/gui don't build there (no gtk4/webkitgtk-6.0 dev packages;
  they pass on mote above), and internal/usage
  TestRequestStateKeptAcrossACatalogFetchedAgain, red on origin/main
  7c3e68908 too, #6572.
- GUI: group-member-line, group-member-free and the other group-* files
  (10 files) on mote, Chromium and WebKit: 152 pass. The whole suite
  (make test-ui, concurrency 3) in WSL ran about 2,560 tests (files a*
  to codex-*) before it was stopped; 26 files went red, none of them a
  routing page. 23 are red on origin/main f9492fd8e too; 3 pass in a
  run of their own at f8787be1f. All filed in #6973.
- Rebased since onto Gemini, agent, usage and gateway commits that
  don't touch these files; internal/provider and internal/catalog ok
  again on mote, and GOOS=windows vet, at 381076a1f (on b1d5912de).

Broken by hand: each of the three lines named above taken out turns its
tests red, as listed.
2026-11-17 20:21:21 +08:00
yetone 6c31af7ad9 usage: a Fast call is priced at Fast's price, not the standard one (Archivemylife on X)
Every service tier was priced at standard, so a Fast (priority) call
was billed at half its price, and a subscription's API-equivalent
value was half too.

Sources:
- OpenAI, developers.openai.com/api/docs/pricing: gpt-6.1-sol Fast is
  $4 / $20 / $0.20 cached (2x standard $2 / $10 / $0.10); Ultrafast 6x,
  Flex 0.5x. "Priority processing was renamed Fast mode on July 30,
  2026."
- Anthropic, platform.claude.com/docs/en/about-claude/pricing: Claude
  Opus 5.5 fast mode $8 / $40 (2x), "across the full context window".
- models.dev's experimental.modes in magpie's catalog carry the same
  prices: OpenAI's keyed by provider.body.service_tier, Anthropic's by
  speed "fast".

catalog.TierPrice reads those modes, only where the model's base price
is the vendor's own (a relay's or a custom price is left alone). The
Ledger's Pricer and the window's apiPricer both price by the billed
tier: TierServed when the vendor says (Codex's backend always says
auto/default, so servedTierAt keeps it "" and TierSent is used),
otherwise TierSent. The tier ask is noted so a catalog change re-keys
the request index, and settledCountVersion goes to 6 so stored settled
costs are counted again.

Run on mica. The full run was at this change on f9492fd8e; it was then
rebased onto b1d5912de (two commits, Gemini draw and Antigravity
discovery, no file in common). At the pushed head: go vet of gateway,
provider, usage and catalog; go test of internal/agent, usage and
catalog in full; gateway and provider -run Speed|Reasoning|TTFT|
FirstToken|Gemini|Draw|Tier: all ok.
At f9492fd8e:
- gofmt -l: clean
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./..., go build, GOOS=linux go build -tags nogui, GOOS=windows
  go build: ok
- go test -tags nogui -count=1 -timeout 45m ./...: 103 ok, no FAIL
  (usage 108s, catalog 4s), log kept whole and grepped
- Broken by hand: TestFastCallsPricedAtTheirTier on the old ledger.go
  and window_holds.go is red (Codex Fast 0.11 vs 0.22, ledger total
  1.188 vs 2.123); green on the new. Cases: Codex priority 2x,
  ultrafast 6x, standard 1x; API priority served priority 2x, served
  default 1x; flex 0.5x; relay at rate 0.8 unchanged; Claude fast 2x,
  standard 1x; a 300k-input Fast call.

Not tried:
- Long-context Fast is the long-context price times the Fast ratio;
  models.dev lists no long-context Fast price of its own.
- The Usage page was not opened against a real Fast row after the fix.
2026-11-17 20:18:02 +08:00
yetone f9492fd8ed routing: a model offered at a window (claude-haiku-5-5@1m) joins its model's found group (Will on Discord)
Will (0.1.4356, macOS, Cursor plugin) ticked claude-haiku-5-5@1m and
claude-fable-5-2@1m in Cursor: served, but never in auto/claude-haiku-5-5.
Cause: found groups merge by catalog.SameModel, which keeps everything
after an "@" except a snapshot date, so every sized id the Cursor plugin
lists (it lists Claude only as <model>@<size>) and grok's grok-4.7@500k
formed a key of its own and never met the unsized model at another
provider.

mergeKey now goes through mergeName = sameModel(windowless(id)):
windowless drops a window after "@" by the same patterns pricing already
reads as "the same model at that window" (modelWindow @<n>k|m, and Grok's
@<n>). It is the same model at the same price per token, and a group's
members already differ in window by provider, so it joins rather than
needing Same as. One member per provider still: its unsized model when it
lists one (grok-4.7 over grok-4.7@500k), else the first size it lists.
spelledIn lists the group by the windowless id; MergeName (the editor's
Same as placeholder) shows it. A Vertex @20260801 stays a snapshot date,
any other "@" (model@cf) stays as it is. catalog.SameModel is unchanged,
so models.dev lookups by spelling don't lend a 1M id the base's specs.

Run (mote, mote-run): go test -timeout 45m -count=1 ./internal/provider/...
./internal/catalog/... ./internal/gui/ ./internal/agent/...
./internal/gateway/... at 9d8d9c544 (same tree): all ok (gateway 1179s).
After rebase on a75a1fffc: ./internal/provider/... ./internal/catalog/...
ok at 174152481. gofmt -l clean.

Broken by hand: mergeName back to sameModel(id) ->
TestAutoGroupsJoinAModelAtItsWindow red (haiku/fable groups missing,
xai grok-4.7@131072 not a member); restored, green.

Not tried: a real Cursor account in the GUI (Routing page showing the
member), the GUI suite (no GUI file changed), Linux/Windows runs (pure
string logic). Note: routing a group request to Cursor's @1m member runs
Cursor in Max Mode for that size, as picking the model directly does.
2026-11-17 19:20:18 +08:00
yetone 7c3e68908f claude-desktop: a model past 200K and under 1M runs at its own window in the Code tab (RQuantum198888 on X)
A GPT set to "Each model's most · 872K" still showed 200K in Claude.
Claude Desktop 5.11492 starts its Code tab's Claude Code with
CLAUDE_CODE_MAX_CONTEXT_TOKENS=200000 in its --settings file, and flag
settings come before the 872000 magpie writes to ~/.claude/settings.json.
ccae8e821 fixed this for 1M models through Desktop's 1M entry and called a
model between 200K and 1M "not fixable": Desktop offers no 1M entry for
one.

Claude Code takes a "[1m]" id for 1M over that variable (peo in aV,
2.1.326), and reads modelSettings.<id>.autoCompactWindow by the id
without "[1m]". So a model past 200K and under 1M that isn't Claude's is
now listed to Desktop by its "[1m]" id whatever DesktopLongest says
(desktopMidWindow), described by its own size ("872K context window",
not "1M"). claudePlan gives it an entry at its own window: the window
the user typed whole, else the working window, as before. A Claude
model keeps its id, since Claude Code knows its window. The gateway
already serves a "[1m]" id as the plain one. desktopPlan's work() treats
it as listed at 1M only when its window is 1M or more, so the full-1M
rule (henglu486729) doesn't apply to it.

Changed behaviour: a user's own modelSettings entry past such a model's
window ("auto") no longer holds CLAUDE_CODE_MAX_CONTEXT_TOKENS to that
window. The model's "[1m]" id doesn't read that variable, so holding it
did nothing for the model and held every other model back.

Run (on 074614077 plus this change; pushed on a9cd746da, whose
last two commits touch only README, site files and internal/bark):
- go test -timeout 45m ./... on mica: exit 0, 103 packages ok, no FAIL
  (log kept whole)
- GOOS=linux, GOOS=windows and darwin go vet ./internal/agent
  ./internal/gateway on mica: ok; gofmt -l: clean
- Broken by hand: desktopListed1M without desktopMidWindow turns
  TestClaudeDesktopLongestOnly (exo-free 872K plain), the new
  TestClaudeDesktopMidWindowRunsPast200K and TestClaudeDesktopContextWindow
  red; claudePlan without the new case turns TestClaudePlan's "[1m] under
  1M" (m:1000000) and TestClaudeDesktopMidWindowRunsPast200K red.
- Real Claude Code 2.1.326 binary against a local fake Messages server, in a
  sandbox HOME, with Desktop's flag settings
  (--settings '{"env":{"CLAUDE_CODE_MAX_CONTEXT_TOKENS":"200000"}}'):
  "/context" on anthropic/magpie-123 with 872000 in settings.json read
  "2.1k / 200k" (the report); on anthropic/magpie-123[1m] with
  modelSettings.anthropic/magpie-123.autoCompactWindow 872000 it read
  "2.2k / 872k", and "/ 272k" with the top-level 272000 alone.
  mythos-magpie-123[1m] runs at 1M the same way.

Not tried: a real Claude Desktop 5.11492 on magpie; the reporter's Desktop
build (no screenshot; the CLI path writes 872000 already, so the Code tab
is the likely surface). The GUI is unchanged. Not changed: a user's own
CLAUDE_CODE_MAX_CONTEXT_TOKENS in ~/.claude/settings.json, which magpie
keeps and the GUI doesn't name. Not broken by hand: work()'s 1M condition
(a 400K model untyped compacts at the working window, not its whole).
2026-11-17 18:27:14 +08:00
yetone 0746140772 gateway: the Qwen Token Plan's concurrency 429 is asked again on the same account (pelikanade on X)
pelikanade on X: under many requests at once the Qwen Token Plan answers
"HTTP 429: Qwen Token Plan: Allocated quota exceeded, please increase
your quota limit" with plenty of quota left, and a retry by hand works.

Cause: d83f887a7 made DashScope's "Allocated quota exceeded" a rate
limit for the rest (dashScopeRate, in failureOf), but passing and busy,
which decide whether the same one is asked again and whether patience
waits, read the body through failure(), which knows no vendor and reads
"quota" as out of quota. So a lone Qwen Token Plan provider gave the
agent the 429 after one try. A group moved on at once and rested the
member a minute.

Fix (qwen_plan_busy.go, gateway.go):
- qwenPlanBusy: a 429 from the qwen-token-plan preset or a provider at
  token-plan.maas.qianwenaiapi.com, in dashScopeRate's words (not its
  free allowance, nor a Coding Plan's hour/week/month).
- passingFor/busyFor replace passing/busy at the try loop's last-one
  and patience sites: that 429 is asked again on the same account up to
  rateRetries (3) times, with jittered pauses of about 1, 2 and 4s (half
  to one and a half of each, so one burst's requests don't come back
  together), or after the vendor's Retry-After, then within the
  provider's patience, as any rate limit is. The error is held, so
  nothing reaches the agent before then.
- A group member that isn't last is asked again in place as often
  (planAgain) before the group moves on. Only then does it rest, as a
  rate limit (failRate, a minute), never as out of quota.
- Other vendors are unchanged. DashScope pay-as-you-go (same words, a
  real per-minute limit), the Bailian and Alibaba Cloud Token Plans and
  any other provider still get one try. Bailian and Alibaba Cloud are
  the same plan on other hosts, but nobody has reported the concurrency
  429 there: #6950.
- docs/subsystems/gateway-routing.md: a bullet after the minute-limit one.

Tests (fixtures are the reporter's words, in OpenAI's and DashScope's
error shapes, and Anthropic's for /apps/anthropic):
TestQwenPlanConcurrencyIsAskedAgain (lone: 429, 429, 200 is served on
the 3rd try with no rest; one that never clears is tried 1+3+12 times,
like any rate limit), TestQwenPlanConcurrencyInAGroup (served in place,
or after 4 tries the next member is asked and the member rests as
rate), TestQwenPlanConcurrencyOnAnthropic,
TestOtherVendorsAllocatedQuotaUnchanged (qwen-cn, bailian-token-plan
and a plain relay: one try alone, next member at once in a group),
TestQwenPlanBusyScope.

Run:
- Red on the old code (gateway.go from origin/main, the new tests kept):
  IsAskedAgain gave "429 after 1 tries" with the reporter's exact text
  ("Qwen Token Plan: Allocated quota exceeded, please increase your
  quota limit"), and InAGroup gave qwen 1, b 1.
- Broken by hand, the scope widened to every DashScope provider:
  TestOtherVendorsAllocatedQuotaUnchanged went red for qwen-cn and
  bailian-token-plan (alone 200 after 3 tries; in a group a 3, b 0), and
  TestQwenPlanBusyScope went red for dashscope.aliyuncs.com and
  token-plan.cn-beijing.
- mica: go test ./... -count=1 -timeout 45m at 9fa2a63c0 (this change
  on 167101d57): 102 ok, internal/gateway FAIL on my own test only.
  IsAskedAgain checked Again > 0, but a jittered 1ms test pause can
  round to 0ms. It now checks Fail == rate. The "close of closed
  channel" in the log is a recovered http panic in continuation_test's
  doneHold fake, and the package's verdict didn't depend on it.
- mica: the new tests -count=20 ok after the fix.
- At the pushed tree (rebased on cd89ccdb4): go vet, GOOS=linux go vet
  -tags nogui and GOOS=windows go vet of ./internal/gateway, and go test
  ./internal/gateway -count=1 -timeout 45m: vet ok on all three, ok (957s). gofmt -l empty.
- Rebased again on 64ad53f6c (claude_subscription.go and sessions_mcp.go
  changed in the gateway, not gateway.go): go vet ./internal/gateway and
  go test ./internal/gateway -run 'QwenPlan|OtherVendorsAllocatedQuota|
  DashScope|ClaudeSubscription': ok.

Not tried: a real Qwen Token Plan key under concurrency (there is none
here), so the real host's wait before it serves again is not measured.
2026-11-17 17:40:23 +08:00
yetone 167101d57a gateway: service_tier "fast" reaches a Codex account as Codex sends Fast, "priority" (Archivemylife on X)
Archivemylife on X sent a Responses request for gpt-6.1-sol on a Codex
account with "service_tier": "fast" and got "default" back. magpie
dropped the key: codexBody kept only "priority" and "ultrafast", and the
IR's Fast (Chat and Responses parse) is set by "priority" alone, so
"fast" never reached the ChatGPT backend on either API.

"fast" is Codex's own name for its Fast mode. Codex never sends it:
ServiceTier::from_request_value reads "fast" and "priority" alike as
Fast and request_value sends "priority" (openai/codex
codex-rs/protocol/src/config_types.rs; step_settings.rs normalizes the
legacy "fast" the same way; read at 7fb4014d5).

- handle() turns a top-level string service_tier "fast" into "priority"
  on Chat and Responses (fastTier), before the Codex and key tier
  settings, routing and tier_asked. Those settings still win: they are
  the user's own value. Other tiers, "Fast", nested or non-string
  values go as they came.
- codexBody sends "fast" as "priority" too, for any path that reaches
  it without the handler.
- Anthropic Messages: Claude's equivalent is speed "fast", already read
  as Fast and sent to the ChatGPT backend as priority (covered by the
  new test). Anthropic's own service_tier (auto/standard_only) is about
  capacity, not speed, and is not mapped.
- Not changed: "flex" (Codex's Flex) is still dropped for ChatGPT
  accounts, as before; responses.go untouched.

The backend's reply still says "auto" then "default" with priority
honoured (servedTierAt already knows this), so the client's response
service_tier is not proof either way; speed is.

Run:
- Red on the old code (production files from HEAD, tests new):
  TestFastTierWordReachesCodex red on Responses fast, whole fast, Chat
  fast, whole fast; TestCodexBodyServiceTier red on "fast". Green with
  the change.
- Real Pro ChatGPT account in a sandbox HOME (codex logins only,
  refresh tokens blanked, no agent config touched), binary built at
  this change, gpt-6.1-sol: Responses "fast" (whole and streamed), Chat
  "fast" and Messages speed "fast" each went out with tier priority
  (trace tries); "default" went with none. Streamed Responses reply said
  service_tier auto/default. Two pairs, 600-word essay, effort low:
  priority 28.3 and 30.1 tok/s, none 22.3 and 21.2 tok/s.
- mica: go test -count=1 -timeout 45m ./... at this tree: 103 ok, no
  FAIL. go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
  go vet ./..., go build: ok. gofmt -l: empty. That tree was on
  be6f8b730; after rebasing onto 3f4372cc9 (a gateway change),
  internal/gateway (962s) and internal/provider ran ok again at this
  tree on mica. Rebased again onto c5f2a67d0 (routing.go, agy quota):
  go vet ./internal/gateway ./internal/provider and go test -run
  "Tier|Fast|Codex|Agy" on both packages ok at the pushed tree.

Not tried: a Plus account; Codex's own sign-in route (codexBackend),
where Codex itself never sends "fast".
2026-11-17 16:56:29 +08:00
yetone c5f2a67d0b gateway: Antigravity's quota refusal rests the model's pool, not the account (BruceLu73129013 on X)
magpie 0.1.4342 with agy-cli 0.1.87: once Opus's quota was used up, Gemini 4
Carbon on the same account, with quota left, got the same 429. The rest was
keyed on agy-cli@<account>, and timedHeld answered every model of it from the
rest without asking Antigravity.

Antigravity counts quota per pool of models (Claude and GPT in one, Gemini
apart), and an account has no quota of its own that runs out. The retired
built-in's readings told the pools apart (Allowance.Pooled), but agy-cli's
usage windows are display only (aside), so routing had no reading and
narrowWhenRead never narrowed the rest. Now its refusal's own words
("Individual quota reached … Resets in …", and Code Assist's "You have
exhausted your capacity on this model") rest the model (restID) through
modelLimited, the path modelNamed and modelCooledDown use, so its backoff and
sink follow it too. Only on a Google sign-in (googleSignIn: Antigravity,
Gemini CLI, the antigravity and agy-cli plugins): another vendor's
"Individual quota reached" rests the account as before. A quota refusal in
other words still rests the account.

Other models of a spent pool (Sonnet after Opus) are not rested ahead of
time. Each is asked once and refused, then rests by itself.

Tests:
- TestAgyCLIQuotaRestsTheModelNotTheAccount: restAfter + timedHeld on an
  agy-cli plugin account, both phrasings; controls: a quota in other words
  on agy-cli, and agy's words on another plugin, rest the account.
- TestAgyCLIQuotaLeavesTheOtherPoolAsked: through the server and a real
  plugin host (the fake plugin as agy-cli, no free model, as agy-cli lists
  none): the Claude model refused with agy's notice, the other model is
  asked and answers.

What was run (mote, at c98a9cb4a; doc line added after):
- Both new tests red on origin/main's routing.go: the account rested
  (agy-cli@agy-cli), and the other model answered "429 … not asked again
  before 01:25" from the rest. Green on this change.
- Broke by hand: without the googleSignIn scope,
  TestCodexCompactCutSummaryFailsOver goes red (its non-Google "ag" rested
  only the model); found by the first full suite, fixed here.
- go test -count=1 -timeout 45m ./...: 103 ok, no FAIL (log kept whole).
- gofmt -l clean; GOOS=windows go vet ./... ok; GOOS=linux go vet
  ./internal/gateway/... ok (./... stops in wails' linux GUI package without
  cgo, toolchain, not this change); go vet ./internal/gateway/... on the
  Linux VM (wsl-run) ok.
- Rebased on 3f4372cc9 (gateway's fallback.go changed): go test -count=1
  -timeout 45m ./internal/gateway ok (939s), gofmt clean, linux and windows
  go vet ./internal/gateway ok, at 2edfdff3f.

Not tried: a real agy-cli account out of a pool's quota.
2026-11-17 16:48:21 +08:00
yetone 3f4372cc9e gateway: a DeepSeek channel that refuses reasoning without an id is asked again without it, and its 422 moves a group on (yyhhyyyyyy on X)
Codex continuing on a DeepSeek channel's Responses API, after a reply
that had no reasoning, sent a step with nothing to replay. magpie leads
such a step with a reasoning item holding " " and no id (noReasoningItem,
reasonFirst), which DeepSeek's own /v1/responses wants: without it it
refuses the request with "The `reasoning_text` in the thinking mode must
be passed back to the API" (#1822, #1592, #1687, checked on
api.deepseek.com 2026-10-12). The reporter's channel turns that item
away with 422 "Input tag 'reasoning' found using 'type' does not match
any of the expected tags: 'message', 'tool_result'", pydantic's words
for a tagged-union member it has no type for. It takes a reasoning item
with an id (its own, which Codex sends back), so only the id-less ones,
the " " and a translated turn's reasoning text, are refused. The 422
wasn't retryable, so a group stopped at that member.

What changed:
- idless_reasoning.go: idlessReasoningRefusal matches that message;
  withoutIDlessReasoning drops reasoning input items without an id.
- gateway.go, relayed Responses: on that refusal the request is asked
  once more without them, and once taken the provider/model is marked
  (idlessReasoningRefused) and not sent one again. Items with an id go.
- gateway.go, translated to Responses: the same, through the build
  loop (mark, rebuild, drop).
- fallback.go: "does not match any of the expected tags" is a shape
  refusal (shapeWords), the same kind as xAI's "unknown item type": a
  group's next member (DeepSeek's own API takes the item) is asked, and
  the member doesn't rest. This only matters when the retry without the
  items is refused too, or the member can't drop any.
- The placeholder itself is unchanged: an upstream that never refused it
  (DeepSeek's own API) still gets it, so #1822 stays fixed.
- docs/subsystems/gateway-routing.md: the Responses replay paragraph.

Fixtures are the reporter's message, word for word, in FastAPI's detail
envelope and in OpenAI's error object (the reporter gave the message,
not the envelope).

Run:
- New tests: TestIdlessReasoningRefusedByChannel (relayed, both
  envelopes, second request taken at once),
  TestTranslatedIdlessReasoningRefusedByChannel (a Chat client
  translated), TestGroupFailsOverIdlessReasoningRefusal,
  TestIdlessReasoningKeptForDeepSeek, TestWithoutIDlessReasoning.
- Broken by hand: with gateway.go and fallback.go at origin/main
  (idless_reasoning.go kept so the tests compile), the three refusal
  tests fail with the reporter's 422 reaching the client;
  TestIdlessReasoningKeptForDeepSeek passes, as it guards #1822.
- mote: go test ./internal/gateway -run with the tests above plus
  TestDeepSeekStepSaysBeforeItsCall, TestGroupFailsOverARequestShape,
  TestTranslatedDeepSeek*, TestWithReasoningText*: ok.
- mica (mote had a full suite running, load 24): go test -count=1
  -timeout 45m ./... at 29cb2262a (this change on origin/main 31dcfcc33):
  103 packages ok, exit 0. GOOS=linux and GOOS=windows go vet -tags
  nogui ./...: ok. gofmt -l: clean.
- Rebased onto a5b797d8d (main gained image caps in internal/gateway
  and provider, and sessions timings): mica, go test -count=1 -timeout
  45m ./internal/gateway ./internal/provider ./internal/sessions at the
  pushed tree: ok, ok, ok. gofmt -l: clean. The full suite above ran
  at the earlier base. be6f8b730 (Zen through Bun: internal/provider
  zen_bun.go, internal/netproxy) landed after that run and touches no
  file here; it was not run again with this change.

Not tried: the reporter's channel itself (its URL isn't known), so the
id rule rests on the reporter's reading and their error text. A built
magpie end to end.
2026-11-17 16:14:13 +08:00
yetone be6f8b730e provider: Zen's free models go out through Bun, which Zen serves them to (biubiubiuzone on X)
magpie 0.1.4349 on macOS: with an OpenCode Zen key set, deepseek and the
other free models failed, while the same key worked in the OpenCode app.

Cause: Zen's free tier tells OpenCode from other clients by the
connection, not the request. I captured the bytes real OpenCode 2.3.0
sent (through a recording Bun relay) and replayed them from one computer
(mica) within a minute:
- Bun 1.4.2 (magpie's BunVersion) and Bun 1.4.4 (OpenCode's own) got 200.
- Go's net/http and curl got 429 FreeUsageLimitError, "Free usage limit
  reached. Free models work in OpenCode", over HTTP/1.1 and HTTP/2, with
  the public key or a user's own.
Zen's server source (console/app/src/routes/zen/util/handler.ts) runs
the free model's rate limiter before authenticate(), so a key never
lifts it.

Fix:
- netproxy.Elsewhere is a hook every Dispatch transport asks first.
- internal/provider sets it (zen_bun.go). A request to an OpenCode host's
  /inference/ paths (Zen's free tier, OpenCodeFreeURL) goes through the
  plugin host's fetch, which is Bun's, with its own headers and body and
  the proxy chosen in its context.
- The host is told a provider id no plugin claims, so no plugin's
  sign-in or fetch takes the request over.
- This covers the gateway's turns, the Test button and
  RetryOpenCodeFreeOnZen.
- Where Bun can't be had (HasBun false after the fetch failed), the
  request goes through Go as before.
- Zen's paid paths (/zen/v1, /zen/go/v1) stay in Go.

Run:
- New tests: TestZenFreeTierGoesThroughBun, TestZenPaidAndOthersStayInGo
  and TestZenFreeTierWithoutBun. With the hook not set (init's assignment
  taken out by hand), the first and third are red ("dialed").
- Real end to end on mica, in a sandbox HOME, through
  provider.FromPreset("opencode-zen").TestModels with the public key:
  - this change: deepseek-v4.1-flash-free, big-pickle and
    mimo-v2.6-flash-free gave 200, every time;
  - with Elsewhere set to nil (the old path): all three gave 429
    FreeUsageLimitError, alternating runs, in the same minutes;
  - with magpie downloading Bun 1.4.2 itself: 200 on 4 of 4 calls. The
    first call after the download timed out connecting (10s), on mica's
    flaky network.
- mote:
  - gofmt;
  - go vet of netproxy and provider for darwin, linux and windows;
  - go test -tags nogui -timeout 45m of netproxy, provider, plugin and
    gateway: ok at base 31dcfcc33;
  - netproxy and provider again at this head on origin/main a5b797d8d:
    ok.

Not run: the full suite. mote and mica were each running another
session's full suite. Not tried: a user's paid Zen key; there is none
here, and the free tier's limit comes before the key either way.
2026-11-17 16:00:37 +08:00
yetoneandID-VerNe 3f6a101fe1 providers: Images per request in the editor's Advanced, per model, learned from 100milionseek's and Coarena's words (#6849)
Yuu_jiang_ on X (#6849): 100milionseek and Coarena take at most 8 images
a request, counted over the whole conversation, tool results included,
and every turn after the ninth screenshot failed with no way on but
/clear. ID-VerNe's max-images (the commit before) set one number from
the CLI. This builds on it:

- The cap is per provider, and optionally per model: max-images=8, or
  max-images=8,gemini-3-flash=10. The exact model is looked up first,
  then its upstream name, then "*" for all. The provider's cap moves
  with a model's local id like the other per-model limits.
- 100milionseek's "At most 8 images per request (MAX_IMAGES)." and
  Coarena's "A request may carry at most 8 images." are learned as
  Copilot's words are, by provider and model, so the first refusal is
  the last. A user's own number is fitted before any refusal; a learned
  one that is smaller still lowers it.
- Images are counted everywhere, a tool_result's too; the oldest are
  left out first and the latest user turn keeps its own. Only the
  request sent changes; session files are not touched. A request with
  no cap, or within it, goes out byte for byte as it came.
- The provider editor's Advanced (folded unless set) has Images per
  request under Max output, in maximages.js, imported as that field is
  drawn, in every language. A GUI save keeps the value when the field
  isn't drawn. An editor opened and closed is not dirty (the draft
  takes the value only when typed), and the import, like keyrates.js's,
  draws nothing once the editor has closed: before that, a quick close
  threw "Cannot read properties of null (reading 'maxImages')" and
  ('keyPriceRates'), which add-sheet and key-box-once caught.
- Budgets: app.js and the core +354, said in core_budget_test.go.

What was run:
- go test -count=1 -timeout 45m ./... on mote at 618bfc1a9 + these two
  commits: 102 packages ok; internal/tui red on TestEveryWordHasZh
  ("subagent pool", red on main, fixed by 6fbc24a05). After rebasing on
  origin/main c9e8422fa: internal/gui (budgets), tui, agent, testenv,
  gateway and provider: all ok. gofmt clean; GOOS=linux go vet -tags
  nogui ./... and GOOS=windows go vet ./... ok on mica.
- At 618bfc1a9 + these commits, on mote: provider-max-images 60/0,
  add-sheet 6/0, add-button 6/0, key-box-once 20/0, nokey-editor 4/0,
  provider-base-api 4/0, add-sheet-custom 32/0, kimi-subagent-pool
  20/0, sync-signins-except 20/0; old-webkit 4/2 (#6030 headerpresets,
  #5919), i18n-keys 3/1 (#6877), provider-max-output 4/20 (#6209),
  editor-hints 30/10 (the same at origin/main, in #6934).
- The whole GUI suite (1569 files, chromium + webkit, every language)
  on mote at the pre-fix head under another session's suite: 153 files
  red. Each red file rerun at the fixed head and at origin/main
  ad585ccd6 on mica (and mote for the close ones). Red at head only:
  add-button (Escape showed the discard confirm: the dirty draft, fixed),
  add-sheet and key-box-once (the null draft above, fixed); now 3/0,
  6/0, 20/0, provider-max-images 60/0. Every other red file is red the
  same at origin/main, the same subtests: filed with its numbers as
  #6934 (the #6782 class). i18n-keys' ", with an image" is #6877,
  old-webkit #6030/#5919, provider-max-output #6209.

Broken by hand (each red, then put back): the relay words left out
(TestImageCapLearnedFromRelayWords), per-model lookup by upstream name
gone (TestMaxImagesOnAModelListedByItsOwnID), a copy made when nothing
applies (TestImageCapNoneIsTheSameBytes), the learned cap over the
user's (TestMaxImagesStandsOverTheLearnedCap), the GUI save dropping it
(TestProviderSaveKeepsMaxImages), the CLI's empty value
(TestProviderSetMaxImages), the cap not moving with a local id, the JS
parse without its 1000 limit and the field not unfolding Advanced
(provider-max-images), and the draft written on open (provider-max-
images' Escape check, 20 red).

Not tried: no real 100milionseek or Coarena account (the words are the
reporter's literal ones); no GUI run on Windows or Linux; the suite's
GUI half ran under load, so many reds are shared timeouts.

Co-authored-by: ID-VerNe <yuu_seeing@foxmail.com>
2026-11-17 15:39:12 +08:00
ID-VerNe e049b5cd35 providers: a user-set cap on the images of one request (max-images)
100milionseek's and Coarena's APIs take at most 8 images a request, counted
over the whole conversation, and answer the ninth with a 400 of their own
words (#6849): "At most 8 images per request (MAX_IMAGES)." and "A request
may carry at most 8 images.". imageCapWords matches Copilot's wording
alone, so the cap is never learned there and every turn of a session that
has shown nine screens fails, with no way on but /clear.

`magpie provider set <id> max-images=<n>` sets the user's own cap. The
gateway fits a request over it before it is sent, the oldest images left
out for the line imageOverCap stands, exactly as the learned Copilot cap
does; no refusal is needed to know it. The user's number stands over a
cap Copilot's refusal taught the same provider. 0, the default, keeps
the learned path as it was. The provider editor has no field for it: a
GUI save keeps what the CLI set, as it keeps usefirst and standin.

What was run:
- gofmt -l internal/ (clean); go vet ./internal/gateway ./internal/cli
  ./internal/provider ./internal/gui (clean); GOOS=linux go vet ./...
  (only wails beta.24's own cross-compile errors, the same 12 as at the
  base commit 1bfc6378c)
- go test ./internal/gateway -run 'ImageCap|MaxImages|CopilotGemini'
  -count=1 (ok)
- go test ./internal/cli -run 'MaxImages|ProviderSet' -count=1 (ok)
- go test ./internal/gui -run 'TestProviderSaveKeepsMaxImages|
  TestEveryRouteIsNamedForTheCLI|TestSettingsSaveKeepsWhatItDoesNotSend|
  TestEveryWordHasZh' -count=1 (ok); go test . -run
  'TestNoEagerPackageRegexps' -count=1 (ok)
- full packages: ./internal/cli, ./internal/gateway, ./internal/provider,
  ./internal/gui at -timeout 45m/40m

Broken by hand: TestMaxImagesFitsBeforeSending was written asserting
three images left out of twelve against a cap of eight; it went red on
the correct code and was corrected to four, the count the body shows.
TestMaxImagesUnderCapUntouched first compared the bytes sent with the
bytes posted and went red because the gateway sends the vendor the
model's own id, not the provider-prefixed one; it now compares the
images and texts. Its second case first said "one history image and
eight latest" leaves the history image alone, which was wrong arithmetic
(nine minus one is eight, a fit); it now posts nine in the latest
message alone, where nothing can be left out.

Not tried: a real 100milionseek turn through the built gateway (the
provider serves from this machine; the probe in #6849 measured it on
/v1/messages directly). The learned-Copilot path is unchanged and its
tests pass as before. -race: this Windows box has no C compiler, so
-race doesn't build there; the MaxImages tests were run -count=5
instead. Full-suite reds on this machine, all reproduced at the base
commit 1bfc6378c with this change stashed, none in files this change
touches: internal/gateway (ClaudeAsRootEnv, HandedOver/HandedOff x5
("A device attached to the system is not functioning" on a TCP
handover), HubRootsOfACodexThread, MaskedRecordKeepsSentAndBack in a
full run only), internal/cli (healthcheck x2, library-project,
opencode-default, update-find: the real magpie running on 3425 and a
real OpenCode install), internal/provider (Codex keychain x11, priced
free, resolve x2, Qianwen, saved-but-signed-out, git-on-disk x2: real
proxy settings and Windows keychain), internal/gui
(GatewayHeldByAContainer: Windows file lock on magpie.exe;
LodyImportHandoff: %AppData% undefined), internal/agent (WorkBuddy,
Hermes x4, mise shim x2, DesktopHandler, Grok, Codex own-models,
AppliedOf, AsideOffline, ClaudeViaMagpieKept, ClaudeDesktopLanguage:
macOS-specific paths and real installs), build/darwin
(FreedHeap: darwin overlay build on Windows).
2026-11-17 15:18:24 +08:00
yetone 31dcfcc336 testenv: a docs page edited without its site index fails the package run
site/public/llms-full.txt and search/*.json are built from the docs
pages and committed. A Go change that edited a docs page and ran only Go
tests left them stale on main five times from 11-13 to 11-17
(459d668b3, 256910f17, 9dcec6751, dbbb2f26b, 00b2c11a6), each caught by
CI's node tests after the push.

site/docs-index.mjs now writes all three: llms-full.txt, search/*.json,
and docs-index.sums, a sha256sum line per page they are built from.
`node llms-full.mjs` and `node search-index.mjs` each run all of it, so
running either one is enough. After a package's tests, testenv checks the
pages against the sums the way it checks eagerHere, and fails the run
when any page is edited, added or gone, naming each page. That covers
the 64 packages that use testenv, a -run of one test included.
search.test.mjs checks that the sums are current. The code standards'
criterion 3 and LESSONS say so.

Generating at this base changed neither llms-full.txt nor the search
indexes, so they were current.

Run:
- mote: go vet ./internal/testenv; go test ./internal/testenv
  (TestDocsIndexStaleNamesEachChangedPage, TestDocsIndexCurrent) and
  internal/agent's TestEveryFieldLabelHasTUIZh: ok.
- mote: node --test site/search.test.mjs site/worker.test.mjs: 47 pass.
- Linux (wsl-run) and Windows (win-run): go test ./internal/testenv ok.
- mote: GOOS=windows/linux go vet ./internal/testenv: ok. gofmt -l:
  clean.

Broken by hand: appending a <p> to docs/alma.html without regenerating
made `go test -run TestEveryFieldLabelHasTUIZh ./internal/agent` fail
("testenv: docs pages changed … docs/alma.html") with its test passing.
search.test.mjs went red too.

Not run: the full Go suite. It starts after the push.
2026-11-17 15:17:35 +08:00
yetone c9e8422fa8 agent: a field label with no TUI Chinese fails internal/agent's tests
A new agent field's label with no entry in internal/tui's zh map left
TestEveryWordHasZh red on main twice (e9fcc6229 on 11-15 for
"permission mode", 618bfc1a9 on 11-17 for "subagent pool"), each by a
change that ran internal/agent but not internal/tui.
TestEveryFieldLabelHasTUIZh reads tui's i18n.go and keepAsIs (tui
imports agent) and fails in the package such a change runs. LESSONS and
the code standards' criterion 3 name it.

Run: on mote, go test ./internal/agent: ok (250s). The new test on
Linux (wsl-run) and Windows (win-run): ok. gofmt -l: clean.
Broken by hand: with "subagent pool" taken out of i18n.go, red ("kimi's
field \"subagent_pool\" (label \"subagent pool\") has no Chinese").
2026-11-17 15:09:29 +08:00
yetone 3b4983710a gateway: a usage cap holds with sessions in parallel (yalifesign on X)
yalifesign runs 4 or 5 sessions on one ChatGPT Plus account with a 90%
cap and capStop/capCareful off, and the five-hour window went to 100%
and Codex's own 429. Caps from 99 down to 90 all overshot.

Cause: a Codex reply reports usage (codex.rate_limits, x-codex-*) as
its turn begins, without that turn's own spend. The near-cap gate
(435f04151) took one turn at a time only once a reading was inside the
5-point band. It neither counted nor waited for the turns already out
on the account, and after waiting it read usage again only when the
reading hadn't changed, which a pre-turn reading always changed. Five
sessions start turns on readings outside the band that lag every turn
in flight, and they pile up past the cap.

Fix, in serve's walk and cap_near.go:
- turnSpends learns what one turn spends per account (the rise in used
  over the turns returned since it last moved, at most 2x the band) and
  Server.nearCapOf judges "near" on the reading plus that spend for
  every turn out or returned since the reading.
- Near the cap, after taking the near slot, a turn waits until no other
  turn is out on the account (lanes.out, lanes.idle; a lane slot handed
  to this request is its own and not waited for). With other
  candidates it moves behind them first, as before.
- nearCapAgain reads usage again (bounded by carefulWait) when a turn on
  the account came back after the last good read (lanes.ended vs
  UsageRead), and still when it waited and the reading is unchanged.
The gate is generic over the account, so Claude accounts and plugin
accounts get the same hold. capStop and capCareful are read as before;
nothing changes a value the user set. A key's usage cap has no
near-cap gate at all, before and after this: #6928.

Tests:
- TestCapHoldsUnderParallelSessions: a fake Codex that reports usage
  before each turn and adds 1.5 points after it, 5 sessions x 40 turns
  from 60% to a 90% cap. Fails above cap + one turn (91.5%).
- TestNearCapReadsAgainAfterATurnCameBack, TestNearCapWaitsForTurnsAlreadyOut,
  TestTurnSpendsAhead, TestLaneIdleLeavesItsOwnSlot.
- TestNearCapWaitsThenHolds now has the usage read after the first turn.

Run:
- origin/main adfa196db with the two gateway tests (-count=10, mote):
  TestCapHoldsUnderParallelSessions red 9 of 10 (91.5 to 97.5%),
  TestNearCapReadsAgainAfterATurnCameBack red 10 of 10.
- With the fix: the parallel test 20 of 20 at 90.0%, earlier 39 of 40
  at 90.0% and 1 at 91.5%; near-cap, lanes, key slot and careful tests
  -count=3 ok.
- Broken by hand: no spend estimate, 8 of 20 red (93.0, 94.5%); no
  re-read after a returned turn, ReadsAgainAfterATurnCameBack red 10 of
  10; no wait for turns out, WaitsForTurnsAlreadyOut red on every run.
- go test ./... -timeout 45m on mote at 884bcadb6 (base ff88ec264): 103
  ok, no FAIL. Rebased on 618bfc1a9 (kimi, agent and gui only), then
  internal/gateway, internal/agent and internal/gui again: gateway, agent and gui ok at bb23d1b69.
- gofmt -l clean; GOOS=windows go vet ./... ok; go vet ./... on Linux
  (wsl-run, magpie-desktop): ./internal/gateway/... and ./internal/provider/... ok; the whole tree stops on
  gtk4/webkitgtk-6.0 missing in that distro. GOOS=linux vet from macOS
  stops in Wails' cgo files, as on main.
- No GUI change, so no GUI suite.

Not tried: a real Codex account at its cap with parallel sessions (the
fake reproduces the reported shape, not OpenAI's exact accounting); the
spend estimate on a window that renews mid-run beyond the unit test;
key caps (#6928).
2026-11-17 14:54:11 +08:00
yetone 618bfc1a95 kimi: pick Kimi Code's subagent pool and its effort (XiaoLing_Arisa on X)
XiaoLing_Arisa asked on X for Kimi Code's subagent pool (子代理池) on the
Agents page: which models its subagents may run on, and how hard they
think. Kimi Code 2.x keeps them in config.toml's [secondary_model]:
default_model (the legacy `model` stands for it), the pool
[secondary_model.models] ("alias" = "when to use it") and default_effort.

- internal/agent/kimi_secondary.go: three fields, subagent_model,
  subagent_pool and subagent_effort, written the way Kimi Code takes
  them. Its validator refuses a pool that lacks the default, a name with
  no [models."…"] table, and an effort a pool model can't take, so a
  default goes into the pool, a pool without the default gets its first,
  and only the levels every pool model takes are offered
  (kimiPoolLevels). A magpie model goes in only while [providers.magpie]
  is there. Keys are set in place; hints, other keys and comments stay.
  Before Sync or Unwire drops a magpie model table, its name leaves the
  section (kimiPruneSecondary). The default goes back to the user's own
  (stashed at kimi:<path>:secondary) or to the pool's first, and an empty
  section goes. The user's own pool of their own models is never touched.
  kimi-cli (legacy) has no such section. A stopped WSL distro shows none
  of the three, since each reads the config (#3896).
- GUI: the three fields form one Subagents line in the opened row: the
  model, then the effort (disabled until a model is set), then a
  multi-pick pool menu that stays open between ticks. The model's tick
  can't be removed. The picker's note says an unset model runs each
  subagent on the lead's model. The line is drawn by kimisub.js, which
  Details imports before its first slide so the sheet measures it.
- Size budgets +457 (reason in core_budget_test.go). Translations in
  zh, zh-TW, ja and de. kimisub.js is added to old-webkit's list of
  scripts loaded on demand. The Kimi bullet in agent-wiring.md is
  updated.

Run at this tree on mica (mica-run):
- go test -tags nogui -count=1 ./internal/agent ./internal/gui: ok,
  including TestKimiSubagentPool*, TestWSLColdPlaceOpensNothing and
  TestCoreScriptBudget. An earlier run of these packages found the cold
  read and the budget overrun; both are fixed here.
- go vet ./... on darwin, GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: ok. go build: ok. gofmt -l .: empty.
- GUI: kimi-subagent-pool passes 20 of 20 (Chromium and WebKit, 5
  languages, 1100 and 560px). kimi-thinking passes. agent-details-ready,
  old-webkit and i18n-keys have 35 reds, and origin/main ff88ec264 has
  the same 35, all filed: #6373, #6369 (agent-details-ready), #6030,
  #5919 (old-webkit), #6877 (i18n-keys).
- Broken by hand: with Details not waiting for kimisub.js,
  kimi-subagent-pool goes 10 of 10 red in Chromium ("the Subagents line
  is there when Details first draws").
- Real Kimi Code 2.6.2 (npm) in a sandbox HOME with a fake SSE server:
  the pool and effort written here are read and used. A pool naming a
  model with no table is refused when a subagent starts. A bad effort is
  not refused at runtime, but magpie refuses it anyway, as the validator
  does.

Not run or tried:
- The full go test ./... and the full GUI suite: mica and mote were both
  past their load limits with other sessions' suites. Only the packages
  and GUI files above were run.
- A real Moonshot account. The subagent's "timed out" in the sandbox run
  came from the fake server.
2026-11-17 14:30:55 +08:00
yetone ff88ec264a sync: subscriptions whose sign-ins stay on this computer (Ethereal499 on X)
Sync's sign-ins can now leave chosen subscriptions out on one computer
(`signInsExcept`, provider ids; Ethereal499 on X keeps Claude's accounts
off other computers). On that computer:

- its accounts of those subscriptions never go up;
- the server's accounts of them are never merged in, so a removal or a
  new account on another computer changes nothing here;
- the server keeps them as they are for the computers that do sync them
  (syncOnce splits the remote set with SignIns.Except and puts the held
  part back with With after the merge, so the hash doesn't change);
- the preview and Restore count and restore none of them.

An id names both the built-in and its -plugin id. An old config has no
field and syncs everything as before. The setup text doesn't carry the
choice, since it belongs to one computer.

GUI: Settings > Sync > edit > Advanced, under "Sign-ins", a "Not synced"
row with a multi-select openProtoMenu of the subscriptions with an
account. The row shows only while the sign-ins tick is on. The strings
already existed in en, zh, zh-TW, ja and de. CLI: `sign-ins-except=`
on the WebDAV, S3 and GitHub setups ("none" clears it), and status
shows the excluded ids. docs/subsystems/sync-backup.md says it.

Tests:
- TestSignInsExcept (provider) and TestSyncSignInsExcept (davsync, two
  computers on a fake DAV).
- sync-signins-except.test.cjs: both engines, 1100 and 420px, all 5
  languages.

Broken by hand, each red and then restored:
- the Except in collect;
- the Except on the remote set before the merge;
- the Except in the preview;
- the With after the merge;
- the GUI form's post of signInsExcept.

Run:
- At ac4a4cf84 on mote: `go test -timeout 45m ./...`, 102 packages ok,
  exit 0.
- At ac4a4cf84, the whole GUI suite on mote. The first part ran at
  concurrency 6 under load 25 to 37, and mote rebooted mid-run (not
  this session's doing). The 410 files it never reached ran at
  concurrency 4. Reds fell in 125 files, none of them a sync-* file
  except s3-sync (see below).
- At the rebased head b781d0bcb on mote:
  - go test ./internal/davsync ./internal/provider ./internal/cli
    ./internal/gui: ok.
  - Every sync-*.test.cjs, webdav-settings-refresh and
    sync-signins-except: ok.
- gofmt -l: clean.
- On mica: go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./... ok, plus go build, GOOS=linux go build
  -tags nogui and GOOS=windows go build.

Red the same on origin/main 873b1f7d5, run there alone:
- s3-sync webkit en ("picking S3 must not scroll the page"), #3413 and
  #2448.
- i18n-keys (", with an image" in plugins/routing), #6877.

Not run: the full Go suite at the rebased head. Another session's full
suite held mote, and mica was full. The 125 GUI files red under load
were not each run alone on main.

Not tried: a real sync between two computers with real accounts.
2026-11-17 14:08:48 +08:00
yetone 873b1f7d5e classify: 15 seconds unset for a classifier that reasons, and its cut call is magpie's wait (ESern29751 on X)
ESern29751 on X (v0.1.4341): in a routing group with intent recognition,
magpie often 499-cancels the intent classifier's request, with MiniMax,
GPT-6 Luna and Grok 4.6 as the classifier.

Cause: those models reason before they answer. The classifier asks for
reasoning_effort none, but MiniMax thinks anyway and Grok 4.6 and Luna go
no lower than low. Through the live gateway with the classify prompt over
a real routing prompt (~5k tokens of context): grok-4.6 took 4.7-8.1s
(288-462 reasoning tokens), minimax-m2.5 3.7-10.3s (439-1012 output
tokens), gpt-6-luna 1.2-7.2s; cold calls reached 12-29s. The unset
classifier timeout was 8 seconds, so most turns were cut off, fell back to
the group's order and lost their intent routing. Each cut call was then
logged 499 "the agent canceled the request", which usage counts as no
failure, though no agent had canceled anything: askChat's own
context.WithTimeout had no cause, the mislabel #2318 fixed for an image's
description but never for the classifier.

Fix:
- settings.ClassifyTimeoutDefault 8 -> 15 (an existing Settings segment).
  A user who saved 8 keeps 8; only the unset value moves. The GUI's
  fallback segment follows (app.js), and the docs (en/zh/ja intent and
  start, gateway-routing.md) say 15.
- askChat's wait is context.WithTimeoutCause(..., sideTimedOut{"decision
  model", wait}): the usage row says "magpie stopped waiting: its
  decision model had no answer in Ns", a failure.
- Siblings checked: the advisor and Codex titles use the client's
  context, compaction and vision already carry sideTimedOut; askJev
  (decision providers) logs no 499 row of its own.
- Tests that assumed the 8-second unset wait now use 15 (classify,
  decide, decide_group, nested_classify_wait, settings).
- app.js grows by the one byte of the fallback's second digit: both
  core budgets +1 with the reason (TestCoreScriptBudget was red at
  exactly 1 over without it). A shorter `|| 15` would show a hand-edited
  negative value as its own segment, so it wasn't taken.
- site: llms-full.txt and the search indexes regenerated for the docs
  pages (node llms-full.mjs, node search-index.mjs).

Test: TestReasoningClassifierAnswersInTheWaitUnset - a classifier
answering in 10 units routes the turn with the timeout unset, and one
slower than 60 units gives no answer with one 499 usage row that says
magpie stopped waiting for its decision model and counts as a failure.

Broken by hand (mica-run): with askChat back on a plain WithTimeout the
test is red ("the classifier's cut call: 499 "the agent canceled the
request""); with the default back at 8 it is red ("gave no answer in
400ms").

Run at 0479372b8, this commit's tree (mica, through ~/suite.lock; mote was over its cores):
- gofmt -l: clean. go vet (darwin), GOOS=linux go vet -tags nogui,
  GOOS=windows go vet: rc 0 (darwin vet rc 0 at the first try on mote).
- go test -tags nogui -count=1 -timeout 45m ./...: rc 0, 103 ok.
  (The first run, on mote before the budget raise and the rebase onto
  adfa196db, was red on TestCoreScriptBudget alone.)
- node --test site/*.test.mjs: 132 of 132.
- GUI (node --test, Chromium and WebKit, five languages, 1100 and 420):
  classify-timeout-setting, settings-places, i18n-en-no-cjk green;
  i18n-keys red only on "a plugin's words are its own" over
  claude_image_budget_test.go's ", with an image", already #6877 from
  2896e82cc, untouched here.

Not tried: the real reporter's group in the GUI with these models after
the change (the timings above were measured through the live gateway
before it); the whole GUI suite (only a fallback value changed in app.js).
2026-11-17 13:31:08 +08:00
yetone adfa196db0 lessons: a docs page change regenerates the site's indexes (seen a fifth time)
00b2c11a6 added a docs row and left llms-full.txt and the search
indexes stale, the fifth time since 11-13 (459d668b3, 256910f17,
9dcec6751, dbbb2f26b). The rule moves into the code standards'
criterion 3. Docs only; nothing run.
2026-11-17 12:58:54 +08:00
yetone 255ccdd7ca omp: a Protocol row picks the API magpie's models are asked on (imty42 on X)
omp's models.yml had magpie's provider on openai-completions with no way
to change it: ompKept treated the provider's api as magpie's, so an api
typed there was written back on the next sync, and omp's row had no
protocol as Pi's has. An auto/* group whose members don't all take
Responses (provider.GroupAPI) could only be asked on Chat.

- omp's row gets the Protocol row Pi has (protocolField, now shared with
  Pi's piProtocolField): each model's own (unpicked, as before),
  openai-completions, openai-responses or anthropic-messages. omp takes
  each for the provider and a model (KnownApi in pi-catalog types.ts and
  the api enum of models-config-schema-bundle.ts, omp 18.9.1). The pick
  is kept per place and agent folder, so each profile has its own.
  `magpie omp protocol openai-responses` sets it from the CLI.
- ompOn puts the provider and every chat model on the pick: Chat and
  Responses with no api of their own and thinking mode effort; Messages
  at the gateway's root with budget, or anthropic-adaptive for a Claude
  that thinks only adaptively. Image models stay on openai-images.
- The provider's api typed into models.yml by hand now stays and shows
  as picked (ompAPIKept, the same api:<path>:wanted record as Pi's); a
  pick made after it replaces it.

Unchanged: unpicked, Responses-native models and groups whose members
all take Responses already went on openai-responses per model.

Run at this head (3d0cadfce, the same tree; only this message differs),
on mote:
- gofmt -l internal/agent: nothing. go vet ./..., GOOS=linux go vet
  -tags nogui ./..., GOOS=windows go vet ./...: rc 0. go build, linux
  nogui and windows builds: rc 0.
- go test -tags nogui -count=1 -timeout 45m ./... in a sandbox HOME
  under suite.lock: rc 0, 103 packages ok, no FAIL.
- Broken by hand: without ompAPIKept, TestOmpProtocolPicked is red
  ("an api typed by hand: file openai-completions, field \"\"").
- Real omp 18.9.1 in a sandbox HOME against a stand-in server: with the
  provider on openai-responses a group model posted to /v1/responses;
  a model on anthropic-messages at the root posted to /v1/messages.

Not tried: the GUI suite (no GUI file changed; the Protocol row is the
generic one Pi's uses, shown for any agent with a protocol field), and
omp against the real gateway with a real auto group.
Not changed: a model's api typed by hand in omp's models.yml is still
magpie's (the model list is magpie's whole); site docs for omp.
2026-11-17 12:46:56 +08:00
yetone 90d7ea9331 agent: a new agent named nowhere in the Library fails internal/agent's tests
TestEveryAgentInLibrary (internal/library) went red on main for a new
agent four times: 399010bef and 68cb92e8e (11-10), 7e8214d60 (11-12),
and effdd1beb today after 00b2c11a6 (Open Code Review). A change that
adds an agent runs internal/agent, and the guard is in another package,
so each was found after the push.

TestEveryAgentNamedForTheLibrary reads internal/library's targets.go and
every_agent_test.go (library imports agent, so it reads the files) and
fails when an agent on this machine's list is in neither a targetOf case
nor noLibrary. The library test still checks a target has something in
it. Same shape as internal/gui's TestEveryRouteIsNamedForTheCLI.

LESSONS.md: the route/setting guard lesson now covers agents, seen a
third day. code-standards criterion 3 names both twins.

Run (mote, at effdd1beb + this change):
- go test -count=1 -timeout 45m ./internal/agent ./internal/library: ok
- broken by hand (open-code-review's noLibrary line removed): red,
  "open-code-review (Open Code Review) isn't named in internal/library";
  restored
- win-run and wsl-run, -run TestEveryAgentNamedForTheLibrary: ok
- gofmt -l: clean
Not run: the full ./... suite (test-only change in one package).
2026-11-17 11:47:18 +08:00
yetone 2f25728ddf claude: Use switches Claude Code itself to a setup-token account (liukaybee on X)
liukaybee adds Claude accounts with `claude setup-token` and wants magpie
to switch only which one Claude Code itself uses, without connecting it
to magpie. Such an account has no sign-in to put in Claude Code's
keychain or .credentials.json, so Use was refused ("magpie only").

Claude Code takes CLAUDE_CODE_OAUTH_TOKEN from the env of its user
settings.json ahead of its stored sign-in. Use on a setup-token account
now writes the token there (claude_token_env.go). Claude Code's stored
sign-in stays as it is and stays Active; the token account is listed
with Uses. A switch to a signed-in account, Use on the signed-in row,
or removing the token's account takes the token out again.

- A value the user set is theirs: magpie keeps only the sha256 of what
  it wrote (claude-token-env.json), never writes over another value and
  never removes one whose hash differs, even if it once wrote it.
- An unreadable settings.json is "unknown": nothing is written, the
  record is kept, and the switch fails without moving the sign-in.
- NextLogin (Switch accounts only) leaves Claude Code on a token in use,
  as its allowance can't be read.
- magpie's own runs pass --setting-sources "" and are unaffected.
- GUI: the token row's Use and In use; the signed-in row says Signed in
  with a Use back. Every new string in zh, zh-TW, ja and de.
- app.js +864 bytes over its budget, raised with the reason in
  core_budget_test.go: one swUse helper shared by both buttons, packed;
  renderAccounts draws every account row, so no page to move it to.

Real use: real Claude Code 2.1.316 in a sandbox HOME/CLAUDE_CONFIG_DIR
(never the live ~/.claude) with a deliberately broken .credentials.json
access token. The settings.json magpie's switch writes (dumped from a
test) gave a PONG with a real account's token; the file after switching
back gave "401 OAuth access token is invalid", i.e. Claude Code was on
its stored sign-in again. Sandbox homes holding real tokens deleted.

Run (mote/mica, at f00e2059d rebased on 593517bf0, then this head):
- Rebased on effdd1beb (internal/gui and internal/provider untouched
  since, but for this): TestCoreScriptBudget and the provider TestClaude*,
  NextLogin and Forget tests rerun at the pushed head, ok.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./...: ok. gofmt -l: clean.
- go test ./... -timeout 45m on mote: 102 packages ok, internal/gui
  FAIL: TestCoreScriptBudget (fixed above, then green) and
  TestQuitKeepsTheMenuBarIconsPlace, killed at its 30s AppKit bar under
  load; passes alone in 1.1s here and on origin/main 00b2c11a6. Filed
  #6919.
- GUI, both engines, every language, on mica: the 45 account, Claude,
  switch, sign-in and i18n files (1275 tests, 68 red). The same 9 red
  files on origin/main effdd1beb give 67 of the same reds (#5925, #6660,
  #6179, #6424, #6010, #5998, #5814, #6877). The one red only at this
  head, accounts-own-signin webkit zh (access-control on /api/autobackup)
  is #6038 and passes 20/20 alone. claude-setup-token: green in all 10
  engine x language runs.

Broken by hand, each red, then restored: the own-value check
(TestClaudeOwnEnvTokenLeftAlone), clearing on an OAuth switch
(TestClaudeCodeSwitchedToSetupToken, ...UnreadableSettings), clearing
on Use back (Switched, InUseNotMovedOff), clearing on remove
(TestClaudeSetupTokenRemovedLeavesSettings), the NextLogin guard
(InUseNotMovedOff), unreadable settings read as empty
(TestClaudeEnvTokenUnreadableSettings).

Not tried: the whole GUI suite (both machines were running other
sessions' full suites for hours); a magpie GUI build clicking Use
against the real binary (the switch's file was checked instead);
Windows and Linux Claude Code.
2026-11-17 11:42:27 +08:00
yetone 00b2c11a6b agent: Open Code Review (ocr) is an agent magpie sets up (@AlanWang1027713 on X)
Open Code Review (github.com/alibaba/open-code-review, npm
@alibaba-group/open-code-review) is a Go CLI, `ocr`, that reviews a diff
with a model. Its Claude Code, Codex, Cursor, Kimi Code and OpenCode
plugins and its skills all run that command, which reads
~/.opencodereview/config.json on every run.

Picking one of magpie's models on its row writes a custom provider
"magpie" there (protocol openai, the gateway's /v1, a key naming Open
Code Review, the model) and points provider at it. The user's own
provider and model are stashed and come back on Disconnect, which also
drops a custom_providers left empty. A model of the user's own can be
picked too (written the way `ocr config model` writes it). Check reports
a hand-edited url or key, or a removed entry. The `ocr` command counts
only under a folder named for Open Code Review, since other programs
share the name. WSL distros get the row too (cold distros not opened).
Its User-Agent, open-code-review/<version>, already counts as this agent.
CLI update via npm. Docs, READMEs, site and icon (OCR's own logo,
Apache-2.0).

Run (mica, at 593517bf0; origin/main has one unrelated usage commit since):
- go test ./internal/agent -run 'TestOCR|WSL|Wsl|TestOwnProviderNamedAsMagpies|TestHandWiredMagpieProviderSiblings|TestAgentOf|TestEveryAgentNamedByItsKey|TestMarkedLinesEveryAgent': ok
- gofmt -l: clean; GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: ok
- Broken by hand: url dropped from Check -> TestOCRWiring red; stash
  turned off -> red at the Disconnect restore. TestWSLColdPlaceOpensNothing
  went red before the row's options were given an asleep path.
- Real e2e in a sandbox HOME: npm-installed ocr v1.13.10 (7e5ce06c)
  darwin/arm64, magpie built from this tree, a fake OpenAI upstream that
  calls tools. `magpie agents` lists the row with the user's
  deepseek/deepseek-chat; `magpie open-code-review magpie/fake/m1` wrote
  the entry and kept the user's keys and settings; `ocr llm test`:
  connection ok, tool-call round trip verified; `ocr review` on a repo
  with a nil dereference: 2 findings "[bug · high]" through magpie
  (8 /v1/chat/completions calls, UA open-code-review/v1.13.10, model m1,
  its six review tools); `magpie usage` counts them under Open Code
  Review; `magpie open-code-review default` put deepseek/deepseek-chat
  back and removed custom_providers.
- Full suite: not run before this push (ship at once; mote was running
  another session's suite). It runs on mica right after, at this head.

Not tried: a real vendor model behind magpie; WSL and Windows/Linux
machines for real; the Claude Code / OpenCode plugin path itself (it runs
the same `ocr`); an ocr installed by the curl script outside a folder
named for it is found by ~/.opencodereview only.
2026-11-17 11:10:43 +08:00
yetone 2071195ff4 usage: a plugin window named by one of its models counts that model (Google AI Studio)
WangYeruo on X: with the Google AI Studio plugin (@dorokuma/magpie-gemini-web's
ai-studio), one model's 429 for its quota held the account from every model
until the reset, while AI Studio limits each model's day on its own and argon
still answered after hydrogen was out.

The 429 itself already rested only the model: AIStudio2API's AllCoolingError
("模型 gemini-4-hydrogen 的可用账户均在冷却…;每日限额: … model:
gemini-4-hydrogen …") names it (TestAIStudioModelDayRestsTheModel, a guard;
it passes on the old code too). What held the account was the usage read
after it: the plugin's accountUsage (lib/studio.mjs, 0.15.3) tells a cooldown
as a window named after the model's id, used 100 until it ends, with no
model or models said. magpie read it as the whole account's window, so
Allowance.Full held every model and Pooled said the account was out.

namedModelWindows (pluginLoginQuota) now scopes a plugin window that says no
models, no family and no pool, and isn't text or aside, to the model whose id
its name is, when the provider serves that id. "所有模型" (a cooldown with no
model_id) and any other name stay the whole account's, as before.

Old data: such a reading has a matches, so keepLast doesn't write it down,
as with models/notModels. A reading kept on disk before this, still within
its cooldown, can hold the account from every model after a restart until
the first read (seconds); one past its reset holds nothing.
The plugin can't be fixed upstream: its repo has issues off, and it needs no
change now.

Run (mica-run, at this commit on origin/main acc358f07):
- go test ./internal/provider -run TestPluginWindowNamedByModelCountsThatModel:
  ok; broken by hand (namedModelWindows returning q unchanged) it is red:
  "hydrogen's cooldown holds argon till 2026-11-18 08:00:00", "a 429 of
  hydrogen rests the account, not the model".
- gofmt -l: clean; GOOS=linux go vet -tags nogui ./...: ok;
  GOOS=windows go vet ./...: ok.
- go test -count=1 -timeout 45m ./...: 103 packages ok, no FAIL.
Rebased onto 593517bf0 (codex/t3code/sessions only): go test -count=1
./internal/provider ./internal/gateway at the pushed head: ok.
Not tried: a real AI Studio account through the plugin (none here). No GUI
file touched.
2026-11-17 11:00:09 +08:00
yetone ce16633367 tune: a Codex card locked by config.toml's own compact limit hands it to magpie on a click (sufeng1894 on X)
sufeng1894 asked why Codex's compaction threshold can no longer be set by
hand. The card said config.toml's model_auto_compact_token_limit wins, and
the background row said features.async_compaction's
model_async_compact_threshold_percent wins: both locked, and nothing on
the card did anything about it.

Cause. Only the old tune card (9e665491e to f20118304, 10-10 to 10-28)
wrote model_auto_compact_token_limit, stashing the user's own raw value;
the 10-28 migration puts that raw value back, which then locks the card.
So the values on the screen are the user's, or the user's restored by
that migration. A magpie-written value could have lost its stash through
stash.json races (before 270b52573), an unparsable stash (before
58651568b), tuneMigrateCodex forgetting the stash even when its file
write failed, and codexAsyncSync stashing only after every write. The
last two are fixed here: the migration forgets only after the write
succeeds, and codexAsyncSync records its stash in a defer right after
reading the old state, advancing it per successful write.

Change. A locked card shows one button, "Let magpie set it" (zh 交给
magpie 设置, zh-TW, ja, de), only when the user clicks. POST
/api/tune/takeover (TuneTakeOver):
- the file's limit moves into Long conversations by tuneMigrateCodex's
  rule (a lower Long the user has is kept), the key is deleted from
  config.toml with every other key kept, and the file value is stashed
  (tune.codex.compact_file); Undo puts Long back and writes the key back,
  unless the user changed Long since;
- a background threshold of the user's (enabled = true) is adopted as
  magpie's background share with its own Undo, which turns the share off
  and gives back the percent and enabled as they were. enabled = false
  is not taken.
Nothing removes the user's value without that click.

Run:
- internal/agent, internal/gui, internal/cli, internal/tune at the pushed
  head (rebased on ca87ae9c5) on mica: ok. TestCoreScriptBudget raised
  by 189 (the button, its post and Undo background), reason in the file.
- Full Go suite -timeout 45m on mica at the pre-rebase head (2ba62f7f7
  base): every package ok except TestCoreScriptBudget, since fixed.
- Broken by hand, red: migrate forgetting first (TestTuneCodexMigrateKeepsStash),
  asyncGiveBack disabled (TestTuneCodexTakeOverAsync), longUndo in place
  of codexLongUndo (TestTuneCodexTakeOver), and the GUI button disabled
  (context-tune, 11 red).
- context-tune, compact-one-value, codex-async-compact, i18n-keys at the
  pushed head on mica, Chromium and WebKit, every language, 360 and 1100:
  the new test passes; reds are codex-async-compact's zh/zh-TW "kept the
  share out" (4, the same at ca87ae9c5) and i18n-keys' routing plugin
  word (#6877).
- win-run TestTune|TestCodexAsync in agent and gui: ok. wsl-run vet and
  those tests with -tags nogui: ok. GOOS=windows go vet and GOOS=linux
  go vet -tags nogui: ok. gofmt -l: clean.
- make test-ui on mote, pre-rebase head, through header-centre (about a
  third; the rest still running when pushed): reds in 29 files, none a
  tune file. The first 16 (account-arrange to context-cap) were run
  alone at this head and at origin/main ca87ae9c5 on mica: the same
  reds at both (base has 4 more, in agent-own-direct), the #5475 class.
  The next 13 (ctx-session-line to header-centre) were run the same way at the pushed head: 59 red at head, 60 at ca87ae9c5, the same tests (header-centre's halfway case red in one engine at each).

Not tried: a real Codex session after the takeover; codexAsyncSync's
defer has no test with a failing write.
2026-11-17 06:39:40 +08:00
yetone 2ba62f7f76 gateway: agy's "Individual quota reached … Resets in" rests the account until then
@Airan_FS on X (11-17): an Antigravity account served through agy-cli
answered "⚠ Individual quota reached. Please upgrade your subscription to
increase your limits. Resets in …" as the model's reply, and routing never
asked the next account.

The agy-cli plugin 0.1.87 (magpie-community/plugins afe4c086, on the dist
branch) now ends such a turn with a rate_limit_error in agy's words, before
or after reply text, so the gateway fails over and rests the account as for
any plugin quota error. Here, quotaResetAfter also reads the notice's
"Resets in 1h18m40s" (Go's duration form, which resetsInWords can't read
since no word ends after its "h"), scoped to the "individual quota reached"
line, so the account rests until Google's reset instead of quotaRest's 15
minutes and isn't asked again every quarter hour. gateway-routing.md says so.

Tests from the literal notice (discuss.ai.google.dev report, the tweet):
TestAgyCLIQuotaNoticeRestsUntilItsResetAndFallsOver (group falls over to
the next member, rest "resets" ~1h18m40s, next turn skips it),
TestAgyCLIQuotaNoticeMidReplyStillRests (partial text kept, still rests),
TestAgyQuotaNoticeResetIsRead.

Run (mica, at f33278541 = this change less the doc line): go test ./...
-timeout 45m: 102 ok, no FAIL. mote: GOOS=windows go vet ./... ok,
GOOS=linux go vet -tags nogui ./... ok; gofmt -l clean.

Broken by hand: the old quotaResetAfter with these tests: the account
rests 14m59s by "quota" and resetsAfter reads 0, so all three fail.

Not tried: a real agy account with its quota used up.
2026-11-17 04:14:34 +08:00
yetone ead91a9a50 gui: a browser tab's title names this magpie: MAGPIE_NAME or Settings › Network and sharing › Advanced › Name (starballl on X)
starballl on X (tweet 2122376116220633444) runs several magpie web pages
and every tab is titled "magpie", so they can't be told apart. A magpie
now has a name, and a browser tab's title is "<name> · magpie" (plain
"magpie" with none).

- settings.Name, set in Settings › Network and sharing › Advanced › Name
  (instancename.js, imported when Settings is drawn, so nothing is added
  to app.js's core). Advanced is closed until a name is set.
- MAGPIE_NAME (Docker, magpie web) names it while the field is empty and
  is the field's placeholder. It is read, never written, so a name typed
  in Settings always wins and clearing the field goes back to it.
- One line, at most 60 characters (settings.CleanName).
- This computer's own (KeepOwn): sync and a restored backup never bring
  another magpie's name. A Settings save that leaves `name` out keeps it
  (settingsapi.Merge).
- boot.js titles a browser tab itself for the first paint, so app.js's
  core gains only the line in applyPrefs, which sets the title again from
  every settings read (TestCoreScriptBudget was 74 bytes over with a
  title function in app.js). Only a browser page (web) is retitled: the
  app's windows and tray keep "magpie".
- Docker docs (en, zh, ja) list MAGPIE_NAME; docs/reference.md and
  docs/subsystems/gui-shell.md say how it works.

Tests:
- TestInstanceName (internal/gui): the variable alone names it at boot;
  a saved name wins over it, trimmed; a save without `name` keeps it;
  KeepOwn keeps it; cleared goes back to the variable; no name, none at
  boot. Broken by hand, each red: KeepOwn without Name ("KeepOwn took
  \"other\""), Merge without the keep ("a save without the name changed
  it to \"\""), boot.js with s.Name in place of InstanceName ("named by
  the variable alone: boot <nil>"), boot.js not setting the title ("a
  browser tab's boot.js sets no title"). The app window's boot.js sets
  none.
- TestSettingsSaveKeepsWhatItDoesNotSend now sets Name: the page's other
  saves leave it out, and it is kept.
- instance-name.test.cjs: title from the first paint, the field under a
  closed Advanced, save and clear retitle the tab, Advanced open after a
  reload, 360px, the app's window keeps "magpie"; en, zh, zh-TW, ja, de,
  Chromium and WebKit, 16/16. 14 of 16 red with applyPrefs not setting
  the title.

Run, at this commit on dbbb2f26b plus 9d5d8baf2 (the site index):
- go test ./... -count=1 -timeout 45m on Linux (WSL magpie-desktop, Go
  1.26.8), at the tree before the boot.js move: 99 packages ok,
  internal/gateway included (959s); ., internal/cli and internal/gui
  don't build there without GTK headers. On mica (macOS): . and
  internal/cli ok; internal/gui/... ok at this commit, after the two
  reds that run found (the core budget, the keep test) were fixed.
- go vet and GOOS=linux -tags nogui / GOOS=windows go vet of
  internal/gui and internal/settings, earlier the whole tree on all
  three: ok. gofmt -l clean.
- site: node --test *.test.mjs, 132/132.
- GUI: the 135 files the change reaches (settings, network, LAN, i18n,
  old-webkit, core budget) on mica: 16 files had reds. Run again on this
  tree and on its base, the same tests are red on both (allow-ips
  #4357, settings-hints #6107/#6353, lan-join #6353, i18n-keys #6877,
  old-webkit #6030/#5919 and the rest of the 16) but two:
  search-mcp-library (WebKit, #4756) and gateway-pause (WebKit de 420px,
  #6684), red only beside other files: alone, 0 of 10 and 0 of 3 red on
  both trees.
2026-11-17 03:11:31 +08:00
yetone dbbb2f26b1 groups: free: takes the models a catalog marks free (#5903)
A routing group's pattern may now start with free: (provider.FreePrefix):
free:workbuddy/* is, of the models workbuddy/* matches, those whose
catalog entry says free (Entry.Free, the vendor's or plugin's own flag as
the catalog was last read). The rest after free: is a glob, a re: pattern
or an id, matched as on its own, so free:re:workbuddy/hy.* works too. It
is expanded where every pattern is (matchesIn, PatternHits) each time the
groups are read, from the catalog magpie already keeps: no request to a
vendor, and a model the next list marks free joins without a save.

Only the flag decides. A $0 price (PricedFree), a rate of 0, an account
named Free or "free" in an id never counts; the test holds a
deepseek-v4-free id with no flag, a rate-0 model and an or/y priced at $0
out. Existing patterns read as before: openrouter/*:free still means ids
ending in :free (that is why the rule is a prefix, not a :free suffix),
and a provider's AutoInclude takes no free: (isIDPattern).

GUI: the Routing editor's pattern box counts and lists a free: rule live
as it does any pattern (patternTest in plugins/routing/client.js, from
groups.models' free), refuses "free:" alone, and one hint line says the
flag is the last catalog's, not a promise of no charge, in en, zh, zh-TW,
ja and de. CLI help, docs/subsystems/providers-accounts.md and the site's
routing-groups page (en, zh, ja) say the same.

routing-levels.test.cjs: the Advanced hint line made the editor taller,
so the second group's Levels row opened under the editor's sticky foot
and the click landed on the foot (webkit en). The test already wheels to
that row for its first group; it now does for the second too.

Run:
- TestGroupFreeRule, TestFreeRuleSyntax and the existing pattern tests
  pass. Broken by hand: with groupmatch.go and autolist.go from
  origin/main both are red (no members for free:workbuddy/*, IsPattern);
  with takes() ignoring the flag, TestGroupFreeRule is red (all six
  WorkBuddy models matched).
- group-free-rule.test.cjs (new): chromium and webkit, en and zh,
  green; red with origin/main's client.js.
- go vet ./... (darwin, mica), GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean. gofmt -l: nothing.
- Full suite go test -tags nogui -timeout 45m ./... on Linux (WSL
  magpie-desktop) at 1e180c630 (this change on ac4a4cf84): 102 ok, no
  FAIL. Not run whole on macOS: mote had another session's GUI suite
  and mica's disk was full (2 GB free; a run there failed on "no space
  left on device").
- At the pushed head 6801ae683 on Linux: internal/provider, cli,
  plugin, agent, gui packages; group-free-rule, group-patterns,
  routing-levels, gui-zh-tw, gui-ja, gui-de: all ok, 21 tests pass.
- GUI: the 182 files that reach the Routing page or i18n, on Linux at
  d55680755's tree: 2805 pass, 112 fail in 21 files. The same 21 run on
  origin/main cb4ad12bd: 102 fail in 18 of them. The three red only
  here (input-look, search-keys, routing-levels) were rerun at
  concurrency 2: input-look and search-keys green, routing-levels red
  from this change and fixed above (green 2 of 2). Reds on main, filed:
  group-editor-selected #5049, i18n-keys #6877, codex-memories-settings
  #6372, inner-scroll-contain #4689, grip-inset #6293, and the rest in
  #4120's class; form-align newly filed as #6894.

Not tried: a real WorkBuddy account's catalog (the flags come from the
plugin's list, as the test's fixture has them); the GUI files on macOS.
2026-11-17 02:19:48 +08:00
yetone cb4ad12bd1 zcode: the mover's min is 0.1.68, whose every account takes requests (mathfournity on X)
mathfournity on X: several ZCode accounts in magpie, and requests went to
two of them only. The plugin (0.1.40 to 0.1.67) declared maxAccounts 2,
so keepAtOnce held every account past the first two in reserve until one
rested. magpie's own handling of a plugin's accounts was right: on a
throwaway gateway test with the real plugin under bun and four accounts
on a fake Z.ai, 0.1.67 sent 12 requests at once 6/6 to two accounts and
none to the others, and 1302, 1308, 3008 and 500 on one account each
went to the next and rested the first.

plugins 36dc4007 (zcode 0.1.68) declares no maxAccounts and holds what
zcode.z.ai's firewall refuses an address for instead: six Start Plan
requests in flight from this computer over all accounts, besides each
account's three. On the same throwaway test, 0.1.68 sent the burst
3/3/3/3 over the four accounts, failover unchanged. Raising the min
updates moved users (keepMovedCurrent). gateway-routing.md's Accounts at
once row says the plugin no longer declares two.

npm: registry.npmjs.org has 0.1.68 as latest (npm view --prefer-online
--registry https://registry.npmjs.org). The plugins publish run is red
only for middleware-system-prompt and middleware-think-tags (trusted
publisher); its log shows "+ @magpie-community/opencode-zcode-auth@0.1.68".

Run:
- go test ./... -count=1 -timeout 45m on mica at 1c59acd36 plus this
  change: every package ok (102), exit 0.
- Rebased onto 4c6c3a453 (claudetui only): go test ./internal/provider
  ./internal/claudetui ./internal/plugin on mica: ok.
- Plugin: bun test in packages/zcode (HOME=$(mktemp -d), wsl-run):
  275 pass; the new tests red against 0.1.67's code (3 fail).

Not tried: a real ZCode account.
2026-11-17 01:48:56 +08:00
yetone 1c59acd36d plugin: a fetch whose head never comes is given up on; Devin min 0.1.45 (wu_chong4136 on X)
wu_chong4136 on X: with the Devin plugin a session sometimes hung for
10 to 20 minutes with no reply, until the effort or the context was
changed. The Devin plugin returns its fetch's head only once Devin sends
the reply's first content, and the host's headRead waited for that head
with no bound, while the gateway kept the agent alive on keepalives. A
request Devin took and never answered therefore hung silently. The body
already had bodyIdleWait (30m between bytes, #4934); the head had none.

- host.go headRead: the same bodyIdleWait bounds the wait for the head.
  On it the fetch ends with "the plugin sent no reply in 30m0s; that
  fetch was given up on", Fetch settles the call, and the host writes
  "abort", so the plugin's fetch signal ends its vendor request too. The
  gateway answers the agent its retryable 502 (an SSE error event on a
  stream). This holds for every plugin fetch, not only Devin's.
- ReplyWaitForTest lets the gateway test shorten the wait.
- Devin mover min 0.1.45 (on npm, `npm view --prefer-online`): the
  plugin itself gives up after 5 minutes of quiet from Devin (no head,
  or no frame between reads) with a retryable 504. A real probe saw
  Devin's first frame at 2.5s and at most 13s between frames.
  (magpie-community/plugins e30f8ed0)
- provider-plugins.md says so.

Tests:
- TestHostHeadWaitEndsAFetchNeverAnswered: a head that never comes ends
  in "sent no reply", the host is sent "abort", and the call is
  released; TestHostHeadWaitSparesAHeadInTime: a head in time is kept.
- TestPluginHeadNeverSentEndsInAnError (gateway, through the fake
  plugin in Bun): a vendor that reads the request and never answers
  gives the agent the error on a stream and on a whole reply, and every
  vendor request the plugin made is closed afterwards (asked 30, open 0).

Run:
- mote: the three tests above, ok.
- Broken by hand (headRead without the timer case): the host test fails
  ("held its reader for ever") and the gateway test hangs to its 60s
  timeout in io.ReadAll.
- mica: gofmt -l clean; go vet for darwin, GOOS=linux and GOOS=windows
  on internal/plugin, internal/gateway, internal/provider: ok.
- mica: go test -tags nogui -timeout 45m ./... at this tree (rebased on
  ac4a4cf84): 101 packages ok; internal/gateway FAIL on
  TestImageMCPKeepsDrawingsOffTheHeap alone ("the heap grew by 31 MB"),
  which passes 3 of 3 alone at the same tree and reads the whole
  process heap; filed as #6890.

Not tried: a real Devin request that goes quiet (it can't be made to
happen on demand).
2026-11-17 00:39:50 +08:00