Commit Graph
8593 Commits
Author SHA1 Message Date
yetone 5bfa57e3d3 usage: check one model on one provider with a few fixed-answer calls, kept beside the other providers
skingstyle48487 on X runs more than ten relays and asked for something
like the "pelican test" to spot one that waters a model down. In a
follow-up (2122694296054972815) they said speed, failures and the model's
name show whether a relay is fast and stable, not whether the model got
weaker. They asked for small tests with known answers, the share of right
answers and of right tool calls, and relays compared side by side.

On Usage › Requests › Model speed › Providers, each row has a Check… that
opens a dialog. Opening it sends nothing; only its Check makes the calls.
POST /api/relay-check (gateway.CheckRelay) makes 6 small streamed Chat
Completions calls through the gateway, pinned to provider/model as an
agent would, three at a time:
- write 1 to 40;
- 1234 × 5678, 987 × 654 and 2468 × 1357;
- weather in Paris and time in Tokyo, each call offering both tools,
  so the right one has to be picked.

Each part says what it found, never a verdict on the provider:
- whether the answer was the expected one, and what came back;
- the model the reply named, when the ledger would call it another
  model (usage.Swapped, not SameSpelled or ListedAs);
- the provider that answered, when the call was handed on;
- how many input tokens the 118-character prompt was counted as;
- first token, tok/s and the whole time.

The dialog heads the parts with "Answers right: n of m" and "Right tool
calls: n of m". The numbers come from the gateway's own usage records (a
tap in appendUsage keyed on the request's context), not from each
protocol's reply. The tally of each provider's last check is kept in the
window's storage. The Providers table then shows Answers and Tool calls
columns: sortable, amber when short of all, a dash for providers not
checked, so relays are compared side by side. The dialog code is a
lazily loaded root script (relaycheck.js), as app.js has no room left.

Run, at this head:
- mote: go test -timeout 45m ./internal/gateway ./internal/gui
  ./internal/cli ./internal/usage: ok (the full ./... suite passed at
  41d88731c, before the fixed-answer calls; mote and mica were each
  running another session's GUI suite at this head);
- gofmt -l, GOOS=linux go vet -tags nogui ./... and GOOS=windows go
  vet ./...: clean;
- go test -run 'CheckRelay|ReadChatStream' -v ./internal/gateway
  (5 tests pass);
- usage-model-speed.test.cjs, chromium and webkit, en, zh, zh-TW, ja and
  de at 400px: 12/12;
- i18n-keys and old-webkit: their only reds are the three on origin/main,
  each filed (#6877 ", with an image", #5919 :has(), #6030
  headerpresets.js);
- TestCoreScriptBudget and the app.js budget: ok, not raised.
Broken by hand:
- taking tapUsage out of appendUsage turns TestCheckRelayAnsweredAsAsked
  and TestCheckRelaySaysWhatDiffers red;
- dropping the tool-name check turns TestCheckRelayCountsEachAnswer red
  (get_weather for Tokyo read as right);
- pressing Check as the dialog opens turns the GUI test red ("opening the
  dialog sends no call").
Not tried:
- the whole GUI suite at this head (both machines busy with another
  session's suite);
- a real relay (fakes only);
- a context-window probe;
- a comparison with the vendor's own count_tokens;
- a periodic check (the check runs only on a press).
2026-11-17 23:13:03 +08:00
yetone 2ace161020 usage: the model speed ranking by provider, with each provider's failed and swapped tries
skingstyle48487 on X runs more than ten relays and asked for a live view of
each one's speed and model performance. The ranking's key is now model plus
provider: each key counts its tries, the failed ones (failed or handed on)
and the swapped ones (the reply named another model, Row.Swapped). The
ledger sends them as provider_speeds; the model view merges them back as
before. settledCountVersion goes to 7 so settled pages are counted again
with the new fields.

Run (mote): go test ./internal/usage ./internal/usageapi, and the full
suite (see the last commit of this push).
Broken by hand: dropping m.Swapped++ or m.Failed++ turns
TestModelSpeedRankByProvider red.
2026-11-17 23:13:03 +08:00
yetone d4af0ca4f3 LESSONS: a filed red cited by two commits and taken by none (#6877) 2026-11-17 23:02:30 +08:00
yetone db02200ce1 gui tests: i18n-keys leaves Go test files out of a plugin's words (#6877)
"a plugin's words are its own" read every .go file but dropped only
whole-line comments. claude_image_budget_test.go (2896e82cc) has a
trailing comment "the user's message of turn i, with an image", so the
routing plugin's ", with an image" counted as said elsewhere, and the
test was red on main for a day. A _test.go file says nothing to the
window, so it is left out, as tests/ and testdata/ already are.

Run on mote (mote-run, node --test internal/gui/tests/i18n-keys.test.cjs)
at origin/main 659e8850a plus this change: 4 pass.
Broken by hand: without the _test.go clause, red on that test (the
#6877 line); a non-test internal/gateway/zz_probe.go saying ", with an
image" is still red with the change, so the guard keeps its reach.
Not run: the rest of the GUI suite (this test reads files only).
2026-11-17 23:02:00 +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 4a1ac84421 usage: Qianfan's card counts its gift and bought credit packs beside the month (yuushabu_buyinn on X)
Baidu Qianfan's Token Plan Personal also holds credit packs, Baidu's
gifts (赠送积分包) among them, and the card read only the month's plan
quota. The card now reads the console's pack list too and shows:

- "Gift credits": the gift packs still live, credits used of their
  total, and how many run out when (the soonest end with credits left);
- "Credit packs": the bought packs, the same way.

Each row shows only when the account has such packs. A pack list that
can't be read (refused, not JSON, a pack with no amount) is a "Credit
packs · Unknown" row, never 0 left. The month window goes on to credits
(Credits) while a usable pack holds some, since Baidu spends the month,
then the gift packs, then the bought ones. The pack rows are set aside
from routing. An account with no plan but live gift packs shows them as
its allowance, since Baidu spends gift packs without a plan; with no
plan and no packs (or none read) the card says there is no plan, as
before.

Endpoint: GET /api/qianfan/charge/tokenPlanPersonal/pack/list on
console.bce.baidu.com, with the cookie and headers the card already
sends for the resource list. Found in the console's public JS: the
qiankun "resource" micro-app (aip-static.cdn.bcebos.com/mb-static/
resource/), chunk index-5e21b2bb.js, which calls
send("charge/tokenPlanPersonal/pack/list", {}, {httpMethod: "GET"}) and
reads result.items: packType ("gift", "guoqing_lite", "guoqing_pro",
others bought), status ("active"), totalCredits, usedCredits,
remainingCredits, expiresAt, isUsable. The rules follow that page: a
gift pack counts while its expiresAt is ahead; bought packs while
active; guoqing packs are left out, as the page leaves them out.

No real account was used: no one here has a Baidu Cloud account with
a Token Plan or packs. The fixtures are built from the field names the
bundle reads, not a captured reply. String or number amounts are both
read.

Run at origin/main fefe3f658, then rebased on 05d46f42e (which changes
i18n.js and internal/gui); at the pushed head, on mica: gofmt clean,
go test -run 'Qianfan|Word|I18n|Tray' ./internal/provider ./internal/gui
ok, qianfan-credit-packs 2/2. At fefe3f658:
- go test -count=1 -timeout 45m ./internal/provider/ ./internal/gui/ on
  mica: ok (152s, 239s).
- gofmt -l: clean. go vet ./internal/provider ./internal/gui for
  darwin, GOOS=linux (-tags nogui) and GOOS=windows on mote: ok.
- GUI, on mote, both engines: qianfan-credit-packs (new) 2/2: en, zh,
  zh-TW, ja and de at 360, 440 and 1000px. 47 more quota, usage-card,
  credits and i18n files: the reds are the same 48 tests in 6 files
  on an origin/main fefe3f658 copy, all filed: i18n-keys #6877,
  quota-credits #6807, quota-curve #6789, quota-refresh-order #6180,
  quota-bars-alike and usage-cards-hide #6975.

Broken by hand, each red, then green again: the Unknown row dropped
(TestQianfanPlanCardPacks), Credits never set (same), expired gift
packs counted, guoqing packs counted (TestReadQianfanPacks,
TestQianfanPlanCard), a pack with no total read as 0, gift packs
always aside, and the zh "Gift credits" translation removed
(qianfan-credit-packs).

Not tried: a real Qianfan account, the pack list's real reply, and the
enterprise plan (the bundle's pack list is the personal plan's). The
full go test ./... did not run before the push: mote and mica each had
another session's full suite going. It runs next.
2026-11-17 22:01:56 +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 a922e3864e provider: moving Antigravity onto agy goes through Antigravity's proxy (huiqiang6 on X)
huiqiang6 on X: in the Docker image, moving Antigravity's accounts onto
"Antigravity (local agy CLI)" always fails at installing agy.

Reproduced with ghcr.io/yetone/magpie:latest (v0.1.4377) on
xiaomi-gpu's Docker, with the owner's real Antigravity account in
plugin-auth.json:
- plain network, amd64 and emulated arm64: the move works (26s, 39s);
  agy 1.5.10 installs into /config/data/magpie-agy-cli.
- Google unreachable directly, reachable only through a squid proxy set
  on Antigravity alone (providers.json proxy, as a user in China sets
  it): the move fails in 7s, every time, with "installing Antigravity
  CLI failed (couldn't reach Antigravity's release server: Unable to
  connect…); install it yourself with `curl … | bash`".

Cause: MoveToAgy ran agy's install and the accounts' import under
agy-cli's proxy, which a new agy-cli doesn't have, so both went direct
and never through the proxy Antigravity's requests used.

Now MoveToAgy first carries Antigravity's proxy onto agy-cli (its
provider proxy while agy-cli has no account and no proxy of its own;
each moving account's own, or Antigravity's, as an account proxy where
agy-cli would take another), then installs agy and imports through
agy-cli's. A proxy the user set on agy-cli is kept.

Run:
- go test ./internal/provider -run Agy on mote: ok. The two new proxy
  tests are red with the carry and Via lines taken out (installed
  through "", imported through "").
- A linux/amd64 nogui build of this tree in the same blocked container
  (fresh volume, same account, same proxy): the move gives
  kumw95ya25@gmail.com "added" in 26s, agy 1.5.10 installed,
  providers.json has agy-cli's proxy, and a chat request to
  agy-cli/gemini-3.8-flash answers "OK", squid logging the CONNECTs.
- gofmt -l; go vet GOOS=linux -tags nogui ./..., GOOS=windows ./...
- Full suite: not run before the push. mote and mica were each running
  another session's suite; it runs after, one per machine, and a red
  gets its own issue.

Not tried: native arm64 hardware with the proxy; the reporter's own
config (the tweet has no screenshot, so their proxy setup is inferred);
an agy-cli that already has accounts and no proxy (the move's import
then goes through agy-cli's, direct; the moving accounts still keep
their proxy afterwards). Moves that already failed simply work on retry;
none half-moved anything.
2026-11-17 21:43:12 +08:00
yetone fefe3f658c library: DS Bot gets MCP servers, skills and instructions in its own DSH home (#5897)
sunset on Discord: DS Bot (ds-bot) can be given a magpie model, but the
Library's MCP page offered no DS Bot. It had no target in targetOf and was
listed "not looked at (#5897)" in noLibrary.

DS Bot's desktop app runs its own DSH (0.2.2-rc.1 in DS Bot 0.3.8) with
DSH_HOME at its data folder (agent.dsbotHome; app/src/main.mjs) and boots
the profile ds-bot (app/src/profile.mjs) with dsh-base's bundles. Read
from github.com/Fei2411/DS-Bot and the npm packages at 0.2.2-rc.1:
- dsh-agent-instructions reads $DSH_HOME/AGENTS.md (then CLAUDE.md);
- dsh-skill-filesystem reads $DSH_HOME/skills and ~/.agents/skills, and
  a project's .agents/skills;
- dsh-mcp-client is in the app's installation (a dependency of
  @deepseek-ai/dsh in app/package-lock.json), so a patch list's insert
  row naming it loads, as in dsh; DS Bot's own bundle patch disables
  none of these.
So ds-bot gets dsh's target on its own home: AGENTS.md, skills, and
MCP rows in every profile's patch list (agent.DshPatchFiles, which globs
profiles/*/cordis.patch.yml, profiles/ds-bot's included). It reads
~/.agents/skills too (readsShared) and .agents/skills in a project.

#5624: when DSH_HOME names DS Bot's folder, the dsh agent's home is
DS Bot's. The Library's dsh target now steps back there
(agent.DshAppHome), so the two agents' rows are never written into one
patch list under two names. This doesn't fix #5624's model wiring.

Run (all at 3b47e8745 rebased on efcf8d9c0, on mica since mote was
over its cores):
- go test -timeout 45m -count=1 ./internal/library ./internal/agent: ok
- GOOS=linux and GOOS=windows go vet ./internal/library ./internal/agent: ok
- gofmt -l internal/library internal/agent: clean
At the first base (4f94b8a82, on mote): the same go test and vet ok,
and node --test internal/gui/tests library-mcp-*.test.cjs,
library-all and library-gone-agents in Chromium and WebKit: 330 of 330
pass. No GUI file changes here; the page lists agents from the API.

Broken by hand: renaming the ds-bot case turned TestDsbotLibraryTarget,
TestDshNotOnDsbotHome and TestEveryAgentInLibrary red; dropping the
DshAppHome check turned TestDshNotOnDsbotHome red.

Not tried: a real DS Bot app loading the server (no DS Bot install on
the test machines); Windows and Linux runs of the package.
2026-11-17 21:31:45 +08:00
yetone efcf8d9c0c routing: a key's row is named by its provider, the key after it (iamleehom on X)
iamleehom on X: "为什么路由中不显示供应商名称了?" Two OpenAI-compatible
providers, each with unnamed keys, showed only "sk-4…ab10" and
"sk-a…eb0c" on the Routing stage, with nothing saying which provider
each belongs to.

Cause: 83545a5d8's twin rule added the provider's name only when two
providers' keys had the same name. A masked key always differs from
every other one, so the rule never fired for unnamed keys, and a named
key unique across providers lost its provider too.

Change (plugins/routing/client.js, routing.css):
- A key's stage row is headed by a new span.prov with its provider's
  name. The key's name follows in span.who, muted, and gives up room
  first (flex-shrink stays on .who). .who keeps the key's name, so every
  test and lookup that finds a row by it is unchanged.
- The twin rule's sub-line is no longer needed for key rows; the plan
  name stays there.
- The answered card says "Provider · key" (where()).
- Rows inside a provider's fold are unchanged: the fold heading already
  names the provider once.

Not changed, filed: the request list rows and the decision lines still
name an unnamed key by its masked key alone (#6982).

Tests:
- routing-key-provider.test.cjs (new): the reporter's case, two
  providers with unnamed keys. Rows read [Relay East, sk-4…ab10] and
  [Relay West, sk-a…eb0c], the provider's name is not cut at 1100px,
  the card reads "Relay East · sk-4…ab10" from a live long-poll, and a
  fold's rows keep only the key under a heading naming the provider.
  Every language, both engines, 1100px and 440px.
- routing-twin-keys.test.cjs: re-derived to [prov, who, sub].

Run:
- Broken by hand: routing-key-provider at base 3f4372cc9's client.js on
  Windows, chromium: every non-fold subtest red (null .prov; the card
  read "sk-4…ab10"). On mica at the first design: 42 red, 20 (folds)
  green.
- Screenshots (zh 1100px chromium, en 440px webkit, de 440px chromium)
  checked by eye: "Relay East sk-4…ab10" on each row, nothing overlaps.
- Windows (xiaomi-gpu, win-run, Node 22, Playwright 1.62.0, Chromium +
  WebKit), at 90aa5bc23 (this change on 3f4372cc9): the 324 GUI files
  the change can reach (every routing-*, i18n-keys, and every file that
  opens view=routing or uses .rt- or plugins/routing): 5911 tests, 5737
  pass, 173 fail, 1 cancelled, ~59 min, beside another session's Go
  builds. The 39 red files run again side by side at base 3f4372cc9 and
  at the change (concurrency 4): 155 vs 161 fail of 774. The ones red
  on only one side are on both sides (WebKit timing, Usage,
  rest-try-now, Codex subagent); none reads a key row except
  routing-many-keys, which alone 3 times is red 1 of 3 at base (#5543)
  and green 3 of 3 with the change.
- After rebasing on origin/main 8e1534f5f, on Windows: routing-key-
  provider, routing-twin-keys, group-member-line, group-member-free,
  i18n-keys, routing-answered-still, routing-agents-apart,
  routing-keys-fold, routing-many-keys, routing-model-chip-whole: 296
  tests, 292 pass, 4 fail. Each red is red the same at origin/main
  3126b0bac on the same box: i18n-keys "a plugin's words are its own"
  (#6877), routing-many-keys chromium en (#5543), and
  routing-model-chip-whole en 1600px live in both engines (#6981, filed
  now).
- mica: go test ./internal/gui/ -run 'Budget|Compress|Revalidate|Plugin'
  ok.

Not run: the whole GUI suite at the pushed head (mote and mica were
busy, and the earlier whole-suite run on Windows was stopped because
its tree was stale); the real app; the reporter's own providers.

Reported-by: iamleehom (X)
2026-11-17 21:15:47 +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 d67ccbd3c7 agent: a provider named magpie at another machine's address is not this magpie's Alma wiring
Alex on Discord: any provider named magpie in Alma, one pointing at a
magpie on a VPS included, was taken as this magpie's own, and the Agents
page said "Alma no longer goes through magpie, its config was changed".
almaMagpie now takes a provider by the name magpie only when its base URL
is on this machine (onAnotherMachine, as ZCode's check does). One at
another machine's address is the user's own provider and left alone; the
second match, an OpenAI-shaped provider at this gateway, is unchanged.

Run (mote), at base f1a4de736; rebased onto 4f94b8a82, which changes two internal/agent files, and the Alma tests run again there: ok.
- go test -count=1 ./internal/agent/: ok (225.9s)
- GOOS=linux and GOOS=windows go vet ./internal/agent/: ok; gofmt -l clean.
Broken by hand: without the onAnotherMachine check,
TestAlmaMagpieOnAServer FAILs ("a magpie on a server taken for this one").
Not tried: a real Alma with a remote magpie provider; the test uses the
reporter's shape (id vps, name magpie, https URL, set as default).
2026-11-17 20:39:31 +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 3edfc1be9b LESSONS: a check and what it counts are one step; a reading counts what it had when taken (#6958) 2026-11-17 20:31:59 +08:00
yetone ff28dc6bd7 gateway: turns of sessions sent together are ahead of a near cap from their check, and of a reading their round isn't in (#6958)
TestCapHoldsUnderParallelSessions went red on ubuntu CI at 93% of a 90%
cap (#6958). Five sessions' turns on one account each checked whether it
was near its cap, and two gaps let a round of them past it:

- A turn found not near was counted out on the account (lanes.out) only
  once its try took its lane. Turns checking in between saw none of the
  others. Now the check and that count are one step under
  nearCaps.check: a turn found not near is counted from its check
  (lanes.plan) until its lane counts it, or it leaves. The near path's
  wait for turns out (lanes.idle) waits for those too. The key's slot is
  taken before the check, as the near path takes it, so a counted turn
  never waits for a key slot that a near turn holds while it waits for
  the count to drop.
- turnSpends took every turn come back as in the reading when the
  reading moved. A reply tells the usage as its turn begins, so the
  reading it brings lacks the round out then. At 20 turns come back, the
  reading said 82.5% while the account was at 90%. What a turn spent was
  halved (7.5 points over 10 turns, not 5), and the 5 turns since were
  never ahead of it. lanes.began now notes the turns come back as each
  try takes its lane, and ahead counts what that reading has (read).
  Turns come back since are ahead of it.

nearChecked is a test hook after the check. TestCapHoldsWithAPauseAfterTheCheck
runs the parallel test with a 15ms pause there, as a busy machine
widens it. TestTurnSpendsAhead gains the case of a round out as the
reading was told.

Run at this change on f9492fd8e:
- mote: go test -race -count=10 -run 'TestCapHolds|TestTurnSpendsAhead|TestLane|Near' ./internal/gateway: ok (31.7s)
- mote: go vet ./internal/gateway: ok
- mote: go test -timeout 45m ./internal/gateway: ok (982.9s)
- mica (mote over its cores then): the cap tests -count=5: ok

Rebased onto f1a4de736 (49e29de7b and 52d527f7b touch the gateway).
At the pushed tree, on mote: the cap, turnSpends, lane and near tests
-count=3 ok; go vet, GOOS=linux and GOOS=windows go vet ./internal/gateway
ok; gofmt -l clean.

Broken by hand, the pause test, 3 runs each:
- On the old code, red 3 of 3: "used 97.5% of a 90% cap after 25
  turns; want at most 91.5%".
- With only the read count taken out (ahead given turns as read): red,
  93.0%.
- With only the planned count taken out of out and idle: red, 93.0%.
- First cut, with the hook inside the check's lock: green with the
  count taken out too, because the lock held the next check for the
  pause. The hook now runs after the unlock, where the real gap is.

Not tried: a real Codex account at its cap with parallel sessions. The
reading's turns are those come back at the latest lane take, so a
reading still on its way (lane taken, reply not begun yet) is taken as
having them: a gap of one reply's first byte, not of a whole turn.
2026-11-17 20:31:59 +08:00
yetone f1a4de736e routing: a group's card says each member as one piece, parted by the list's comma (tmr11235 on X)
tmr11235 on X (v0.1.4334): a found group's card read "Kimi Code · K3.1
Pro · OpenCode Go · Kimi K3.1 Pro (关闭) · Devin · Kimi K3.1 Pro". The
same " · " parted a member's provider from its model and one member
from the next, so nobody could tell where a member ended.

Now each member is one span: its provider in the line's muted colour,
then its model in --fg-2 (both colours the page has), then what is said
after it (account, fast, free, off). Members are parted by the list's
own comma, t(", ") (、 in zh, zh-TW and ja), or " → " in order, never
" · ". Narrow (body.web), a member moves to the next line whole; before,
"(off)" could sit on a line of its own.

Siblings: memberLabel, the one text form, is built from the same parts
(memberParts). The group-picking card (the row drawn while selecting
groups to remove) uses the same memberLine. A nested group's tooltip in
the editor joined with " · " too and now uses memberJoin. The rule
tooltip already joins with ", ". The CLI and TUI list member ids
(provider/model), where "/" already parts provider from model; left as
they are. No new string, no new colour.

group-member-free.test.cjs read the members by splitting on " · ";
it now reads each .mbr.

Red on the old client.js: group-member-line.test.cjs (AssertionErrors:
the members are one text node parted by " · "). Red without the
body.web .mbr rule: WebKit at 420px, "(off)" alone on a line.

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).
2026-11-17 20:21:21 +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 49e29de7ba gateway: Gemini TTS models on Vertex AI and Google Gemini speak on /v1/audio/speech (Pedram on Discord)
Pedram (Discord #help, 11-14) added gemini-*-tts models to a Vertex AI
provider by hand: listed, but every speech call failed. magpie sent the
OpenAI body to <base>/audio/speech: Vertex's …/endpoints/openapi/audio/speech
(404; express mode has no OpenAI base at all, a 400), and AI Studio's
…/v1beta/openai/audio/speech (404). Google serves Gemini's speech on
generateContent alone.

serveRetrieval now asks a retrieval for a vendor shape first
(nativeRetrieval). A speech request for a Gemini TTS model (ServesOf
speech, "gemini" in the id) on Vertex AI (not a partner or Claude model),
on AI Studio (its Gemini API beside the OpenAI one, as drawGemini asks),
or on a keys provider with only a Gemini API, goes to the model's
:generateContent, signed for the Gemini API (x-goog-api-key, or the
project's Google token on Vertex) - signing it as Chat sent the key as a
Bearer, which Gemini refuses:
- text: "instructions: input" (Gemini takes style in the prompt); speed
  has no Gemini field and is left out;
- responseModalities ["AUDIO"], prebuiltVoiceConfig.voiceName: a Gemini
  voice by its name in any case (Puck, Charon…), an OpenAI voice by the
  nearest Gemini one (alloy Kore, coral Sulafat, nova Zephyr, onyx
  Algenib, shimmer Achernar…), anything else Kore;
- the answer's 24 kHz 16-bit PCM is given back as a WAV (audio/wav) by
  default and for wav, raw for pcm (audio/pcm). mp3, opus, aac and flac
  are answered as a WAV too, with Content-Type audio/wav: magpie has no
  encoder, OpenAI clients ask mp3 by default so a 400 would fail them
  all, and players read a WAV by its header. Any other format, an empty
  input and stream_format sse are a 400 before anything is sent;
- an answer with no audio is a 502 naming the finish/block reason and
  any text Gemini said instead.
Masking, routing, key and account holds, side records and the usage row
(operation speech, Gemini's promptTokenCount/candidatesTokenCount) are
serveRetrieval's own, as for every speech call. A relay with an
OpenAI-style API of its own, and plugins, are asked as before.
pipeline_check's silentWAV now uses the shared pcmWAV.

The Settings Quick check (2c644da04) finds a hand-added Vertex TTS model
through p.Models and posts voice alloy through this route, so it now
checks it (alloy -> Kore). Found on the way: such a model also stays in
/v1/models and the chat lists as a chat model; #3279 fixed that for
plugins only. Filed as #6970, not changed here.

Tests (speech_gemini_test.go, fake upstreams, no network):
TestGeminiSpeechOnVertex, TestGeminiSpeechFormatsAndVoices,
TestGeminiSpeechWithoutAudio, TestGeminiSpeechOnAIStudio (masking, the
x-goog-api-key, and a relay still on /audio/speech). On origin/main code
all four are red (Vertex/AI Studio answered with the raw JSON or a 404
path).

Run (mote, mote-run): gofmt -l clean; go test -count=1 -timeout 45m ./internal/gateway
./internal/provider ok (gateway 986s, provider 178s) at base f9492fd8e;
GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./... ok.
After rebase on b1d5912de (no upstream change to these files): gofmt,
go vet ./internal/gateway ./internal/provider and go test -run
"Speech|TestCheck|Embed|Vertex|Rerank|Transcri" ./internal/gateway ok.

Broken by hand: signing with provider.Chat -> TestGeminiSpeechOnAIStudio
red (auth "Bearer AIzaSy-test", no x-goog-api-key); dropping the OpenAI
voice map -> TestGeminiSpeechOnVertex red (voice Kore, not Sulafat);
restored, green.

Not tried: a real Gemini or Vertex call. The user's magpie config has no
AI Studio key or Vertex provider (its gemini provider is a sign-in), so
Google's real answer shape is taken from its docs. The GUI suite (no GUI
file changed).
2026-11-17 20:18:41 +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 52d527f7b2 gateway: a Codex turn that reasons after its preamble tells its speed (Archivemylife on X)
A Codex turn often goes: a one-line preamble, then reasoning (summary
or hidden), then a tool call. firstToken.see stopped looking for
reasoning once the first text had come, so such a turn was timed from
the preamble and its window held all of the thinking. The output then
read as a burst (flow*4 < window) and Usage showed "—" for its speed;
reasoning_hidden was missed for it too. Whether a turn shows a speed
depended on its shape, hence "sometimes there, sometimes not". Fast
(priority) makes the burst rule trip more often, but is not the cause.

Now reasoning seen after text marks the turn "again": the next content
restarts the text clock there, and hidden reasoning is noted. Both SSE
and WS reach the same see().

Fixture: testdata/codex-preamble-reasoning-tool.json is a real capture
(Codex gpt-6.1-sol, service_tier priority, effort high, through
/v1/responses in a sandbox HOME), encrypted_content cut short.

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
  (gateway 1117s), log kept whole and grepped
- Broken by hand: TestCodexPreambleThenReasoningTellsSpeed is red on
  the old ttft.go, green on the new.
- Real use: a sandbox gateway built from this head, real Codex
  account, priority, preamble+reasoning+tool turns: before the fix 3 of
  4 such turns read burst-flow ("—"); after, 2 of 2 show a speed (147,
  125 tok/s) with reasoning_hidden set. Plain preamble+tool turns: 6 of
  6 OK.

Not changed / not tried:
- The preamble's few tokens (~27) count in the post-reasoning window,
  about a 4% overcount.
- Hidden reasoning then a tool call with no text at all stays on
  page.js's "≥" floor (2d3b33bb7).
- The GUI was not opened against the new rows; page.js is unchanged.
2026-11-17 20:18:02 +08:00
yetone b1d5912def gateway: a Gemini image model listed as models/{id} is drawn at models/{id}, and a Lite one is sent no 2K
Dani Ariyanto on Discord: Nano Banana 2.1 on Google AI Studio always
answered 404 "models/nano-banana-2.1 is not found". AI Studio's
OpenAI-compatible /models (the Google Gemini preset's list) names every
model models/{id}, so the provider's id is models/gemini-nano-banana-2.1
(google/models/gemini-nano-banana-2.1 at the gateway, the model
Automatic image generation picked for them). Chat already dropped the
prefix (GeminiPath), but drawGemini put the id after its own /models/,
and asked /v1beta/models/models/gemini-nano-banana-2.1:generateContent.
GeminiModelPath now drops a leading models/ itself, so every path built
from it agrees: chat (GeminiPath), image generation (drawGemini), a
plugin's Code Assist path and Vertex's. The listed ids are left as they
are: renaming them would orphan every pick saved as google/models/... .

The reporter also saw gemini-3.1-flash-lite-image (Nano Banana 2 Lite)
refuse size 1024x1536 with 400 "Image size 2K is not supported for this
model". takesImageSize now says which models may be asked an imageSize
past 1K: not Gemini 2.x (as before) and not a Gemini / Nano Banana Lite,
read without models/ or a relay's google/. imageConfigOf (Gemini API
and Code Assist draws) and openRouterSize (OpenRouter's Image API
resolution) both ask it; such a model gets the aspect ratio alone and
draws at its 1K, as it did with no size asked.

Run at this change on f9492fd8e (rebased since onto 6abea5f8e, which touches internal/agent only; vet below at the pushed head):
- mica: go test -timeout 45m -count=1 ./internal/gateway/ ./internal/provider/: ok (gateway 1124.8s, provider 160.1s)
- wsl-run (Linux): the same: ok (gateway 1532s, provider 199s)
- mica at the pushed head: the three new tests ok; GOOS=linux and GOOS=windows go vet ./internal/gateway/ ./internal/provider/ ok; gofmt -l clean.
Broken by hand (old gemini_api.go and draw.go, openRouterSize given the
new signature only): TestGeminiImageModelListedWithModelsPrefix FAIL
"404 ... (asked /v1beta/models/models/gemini-nano-banana-2.1:generateContent)",
TestOpenRouterSizeOfALiteImageModel FAIL "resolution:2K",
TestGeminiModelPathKeepsSlashes FAIL for the three models/ ids. With
takesImageSize returning true for Lite, the lite case is red
(imageConfig {"aspectRatio":"2:3","imageSize":"2K"}).
Not tried: a real AI Studio key drawing Nano Banana 2.1 or 2 Lite; the
tests use the reporter's 404 and 400 texts with no network. Whether
Lite takes imageSize 512 is not known, so it is asked none.
2026-11-17 20:06:48 +08:00
yetone 6abea5f8e8 agent: Antigravity's app on Windows is found by its installer's registration (JJasonsun on Discord)
On Windows magpie's Agents page showed agy but not Antigravity's desktop
app, which macOS finds right after install. desktopApps["antigravity"]
knew only the macOS bundle, so on Windows the app was found only by
~/.gemini/antigravity/agyhub_summaries_proto.pb, which a fresh install
hasn't written (the Windows box's real 2.30.0 install has no
~/.gemini/antigravity at all).

Google's Antigravity-x64.exe (2.32.1, antigravity.google/download) is
electron-builder's per-user NSIS installer (app-64.7z, SpiderBanner,
package name antigravity). The real 2.30.0 install on xiaomi-gpu is
%LOCALAPPDATA%\Programs\antigravity\Antigravity.exe, registered under
HKCU\Software\121a0be4-63bd-531e-acf8-fc3924c7e984 (InstallLocation) and
its Uninstall entry (DisplayIcon ...\Antigravity.exe,0, DisplayVersion
2.30.0, no InstallLocation). The guid is the UUID v5 of
com.google.antigravity in electron-builder's namespace, as dsh's is. The
entry now has win and guid, so AppVersion reads the registered version
(the 2.15 gate still holds) and HasApp finds the default folder too.
Linux ships only a tarball to unpack anywhere, with no desktop entry of
its own, so Linux keeps the backend-file rule.

Run:
- Windows (xiaomi-gpu, real HKCU and 2.30.0 install, sandbox
  USERPROFILE/HOME/APPDATA/LOCALAPPDATA, PATH without agy): `magpie ls`
  from origin/main's desktopapp.go lists no Antigravity; from this tree
  it lists Antigravity.
- win-run go test -count=1 -timeout 45m ./internal/agent: every
  TestAntigravity* and the new test pass; 36 reds, 35 of them listed
  in #6068 (Windows CI only compiles tests), and
  TestEveryFieldLabelHasTUIZh (Hermes profile labels from outside the
  test home), filed as #6972. None touch desktop apps' detection.
- mote: go test -count=1 ./internal/agent ok; go vet ./...,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok;
  gofmt -l clean.

Broken by hand: origin/main's desktopapp.go with the new test ->
TestAntigravityWindowsAppRegistered red ("guid \"\""; with that check
skipped, "AppVersion \"\"").

Not tried: the gateway wiring again on Windows in this change (031938ca9
ran 2.30.0's language server headless on this box and it resolved its
models from ~/.gemini/config/config.json's gateway); a chat turn from the
real GUI app; Linux; a full go test ./... (mote and mica are near full
disk and loaded).
2026-11-17 20:05:03 +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 a75a1fffcb provider: agy's Orchestrator (Argon), gemini-pro-orchestrator-g1-pro, is priced as Gemini 4 Argon (mu33410 on X)
mu33410 on X: agy's Orchestrator model showed no cost. 9bcdcfb7d priced
the Antigravity app's Orchestrator ids (gemini-pro-orchestrator-argon,
-carbon, gemini-flash-worker-agy) as the Gemini model each is, but the
agy CLI names Orchestrator (Argon) gemini-pro-orchestrator-g1-pro: the
id `agy models` lists for a Google AI Pro account (agy 1.5.9), kept
verbatim in the agy-cli plugin's test/usage.mjs and test/catalog.mjs.
Its calls, and its rows in Usage and Sessions, had tokens and no price.
It is now in antigravityRoles at gemini-4-argon, the model Antigravity's
docs say Orchestrator (Argon) plans with; at an effort and under an
agy-cli/ route too. Orchestrator (Carbon) is gemini-pro-orchestrator in
agy, already priced as Carbon.

Tests: TestAntigravityOrchestratorIDsPricedAsTheirModel (MakerPrice,
ListPrice, PricedName), TestAntigravityOrchestratorCallsPriced (an agy
call in the ledger, its total and agy's own view) and
TestPriceOfAntigravityOrchestratorRoles take the agy id; g1 and
g1-pro-ultra stay unpriced. Broken by hand: with the old models.go all
three are red on the g1-pro cases, green with the fix (mote).

Run (mica, at this tree on origin/main 074614077): gofmt -l clean;
go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./... ok; go test -count=1 -timeout 45m ./... : 103 packages ok, no FAIL.
Rebased on origin/main 7c3e68908 (15 files, none of them pricing): internal/provider,
internal/usage and internal/sessions run again there (mica): ok.
No GUI files changed.

Not tried: a real agy Orchestrator conversation on disk. This Mac's agy
1.5.10 conversations used no Orchestrator, so the id agy writes into a
step's gen_metadata is taken from `agy models`, not seen in a database.
The worker agy records for Orchestrator's Hydrogen handoff is unknown;
gemini-flash-worker-agy (the app's) is the only worker id priced.
2026-11-17 18:59:48 +08:00
yetone 738ede4a70 agents: Speed beside Model and Effort, with what decides it (Tengs999 on X)
An agent whose model has a fast mode now shows Speed next to Model and
Effort: in the window's Details and in the tray panel's opened row. It
reads Usual, Fast (one bolt) or Ultrafast (two), and its menu (the app's
openProtoMenu, never a native select) offers Default, Fast and, where the
model has it, Ultrafast. It sets the very pick the model's bolt in the
picker sets: POST /api/agent-fast {for, ref, fast, ultra}; no new state.
A refused post puts the old pick back.

What decides the speed is said as the gateway decides it (speedNow): the
agent's own pick, else the model's own tier (ModelTiers) -> "Fast · model
setting", else for Codex its service tier in Settings -> "Fast · Codex
setting", or "As Codex asks" when that tier is unset. The tooltip says
it in a sentence, and Default's note in the menu says what Default gives.
Words in en, zh, zh-TW, ja and de.

speedNow and speedField live in agentspeed.js, imported when such a row
draws, and before a fast model's Details first slides open so it measures
the line. What is left in app.js (two helpers and three call sites) is
499 bytes; both script budgets go up by that, with the reason written.

Run (mote/mica, at this head):
- internal/gui/tests/agent-speed.test.cjs: Chromium and WebKit, en zh
  zh-TW ja de, window 1100px and panel 440px, all green. Broken by hand:
  dropping the model-tier line in speedNow turns it red ("Fast · model
  setting" expected, "Usual" actual); the panel's lazy line not taking a
  .field's place was found by it (0 Speed fields) and fixed.
- go test ./internal/gui/: ok (TestCoreScriptBudget included). gofmt -l
  clean.
- GUI files that reach the agent rows and the guards (agent-menu-label,
  fast-pick, fast-ultra, desktop-tiers, i18n-keys, kimi-subagent-pool and
  more) at this change and at origin/main 074614077, and
  agent-details-ready and old-webkit again at this head and origin/main
  7c3e68908 (the same tests red with the same numbers, e.g. 823.98 ->
  903.92): the same reds on both, each filed: agent-details-ready
  #6373/#6369, agent-menu-label (WebKit) #6371, aside-native #6212,
  codex-memories-settings #6372, desktop-tiers #6475, fast-pick/fast-ultra
  #6201, found-skill-pick-remove #5013/#4097, grip-inset #6293, i18n-keys
  ", with an image" #6877, old-webkit headerpresets.js #6030 and app.css
  :has() #5919.

Not tried: the whole GUI suite and go test ./... (both boxes were busy
with other sessions' suites); the real app, and Linux WebKitGTK.
2026-11-17 18:59:24 +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 a9cd746da3 bark: each push carries magpie's icon (豆子 on Discord)
A Bark push showed Bark's default icon, so in the notification list it
wasn't clear the push came from magpie. Push now sends Bark's `icon`
field, pointing at https://usemagpie.ai/apple-touch-icon.png: the
app's own 180px apple-touch-icon, copied into site/public and already
deployed (curl: 200 image/png).

Run:
- mote-run go test -count=1 ./internal/bark: ok (the push test now
  checks the icon field).
- gofmt -l internal/bark: clean.

Not tried: a real push to the Bark app on a phone.
2026-11-17 18:26:56 +08:00
yetone 4e977bea9e readme: x6.ai takes the README seat beside ModelGo
x6.ai paid the first month of the README seat (the owner confirmed
receipt 11-17). The logos are the two SVGs Miu sent
(x6ai-sponsor-light.svg, x6ai-sponsor-dark.svg), byte for byte: their
SHA-256 matches the mail attachments. /go/x6ai/readme sends the click
to the register link they gave.

Run: node --test site/*.test.mjs on mote, 133/133 at this head
(074614077).
2026-11-17 18:26:10 +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 64ad53f6c7 sessions: magpie sessions search and show, for agents (yansheng1003 on X)
yansheng1003 asked for a command or skill an agent can call to search
and read its sessions. magpie had the search on the Sessions page and
in the Magpie Sessions MCP server, but not on the command line.

- `magpie sessions search <words…> [--agent] [--days N|today|all]
  [--limit N] [--wait] [--json]`: the Sessions page's search
  (sessions.SearchSaid over said-v1.db; SearchSaidSince adds the --days
  bound), newest first, each hit named agent:id with title, folder,
  time and the words round the match. A one-shot command waits for the
  index (SaidReady, 60s by default, a progress line on a TTY only).
- `magpie sessions show <agent:id|id> [--find] [--from N] [--max-chars N]
  [--json]`: the viewer's reader (TranscriptOf, TranscriptAt) as text,
  from where the words were said; --json is the page's transcript.
- One renderer: the MCP server's search_sessions/read_session text moved
  to sessions.SaidText/SessionText (said_text.go), with how to ask for
  more given by each caller (TextHow). The MCP server's output is
  unchanged (its tests pass as before).
- Consent: neither reads, nor makes the index, until the user has
  answered which agents magpie may read; it prints notAskedLine and
  exits 1. An agent not allowed is ErrNotRead for --agent and show.
- Flags: an unknown flag or a missing value is refused with the usage,
  never taken for words or a session id; `--` ends flags; -h/--help
  prints the subcommand's own usage (help_cli.go).
- Parity: /api/sessions/said and /api/sessions/transcript now map to
  these commands (settings_parity_test.go).
- Library: magpie-sessions is a featured official skill
  (magpie-community/plugins skills/magpie-sessions, pushed as plugins
  cf5b0312), listed after magpie-quota.
- Docs: usage.html "Search what was said" in en, zh and ja; llms-full,
  search indexes and docs-index.sums regenerated (node docs-index.mjs).

Run at 114eb4592 (rebased on a2213b1b6), on mote:
- gofmt -l internal: clean. go vet darwin, GOOS=linux -tags nogui and
  GOOS=windows of internal/cli, sessions, gateway, library: ok (before
  the rebase; upstream's one commit touches none of these).
- go test -count=1: internal/cli -run 'TestSessions|TestEveryRoute|TestHelp'
  ok; internal/library -run TestFeaturedSkills ok; internal/gui -run
  TestEveryRouteIsNamedForTheCLI ok; internal/sessions (whole package)
  ok; internal/gateway -run 'SessionsMCP|Sessions' ok.
- site: node --test search.test.mjs worker.test.mjs, 47 pass.
- Real binary, sandbox HOME holding internal/sessions/testdata's Claude
  and Codex sessions: search before `sessions read on all` printed the
  not-asked line, exit 1; --help printed usage, exit 0; --bogus refused,
  exit 1; then search "login bug" found the Claude session, --json gave
  the Codex hit, show --find and a bare Codex id read their sessions.

Broken by hand: without the consent check TestSessionsSearchNotAsked is
red; without the since filter the --days today case is red.

Not run before the push: the full suite. Both mote (load 31 on 18
cores) and mica (21 to 30 on 12, another session's gateway run) were
over their limits; it runs at this head after the push. Not tried: real
agents' long histories (the index on a large history is the GUI's, as
before), Windows and Linux runs of the command.
2026-11-17 17:33:23 +08:00
yetone a2213b1b67 claude: a run left waiting by a compacted conversation is ended, not left working for no one (Kling__Lab on X)
Alma (autoCompact) compacted a conversation while a Claude Code run
waited on its tool calls. The compacted request went to a new run, and
the old one was never ended. With the results in the request it was
released to parkLongest (#2933's path); without them nothing touched it
and it waited runTimeout. Claude Code 2.1.317 in its interactive mode
moves an unanswered MCP call to the background after 120s and goes on,
so the orphan kept writing its session for 30 to 80 minutes, exited 1,
and the new run's model stopped to ask about the other session.

After a Claude Code run is started for a request, supersede looks at the
account's other runs (not idle ones):

- Compacted: the run waits on calls, the request names a call it made
  (pending, last answered, or in its session's lines), and the request
  begins with another first message than the conversation the run last
  heard (opening, set in heard). It is ended at once (abortFor, which
  stops its process tree). A fork or a --resume/--fork-session session
  begins with its lead's own first message and still gets #2933's
  parkLongest.
- The very turn sent again (Alma re-sent a sub-agent's Task): the first
  run is not ended, since two sub-agents may be asked the same thing. It
  waits parkLongest at most on its calls (resent, also applied in park
  if it was busy), and continueWith clears that when its own results
  come.

The two #2933 tests rewrote the conversation into a summary, which is
now a compaction; they rewrite a later message instead, as a fork does.

Run:
- New tests (claude_subscription_supersede_test.go) on the old code
  (mica): the compacted run had 5m0s and 29m59s left, the resent one
  30m0s, 3 red; the unrelated-conversation test passes on both.
- Broken by hand: without the opening check both #2933 tests go red
  (the run is ended by a fork's results); without the resend bound the
  resend test goes red.
- go test -tags nogui -race -count=3 of the Claude/subscription tests
  (mica): only TestNearCapClaudeAccountsTakeOneTurnEach, "read at 0%",
  which fails the same on 3f4372cc9 in that set and passes 8/8 alone;
  filed as #6951.
- GOOS=linux and GOOS=windows go vet ./internal/gateway/: ok. gofmt -l
  clean.
- Full suite on mote at 20e7530bc (this change on 167101d57):
  go test -tags nogui -count=1 -timeout 45m ./...: 103 ok, no FAIL
  (gateway 1020s), log kept whole. Rebased after onto cd89ccdb4, which
  changes only CI workflow files and build/pkg-shards.sh.

Not tried: a real Alma and Claude Code session; the tests drive the
bridge with fake runs. Not covered: a compacted request that keeps none
of the old run's call ids has no link to it, and runTimeout (30m) still
bounds that run. Claude Code's own 120s backgrounding is unchanged.
2026-11-17 17:26:13 +08:00
yetone cd89ccdb40 ci: macOS tests in four parts at once (#6903)
macOS ran everything in one job on a 3-core runner: ~93 minutes on
44024695993 (Test 65m, Race 24m), and the Test step met its 75m cap with
no test failing (#6903). The packages' own times sum to ~2250s; the rest
was waiting for a processor. Raising the cap would only be met again.

macOS now runs as four jobs: three shares of the packages but the gateway
(build/pkg-shards.sh, slowest first onto the lightest share, with macOS
CI's seconds for the slow packages), and the gateway with the race steps.
The old Test step is split into Test (packages) and Gateway; ubuntu and
Windows run whole as before. Vet runs once on macOS, in share 1/3. The
Test cap goes from 75 to 45 minutes.

Run: build/pkg-shards.sh 1..3 of 3 over `go list ./...` (124 packages):
41/42/41, each with three of the slow packages, ~870s apiece, and their
union is the list; the step's pipeline under bash -eo pipefail (bash
3.2 too) for each part; actionlint (only the Gofmt step's old SC2046).
workflow_dispatch run 44046493476 at this tree (branch ci-mac-parts),
all green: macOS 1/3 12m, 2/3 17m, 3/3 15m, gateway with race 34m
(the macOS job was ~93m); ubuntu 37m, windows 5m.
2026-11-17 17:04:02 +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
yetone a5b797d8d0 gui: the sidebar's torch lights a row's icon too, not only its word
Since the sidebar's sub-lists got icons, the torch hover (navlamp.js)
lit a row's word and left its icon dim in --muted. Page rows' icons and
Settings' gear were never lit either (the owner noticed it on the
sub-lists).

navlamp.js now lights the row's icon (a direct svg, .nav-ic or
.nav-s-ic) with the word: class lit, --si as the word's, and --iw, how
much of the torch's heart the word's ink would have at the icon's
middle, from the pointer's distance over the light's 36px reach with
the gradient's own stops (all of it to 12%, 45% at 45%, none at the
edge). app.css colours a lit icon between the same --hot and --far as
the word, from the icon's own ink (--lo: --muted), with no transition
of its own, inside the same color-mix @supports guard, and takes --hi
past --fg the same way. The open page's row and the selected sub-row
are never lit, as before. The gateway's status dot keeps its colour
(a plain <i>, not matched). A plugin page's mask icon follows the
colour; a plugin's favicon drawn as an <img> can't be coloured and
stays as it is. Reduced motion lights it at once, as the word. Its
light goes out with the word's, and every property it set is removed.
No :has() is added.

Run (mica-run unless named):
- new nav-lamp-icon.test.cjs: a sub-list row's icon, Providers' icon
  and Settings' gear rest in --muted, are near --fg under the pointer,
  lit less with the pointer at the word's end and back in --muted once
  it leaves; the selected and open rows' icons are never lit. chromium
  and webkit, en zh zh-TW ja de, 1024px (the narrowest sidebar) and
  1440px, light and dark. With nav-lamp.test.cjs: 42 of 42.
- broken by hand, chromium: the icon never marked lit: 10 of 10 red;
  the CSS colour line taken out: red at "lit under the pointer" (the
  icon fell back to the hover's --ctl-fg).
- old-webkit, phone-web, phone-tabs, plugin-page-icon-tone,
  plugin-page, sidebar, i18n-keys, nav-sub-fold, nav-sub-icons,
  nav-sub-unroll, side-toggle, side-width, side-gateway-lan,
  routing-side-calls: 203 of 208. The reds: i18n-keys' "a plugin's
  words are its own" (#6877), old-webkit's headerpresets.js (#6030)
  and Safari 15.0 :has() (#5919), each red on origin/main 31dcfcc33
  too; nav-sub-fold's chevron, a race in the test, fixed in the
  commit before this one.
- go test ./internal/gui (mote), the core budget with it: ok.
Not tried: the whole GUI suite (another session's full suite was on
both mote and mica); the real app's WebKitGTK and WebView2.
2026-11-17 15:48:41 +08:00
yetone ff62633a88 gui tests: nav-sub-fold waits for Settings' chevron, drawn once navicons.js is in
The sidebar draws a page's list first and draws it again with the fold
chevron once navicons.js is imported (app.js navSubs). The test read the
chevron's visibility right after the first draw, so under load it went
red at "Settings' row shows a disclosure chevron" (1 run in 3 on mica at
load 55, a different language each time). It now waits for the chevron
(up to 10s), then asserts as before.

Run (mica-run):
- navicons.js held back 1.5s in the test's server, old test: red in en,
  zh and zh-TW at that assertion; new test: 12 of 12 in chromium and
  webkit. The delay is taken out again.
- origin/main 31dcfcc33 as it is: 4 of 4 green; at load the old test was
  red 1 of 3.
Not tried: the whole GUI suite (another session's full suite was on
both mote and mica).
2026-11-17 15:48:41 +08:00
yetone 1549ccf743 sessions: agy's and Antigravity's own calls carry their first-token time and duration (guyng35955 on X)
Usage → Requests showed agy's own calls with no time to the first
token, no duration and so no speed. Those calls don't go through the
gateway, which is where other calls are timed, and the readers of agy's
and the Antigravity app's conversations never read the step's times.

Each step's metadata row (exa.cortex_pb.CortexStepMetadata) has them:
1 created_at, 6 viewable_at, 7 finished_generating_at. A model step is
created as its request goes out, so 6 less 1 is the time to the first
token and 7 less 1 the call's duration (stepTimesOf). A response that
two steps share is timed from the first step's start to the last's end.
A step with no end, or times out of order, has none (unknown, not 0).
agy and antigravity call-cache versions go to 2 so cached shards are
read again.

Checked with real agy 1.5.9 in a sandbox HOME against a fake Gemini
endpoint that held its first chunk 2.01s and ended at 4.03s: the row
said 2014ms and 4032ms. That row and transcript are the new fixture
(testdata/agy-times).

Run:
- TestAgyCallsCarryTheirTimes, TestAntigravityAppCallTimes,
  TestAntigravityAppOneResponseTimedWhole, TestStepTimesUnknown: red
  on the old readers (all 0ms), green on these (mote).
- go vet ./internal/sessions ./internal/usage, GOOS=linux and
  GOOS=windows go vet ./internal/sessions, gofmt -l: clean (mote).
- go test -count=1 -timeout 45m ./internal/sessions ./internal/usage:
  ok (mote, at 31dcfcc33).

Not run here: the full suite (running after the push) and the GUI suite
(no GUI change). Not tried: a real agy call to Google (the local
account is refused), so the times rest on the fake endpoint's run.
Seven other agents' own calls have the same gap: #6940.
2026-11-17 15:39:43 +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