Commit Graph
1538 Commits
Author SHA1 Message Date
yetone 3af592f587 gateway: the overflow memory is read under its lock, so two requests of one conversation don't crash the gateway (#3453)
Review follow-up to ggbdpq's 075aaef62. behindOverflow took the
conversation's inner map under overflowLearned's lock, let go, and then
read it, while noteOverflow and forgetOverflow write that same map under
the lock. Two requests of one conversation at once (a turn beside its
title ask, a client's retry) read and wrote one Go map together, which
is a fatal "concurrent map read and map write", the whole gateway gone.
The loop now runs under the lock.

TestOverflowMemoryReadWhileNoted notes and forgets on one goroutine while
another orders members by the memory. Before this commit, on mote:
go test -tags nogui -race -count=1 -run TestOverflowMemoryReadWhileNoted
./internal/gateway/ -> "--- FAIL: TestOverflowMemoryReadWhileNoted ...
race detected during execution of test". With it, -race -count=20 of
that test, TestOverflowRefusedOnceIsAskedLast and
TestRelayInputCapGoesToTheNextMember: ok.

Also: behindOverflow's comment said resting members keep their order;
the code moves a refused member behind every other one, resting or not,
so the sentence is dropped. gateway-routing.md now describes the memory
beside withRoom's overflow paragraph.
2026-11-01 16:43:21 +08:00
ggbdpq 9a4eaab82a gateway: a Chat body relayed to Gemini's OpenAI-compatible API goes without Ollama's options (#3097)
What changed: a client that takes the gateway for an Ollama server (its
/api/show is answered in Ollama's shape) sends Ollama's per-request
options beside its Chat fields. The google preset serves a model on
Gemini's OpenAI-compatible endpoint, so such a request is relayed as it
came, and that endpoint reads proto JSON: an unknown name turns the
whole request away with 400 "Invalid JSON payload received. Unknown
name \"options\": Cannot find field", every call, whatever the effort.
A body relayed to a Gemini OpenAI-compatible upstream (geminiCompat)
now goes without the top-level options, whose runner settings have no
place on a Chat API, as the Ollama route's own body builder already
leaves them out (ollamaChatBody). Another vendor's Chat upstream still
gets the body as the client sent it, and translated requests are
unchanged: they are built from the request's own fields, which never
carried options. geminiCompat is worked out once where the thought
signatures ask for it too.

Run: TestGeminiCompatRelayLeavesOutOllamaOptions fails on the old code
with "Ollama's options reached Gemini's OpenAI-compatible API" and
passes with the change; a request to another vendor's Chat upstream
still carries options there. go test ./internal/gateway/ ok (346.6s);
go test ./... -timeout 45m: 66 packages ok, internal/agent TestMothX
and internal/gui TestProxyCheckSaysAProxyPassedBy red, both red with
the change stashed on f5b01574 too (this machine's, not this change's);
gofmt -l clean; go vet ./... exits 0 (a cgo warning in internal/gui is
the baseline's); GOOS=linux GOARCH=amd64 go vet -tags nogui ./... and
GOOS=windows GOARCH=amd64 go vet ./... clean (GOOS=linux/darwin vet of
the gui fails in wails v3 beta on the baseline too); go build (darwin
arm64), GOOS=windows GOARCH=amd64 and GOOS=linux GOARCH=amd64
-tags nogui builds ok (a plain GOOS=linux/darwin build fails inside
wails v3 beta on the baseline too). Not tried against Google's real
endpoint: the reporter's 400 names the unknown field, and the fake
upstream checks what it is sent.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 16:43:20 +08:00
ggbdpq 026d4423d0 gateway: a Command Code stream that ends with no finish_reason is a cut (#2471)
What changed: a Chat stream of Command Code's whose reply ends with no
finish_reason anywhere - esp32gallery's day had 665 requests, 624 ended
with one, and the 20 that didn't were turns its slow starts lost to a
killed worker, each a ledger 200 with no stop and no error while the
client read "Stream ended without finish_reason" - was taken for a
turn that ended as it should, silence in the ledger and a bare
half-reply for the agent. Its API joins Gemini's OpenAI-compatible one
in saysItsEnd: every whole reply of its says its end, so a stream that
stops short of a finish_reason is said as the cut it is, in the stream,
the same way a relayed Gemini one is (#1644) - and one still held, with
nothing of the reply said yet, fails there for the group's next
candidate. Another vendor's Chat stream may still end whole with
neither a finish_reason nor [DONE]: nothing changes there.

Run: Four new tests, the first two red on cef8c1a4a before the change (the
cut passing as a whole reply, the next member never asked):
TestCommandCodeRelayEndedShort, a half-reply cut ends with "the reply
ended before it was complete", no finish_reason filled in;
TestCommandCodeTaillessFailsOver, a held lead-only stream fails 502 for
the next member; TestAnotherChatStreamWithoutAFinishReasonStaysAsItCame,
another vendor's tailless stream goes as it came; and
TestCommandCodeRelayWholeStaysWhole, a finished reply is never given a
second end.
TestGeminiCompatRelayEndedShort and TestGeminiCompatTranslatedEndedShort
green throughout. Not tried: a real Command Code upstream (the frames
are the reporter's ledger shapes, the host the one balance.go reads).

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 16:43:20 +08:00
ggbdpq eb7e72cc7f gateway: a response.completed with no output and no tokens fails over (#2471)
What changed: a Responses upstream that ends its 200 stream with a
response.completed carrying no output and counting no token - WorkBuddy
AI's account answered Codex's request with created, in_progress,
completed and `output: []` three times running (MurmuredVelpro) - had
the completed event taken for a reply's end: the held stream went to the
agent as a completed turn, the try stood as a 200 success, and the
group's healthy members were never asked. streamEvent now reads a
completed with an empty output and a zero usage as the no reply it is -
the same shape a translated reply that said nothing and counted nothing
has failed as since #2086 (repliesCounted) - and fails the held try for
the group's next candidate, in the candidate walk as an empty reply's
does: nobody rests, as the reply's shape failed, not the account. A
completed that counted a token stays a reply, as Claude's own empty
end_turn does; and an event this reaches is one nothing was said before,
since the hold lets the first content through and reads no event beside
it, so nothing of the try has reached the agent when it fires.

The fields said are what is read: a completed that names neither field
goes as it came, as the streamEvent table pinned it
(TestStreamEventRefusals, which caught the first draft reading an
omitted output as an empty one), and a completed that counted a token
stays a reply.

Run: TestEmptyCompletedFailsOver (new) red on 06c2c35d1 before the fix -
one try, status 200, Fail empty, the second member never asked, the
reported ledger shape byte for byte - green after, with
TestEmptyCompletedLeavesAWholeReplyAlone (new: a completed with output
and usage goes as it came) and TestFinishReasonErrorFailsOver green.
Not tried: a real WorkBuddy AI account (the stream is built from the
frames the reporter pasted).

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 16:43:16 +08:00
yetone c991733dca docs: the Claude bridge's tool_choice none, asides and cut-copy branches (bbfatx on X)
claude-subscription-bridge.md now describes the four commits before
this one:
- a tool_choice none turn is offered every tool, and what it may call is
  kept apart (subscriptionRun.allowed, mcpCall's refusal);
- an aside of a run that was told tools neither retires the
  conversation's run nor is taken as rewritten (asideOf);
- a branch is a cut copy of its run's session (cutSession), resumed in
  its run's mode (savedSession.tui), in place of --fork-session
  --resume-session-at, with the cache numbers measured on mote; the
  "-p because it is a branch" reason is only for a -p run's branch;
- an interactive run behind a prompt suggestion is cut at the line
  before it (branchAt, lastLine/backLine/behindLine), not told whole.
Verification lists the new tests.

Run at this tree (mote, the whole stack 252006e87..this):
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway
  ./internal/claudetui: ok (gateway 1045.8s, claudetui 9.6s)
- go vet -tags nogui, GOOS=linux go vet -tags nogui and GOOS=windows
  go vet of both packages: clean; gofmt -l internal/: clean
Every symbol and test named was checked against the tree with grep.

Not run: the full go test ./... ; queued behind other sessions' suites
on mote, it was lost before it started.

Not changed: gateway-sessions.md's --fork-session line, which is about
Claude Code's own forks of a user's sessions, not the bridge.
2026-11-01 16:33:07 +08:00
yetone 1adff37796 claude: a refusal Claude Code falls back from goes on to the fallback model's answer (Chixi_Fang on X)
Claude Code 2.1.316 doesn't end a turn at a refusal. It asks the same
model again, then its fallback model (claude-opus-4-8 for Opus 5.5),
whose answer ends the turn with result success. The bridge ended the
reply at the first stop_reason refusal, so the client got "Partial "
plus a refusal, and the gateway's hw.refused moved to another account
or handed the refusal back. That is the "model error" the reporter saw.

readOutput now holds a refusal from Claude Code's own model and goes on
with the next message as one reply. Not held: a client tool call, or a
schema reply. The refusal's stop_details are held too. The refusal is
told only if it stands: at a result with no API status (Claude Code's
model_refusal_no_fallback, -p or TUI) or at the end of output. Then
hw.refused and b01766d13 see it as before. A result with a status after
a refusal is that error, not a refusal. The continuing message's model
goes on the KUsage as Model and Served. The try records the fallback
model, and a reply told whole names it. A stream's message_start can't
change it. Prompts and system text sent upstream are unchanged.

Real behaviour: Claude Code 2.1.316 on mote, in a sandbox HOME and
CLAUDE_CONFIG_DIR, against a fake Anthropic upstream that refuses
claude-opus-5-5 (or every model). The -p and TUI stream-json lines were
captured and trimmed into the fixtures in
claude_refusal_fallback_test.go.

Run (mote-run, worktree at base 4a4a82cd4):
- gofmt -l internal/gateway: no output.
- go vet -tags nogui ./internal/gateway on darwin, GOOS=linux and
  GOOS=windows: clean.
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway: ok
  (813s).
- The new tests plus TestClaudeSubscriptionRefusal*,
  TestClaudeSubscriptionBigRefusal*, TestClaudeCutStream* and
  TestClaudeRefusalMovesToNextKey: ok.

Broken by hand:
- On the unmodified claude_subscription.go (stashed), FallbackAnswers
  (print, tui) are red with reply "Partial " stop "refusal", and
  RetryFails is red. NoFallback passes, so that behaviour is unchanged.
- Dropping the Served on the continuing usage turns the served
  assertions red.
- Dropping the collector's KUsage Model turns the non-stream try's
  Served red (claude-opus-5-5).
- Making the standing-refusal case `case standing:` (no status check)
  turns RetryFails red.

Not tried:
- A real Claude account (none on mote). The fallback was a fake
  upstream's refusal.
- The full go test ./... suite.
- Words a retracted try streamed before its refusal stay in a stream.
  Claude Code shows them too.
- A refusal after the client's own tool call keeps the old behaviour
  (the reply ends there).
- The overload/529 fallback needs --fallback-model, which the bridge
  doesn't pass (nor does Claude Code by default). That path is
  unchanged.
2026-11-01 16:19:01 +08:00
yetone 5416fdb76b agent: Claude Code on magpie keeps its MCP tools deferred (ENABLE_TOOL_SEARCH)
cybercaius on Discord (#help): the MCP router's 245 tools took 124K
tokens of a 341K context ("Magpie ×245" in Usage › Context). Claude Code
before 2.1.304 keeps tool search off behind an ANTHROPIC_BASE_URL that
isn't Anthropic's, so every router tool's definition went on every
request. 2.1.304 (10-19) turned it on for gateways itself, but a
conversation begun without it stays held off.

While Claude Code is routed through magpie, magpie now writes
env.ENABLE_TOOL_SEARCH="true" into ~/.claude/settings.json: Claude
Code's own documented switch, no prompt or identity change. The gateway
carries deferred tools to every upstream already (#2660,
withoutDeferredTools). It follows the auto-mode review's ownership:
magpie's value is stashed (claude.tool_search), a value the user set,
an empty one too, is theirs, and magpie's goes in desktopOnly/unroute.
T3 Code's magpie instance gets the same "true" in its environment
unless the user gave it a value there.

Not changed, filed as #4755: agents with no tool search of their own
(OpenCode, Gemini CLI, ...) still get the router's whole list; a lazy
router mode for them needs an owner decision. Not changed: Codex, which
already sends tool_search on magpie's catalog (0.165.0 measured: 14
tools, no MCP ones), and newmax/claudescience, which run Claude Code
through the SDK and set no gateway env of this kind.

Run:
- Real Claude Code 2.1.290 on mote, sandbox HOME, sandbox magpie serve
  on 127.0.0.1:3563 built from this tree, a fake Anthropic upstream, a
  245-tool stdio MCP server in the Library behind the router, wired
  with `magpie claude up/fake-1`: first /v1/messages had 12 tools,
  27,443 bytes of tools JSON (+~9KB of deferred names in the messages).
  The same with magpie's ENABLE_TOOL_SEARCH taken out (the old
  wiring): 266 tools, 245 of them MCP, 242,346 bytes.
- Without magpie, against a capture server: 2.1.200 to 2.1.303 send
  every MCP tool (239-257KB); 2.1.304 to 2.1.316 defer them (~28KB);
  ENABLE_TOOL_SEARCH=true in settings.json env or the process env makes
  2.1.200, 2.1.260 and 2.1.290 defer them too.
- TestClaudeToolSearchOn, TestT3CodeToolSearchOn (new); #4755 filed.
- go test -tags nogui ./internal/agent on mote; GOOS=linux and
  GOOS=windows go vet ./internal/agent; gofmt -l.
Broken by hand: writeSearch stashing nothing and writing nothing, and
T3's entry left out: both new tests red. The user-value check skipped:
TestClaudeToolSearchOn red on the user's "false".
Not tried: a real model loading a deferred router tool through
ToolSearch and calling it via magpie (gateway tests cover deferred
tools); Claude Code on Windows/Linux; T3 Code's real app.
2026-11-01 16:15:27 +08:00
yetone de74cb53f7 mcp router: each caller gets its own Magpie Browser session
The router keeps one backend per Library server for every agent, so all
agents behind it shared one `magpie mcp browser`, one browser session and
so one tab (packinggoodsllc_07668 on Discord: two agents through a remote
router fought over one tab).

- serveMCP gives a client that initializes an Mcp-Session-Id (nothing is
  kept or checked by it).
- hubSession names each tools/call's caller: _meta magpie/session from a
  router in front, else hub-<agent>-<Mcp-Session-Id>.
- The router passes it in _meta magpie/session to `magpie mcp browser` and
  to another magpie's router only (keepsSession); the bridge sends it as
  that call's X-Magpie-Browser-Session (callerSession). A call naming none
  goes as the bridge's own session, as before.

Run (mote-run): go test ./internal/browsermcp; ./internal/gateway -run
'MCP|Hub'; ./internal/library -run 'TestHubTellsMagpieBrowser|TestKeepsSession|TestHubGivesMagpieImage'. ok.
Broken by hand, each red: no meta from the library (library test), no
Mcp-Session-Id from serveMCP and ignoring _meta in hubSession (gateway test).
Not tried: a real remote router chain between two machines.
2026-11-01 16:10:16 +08:00
yetone 5dfbca6274 cli: magpie settings list|get|set|reset, through the window's own save (#4745)
Stage 1 of #4745 (StringKe): every setting POST /api/settings saves can
be read and set from the terminal.

- internal/settingsapi holds the save the handler made: Merge (the
  carry of keys a page leaves out, moved verbatim from api.go, plus
  upstream's RouterNote line), the vision/imageGen/searcher checks,
  settings.Save's own checks, catalog.Touched. POST /api/settings and
  `magpie settings` both call settingsapi.Apply, so a value is checked
  and saved one way. It sits outside internal/gui so the nogui build
  has it.
- `magpie settings` (list, the default, with value, default and
  choices; get; set; reset to settings.Defaults()), --json on list and
  get. Body sends the whole file with one key changed, so a key the
  save keeps when absent (noBird, refusalRetries, ...) is set even to
  off. A flag where a key or value goes, an unknown key (with near
  matches named) or a refused value writes nothing and exits 1;
  --help prints usage.
- Parity guards: TestKeysAreWhatTheSaveWrites (each Settings field sent
  changed on its own; what the save takes must equal Keys),
  TestSettingsCLISetsWhatTheWindowSaves (every key the page's prefsKeep
  and savePrefs send is a key), TestEveryRouteHasACommandOrIsNamed
  (each /api route has a command or a reason in notYet, which later
  stages shrink; 36 have one now).
- Item 3 of the stage (per-provider CLI-only fields in the window) is
  left for stage 2.
- The open app's in-process follow-ups (fonts, Dock, tray menu, alerts,
  language, update re-check) run only from the window's save: #4752.

Run (mote, at the pushed head 1c3591b5d + this):
- gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; GOOS=linux go build -tags nogui;
  GOOS=windows go build: clean (before rebase, the vets again after).
- go test internal/settingsapi, internal/settings, internal/cli: ok.
  internal/gui -run Settings|Prefs|Keep after the rebase: ok. The full
  internal/gui run before the rebase had three reds:
  TestSettingsSaveKeepsWhatItDoesNotSend (BusyLoad, fixed on main in
  b646a9127), TestColdTurnsTaken (fixed on main in 647323409) and
  TestMainWindowCorners/macOS_26_SDK (#3949, mote is macOS 27).
- Real run in a sandbox HOME on mote with a magpie built from this:
  settings --help / help, list, get, set theme dark, noBird on,
  redactWords "acme, globex", usageAlert 85; refused theme neon, `them`
  (names theme), usageAlert lots, trayUsageEvery 4, vision
  nobody/nothing, each exit 1 with settings.json unchanged; set
  usageAlert --help printed usage and wrote nothing. Then `magpie web`
  with MAGPIE_WEB_KEY: GET /api/settings read back each value the CLI
  set; POST /api/settings lang ja, then `settings get lang` said ja;
  reset theme gave system.

Broken by hand, each red, then put back: noBird dropped from Keys
(TestKeys, TestBodySetsOneKeyOnly, the CLI set test and the GUI parity
test red); Body dropping false values (TestBodySetsOneKeyOnly and the
CLI "noBird off" check red); a route taken out of notYet and another
renamed (TestEveryRouteHasACommandOrIsNamed red, 3 errors). On the old
code the new tests don't compile (no settingsapi, no command).

Not tried: a real run on Windows or Linux; the live app reacting to a
CLI write while open (#4752); the GUI node suite (no page file changed).
2026-11-01 15:57:43 +08:00
yetone 403323af7f claude: a switch waits for another magpie's runs in the account's directory (#4532)
StringKe's audit, item 2. claudeDirRun is an in-process RWMutex, so
`magpie accounts switch` from the CLI never waited for the app's /usage,
warm-up or keep-alive run in the saved account's directory: it handed
Claude Code the refresh token that run could still spend, and removed
the directory under it. And the gateway's hand-over let go only of idle
runs; a run in a turn when the switch came was kept for its next turn,
waiting up to idleLongest in the removed directory with the same token.

- inSavedClaudeDir also holds a lock file of its own beside the
  account's directory (markClaudeRun, <dir>.run-<pid>-<n>.lock,
  filelock), removed as it ends.
- switchSavedLogin waits on every such file (waitClaudeRuns) up to
  claudeRunWait (90s), then fails with errClaudeRunning and leaves the
  sign-in as it was. A file whose run ended without removing it is free
  and taken out.
- handedOver marks the account's runs in a turn (subscriptionRun.handed);
  keepIdle ends such a run instead of keeping it.

Shelved (parked) sessions hold no process or token; a later turn starts
a new run under the account the gateway picks then, so nothing changes
there.

Run (mote, nogui):
- new tests TestClaudeSwitchWaitsForAnotherMagpiesRun,
  TestClaudeSwitchRunHeldAndLeft, TestSavedClaudeRunHoldsItsLock,
  TestClaudeHandOverEndsTheAccountsBusyRuns, plus TestClaudeSwitch*,
  TestSavedClaude*, TestClaudeHandOver*: ok.
- Broken by hand (wait call, run mark and the handed check taken out,
  helpers kept): all four new tests red ("switched while another magpie
  ran Claude Code…", "got <nil>", "a left lock file kept", "run locks []",
  "a run of the handed-over account was kept for its next turn").
- go vet darwin/linux/windows for provider and gateway: ok.
- Windows (win-run): the three provider tests and
  TestSavedClaudeUsageKeepsRotatedSignIn: ok.

Not tried: two real magpie processes with a real Claude Code (the other
process is a second open of the lock file, which flock and LockFileEx
treat as another holder; filelock's own test covers a real second
process). Not covered, filed as #4750: a run queued behind the switch
makes the handed-over account's directory again, and a run in a turn
can still refresh during that turn.
2026-11-01 15:25:56 +08:00
yetone 01ccbd40a0 library: an MCP router says which computer it is, so an agent can pick between two (packinggoodsllc_07668 on Discord)
Two magpies, one in China and one in Los Angeles, each serve the same
tools through their MCP router (/mcp/magpie/hub). An agent connected to
both saw two identical web fetches and couldn't pick the one in Los
Angeles to reach Google.

Each router now says where it is:
- initialize's instructions end "This router: <name>. Each of its
  tools' descriptions starts with [<name>]; ...", and serverInfo.title
  is "Magpie MCP hub · <name>";
- each tool's description in tools/list starts "[<name>] " (once: a
  description that starts so already, another magpie's router behind
  this one, isn't given it twice).
<name> is the user's words (settings.RouterNote, one line, 80
characters at most) to every caller. With none it is this computer's
name, to callers on other computers only: an agent on this computer
has one router at hand, and its prompts stay as they were.

RouterNote is this computer's own (KeepOwn): library.json is synced,
settings.json isn't, so a sync never brings the other machine's name.
It is set in the Library's MCP tab, in a Router name row under the
router's address (shown while the router is on): a plain field with the
computer's name as placeholder, saved on Enter or leaving it, Escape
puts the saved words back, an input method's Enter is its own. POST
/api/settings keeps it. Translated in zh, zh-TW, ja, de.
docs/subsystems/mcp-router.md has the rule.

Run (mote, at a5a9cdf7b + this change): go vet ./... for darwin, linux
and windows ok; go test -tags nogui ./... -timeout 45m: every package
ok except internal/gui's TestSettingsSaveKeepsWhatItDoesNotSend on
BusyLoad, red on main since 8d8df0639 (#4739, fixed in the next
commit). After rebasing on 9feb1024c: internal/gui, settings, library
and gateway again, and node --test library-mcp-router-note (new),
library-mcp-hub, mcp-hub-direct and i18n-keys, chromium and webkit,
en/zh/zh-TW/ja/de, at 1100 and 420 wide.

Broken by hand: hubWhere returning "" turns TestHubMCPSaysWhere red;
dropping RouterNote from KeepOwn turns TestRouterNote red; dropping it
from POST /api/settings' carry list turns TestHubNoteSaved and
TestSettingsSaveKeepsWhatItDoesNotSend red. i18n-keys caught a test
comment saying "Router name", reworded.

Not tried: two real magpies on two computers with a real Claude Code
or Codex connected to both, and whether a model actually picks by the
prefix; the Linux and Windows apps' Library tab.
2026-11-01 15:23:15 +08:00
yetone 822f526a63 claude: /usage's "Sonnet only" week is the Sonnet week (#4532)
Claude Code 2.1.316 names it "Current week (Sonnet only)", and
claudeScopeModel made that the model word "sonnet-only", which no model
id holds: the Sonnet week used up stopped no Sonnet request in routing,
and it was a row apart from the "7 days · Sonnet" its seven_day_sonnet
header keeps (StringKe's audit, item 4, second half). A trailing " only"
is now dropped from the scope, so it reads "7 days · Sonnet", counts
sonnet, and the header replaces it in place; the GUI's existing
translation of the name applies too.

Not changed (item 4, first half): a model's own week still doesn't move
Claude Code's sign-in; usedPast counts windows that hold every model.
Moving the sign-in for one model's limit is a design question left on
#4532.

Run (mote, -tags nogui):
- TestClaudeUsageSonnetOnly: red on the old claude_usage_cli.go
  (Model sonnet-only, name "Sonnet only"), green now.
- go test ./internal/provider -run 'Claude|Allowance|Routing' ok.
- go vet darwin/linux/windows; gofmt clean.

Not tried: a real Sonnet-limited account.
2026-11-01 15:19:06 +08:00
yetone 7b6b7492a9 claude: an account on overages is read with its windows and switched off (#4532)
Claude Code's /usage line "You are currently using your overages to
power your Claude Code usage…" was in claudeUsageDenied, so the whole
reading became an error: the card lost its windows, and NextLogin, which
stays on an account it can't read, left Claude Code billing overages
while other accounts had room (StringKe's audit, item 3).

Now the line is no error. The windows under it are read as usual, and a
Text row "Extra usage" with Used 100 is added (claudeOveragesWindow), so
usedPast/roomLeft count the account spent and the switch moves off it.
The row ends when the last used-up window renews (the time Claude Code
says it switches back), else at the next reading. Routing skips Text
rows, so the gateway's own account choice is unchanged. The GUI says the
row "In use" in the reader's language (quotaText; a plugin's text row
keeps its display as it came). The overages case is out of
TestClaudeUsageFailureDoesNotHideAccountErrors: it was the bug.

Run (mote):
- TestClaudeUsageOverages, TestClaudeSwitchOffOverages: red on the old
  claude_usage_cli.go (an error; switched to ""), red with the row's Used
  set to 0 by hand, green now.
- go test -tags nogui ./internal/provider -run
  'Claude|Usage|NextLogin|Next|Switch' ok.
- GUI: claude-overages (new, 5 languages, chromium + webkit) red 8 of 10
  on the old app.js (en passes there), green now; with quota-text-row,
  quota-name-translated, i18n-keys, usage-no-reading: 40 pass.
- go vet darwin/linux/windows; gofmt clean.

Not tried: a real account on overages; the text is Claude Code
2.1.316's string table, and the windows under it are what StringKe
describes.
2026-11-01 15:16:00 +08:00
9097687a31 gui: Hide accounts leaves the user's own account names and plans in sight (#3656)
With Hide accounts (账号打码) on, the name a user gave an account
(#1515) was blurred like the account, so faketrader's several
Antigravity accounts couldn't be told apart; and an Antigravity
account whose value is "Google" blurred "Google" of its plan
"Google AI Pro" on Usage and on the Providers row. The name the user
gave an account is shown text, not an identity. The account is.

- provider: a card's Alias says whether it is the user's own name
  (SubscriptionQuota.Named, set by withAccountNames from
  AccountNameOf), since Alias is also a plugin's name for an account
  (PluginUserOf, a masked phone, #4416) or a seat's key plan, and the
  Usage page and tray panel may have no /api/providers to tell them
  apart. labelProvider is AccountLabelOf's "plugin:" lookup, shared.
- app.js names(): the user's own names (accountNames) and named
  aliases are no longer accounts to hide; accountUsers, an unnamed
  alias and a seat still are (noteAccounts keeps an alias without
  named).
- app.js mask(): labels are scoped by element, never by value
  (LESSONS: scope an exemption by where the value sits). In
  .own-name, .plan, .acct-plan (the Providers row's plan pill, new
  class), .model-value and .subscription-head > b only an address is
  hidden; a plan's and a model's tooltip too (TIPS). The own name's
  tooltip ("name · account") is masked in full.
- .own-name is set only where the text is the user's own: the
  editor's rename span when it has one (else it shows the raw
  account and stays hidden), Usage's quota-alias and the panel's
  pq-user when q.named.

From skygunner's patch (95c0511 on 19253f67), changed:
- Its .acct-who .rename exemption showed a raw non-email account
  (the rename span shows the account when it has no name of the
  user's). Now only an own-name span is exempt.
- Its [title]:not(LABELS) skipped those elements' tooltips
  altogether, so the address in "alias · user" (quota-alias, rename)
  went unmasked. Tooltips are masked; only a plan's or model's hides
  just an address.
- Dropping every alias from names() would have shown a plugin's name
  for an account (#4416 came after the patch's base). Named tells
  the user's own apart.
- The n.data.length < 2 skip the patch removed is kept.
- Its test is rewritten on the new fixtures: an unnamed plugin
  alias, an address in a plan, the editor with and without an own
  name, the panel, a model value, tooltips.

account-alias.test.cjs and account-eye.test.cjs said Hide accounts
hides the user's own name; they now say it stays in sight, the
accounts still hidden. account-alias brings the window's page to the
front before clicking #usageMask, and the panel's before waiting on
it: behind the panel's page it gets no
frames and the click waited for one, red 5 times in 2 runs at
fb3942ee6 (#2984's account-alias half), 0 in 100 after.

Not changed: the tray panel card's tooltip is one string of account
and plan, so a plan word that equals an account's value is still
hidden there (#4677). OpenCode Zen's "Signed in as <account>"
in the issue's screenshot is the raw account, hidden as before.

Core scripts: app.js's own comments in the masking module are cut, so
the core is 742 bytes under its budget at the pushed head (no raise).

What was run:
- At this on 4c815ac2a, on mote (then rebased onto 39bade71d, whose 8
  commits change only i18n.js and plugins/gateway/settings.js; the
  budget measured again, 742 under): gofmt -l; go vet
  of provider, gui, usageapi; go test -tags nogui ./internal/provider
  ./internal/usageapi ok; TestCoreScriptBudget ok; the 19 masking GUI
  files (account-*, mask-*, masking-records, privacy-*, provider-mask,
  provider-unmasked, routing-masking, window-mask, click-scroll,
  i18n-keys), both engines: 539/540. The red was account-alias's
  panel wait behind the window's page, fixed by the panel bringToFront
  above. account-alias + account-mask-alias-plan after it: 4 runs,
  159/160 (one red in "renamed in place", whose body this change doesn't
  touch, #4749). account-alias 6 more runs: 120/120 here, 117/120 on
  origin/main 90c02326b (#2984).
- account-mask-alias-plan: 20/20 on the fix (Chromium, WebKit; en, zh,
  zh-TW, ja, de; 1100 and 420), 20/20 red at fb3942ee6 (the alias is
  masked); red with the plan selectors taken out of LABELS by hand.
  account_plugin_user_test red with Named always false by hand.
- At 4eeba1ca6 (this on 90c02326b): go vet ./..., GOOS=linux go vet
  -tags nogui ./..., GOOS=windows go vet ./..., go build for darwin,
  linux (nogui) and windows: ok. go test -tags nogui ./... on the
  Linux box: every package ok except internal/agent (8 install tests
  red the same on origin/main there, #4033, #3548) and internal/gui
  (TestSettingsSaveKeepsWhatItDoesNotSend, red on main, #4514;
  TestColdTurnsTaken on mote once, #4510). The whole GUI suite on the
  Linux box, 6 wide: 16857 pass, 491 fail in 100 files, none of them
  the masking files but account-every-reset; being run against
  origin/main to sort.

Co-authored-by: skygunner <84759+skygunner@users.noreply.github.com>
Co-authored-by: vincent <vincent@users.noreply.github.com>
Co-authored-by: Fake Trader <9635792+faketrader@users.noreply.github.com>
2026-11-01 15:15:08 +08:00
yetone 39bade71d1 gateway: a plain <invoke> written into a reply's text is the call it is, on a relayed Messages reply too
packinggoodsllc_07668 on Discord (#general): Claude Code v2.1.316, magpie's
routing group "Hard to strong, easy to cheap", asked to open Google in
magpie's browser. The reply showed
  <invoke name="ToolSearch"><parameter name="query">select:…</parameter></invoke>
  *Result: Tool loaded.*
  <invoke name="mcp__magpie__magpie-browser__browser_navigate">…</invoke>
  *Result: Navigated to https://www.google.com — page title: "Google"*
  已用 magpie 的浏览器打开了谷歌 ...
as text. Nothing ran: the model wrote its calls and made up their results.
Asked, the reporter said the group holds only Claude models (v0.1.2545).

Cause: Claude wrote its own call form as text, and none of magpie's
readers of written calls knew that form on the routes Claude takes.
- The plain <invoke name=…><parameter name=…> shape (Claude's own calls,
  MiniMax's in <minimax:tool_call>, Claude's in <function_calls>) wasn't
  a mark: only <tool_call> and DeepSeek's DSML invoke were.
- A reply relayed as it came on the Messages API (a group member on a
  provider that speaks Messages itself: MiniMax, Kimi, GLM, DeepSeek, Claude
  relays) was never read for written calls at all; the subsystem doc said
  so. Claude Code's request to such a member takes that route.
- A Claude subscription member runs Claude Code itself (the bridge), whose
  textCalls held back only "[tool call …]" lines.
Not the cause: history isn't flattened (tool_use/tool_result translate to
native calls on every API), and this was the conversation's first turn.

Fix:
- textcalls.go: the invoke regexes take DSML's pipes, a namespace, or
  nothing; <invoke name=, <function_calls> and <minimax:tool_call> are
  marks; their leftover tags go. Text after a call read out, other than
  tags, ends the calls and goes with all after it: it is the model going
  on as if the call had run. This changes the old rule for every shape:
  prose after a Hermes call ("Done.") went on as text and now goes
  (TestTextWrittenCallCutEarlyNotCalled updated).
- textcalls_anthropic.go: anthropicTextCalls in passthrough, for a
  streamed Messages reply (holds the text block's start and stop with the
  held text, adds tool_use blocks after it or in its place, stop_reason
  tool_use) and a whole one.
- claude_text_calls.go: the bridge's textCalls also holds a line opening
  <invoke name= or <function_calls>, so the run is asked once to make the
  calls (textCallsAsk no longer names the "[tool call …]" form only).
- Responses and Gemini relays still aren't read: #4743.

Tests (textcalls_invoke_test.go), on the reporter's literal text: parse,
a relayed Chat stream, a Messages passthrough through a routing group
(streamed, with lead text, a lookalike left alone, and whole), and a
Chat upstream translated for a Messages client.
TestClaudeTextInvokeCallsAreMadeForReal: the bridge, bare and wrapped.

Run:
- On origin/main 586b59fe7 with only the new test file: all four
  TestInvokeReported* red. With the parser change but not the passthrough
  wiring: TestInvokeReportedAnthropicPassthrough red.
- mote-run at a6c37f936 (on origin/main 9feb1024c): gofmt -l clean, go vet ./internal/gateway for darwin, linux, windows ok, go test ./internal/gateway -timeout 45m -count=1 ok 716.8s.
- Rebased onto origin/main 5d63b3f99 (5 commits, two in internal/gateway: Codex
  loaded tools, HEIC images; no file of this change): gofmt clean, vet ok,
  and -run TestInvokeReported|TestTextWritten|TestTextCall|TestClaudeText|
  TestWritten|Passthrough ok. The full gateway suite was not rerun there.
Not tried: a real Claude Code against a real group member that writes
invokes (which provider serves the reporter's Claude models is unknown), and Responses/Gemini relays.
2026-11-01 15:08:24 +08:00
yetone 5d63b3f995 accounts: a Claude import never writes an older sign-in over a newer one (#4532)
Importing a claude-swap export of the account Claude Code was signed in
to wrote the file's sign-in over Claude Code's own (addLogin, using).
cswap exports what it saved when it last switched; Claude Code has
refreshed since, each refresh spending the refresh token before it, so
the file's was spent and Claude Code was signed out. A saved account was
replaced the same way. Only an identical refresh token was caught.

Now a Claude sign-in for an account magpie already has (Claude Code's
own, or a saved one that can still be used) with another refresh token
is taken only when the file's expiresAt is later than what magpie has,
the account's own config directory counted (claudeNewerKept). Otherwise
it is "exists" with why, nothing written. cswapEntry and loginEntry read
claudeAiOauth.expiresAt. The CLI prints the reason.

Run (mote, -tags nogui):
- TestImportCswapKeepsNewerSignIn: older-than-live, undated, newer-than-
  live, older-than-saved. Red with the check turned off by hand (three
  subtests: updated over live / saved), green with it.
- go test ./internal/provider -run 'TestImport|Login' ok.
- go vet ./internal/provider ./internal/cli on darwin, linux, windows;
  gofmt clean.

Not tried: a real cswap export against a real Claude Code sign-in. A
sign-in that was itself imported and never run is saved with expiresAt 1
(so Claude Code refreshes it first), so any dated file still replaces it.
2026-11-01 15:07:37 +08:00
yetone 0b7d5f3a20 claude: a switch waits for Claude Code's own refresh locks (#4532)
A switch read the sign-in it was replacing while Claude Code could be
refreshing it. Claude Code 2.1.316 refreshes under two mkdir locks,
<config dir>/.oauth_refresh.lock then <realpath(config dir)>.lock
(~/.claude.lock), both stale after 60s, and saves the rotated pair with a
compare-and-swap on the refresh token. So the outgoing account's token
was not written over the incoming one, but magpie kept the outgoing
account with the refresh token that refresh spent, and it was signed out
of magpie on its next use.

switchSavedLogin and addLogin (Claude) now take both locks the way
Claude Code takes them (claude_lock.go: mkdir, touch while held, take
over one untouched past the stale time, let go in reverse order) before
reading the live sign-in, and hold them until the new one is written.
putClaudeLogin's ~/.claude.json rewrite takes <real path>.lock (stale
10s), after the refresh locks, the order Claude Code saves in. A lock
held past 20s fails the switch with nothing written.

Read from Claude Code 2.1.316's bundled source: lgr/Cki/cl (refresh
locks, owner record, retries), Vno (CAS write), gi (config save lock).

Run (mote, -tags nogui):
- TestClaudeSwitchWaitsForClaudeCodesRefresh (refresh/legacy/config) and
  TestClaudeSwitchStaleAndHeldLocks: red on the old code (switched while
  each lock was held; no error when held), green now. Also green on
  Windows (win-run).
- Broken by hand: no stale takeover -> stale subtest red (20s, locked).
- go test ./internal/provider -run 'TestClaudeSwitch|TestClaudeAccount|Login'
- go vet ./internal/provider for darwin, linux, windows; gofmt clean.

Not tried: a real Claude Code refreshing while a real switch runs (its
refresh fires only near expiry). magpie writes no
.oauth_refresh.lock.owner, so Claude Code takes over a lock magpie left
only by its 60s stale time. The Library's MCP writes to ~/.claude.json
don't take the config lock yet: #4747.
2026-11-01 15:02:38 +08:00
yetone 66c0ddc19a gui: Busy models last takes a custom threshold, 1 to 9999 (axelburks)
axelburks on Discord: a vendor that queues reports loads past 100%, and
the only way to a threshold such as 150 was settings.json. Settings ›
Network and sharing › Busy models last now ends in Custom…, one more
choice in the same in-app switch (no <select>). It opens a small field
in the row whose sub says what the number means: a load in percent as
the plugin reports it, 100 is all the vendor serves at once, past 100
requests queue (200 is twice that), 1 to 9999. Enter or Apply saves it
through settings/busy-load, Escape or Cancel closes it untouched. A
value that is not a whole number from 1 to 9999 is said in red in the
sub and nothing is posted; the field keeps it to correct. The number
saved shows as its own choice ("Over 150%"), and Custom… opens with it
filled in. The site docs (en, zh, ja) and gateway-routing.md say
Custom… instead of settings.json. Code in plugins/gateway/settings.js
and i18n.js only, so the core budget is untouched.

Run on mote at this tree:
- node --test model-load, i18n-keys, bare-ids, gateway-port: all pass.
  model-load's new test runs in Chromium and WebKit, at 420 and 900, in
  en, zh, zh-TW, ja and de: Custom… focuses the field, says what the
  number means, refuses abc, 0, 10000, 1.5 and -3 with nothing posted,
  Escape closes, 150 posts {at:150} and shows Over 150% picked, 2000 by
  Enter replaces it, the row and settings don't run sideways, and no
  press moves the page more than the row changed height.
- go test ./internal/gui -run Budget: ok. gofmt -l: clean.

Broken by hand: validation turned off (if (false)) went red in every
language; the Custom… entry taken out went red in the old and new
tests; the field without flex:none was squeezed to ~20px and the width
check went red.

Not tried: the real app window (only Playwright's engines), and the
full GUI and Go suites, which run after the push (one suite on mote at
a time).
2026-11-01 15:01:24 +08:00
yetone c688211d13 gateway: a ChatGPT (Codex) account gets loaded tools where they were loaded, keeping its cache (#4738)
infinitex233 (#4738, Discord): Claude Code -> magpie -> a Codex account,
and every ToolSearch load dropped cache_read to 0. loadsInPlace sent the
additional_tools item (#2660) only to OpenAI's own API, so for an
account the loaded tool went into the top-level tools and the cached
prefix broke at the tools.

Tried on the real ChatGPT backend first (owner's account, sandbox HOME
on mote with a copied auth.json whose refresh_token was replaced, so the
live token was never rotated; ~/.codex untouched). A probe client sent
Claude Code's shape: ToolSearch with two deferred mcp tools, then the
tool_reference result, then the calls, 4 requests per run.
- additional_tools item (on, and this commit's default): request 2..4
  read 7680-8320 tokens from cache on gpt-5.6-terra, gpt-6-luna and
  gpt-6-sol; the model called read_a and read_b from the item; no
  "turned away additional_tools" in the log.
- tools top-level (off): request 2 and 3 read 0 from cache (8044 and
  8163 tokens in), as the reporter saw.
So the backend takes it, and this makes it the default for a ChatGPT
account (p.Account.Agent == "codex"). Copilot and other sign-ins stay
off: not tried.

- loadsInPlace: AdditionalToolsOff wins, then AdditionalTools, then an
  account is in only if it's Codex's, then OpenAI's API as before.
- `magpie provider set <id> additional-tools=on|off|default`: off is new
  (AdditionalToolsOff, kept through an account's Save by accountSettings
  and through the GUI editor's save like AdditionalTools). The old
  "off"/"no" meant default; now they turn it off where the default is on.
- The 400/422 fallback that names the item still applies, so a backend
  that stops taking it costs one retry and then sends tools top-level.
- No prompt, instructions or identity line changed.

Run (mote, at base 586b59fe7, this commit and the previous together):
- go test -count=1 -timeout 45m ./internal/provider ./internal/gateway
  ./internal/cli ./internal/gui: provider ok 248s, gateway ok 830s,
  cli ok 105s; gui FAIL on two filed reds that this doesn't touch:
  TestSettingsSaveKeepsWhatItDoesNotSend (BusyLoad, #4739) and
  TestMainWindowCorners/macOS_26_SDK on macOS 27 (#3949).
- Rebased on origin/main 9feb1024c, then again at this head: gofmt
  clean, vet darwin/linux/windows ok, provider ok 179s, cli ok 88s,
  gateway -run 'LoadsInPlace|LoadedTools|Codex|AdditionalTools|InPlace|
  Account' ok 99s, gui -run 'Provider|Settings|Account' red only on
  #4739. The whole gateway and gui packages ran at the base only.
- gofmt -l clean; go vet -tags nogui ./... for darwin, linux, windows ok.
- New TestCodexAccountLoadsInPlace (a fake ChatGPT backend through the
  gateway: the item with read_a, then tools top-level after
  additionalToolsOff in providers.json); TestLoadsInPlaceScope extended
  (Codex on, Codex off, OpenAI off, Copilot off by default and on when
  set); CLI test for off, on after off, default.
- Broken by hand: with the Codex default taken out of loadsInPlace,
  TestCodexAccountLoadsInPlace and TestLoadsInPlaceScope go red.
- GUI node suite not run: no JS changed; the Go editor save only keeps
  one more field, covered by the Go tests above.

Not tried: the reporter's own setup (Windows, gpt-6.1-terra), a real
Claude Code client (the probe sent its request shape), Copilot or any
other signed-in vendor with the item.
2026-11-01 14:59:44 +08:00
yetone 8042d1bf3b provider: a signed-in account's settings go through one list, so Save keeps what withPicks reads (#4738)
infinitex233 (#4738, Discord): `magpie provider set codex
additional-tools=on` said "saved" and changed nothing. Save rebuilt a
signed-in account's entry from one field list and withPicks read it back
from another; AdditionalTools was on neither.

The two lists had drifted in both directions, so the same class hit
other settings on every subscription account (Codex, Copilot, ...):
- written, never read back: QuotaRest, QuotaResetAt, RestCap. The gateway
  never saw them on an account, and the next Save of anything cleared
  them, since Save starts from Find.
- read back, never written: ExtraBody and ReplyHeaders. A Codex
  account's extraBody (magpie-releases#18), written by hand, was wiped
  by the next editor Save.
- on neither: AdditionalTools, LimitRestOff, Patience.

Fix: accountSettings is the one list. withPicks is it, and Save's account
branch builds {ID, Key, Hidden, Quiet, Tucked} and runs it, so a field
added to one is in both.

Run:
- New TestAccountSettingsKept (codex and copilot accounts): sets
  AdditionalTools, ExtraBody, ReplyHeaders, QuotaRest, RestCap,
  LimitRestOff and Patience, Save, Find, then clears them. Red on the
  old provider.go (every field lost on both accounts), green now.
  TestAccountPriceRateKept still green.
- Real CLI path in a sandbox HOME on mote: `magpie provider set codex
  additional-tools=on` wrote "additionalTools": true to providers.json
  and the running gateway used it (see the next commit for the backend).
- Suite record for this and the next commit together is in the next
  commit's body.
2026-11-01 14:50:45 +08:00
yetone 4c815ac2a5 search: searchers picked to follow the one named, tried in their order when it fails (axelburks on Discord)
axelburks asked for more than one searcher, so that when one fails
another provider searches. A searcher named in Settings gave way to no
other provider before, only to the Search APIs. Automatic already fell
back to up to three.

- settings: SearcherThen, the searchers after the one named. Entries
  are trimmed. Blanks, "off", the named one and repeats are dropped.
- gateway: when the named searcher fails (the context still live),
  modelSearch asks each of SearcherThen in order and skips one that
  can't search now or is the same model. The first that searches
  answers, and the call is marked searchingInstead, so the Routing row
  says why the named one didn't search. If all of them fail, their
  errors go back together, saying "the searchers picked ..., in their
  order", and webSearch goes on to the Search APIs as before.
  SearchFailure.Instead names the one that searched in its place.
- gui api: searchFailed.instead. A save takes only searchers that
  Searchers() offers. A save without searcherThen keeps the list, since
  the page's prefsKeep doesn't send it, and [] clears it.
- Settings › Web search (plugins/search/settings.js, outside app.js's
  budget): an "If it fails" row under a named searcher, with numbered
  chips and Add. A chip's picker changes the chip or removes it. The
  row is hidden for Automatic and Off. The failure line names who
  searched instead, or says the ones after it failed too. The help
  text says the same in en, zh, zh-TW, ja and de.
- docs: gateway-routing's failing searcher, and gui-shell.

Tests:
- TestPickedSearchersInTheirOrder (gateway): one test where the named
  searcher answers without searching and one where it fails. A gone
  entry and one that can't search are skipped, and the third searches
  once. With no working entry, the error says so and Instead is empty.
- TestSearcherThenSaved (settings) and TestSearcherThenFromSettings
  (gui): what is saved, kept and cleared; refusing an entry that can't
  search. settings_keep_test sets SearcherThen.
- searcher-then.test.cjs: chromium and webkit, en, zh, zh-TW, ja, de,
  at 560 and 1000 wide. Checks the row's place and words, what Add
  offers, the posted lists, that the chips fit with no horizontal
  scroll, that no click moves the page, and both failure lines.
Broken by hand: running no fallback turned TestPickedSearchersInTheirOrder
red (both subtests: "ds2 searched []"). Not keeping the list on save
turned TestSearcherThenFromSettings and the keep test red.

Run on mote (mote-run):
- At the pre-rebase tree (base 21882a68d): go test of settings, and
  -run 'Searcher|Search' of gateway and gui: ok.
- searcher-then, searcher-pick and i18n-keys in both engines: 46 of 46.
- gofmt clean. go vet: darwin gateway, gui, settings; windows the same;
  linux gateway and settings on mote, gui with -tags gtk3 on the Linux
  box (wsl-run): ok.
- Rebased onto origin/main 1e6a27d4f, this tree: -run
  'Search|Searcher|CoreScriptBudget|SettingsSave' of gateway, gui and
  settings: gateway and settings ok; gui ok but for
  TestSettingsSaveKeepsWhatItDoesNotSend on BusyLoad, red on main
  since 8d8df0639 (#4739, not this change; SearcherThen passes its
  check). The three GUI files above: 46 of 46.
  Pushed on origin/main e62a1bc51. Its 6 commits since touch routing,
  sessions and rex files only, none of these, and weren't run here.
Not run before the tag: the whole GUI suite and the full go test of
gateway, gui and settings. They are queued behind other sessions'
suites on mote and run after the push; any red they find gets its own
commit.
Not tried: a real relay or a real searcher failing in the GUI app.
2026-11-01 14:43:18 +08:00
yetone 0b4aa96fd0 gateway: a relay whose models are typed in by hand is offered as a searcher (axelburks on Discord)
axelburks added a custom provider on OpenAI's Responses API and ticked
"Searches the web by itself", but Settings › Web search's searcher
picker didn't offer it. Searchers() and namedSearcher took a
provider's models from Available() alone. A relay with no /models
list has its models typed in by hand (Exposed) and none available, so
it was left out of the picker, while the same row named it among the
relays to pick there. searcherModels gives what the provider lists,
then the hand-typed ones it doesn't. A relay that lists its models was
offered before this already.

Tests:
- TestSearcherRelayWithoutModelList (gateway): a Responses relay with
  no /models and a typed model is a searcher and is resolved by name.
- TestSearcherPickerOffersResponsesRelay (gui): the relay saved the way
  the editor saves it is in SearchChoices with its model.
Both were red on the old code.

Run (mote-run), at this commit alone: go vet of gateway and gui, and
go test -run 'Searcher' of gateway and gui: ok. The full checks ran
with the next commit; its body has them.
Not tried: the reporter's own relay (we don't know whether it lists
its models; the reply asks).
2026-11-01 14:43:07 +08:00
yetone 994cd4fb68 gui: Rex switches to the tab magpie opens, through the app's session.select (#4565, StringKe)
StringKe tried v0.1.2446 on the real Rex app (Rex Beta 0.1.0 (1696)):
the tab opens, but the app keeps showing the tab the user was on. The
new tab shows only in the sidebar, and `open -b` only brings the window
forward. The app's own session.select action, sent to the app client,
does switch to it.

After `rex run` (reused magpie session) or `rex new` (now with --json,
for session_id and initial_windows[0].window_id), openInRex brings Rex
forward and then calls rexSelect. rexSelect reads `rex client list
--json`, takes the client of info.kind "app" whose session_ids hold the
session, else the last app connected, and skips one whose
connection_state is "lost". Then it runs `rex -C <client_id> do
session.select session_id=<id> window_id=<window>`. App actions need
Remote Control on in Rex's settings. With no app, a failed list, a
refused do or no answer within 3s (rexSelectWait), the open still
succeeds, the same way a failed rename is ignored. docs/reference.md's
Rex paragraph says this.

Command shapes come from the real rex CLI, snapshot 0.0.1793420730-
g6d0d9a, on mote with a sandbox HOME and XDG_RUNTIME_DIR: `rex --help`
(-C is a global flag, label or ID), `rex do --help`, `rex client ls
--help`, `rex api describe client.list` (client_id, info.kind
app|cli|agent|other, connection_state connected|lost, session_ids),
`rex new --json` output. With no app connected, `do` without -C exits 3
("no app client is connected"), and -C <unknown> exits 3. A client that
doesn't answer keeps `do` waiting 10s ("did not answer within 10s").
That is why the select runs after open -b and has its own 3s bound.

Tests: TestOpenInRexSelectsTheTab runs a fake rex program (a sh script,
so arguments go through a real exec), with a new session and with
magpie's session reused. It checks that the app attached to the session
is picked over another, that a lost app is never asked, and that no
app, a failing client list, a refused do (exit 1) or a do that never
answers (exec sleep 30, killed at the bound) leave the open a success
within its time. The in-process fakeRex answers client list (no app)
and new --json. TestOpenInRexReal runs these paths against the real rex
server, with no app client.

Ran, through mote-run, on this tree before the rebase onto 1e6a27d4f:
- gofmt -l; go vet ./internal/gui; GOOS=linux -tags nogui and
  GOOS=windows go vet ./internal/gui; GOOS=linux -tags nogui and
  GOOS=windows go build .: ok.
- MAGPIE_TEST_REX=<real rex> go test -count=1 -timeout 45m
  ./internal/gui: everything passed, TestOpenInRexReal included, except
  TestSettingsSaveKeepsWhatItDoesNotSend (#4739, #4514) and
  TestMainWindowCorners/macOS_26_SDK (#3949). Both fail the same way
  alone on a detached origin/main 1e6a27d4f.
- At the rebased head on 1e6a27d4f: gofmt, go vet ./internal/gui and
  MAGPIE_TEST_REX=<real rex> go test -run
  "Rex|DiscoverTerminals|TerminalOpenArgs|AgentOpen" ./internal/gui: ok.
- No sleep, rex server or /tmp/rx* left on mote afterwards.

Broken by hand, each red, then restored: the old openInRex (4 of 7
cases red: "asked [], want [-C client:… do session.select …]"); the
attached-app preference dropped (the other app asked); the lost-state
skip dropped (the lost client asked); the 3s bound made an hour (the
never-answering case took 20.0s).

Not tried: the Rex app itself (its download needs a Discord sign-in),
so a real app client's session.select and what a refusal with Remote
Control off looks like are known only from StringKe's report and the
docs; the handling doesn't depend on which. Not the full go test ./...
(only internal/gui changed). No GUI Playwright run (no JS changed). Not
run on Linux or Windows (the tests skip on Windows).
2026-11-01 14:39:13 +08:00
yetone a5a9cdf7be gateway: a refused big conversation isn't told again to the Claude subscription's other accounts (Aisiverto on X)
Aisiverto on X: a refused turn of a ~900K-token conversation made magpie
switch accounts and send it again, "one user action becomes several
expensive requests". In the usage, pairs ~100ms apart: one read the whole
conversation from the cache, the other read ~26K and wrote ~877K.

The cause: a refusal goes to the next candidate under RefusalRetries
(unset: every one left), and matesFirst puts the same model's other
accounts first (#248, where a verified account may answer). For a Claude
subscription each other account is a new Claude Code told the whole
conversation, all of it written to that account's cache again, for a
refusal about the content that it most likely gives too.

Now, before a Claude subscription account's try, a conversation of
retellMost (100K) tokens or more by estimate (tooBigToRetell) leaves the
subscription's other accounts out if that account refuses
(otherThanClaudeAccounts). Other members are still asked; with none left
the refusal is the agent's, and it isn't handed over mid-stream to
nobody (handsOver is given last). A smaller conversation goes to the next
account as before. The size is measured only when another Claude
subscription account is left. gateway-routing.md says so beside
RefusalRetries.

Run:
- TestClaudeSubscriptionBigRefusalNotToldAgain (new; streamed and not):
  red on the old code (runs "own,tok-spare"), green with the fix, the
  agent getting the refusal. TestClaudeSubscriptionRefusalMovesToNextAccount
  (small conversation, spare still asked), TestRefusalRetries* and
  TestPolicyRefusal* green.
- Broken by hand: tooBigToRetell always false, red.
- On mote: gofmt -l clean; go vet, GOOS=linux go vet -tags nogui and
  GOOS=windows go vet of internal/gateway ok; go test -tags nogui
  -timeout 45m ./internal/gateway: ok (702s). The whole suite ran at the
  parent commit (its body); this commit touches internal/gateway only.

Not tried:
- The handsOver change: the test's refusal comes with no reasoning
  before it, so nothing is handed over, and taking the change out stays
  green. Not covered by a test.
- A large conversation where another member of the group is a Claude
  subscription of a different provider id: it is left out too, as every
  Claude subscription account is.
- A real Claude refusal on a real account.
2026-11-01 14:28:40 +08:00
yetone 2af4d8c62d claude bridge: tool results another request answered first branch off the run's session (Aisiverto on X)
Aisiverto on X: a Claude Pro account's five hours went from 96% left to
1% in about five messages of a ~900K-token conversation. The usage had
pairs of requests about 100ms apart: one read ~900K from the cache, the
other read ~26K and wrote ~877K.

The cause: Claude Code's fork sub-agents start from their lead's
conversation, each of the lead's calls answered "Fork started", and they
come with the lead's own next turn. One of them goes on in the run that
made the calls. Each other one (and a resend, or one after the run has
delivered) got a new Claude Code told the whole conversation in one
message, a prefix Anthropic's cache had never seen. So it was written
to the cache again, about a fifth of the plan's five hours each time.

Now the run keeps where in its session each call of the client's tools
was written: the uuid on Claude Code's stream-json assistant line
(noteLines). As it parks, it also keeps the conversation those calls
answered. A request no run takes, whose last reply's calls a live run of
the same owner made from the same conversation, goes on in a -p branch:
--resume <session> --fork-session --resume-session-at <uuid>. That is the
conversation as Claude Code sent it to Anthropic, so it reads the
cache, and it is told only the results and the directive after them. The
lead's session file stays the lead's. There is no branch with client
cache marks, in interactive-only mode, or from a rewound, closed or
sessionless run. Then, and if the resume fails, the old path is taken.
The -p reason is "branch", worded in claudemode.js and i18n.js (zh, zh-TW,
ja, de). The subsystem doc's section says so.

Run:
- Claude Code 2.1.316 (real binary, on mote), against a fake Anthropic API and a
  fake MCP tool. --resume S --fork-session works while another
  process holds S. --resume-session-at <assistant uuid> cuts the copy
  there even after the lead went on, and the prefix up to the tool_use
  matches the lead's. Calls it answered nothing for get a
  synthetic error result.
- TestClaudeForkBranchesOffTheLeadsSession (new): red on the old code
  ("told it whole"), green with the fix.
- Broken by hand, each red: park() not stamping the conversation the
  calls answered; serveSubscription not asking branch().
- On mote, before the rebase onto origin/main 21882a68d: gofmt -l
  clean; go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./... ok.
- On mote at this commit (on 21882a68d):
  - go test -tags nogui -timeout 45m ./...: every package ok but
    internal/gui, whose two reds are filed and untouched here:
    TestSettingsSaveKeepsWhatItDoesNotSend (BusyLoad, #4739) and
    TestColdTurnsTaken (#4510).
  - GUI claude-mode and i18n-keys, Chromium and WebKit: 78 of 78 pass.

Not tried:
- A real fork sub-agent against a real Claude subscription through
  magpie. The branch flags were run with the real binary, not through
  the gateway.
- A winner running in the interactive (TUI) mode: if its output has no
  uuid on assistant lines, there is no branch and the old path is taken.
- A loser that comes before the winner's run has parked takes the old
  path.
- Windows and WSL.
2026-11-01 14:28:40 +08:00
yetone 7503beee72 plugin, settings: a model's load goes past 100% for a vendor that queues (axelburks on Discord)
axelburks, on v0.1.2547: their vendor queues, so a model's load can be
past 100%, even 200%. magpie clamped every load to 100, and Busy models
last allowed 1-99 only.

- host.js reportLoad and plugin.noteLoads keep a load from 0 up. The
  floor is still 0, null still clears it, and a sanity cap of 10000
  (LOAD_MOST, plugin.LoadMost) keeps an absurd value from reaching the
  UI or the trace.
- settings.BusyLoad takes 1 to 9999 (BusyLoadMost-1). The segment
  choices stay Off/50/70/80/90, and a value set in settings.json (150)
  shows as its own choice, as before.
- The editor's badge reads "180%". It is a badge, not a bar, so nothing
  assumed 100 wide; the test checks it stays on one line.
- Docs: site plugins page (en, zh, ja) Values and Routing bullets, and
  provider-plugins.md and gateway-routing.md.

Run on mote via mote-run, on origin/main 8d8df0639+ rebased:
- go test ./internal/plugin ./internal/gateway ./internal/settings -run
  'ModelLoad|TestBusy' -v: all pass. TestPluginReportsModelLoad has
  over:250 kept and huge:1e9 at 10000. TestBusyModelGoesBehind has 180
  behind 120 at a threshold of 150, and 10000 refused.
- Broken by hand in a copy, with the old 100 clamps and the 99 limit:
  TestPluginReportsModelLoad red ("ModelLoad(over) = 100; want 250"),
  TestBusyModelGoesBehind red (150 refused).
- node --test model-load (with Queued 180% in every language, Chromium
  and WebKit, 420 and 900, plus Over 150% picked at 420) and i18n-keys:
  46/46 pass. go test ./internal/gui -run Budget: ok.
- gofmt -l: empty. GOOS=linux go vet -tags nogui and GOOS=windows go
  vet on plugin, settings and gateway: ok.

Not run before the push (owner: push and tag first): go test ./... and
the whole GUI suite. They are queued on mote behind another session's
suite.
2026-11-01 14:28:25 +08:00
yetone f2f75ee4ae provider: Volcengine Ark's System One API, in beta, as a decider (axelburks on Discord)
Ark answers System One at https://ark.cn-beijing.volces.com/api/v1/systemone
(and /api/v3/systemone) only with the beta header ark-beta-systemone-api:
true; without it the reply is a bare 404. The new volcengine-decision preset
asks it with an Ark API key, and magpie sets the header (DecideHeaders) on
Ark's own host only, ark.<region>.volces.com, in both the gateway's
/v1/systemone and the provider's Test. Its decision model,
doubao-seed-2-1-lite-260915 (ArkDecision), is kept apart from Ark's chat
list as Bailian's is (vendorDecision), since no /models names it.

Learnt from the real API on 11-01 with the owner's Ark key (read from
magpie's config, never printed): only doubao-seed-2-1-lite-260915 answers;
doubao-seed-2-1-pro-260628, doubao-seed-2-0-lite-260428 and
deepseek-v4-1-flash are refused 400 "does not support the SystemOne API".
The Coding and Agent Plans' paths (/api/coding/v3, /api/plan/v3, their v1s)
answer an empty 404 even with the header, so it bills as pay as you go. An
image in the request was left unread (a red square came back 0.48, input
tokens as for no image), so images are off. The tests' replies are the
real response bytes.

Run:
- Real: a magpie built from this tree on mote, in a sandbox HOME:
  `magpie provider add volcengine-decision <key>` and `provider test`
  (decide ok, 413 ms), then `magpie serve` on a free port and POST
  /v1/systemone through it: a real 200 with Ark's choice.
- gofmt -l internal/: clean. go vet darwin, linux, windows of
  internal/provider and internal/gateway: ok.
- mote-run go test -count=1 -timeout 45m ./internal/provider/
  ./internal/gateway/ ./internal/gui/ ./internal/cli/ at base 21882a68d:
  provider ok (140.6s), gateway ok (652.6s), cli ok (58.7s); gui FAIL on
  two tests this change doesn't reach, both filed:
  TestSettingsSaveKeepsWhatItDoesNotSend (BusyLoad, red on main, #4739)
  and TestMainWindowCorners/macOS_26_SDK (mote's macOS 27, #3949).
- Rebased onto origin/main 788057340, this tree: vet darwin, linux,
  windows ok; go test -run 'Ark|Decid|SystemOne|Bailian' of provider
  and gateway ok.
- Broken by hand: without the DecideHeaders calls both Ark tests go red
  (provider: Ark's empty 404; gateway: FAIL).

Not tried: a routing group classified by Ark end to end in an agent;
regions other than cn-beijing; Ark's window on System One (no docs page
for it was found, so none is set).
2026-11-01 14:17:21 +08:00
yetone 788057340b library: Magpie Image Recognition in Discover beside Magpie Image and Web Search (matrix0487 on Discord, #4653)
matrix0487 asked on Discord (#feedback) for all three of magpie's own MCP
servers, image recognition, image generation and search, in the Library's
Discover. Image generation and search were there; image recognition was
an address to copy in Settings only (#4653).

- `magpie mcp vision` (browsermcp.RunVision) relays stdio to the
  gateway's /mcp/magpie/vision, as `mcp search` does. analyze_image's
  relative image path is made one in the agent's folder on the way
  (imageFrom), since the gateway can't know where the agent runs; an
  absolute path, ~, a URL or a drive goes as written.
- library: magpie-vision is a featured, opt-in server (no agents until
  picked), any binary's `mcp vision` is one server (serverKey), and it
  gets the 120s tool timeout (selfTimeout).
- Settings › Models › Images: the Image recognition row has Give agents
  Magpie Image Recognition… / Turn on the Library, none with recognition
  off or in gateway mode. The three links are one helper, libWay, used by
  Image generation and Web search too (no budget raised: core 1,533,011
  of 1,533,105).
- Never a dead tool: Discover lists all three whatever is set up, and one
  that can't answer yet says why (gateway.OwnUnready, set by
  /api/library/market/servers as `unready`): a "Not set up yet" badge on
  its card with the reason as its title, and the reason in its sheet
  (nothing set up, or turned off in Settings / Plugins). It can still be
  added; its tools already answer with the same reason until then.
- Strings in en, zh, zh-TW, ja, de; docs/subsystems/library.md.

Run, all on mote (macOS 27) through mote-run, at this head's tree
(rebased on 21882a68d):
- gofmt -l internal/: clean. go vet darwin; GOOS=linux -tags nogui;
  GOOS=windows: browsermcp, cli, library, gateway, gui, imagemcp ok.
- go test -timeout 45m: internal/library, browsermcp, cli, imagemcp ok;
  internal/gateway ok (whole package, 556s, before the rebase; OwnMCP,
  OwnUnready, VisionMCP, SearchMCP after it). internal/gui: three reds,
  none from this change, each red on origin/main 21882a68d too:
  TestSettingsSaveKeepsWhatItDoesNotSend (BusyLoad, from 8d8df0639,
  filed #4739), TestMainWindowCorners/macOS_26_SDK (#3949),
  TestColdTurnsTaken (#4510). Budget tests ok.
- New: TestMagpieImageRecognitionIsOptIn, TestVisionBridgePassesLines,
  TestImageFromLeavesTheRest, TestOwnUnreadyWhileNotListed.
- New GUI test vision-mcp-library.test.cjs: chromium + webkit, en, zh,
  zh-TW, ja, de, 1100 and 420px (link opens the sheet with its hint and
  unready line; Library off → Turn on the Library; one added opens
  Discover with all three, only the unready one badged, inside its card;
  gateway mode and recognition off show no link; no horizontal overflow,
  no page errors): 206/206 with search-mcp-library and
  images-library-way. On e84870f17 (old code), chromium: every link and
  Discover case red.
- i18n-keys, gui-de, gui-zh-tw ok; gui-ja's one red is #4580, the same
  on origin/main 21882a68d.
- Broken by hand: serverKey without "vision" → TestMagpieImageRecognitionIsOptIn
  red; imageFrom not joining the folder → both browsermcp tests red.
- Real use, sandbox HOME on mote, nogui build, `magpie serve` on
  127.0.0.1:3591: `magpie mcp vision` initialize / tools/list answered;
  analyze_image of shots/a.png says "magpie has no model that sees
  images…"; missing/b.png names /…/work/missing/b.png (relative path
  resolved); an extra argument exits 1; gateway down answers id 9 with
  "magpie isn't running, so Magpie Image Recognition can't be reached".

Not tried: analyze_image against a real seeing model through the relay
(the sandbox had no provider; the gateway path is the one /mcp/magpie/vision
already serves); a real agent adding it from Discover; WSL (unchanged,
the MCP router serves it there); the whole GUI suite, queued after
mote's running one.

Reported-by: matrix0487 (Discord)
Closes #4653
2026-11-01 14:12:42 +08:00
yetone 8d8df06399 plugin, gateway: a plugin reports its models' load, and busy models can go last (axelburks on Discord)
axelburks (Discord #feedback): an in-house vendor queues requests to
its busy models, and the plugin could only put the load in the model's
name, which changed only when magpie re-read the list.

- A provider plugin calls input.magpie.load(provider, {"<model id>":
  0-100 | null}) whenever it likes, from its own timer. host.js
  (reportLoad) clamps each number to 0-100, null clears a model, every
  other value is dropped, at most 1000 a call, and it returns the count
  taken. A provider that isn't a string or loads that isn't an object
  throws a TypeError. It goes to Go as an unasked {event:"load"}.
- internal/plugin/load.go keeps each by provider and lowercased model
  id. ModelLoad answers unknown once a load is older than LoadFresh
  (5 minutes), never idle. model@size falls back to its model.
- The provider editor shows it by the model as a grey ctx badge
  ("87%", titled "87% busy now, as its plugin says").
- Settings > Network and sharing > Busy models last (settings.BusyLoad,
  POST /api/settings/busy-load, Off by default, over 50/70/80/90% or
  1-99 by hand): restLast puts a model reported over it behind the
  ready candidates, ahead of the resting. The trace row has busy:<load>.
  At a new turn affine moves a conversation off it (Why "busy",
  busyBehind); within a turn it stays. after, readyForNew and leastHeld
  skip it. Unknown load, a lone candidate, or all busy: nothing moves.
- Docs: site plugins page (en, zh, ja) "Model load" section and input
  table; docs/subsystems provider-plugins.md and gateway-routing.md.

Run, all on mote via mote-run at a42736807's tree rebased on
origin/main b683f1c0e:
- go test ./internal/plugin ./internal/gateway -run
  'ModelLoad|TestBusy' -v: TestPluginReportsModelLoad,
  TestModelLoadGoesStale, TestBusyModelGoesBehind,
  TestBusyModelNotKeptAtNewTurn pass.
- Broken by hand, each red: host.js not sending the event
  (TestPluginReportsModelLoad "the plugin's loads never arrived"), the
  busy case off in restLast (TestBusyModelGoesBehind order), the affine
  "busy" case off (TestBusyModelNotKeptAtNewTurn "kept true, why
  session").
- go test ./internal/gui -run Budget: ok. No budget raised. app.js
  +86 bytes, two comments trimmed to fit. The settings row lives in
  plugins/gateway/settings.js.
- node --test model-load, i18n-keys, bare-ids, model-rate: 69/69 pass.
  model-load is Chromium and WebKit, 420 and 900 wide, en zh zh-TW ja
  de.
- gofmt -l: empty. go vet ./... (darwin), GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./..., go build: ok.

Not run before the push (owner: push and tag first): go test ./...
-timeout 45m and the whole GUI suite. mote and the WSL box were each
running another session's full suite. Both run next, and any red gets
its own commit.
Not tried: a real plugin and vendor reporting load. The plugin side is
tested through the real Bun host with a plugin written in the test.
2026-11-01 13:45:40 +08:00
yetone 3defaf6622 dsh: a new desktop profile gets magpie's routes when the start is the user's (zyh6036 on X)
DeepSeek Harness Desktop 0.2.1-rc.5's picker listed only "DeepSeek 账号".
The app reads $DSH_HOME/profiles/desktop (apps/desktop/src/paths.ts) and
makes it from an empty template on its first start. dshFillNewProfiles
gave such a profile magpie's routes only when a wired profile started on
one of magpie's models; with the web profile wired but started on one of
dsh's own, it returned early and the desktop profile stayed bare. Now a
bare profile gets the routes alone in that case (no start written, the
user's pick stays theirs), and nothing is filled when no profile is wired.

Run:
- go test ./internal/agent -run TestDshFillNewProfiles on mote at
  ed5872d18: the new TestDshFillNewProfilesWhenTheStartIsTheUsers red on
  the old code (desktop profile left as the template), green after.
- go vet ./internal/agent (darwin, GOOS=linux, GOOS=windows) and
  go test -count=1 -timeout 45m ./internal/agent on mote: ok (183s).
- Real DeepSeek Harness Desktop 0.2.1-rc.5 (official zip, sha512 checked
  against nightly-mac.yml) on mote, sandbox DSH_HOME, not signed in:
  first start wrote profiles/desktop/cordis.patch.yml as the empty
  template; with a route-only patch (no agent-default-model), as this
  change writes, the picker listed the Magpie group (35 models).

Broken by hand: the no-profile-wired guard taken out, the test's last
check goes red (web and desktop templates filled).

Not tried: the reporter's own patch (not sent yet); a signed-in DeepSeek
account in the desktop app; the full go test ./... suite; Windows.

At the pushed head (rebased on e84870f17): go test -count=1 -run Dsh
./internal/agent on mote ok, gofmt -l clean.
2026-11-01 13:29:19 +08:00
yetone e84870f173 plugins: an option's words in the window's language, and a filtered model list says so (plugins#590)
anewuser6937 (Discord, plugins#590) saw one model in WorkBuddy's editor
and took the plugin for broken. They had turned on "Free models only"
themselves, but its label and description read in English in the Chinese
window, and nothing by the models said the list was filtered.

A plugin option (auth.options, magpie's own field; OpenCode's AuthHook is
provider/loader/methods and never reads it) may now give `labels`,
`descriptions` and `confirms`, each keyed by the window's language
("zh", "zh-TW", "ja", "de"), beside the plain strings, as a page's
`titles` do. The host keeps only non-empty strings under language names
of 16 or less, 16 languages at most, each capped as the plain one is
(60/300/300). The editor shows the exact language, then its first part
(zh-TW reads zh), else the plain words, in the row, the hint, and the
confirm dialog and its title. `filtersModels: true` says the plugin's
model list leaves models out while the switch is on; while one is on, as
saved, the Models field says under the chips "Only some models are
listed: the plugin option “…” is on." (zh 只列出部分模型:插件选项「…」已开启。,
zh-TW, ja, de too). An older plugin shows what it showed before, and an
older magpie shows a new plugin's plain words with no note.

WorkBuddy 0.2.10 gives "Free models only" in all four languages with
filtersModels (magpie-community/plugins aec58ae, on npm: `npm view
@magpie-community/opencode-workbuddy-auth@0.2.10 --prefer-online` on mote
says 0.2.10, latest), and the mover's min is raised to it so every moved
user gets it. The CLI's `magpie plugin options` stays English, as the CLI is.

The core scripts would have gone 608 bytes over their budget; three of the
provider editor's comments in app.js are cut down instead, no raise
(1,532,865 of 1,533,105).

Run, on mote (mote-run), at this tree:
- node --test plugin-option-words.test.cjs (new): Chromium and WebKit,
  1100 and 420 wide, en/zh/zh-TW/ja/de, switch on and off: each
  language's label and description, zh-TW falling back to zh and ja/de to
  the plain words for a zh-only option, the note exactly once under the
  chips in a .hint inside the editor with no sideways scroll, none while
  off, the confirm in the language. With app.js put back: 19 of 21 red
  in Chromium (only "en off" passes, both widths).
- With plugin-options.test.cjs and i18n-keys.test.cjs, both engines:
  68 pass, 0 fail.
- go test ./internal/plugin ./internal/provider ./internal/cli: ok.
  TestPluginOptions with host.js put back: red (empty maps, FiltersModels
  false). The real WorkBuddy 0.2.10 index.mjs loaded into this host
  (a temporary test, not kept): plugin.Providers lists free_only for
  workbuddy and workbuddy-ai with all four languages and filtersModels true.
- go test ./internal/gui: TestCoreScriptBudget ok after the cut. Red,
  and red the same at origin/main ed5872d18 (run there too):
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners
  /macOS_26_SDK on macOS 27 (#3949); TestColdTurnsTaken red once in the
  package run and passed at origin/main (#4510, the same 0.00s red).
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- plugins: HOME=$(mktemp -d) bun test packages/workbuddy 303 pass 0
  fail; the new freeonly test red 2 of 2 with index.mjs put back.

Not run: the whole GUI suite. mote and the WSL box were each running
another session's full GUI suite (hours left on both), and one runs per
machine; it runs on mote once that one ends. Not tried: a real WorkBuddy
account in the real app window. go test ./... was not run.
2026-11-01 13:24:50 +08:00
yetone b1fc435407 library: Magpie Web Search, magpie's search MCP server in Library › MCP (lutra_fs)
lutra_fs on Discord: magpie's search MCP shows in Settings › Models but
not in Library › MCP servers. They were right. The gateway's web search
MCP (/mcp/magpie/web-search) was only an address to copy in Settings ›
Models › Web search. It was never a Library server, so no agent could be
given it from the Library, and the Library didn't list it.

Change:
- `magpie mcp search`: a stdio relay to the gateway's search MCP, made by
  widening browsermcp's Magpie Browser relay into a bridge with its own
  path, title and an optional session (search sends none, and has a 5
  minute client). It takes no arguments. When magpie isn't running, it
  says "Magpie Web Search can't be reached: start magpie".
- library: Magpie Web Search (magpie-web-search) is a featured,
  opt-in server beside Magpie Image and Magpie Browser. It is installed
  with no agents, so the user picks them in its sheet, and it switches
  per agent like any other row. Its command is the full binary path, and
  serverKey treats any binary's `mcp search` as the same server. Each
  agent's tool timeout is at least 120s.
- Settings › Models › Web search › MCP server: under the address there is
  a "Give agents Magpie Web Search…" link that opens its Library sheet,
  or "Turn on the Library" while the Library is off, as Images does for
  Magpie Image. Gateway mode has no link.
- The sheet's hint says where each search goes and what it costs. All
  strings are in en, zh, zh-TW, ja and de.
- docs/subsystems/library.md names magpie's own servers and the new one.
- An agent in WSL gets it through the MCP router, as Magpie Browser
  does. The image-only WSL side() is unchanged.
- The sibling, Image recognition's MCP server, is still in Settings only.
  That is filed as #4653.

Run, at this head (rebased on origin/main a6217e83d), on mote: gofmt -l
is empty. go vet passes for darwin, linux (nogui) and windows.
internal/library, browsermcp, cli and imagemcp pass. The internal/gui Go
package and the GUI files search-mcp-library, search-mcp,
images-library-way, i18n-keys, gui-ja/de/zh-tw, searcher-pick and
search-keys: 197 passed, 2 failed. The 2 reds are both known. gui-ja is
the {agent} ja string, #4580. searcher-pick's chromium en case reads a
null box: red 1 of 3 here and 2 of 3 at a6217e83d, filed as #4274.
internal/gui's three reds are red at base and filed:
TestSettingsSaveKeepsWhatItDoesNotSend #4514,
TestMainWindowCorners/macOS_26_SDK #3949 and TestColdTurnsTaken #4510.

New test: search-mcp-library.test.cjs covers Chromium and WebKit, 5
languages, at 1100 and 420px. On the old code it is red, 52 failed and
10 passed; the passes are its gateway-mode cases, which expect no link.
TestMagpieWebSearchIsOptIn and TestSearchBridgePassesLines are new too.

Broken by hand: with "search" taken out of serverKey,
TestMagpieWebSearchIsOptIn goes red (Have empty).

Real use: on mote, in a sandbox HOME, with a nogui build and the
gateway on 127.0.0.1:3611. `magpie mcp search` answered initialize with
serverInfo magpie-web-search and listed web_search in tools/list.
web_fetch https://example.com returned "Example Domain". With the
gateway killed it gave -32603 "magpie isn't running, so Magpie Web
Search can't be reached…". With an extra argument it exited 1 with
"takes no arguments".

Whole GUI suite on WSL magpie-desktop (load 120 to 180), at the
pre-rebase tree 73595f737: 17260 tests, 16684 passed, 574 failed. The
base, origin/main da0005df8, ran on the same machine: 516 failed, and
324 top-level tests were red. Each of the 161 files with a red was then
run alone on mote at head:
- At head, 118 of them pass alone. They aren't caused by this change.
- 43 fail alone at head, and every one of those also fails alone at
  base. Two pass at base once: login-import is flaky at both (#1307),
  and usage-curve-zoom-back went red once of two at base and passed 2 of
  2 at head.
  view-open-wheel was red 1 of 2 at both, filed as #4723.
- segs-press-redraw ("searchAllRow option 1") fails the same way at
  base, filed as #4566. gui-ja's {agent} string is #4580, and
  usage-ledger is #4078.
- Reds with no issue are now filed one per test: #4680 to #4728.
  Already filed: #4638 claude-mode, #4650 routing-request-model, #4176
  skeleton-bird and #1937 name-suffix-no-names.
Not tried: web_search with a real search API key (mote has none). An
agent in WSL using it directly. A run on the Windows box.
2026-11-01 12:38:01 +08:00
yetoneandFake Trader 0cabaaf243 agent: a portable VS Code on a Mac is wired in its code-portable-data folder (#4151)
faketrader runs VS Code portable on a Mac: /usr/local/bin/code links into
/Applications/Code/Visual Studio Code.app, and the build reads
/Applications/Code/code-portable-data/user-data/User. magpie detected it
but wrote ~/Library/Application Support/Code/User, which that build never
reads. Their patch on #4151 is the base; this takes its rule and makes it
VS Code's own (configurePortable in src/bootstrap-node.ts), on every OS:

- A build is portable when its product.json has no `target` (an
  installer's build has one) and its data folder exists: on a Mac
  product.json's `portable`, else `<applicationName>-portable-data`,
  beside the .app; on Windows and Linux `data` beside the install, also
  for a build that updates into `<install>/<version>/resources/app`.
- The build is the one the launcher on PATH is, through a Scoop shim and
  every symlink. A launcher whose product.json names another editor (a
  fork's `code`) isn't the build's. With no launcher of its own, a Mac
  reads the app folders and Spotlight and takes a portable bundle only
  when every bundle found is that one; beside an installed bundle, which
  one runs is unknown and nothing moves.
- VS Code, Insiders and VSCodium each go by their own bundle and launcher.
- User and extensions come from one place (vscodeDirs): connect, Sync,
  profiles and Disconnect use the portable User folder, and Zoo Code is
  found by its extension in <data>/extensions and writes its import file
  there. Windows' Zoo Code under Scoop looked in ~/.vscode/extensions.
- Disconnect's preview is refused for a file in a portable data folder:
  the preview's child keeps PATH, and its launcher would reach the build's
  real files, not the copy. That also covers Scoop under home on Windows,
  which main previewed.
- An installed build with no portable folder keeps the OS's folder and
  ~/.vscode/extensions, unchanged.

#3260 and #4009 (Windows): 509d8e7d1 (ggbdpq) already moved Scoop's
`current\data`; this adds the target check, the versioned layout, the
Windows Zoo Code folder and the preview refusal above.

Tests (fixtures under t.TempDir, never /Applications or ~/Library; app
folders and Spotlight stubbed): TestVSCodeMacPortableDirs (stable,
Insiders, product's `portable`, no data folder, Windows' `data` name,
another editor, another channel's folder, unreadable product, installer
target), TestVSCodeMacPortableLinkChain (three links, folders with
spaces), TestVSCodeMacPortableWiring, TestVSCodeMacPortableWithoutLauncher,
TestVSCodeMacPortableLauncherPicks, TestVSCodeMacPortableForkLauncher,
TestVSCodePortableProduct (Windows/Linux: target, fork product, versioned
install, Zoo Code, Scoop preview).

Broken by hand, each went red and was restored: main's rule on darwin
(6 Mac tests FAIL, standard folder used), target ignored (Dirs, Product),
no preview refusal (Wiring, Product), first bundle wins
(WithoutLauncher), fork launcher decides (ForkLauncher), Zoo Code on
home's extensions (3 FAIL). On origin/main the new tests don't compile
(vscodeDirs is new); break #1 is main's Mac behaviour.

Run:
- mote (macOS 27), full suite at this change on 479476784:
  go test -tags nogui -timeout 45m -count=1 ./... : 85 packages ok
  (internal/agent 405s, gateway 832s, provider 251s), internal/gui red on
  two filed tests this change doesn't reach: TestSettingsSaveKeepsWhat-
  ItDoesNotSend (SearchAll, #4514) and TestColdTurnsTaken (#4510).
  Rebased onto 90c02326b (gui takeover, sessions save, kiro min; nothing
  in internal/agent): go build, go vet of agent/gui/sessions/provider and
  go test of internal/agent, internal/sessions, internal/provider again
  at the pushed head: ok (agent 352s, sessions 110s, provider 228s).
- mote (macOS 27): go test -tags nogui ./internal/agent -run
  'TestVSCode|TestZooCode' ok; gofmt -l clean; go vet ./...,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., GOOS=linux
  go build -tags nogui, GOOS=windows go build ok.
- win-run (Windows 11) and wsl-run (Ubuntu 24.04): the agent tests above
  plus Preview, ok.
- Real use on mote, sandbox HOME, PATH=$SB/bin:/usr/bin:/bin: VS Code
  1.144.0 darwin-arm64 from update.code.visualstudio.com unpacked to
  "$SB/Apps With Space/Code/Visual Studio Code.app", `code` linked
  bin/code -> "link one/code" -> the bundle's bin/code. Without
  code-portable-data, `magpie agents` lists ~/Library/Application
  Support/Code/User/settings.json; with it, ".../code-portable-data/
  user-data/User/settings.json". The real `code --install-extension
  zoocodeorganization.zoo-code` put Zoo Code 3.94.0 in
  code-portable-data/extensions (no ~/.vscode made), and magpie then
  listed Zoo Code at the portable User folder. `magpie vscode
  deepseek/deepseek-chat` wrote settings.json and chatLanguageModels.json
  there, `magpie vscode default` took magpie out of both, and Zoo Code's
  connect wrote its import file under the portable globalStorage and its
  disconnect removed the setting; ~/Library/Application Support/Code was
  never made.
- Real use on xiaomi-gpu (Windows 11), sandbox USERPROFILE/APPDATA,
  PATH=<install>\bin;System32: VS Code's win32-x64 ZIP (its versioned
  layout, <install>\2c33b50b16\resources\app) unpacked to "Apps With
  Space\VSCode". Without data, `magpie agents` lists ~\AppData\Roaming\
  Code\User\settings.json; with data, <install>\data\user-data\User\
  settings.json. The real code.cmd --install-extension put Zoo Code in
  data\extensions (no ~\.vscode), magpie then listed Zoo Code there,
  and connect/disconnect wrote and cleaned that User folder; %APPDATA%\Code
  was never made.

Not tried / not handled: VS Code's window wasn't opened to see the model
picker (headless ssh). VSCODE_PORTABLE isn't read: it is the editor's
environment, not magpie's. A Windows or Linux portable build with no
launcher on PATH isn't found (there is no standard place to look). A group
an older magpie wrote in the OS's folder for a portable build stays there;
connecting again writes the portable one. A Claude Code or Codex extension
in a portable build doesn't keep that CLI from showing as gone: #4672.

Co-authored-by: Fake Trader <9635792+faketrader@users.noreply.github.com>
2026-11-01 11:55:33 +08:00
yetone 2be5d206e1 gateway: a Codex summary request too large for the vendor is asked again as text, then compacted locally (celestial_eagle_99230 on Discord)
celestial_eagle_99230 (Discord #general, v0.1.2403) runs Codex on official
DeepSeek (DeepSeek-V4.1-Flash, 1M window) and gets "413 Request Entity Too
Large: Failed to buffer the request body: length limit exceeded". The turn
path was fixed by 2cca11176 (v0.1.2419): Codex gets context_length_exceeded
and compacts. But the compaction is the problem. Codex (openai/codex main,
compact_remote_v2.rs) sends its summary request through the same /responses
route, trims only by its token estimate against the catalog's 1M window, and
on ContextWindowExceeded does not trim and retry. A conversation that is
over DeepSeek's byte cap (base64 images and long tool outputs sent each
turn) is under 1M tokens, so the summary request was the same oversize
body. magpie passed the 413 (or overflow) back, compaction failed each
time, compactFails held later tries, and the session could neither compact
nor go on.

codexCompact now counts a 413 or an overflow on the summary request
(summaryTooLarge) with the failures it already asks again as text
(plainCompact: images left out, tool outputs over 4000 chars cut, at most
400K chars), then compacts without a model (localSummary) when that is
refused too. This is keyed on the status and overflow words, not on
DeepSeek: a summary request refused for its size means the same thing for
every vendor, and the old result (a session stuck) is never better. Any
other refusal goes back unchanged (TestCodexCompactOtherRefusalStays,
TestCodexCompactOtherFailuresStay), and a non-Codex client still gets the
413 as request_too_large (TestDeepSeekByteCapTurn's opencode case,
TestByteCapBeforeStreamStaysStatusForOthers).

DeepSeek probed without a key (no tokens): bodies of 1 to 40MB to
api.deepseek.com/chat/completions get 401 "Authentication Fails"; 80MB and
120MB get openresty's text/html 413 page. The reporter's text is axum's
body-limit error, which sits behind auth, so its value is unknown. DeepSeek's
docs list no 413 and no byte limit.

Run, mote (mote-run):
- Red at origin/main fb3942ee6 with only the new test file:
  TestCodexCompactTooLargeAsksSmaller (all 4: Chat/Responses x byte
  cap/overflow) got 413 "compaction: ... answered the summary request 413"
  or 400 context_length_exceeded; TestCodexCompactTooLargeCompactsLocally
  got 413. TestDeepSeekByteCapTurn passed (2cca11176's turn path).
- Green with the fix; broken by hand (summaryTooLarge returning false):
  all 4 AsksSmaller subtests and CompactsLocally red again.
- At the pushed head (rebased on 90c02326b): go test -count=1 -run
  'Codex|Compact|Overflow|ByteCap|TooLarge|DeepSeek|StreamError'
  ./internal/gateway ok (90s). go vet ./internal/gateway on darwin,
  GOOS=linux -tags nogui and GOOS=windows ok. gofmt -l clean.

Not tried: the whole internal/gateway package and ./... (mote was running
another session's 45m multi-package suite at load ~210, and one suite runs
at a time); a real Codex binary end to end (its compaction was read from
source); a real signed-in DeepSeek request (the cap's value is unknown).
2026-11-01 11:52:46 +08:00
yetone 90c02326bb gui: an app takes the gateway over from its older copy once idle, and says any other version serving it (matrix0487)
matrix0487 on Discord: after an update, pi said 404 'magpie knows no
model "kimi/k3.1-pro" ... add a provider in magpie first'. The app had
written pi a model its older gateway didn't know, and updating the
gateway fixed it. A magpie that finds another one serving the gateway
used to log it and wait for that one to quit (watchGateway took the
port only once nothing answered). Only the Gateway page said so.

Now (otherServes, gateway_older.go):
- An older released copy of the app (it says serves app or tray, and a
  pid) is this app's predecessor. Once its /v1/magpie/concurrency says
  nothing is in flight (gateway.ServedBusy; unknown is never idle),
  the app quits it the way the Gateway page's button does
  (quitMagpieOnPort: a magpie only, by its program) and serves the
  gateway. A stream through it runs to its end first. watchGateway
  looks again every 15s while another serves. At most three times a
  run; a quit that fails is left to the button.
- Any other one (magpie serve or the service, magpie web, a TUI, a
  newer magpie, a build of its own) is left running. /api/state
  carries it as gatewayOther, and the Agents page says it above the
  list with what to do, plus the take-over button for an older one
  (gatewaySkewLine, in plugins/gateway/client.js so app.js stays under
  its budget). A dev build of this magpie says nothing. New strings in
  zh, zh-TW, ja and de.

How the reporter's older gateway outlived the update isn't known: they
never said whether one ran separately. A failed handover leaves the
old app serving for up to 15m, and a magpie serve left running is
another source. Both are covered now: the first is replaced, and the
second is said.

Known gap: a request that starts between the idle read and the quit
gets the older app's short drain. A socket handover between two
running apps (no gap) is not built.

Run on mote at 0f8ea30bb (this change on 2b067434d):
- go vet for internal/gui and internal/gateway, also GOOS=linux
  -tags nogui and GOOS=windows; gofmt -l clean.
- go test -count=1 -timeout 45m ./internal/gui ./internal/gateway:
  gateway ok. gui has two reds, the same on origin/main 0c3163804:
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestMainWindowCorners/macOS_26_SDK (#3949).
- GUI subset, Chromium and WebKit: gateway-*, agent-layout, agents-*,
  getting-started, i18n-keys, gui-ja/de/zh, panel-arrange, panel-fold:
  411 pass. Two reds, the same on origin/main 0c3163804:
  gateway-caller-keys chromium en (#3797) and gui-ja (#4580). Passing: the new gateway-skew.test.cjs (en and zh at 380px, the
  button POSTs take-over and the line goes).
- Real app on mote, sandbox HOMEs, port 3591, update feed pointed
  nowhere:
  - origin/main built as 0.1.2400 ran `magpie app`, and this head
    built as 0.1.2500 ran `magpie app` beside it. The new one logged
    "an older copy of this app ... with nothing in flight; quitting
    it" and served 0.1.2500 on the port 2s later. The old process was
    gone.
  - The same with the old one as `magpie serve`: it was left running,
    and the new one logged that it serves, older.

Red on origin/main: TestAppReplacesItsOlderGatewayOnceIdle ("the
older copy of the app still serves the gateway", 17s).

Again at the pushed head (this change on 6f3dfc282, mote): vet darwin, linux
nogui and windows; TestCoreScriptBudget (the core is 1,533,104 of
1,533,105: main's #4652 took the room, so app.js's hook line lost its
comment, no raise), TestAppReplacesItsOlderGatewayOnceIdle,
TestGatewaySkew*, TestGatewayFixQuitsOnlyAMagpie,
TestGatewayServedByAnOlderMagpie: ok. gateway-skew, i18n-keys, gui-zh,
gui-de: 11 of 11 pass.

Broken by hand, each red:
- quit without waiting for idle: "quit with a request in flight"
- replaceable() false: "still serves the gateway"
- any serves replaceable: TestGatewaySkewOfAnotherIsSaidNotQuit, the
  serve holder quit
- the Agents hook removed: gateway-skew.test.cjs red in both langs

Not tried: the whole GUI suite (mote was running another session's
full suite), a real app with a real agent stream in flight during the
take-over (the Go test holds a stream through a fake), Windows and
Linux apps (the replace path needs handoverHost, set by the app's Run
on every OS, but it was tried on macOS only).
2026-11-01 11:43:56 +08:00
hlyx1 2b067434d7 provider: a Kimi Code membership's k3.1-pro and k3.1-pro-highspeed are priced at the Kimi API's (#4635)
hlyx1's fix (#4635, branch hlyx1/magpie kimi-code-k31-pro-price), asked
to be expedited by matrix0487 on Discord. Kimi Code's plans serve
k3.1-pro and k3.1-pro-highspeed, which models.dev's kimi-code-plan-*
catalogs list at the membership's $0. Neither id was in kimiCodeAPI, so
a membership's call on either was unpriced on Usage. They now map to
kimi-k3.1-pro and kimi-k3.1-pro-highspeed, like k3 to kimi-k3, and the
Requests list names that model (PricedNameFor).

Checked: Kimi Code's own /models answer (internal/catalog/testdata/
kimi-code-cn-models-2026-10-31.json) lists k3.1-pro "K3.1 Pro" and
k3.1-pro-highspeed "K3.1 Pro Highspeed". Kimi's pricing page
(platform.kimi.ai/docs/pricing/chat, read 2026-11-01) and models.dev's
live moonshotai entry both give kimi-k3.1-pro $2 in / $10 out / $0.20
cached / $2 5m write, and kimi-k3.1-pro-highspeed $4 / $20 / $0.20 / $4.
The fixture's new entries match models.dev's api.json in id, name, cost
and canonical_model_id.

The alias stays Kimi Code's (kimiCodePlans): the test's relay catalog
now lists a k3.1-pro of its own at $0.50/$1, which keeps that price, and
PricedNameFor(relay, k3.1-pro) stays k3.1-pro.

Docs: docs/reference.md, docs/subsystems/providers-accounts.md.

Run on mote (Go 1.26.8), at this change rebased on fb3942ee6 (the
pushed head adds only 784b66366, app.js and a GUI test): gofmt -l
clean; go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
go vet ./... ok; go test -count=1 -timeout 45m for internal/provider,
usage, gateway, agent, cli, routes, sessions, usageapi: all ok.
TestKimiCodeListPrice and TestKimiCodeCost red with models.go at
origin/main (k3.1-pro {0 0 0 0} false; kimi-code-cn/k3.1-pro
priced=false cost=0, want true 3.264), green with it. Taking the
kimiCodeMember() check out by hand turns PricedNameFor(relay, k3.1-pro)
into kimi-k3.1-pro and the test red.
Full go test ./... at base da0005df8: every package ok but internal/gui,
red on TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestMainWindowCorners/macOS_26_SDK (#3949), both open on main and not
touched here.
Not tried: a real Kimi Code membership's k3.1-pro call through the GUI.
2026-11-01 11:19:26 +08:00
yetone 733fac48fb qwenpaw: each model says how its thinking is set, and the editor sets the level (Pkh)
Pkh (Discord, 0.1.2509 on Linux, QwenPaw 2.2.2.post1): QwenPaw's
thinking strength did nothing on magpie's models.

Cause, from QwenPaw 2.2.2.post1's own source:
- providers/provider.py thinking_control() takes a model's
  thinking_control, else its thinking_param_style; with neither it is
  ThinkingControl() of kind "unknown".
- providers/thinking.py resolve_thinking drops an unknown control to
  inherit, so agent.json's thinking_level was never sent.
- magpie wrote neither key in magpie.json's models, so every magpie
  model was "unknown".

Change:
- qwenpawModelJSON writes thinking_param_style "effort" and
  reasoning_effort_options for a model whose catalog efforts include
  levels QwenPaw names (minimal, low, medium, high, xhigh, max), in
  QwenPaw's order. "none" is left out: QwenPaw's off sends
  enable_thinking / thinking extra_body, which the gateway strips for
  some upstreams.
- Both keys are magpie-owned. A model whose efforts go away has them
  taken back. A null magpie writes where it never wrote is dropped,
  so a user's own config_overrides are kept.
- The QwenPaw agent editor gets an effort field over agent.json's
  thinking_level. "" writes inherit. Setting a level drops
  thinking_budget, which QwenPaw's validator requires. A budget or
  off level the user set is shown and kept.
- Docs: agent-wiring.md and reference.md.

Run:
- gofmt -l: clean.
- go vet darwin, windows, and linux (-tags nogui): clean (mote).
- go test -timeout 45m ./internal/agent/...: ok (mote).
- go test ./internal/gui: 3 reds, also red on origin/main 8ac1c7a56
  and already filed (#4514, #3949, #4510).
- Real QwenPaw 2.2.2.post1 in a sandbox HOME, in WSL magpie-desktop:
  - Loaded magpie's generated magpie.json and agent.json with
    QwenPaw's own ProviderManager and AgentProfileConfig.
  - kimi/k2 resolves to {kind: effort, efforts: [low, medium, high,
    max]}.
  - A real request to a local capture server carries
    reasoning_effort "high" at level high, and none at inherit.
  - The old file's model resolves to kind unknown, and sends nothing
    at any level.

Broken by hand:
- With the origin qwenpaw.go, both new tests are red.
- Without the thinking_budget delete, TestQwenPawEffortField is red.
- Without the new owned keys, the take-back assertion is red.

Not tried:
- QwenPaw's full app UI against a running magpie gateway.
2026-11-01 10:54:38 +08:00
yetone f435aadbf3 gateway: an image is described once, whatever model describes it, and a canceled request stops its descriptions
Pkh on Discord (0.1.2509, Linux, QwenPaw, Auto routing): with images in
the conversation, the Routing view filled with "Image description" rows,
one request asking for 63 in ~60ms, and the request they were for had no
row of its own.

Causes, each red on origin/main b2145eac1 (the new tests run there):
- A description was kept under the describing model and its level
  (sha256(model, effort, src)): AutoVision's pick changing between turns
  (opencode-go/deepseek-v4.1-flash, auto/qwen3.8-flash) read every image
  again. It is now kept under sightKey: a base64 data URL's decoded bytes
  (strict base64), else the URL, with the level picked in Settings, so
  the same picture on another protocol or media type is described once
  too, and seenBody dedupes by the key.
- describe ran on the first asker's context. Its agent canceling it failed
  the description for every request waiting on it ("context canceled",
  a 502 to a request nobody canceled) and took it out of the cache. The
  work now runs on its own context (WithoutCancel + cancel); a request
  that goes stops waiting, and only the last to go stops it and forgets
  it. A reply that came whole is kept though its asker ended.
- seenBody's queued images took a slot without looking at the context,
  so after a cancel each went on to serve with a dead context and put an
  instant 499 row on the Routing page. One waiting for a slot when its
  request ends is now asked of no one.
- The descriptions' routes are noted on the request's inflight (they run
  on its context), which dropped its "routing" placeholder; a cancel
  then left it no route at all. It now gets one (notDescribed), 499 when
  its agent canceled and 502 else, and the usage record names it. A
  group's request ends 499 on a cancel too.

Not as reported: a failure never threw away good descriptions (only the
failed one went), and seenBody already deduped and shared in-flight work
within the cache; it was the cancel, the model in the key, and the
queued work that made it read everything again.

Run on mote at this tree (rebased on da0005df8):
- gofmt -l internal: clean. go vet ./... on darwin, and GOOS=linux /
  GOOS=windows -tags nogui go vet ./...: ok.
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway: ok
  (806s); also ok on the earlier bases 8ac1c7a56 (with ./internal/catalog)
  and ccb75030a.
- -race -count=10 on the four new tests, TestUnrouted* and
  TestTextOnlyModelIsGivenTheImagesDescription: ok.

Broken by hand, each red with the named test:
- the model back in the key, and the key by src string:
  TestSameImageDescribedOnceWhateverDescribesIt;
- the work on the first asker's context:
  TestOneRequestGoneLeavesTheDescriptionToAnother (502 context canceled);
- the slot taken without the context: TestCanceledRequestAsksNoMoreDescriptions
  (9 rows, want 4); on origin/main 10;
- no notDescribed: TestCanceledWhileDescribingKeepsItsRoute (no route).

Not tried: Pkh's own QwenPaw conversation and providers; the fix is
tested with a fake describer only. heldSight (unrouted_test.go) now seeds
the cache under sightKey.
2026-11-01 10:50:31 +08:00
yetone 9162277b91 routing: Until used up stays on the next account once the first is used up (dzxx0496)
dzxx0496 on Discord: with free accounts one after another, the first used
up, requests went to the second; when the first renewed they went back to
it ("如果第一个恢复了,它又优先用第一个了"). No routing did what they asked:
In order and Smart both put the first back first.

A new routing, Until used up (drain, 用完再换): requests stay on one seat
until its quota is used up, then go on to the next in the list and stay
there. A seat counts as used up when its known allowance is at 100% or
it was refused for quota or credit (failQuota / failCredit, routes.Drained
called where the rest is recorded, so a failover inside one request moves
the pool too). A rate limit or other failure only passes it over while
it rests, as In order does. Each pool (a provider, a group/<id>) keeps its
own place; routes.Forget clears it.

Offered wherever a routing is picked: the provider editor, a group's row
menu and editor (app menu, no native select), the TUI, `magpie group set
<id> routing=drain` and a provider's routing=drain. Nothing defaults to
it, so no saved setting changes. SpentShareOf is 100 for it, as for In
order. Words in en, zh, zh-TW, ja and de (i18n.js and the routing
plugin's own), docs/subsystems and the site's start page (en, zh, ja).

Tests:
- internal/routes/drain_test.go: stays on the next when the first renews,
  through a rate limit, all used up, a seat gone, per pool, Forget,
  Drained after a renewal.
- internal/gateway/drain_test.go: a real request path with a fake upstream;
  k1 refused for quota, k2 takes over, k1 renews: drain stays on k2,
  In order goes back to k1. Red without the Drained hook (request 3 went
  to k1). A rate limit comes back to k1; drain is saved on a provider and
  a group.
- routing-drain.test.cjs: the Routing page's why and mode line in 5
  languages, 1100px and 420px, Chromium and WebKit; red on the old assets
  (20 of 20).
- routing-group-strategy, routing-save, builtins: the menu has 11 routings.

Run on mote (macOS) at origin/main 699ddf152 with this commit and its
two neighbours (nb5p chip, dzxx0496 renewal, dzxx0496 Until used up).
Pushed on b2145eac1, whose five commits since change app.css and app.js
only for a key row's chips; at the pushed tree gofmt, the gui, routes
and gateway vets (Linux nogui, Windows), TestCoreScriptBudget (core
1,532,891), the Drain Go tests and 11 GUI files (gateway-model-chip-
height, routing-drain, routing-renews-stay, routing-behind-why,
routing-group-strategy, routing-save, builtins, i18n-keys, gui-de,
gui-zh-tw, key-row-chips-fit) were run again: 190 of 190 ok.
- gofmt -l clean; GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./... and go vet ok.
- go test internal/routes, internal/gateway, internal/provider,
  internal/cli, internal/tui, plugins/rotation: ok; internal/gui's
  TestCoreScriptBudget ok (core 1,532,816 of 1,533,105).
- GUI: routing-*, builtins, gateway-model*, model-chip*, i18n-keys,
  gui-* and codex-credits-last in both engines: 2211 tests, 68 red,
  none new: model-chip-steady 20 (#4388), gui-ja's {agent} string
  (#4580), and 11 routing-* files under load (#4585, #3789, #3799).
  The same 11 files run alone at cdfdb62c6 were 32 of 116 red, and 26
  with the stack, the same tests but rule-remove, whose red languages
  vary run to run (9 cases, then 5). model-chip-steady was 20 of 20 red
  at cdfdb62c6 alone.
Earlier, at f811bf291 with the stack: go test -timeout 45m ./... had 82
packages ok, internal/gui red only on
TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestMainWindowCorners/macOS_26_SDK (#3949). The whole GUI suite had 301
of 16930 red in 52 files. Those 52 files rerun had 272 red with the
stack and 276 at f811bf291 alone, the same tests.
2026-11-01 09:53:50 +08:00
yetone 699ddf1524 gateway: a Codex account can spend its credits only after every other account, key and fallback (gokoshiki on Discord)
gokoshiki wants a Codex subscription first, then an OpenAI API key, then
the subscription's credits. Until now an account at 100% that holds
credits either kept its place and spent them there (on) or was held
(off). This adds a third way per account, "last":

- settings: CodexCreditsLast []string, empty by default, so a setting
  saved before it keeps its order. provider.CodexCreditsLast,
  CodexCreditsMode and SetCodexCreditsMode(user, on|last|off);
  SetCodexCredits(on) still means "in its place" and clears last.
- gateway: candidate.creditsLast is true for such an account once a
  window for the model is used up and it is going on its credits (a
  call ChatGPT counts in no window stays in its place). restLast orders
  ready, then resting, then those, and marks Weighed.CreditsLast.
  restLast runs over the asides too, so such an account goes behind a
  provider's reserves (Accounts at once, 2c6b7c063) as well.
  lastBehind keeps In turn's next turn (after), a new conversation's
  spread (leastHeld) and a subagent's lead (readyForNew) from bringing
  it forward, and a kept conversation moves off it to one not on its
  credits (Affinity.Why "credits").
- CLI: magpie quota credits <account> [on|last|off]; alone it lists
  accounts set off and last.
- API: POST /api/settings/codex-credits takes {user, on, last?}.
- GUI: under a Codex account's Use credits, while on, a second switch
  "Only after every other account, key and fallback", in the Usage
  page's card and the tray panel's (both wrap it to its own line at 360
  to 900px), and the panel's folded brief says "On, after everything
  else". The Routing page's trace says why such an account is behind
  (aside, the kept conversation's why, the row tag). zh, zh-TW, ja, de.
  creditsButton and the new switch share creditsSwitch, and the Codex
  options' comments in app.js were cut, so the core budget holds with
  no raise (1,532,664 of 1,533,105).
- docs: reference.md (quota credits) and gateway-routing.md.

Tests:
- gateway: TestCodexCreditsLastAfterTheOthers (two accounts, In order:
  the one at 100% on its credits goes behind, the trace says so, and
  back in place when turned on), TestCodexCreditsLastAfterTheFallback
  (both accounts at 100% and set last: the API key the provider falls
  back to answers before either one's credits; with the credits in
  their place an account answers on them, as before),
  TestCodexCreditsLastNotKept (a kept conversation moves off it).
  All three red with creditsLast and lastBehind forced false.
- provider: TestCodexCreditsLastMode.
- gui: settings_keep_test carries CodexCreditsLast;
  tests/codex-credits-last.test.cjs (Chromium and WebKit, en zh zh-TW
  ja de; Usage at 900 and 440, the panel at 440 and 360, the folded
  brief, the Routing page's aside and why, every key in I18N). Red on
  the old assets (no .ar-credits-last).

Run at this change on origin/main c76bcaea7, on mote (pushed on fd70def82, whose
one commit since, fd70def82, changes only the Providers poll's Go
files in internal/gui):
gofmt clean; go vet of gateway, provider, gui, cli and settings ok;
their tests ok but internal/gui's #4514 and #3949, both on main. The
8 commits between d6aa9cdf6 and c76bcaea7 touch none of this
change's files.

Run at this change on origin/main d6aa9cdf6, Go 1.26.8:
- mote: gofmt -l clean; go vet ./..., and GOOS=linux and GOOS=windows
  go vet -tags nogui ./...: ok. go test -count=1 -timeout 45m ./...:
  85 packages ok; internal/gui red only on TestSettingsSaveKeepsWhatIt
  DoesNotSend's SearchAll (#4514), TestMainWindowCorners (#3949) and
  TestColdTurnsTaken (#4510), all three on main. TestCoreScriptBudget
  passes.
- WSL magpie-desktop, Playwright 1.62.0, both engines: codex-credits*,
  i18n-keys, gui-ja, gui-zh-tw, panel-options-fold, provider-at-once and
  every routing-* file: 2127 tests, 2064 pass. Every codex-credits and
  codex-credits-last test passed (26). The red files (gui-ja, 19 routing
  files) run again at this tree and at d6aa9cdf6, alike: 200 tests, 61
  and 57 red. gui-ja is #4580; the routing reds are timeouts and
  waits, on both. The one file red at this tree only,
  routing-request-model (WebKit 420px "the model is cut"), is 5 of 5
  green alone at both, and with six copies at once red at both (29 and
  27 of 30 here, 28 and 27 of 30 at d6aa9cdf6): a fixed 150ms wait
  after a resize, filed as #4650. Nothing this change adds to Routing
  draws unless an account is set last (fixtures don't).
- Earlier, at 3564eb04b (this change on 7428f3229), WSL: the whole GUI
  suite beside two other sessions' suites, 16944 tests, 16496 pass;
  its 102 red files again at that head and at 7428f3229, 444 and 425
  red. The files red at the head only, run alone: view-open-wheel,
  usage-accounts, add-button, usage-ledger-open-settled 0 red;
  view-wheel-after-click, view-wheel-unheard and context-map (#3488)
  red alone at 7428f3229 too. mote, the credits and i18n files: 172 of
  174, the two #4580 and a click timeout in quota-curve at load 148
  (alone 30 of 30).

Not tried: a real ChatGPT account at 100% with credits beside a real
OpenAI key; the order is shown with the gateway's fake Codex backend.
2026-11-01 09:08:07 +08:00
yetone 2c6b7c0632 gateway, provider, gui: Accounts at once keeps the first N accounts taking requests, the others in reserve
01huadalang on Discord (#feedback 1566170404542742740): three ZCode
accounts used at once from one address got the address refused with a
405; two were served. They asked for one account to be used until it
runs out, then the next. Even under "In order", ZCode's maxConcurrency 3
spilled a full lane onto the next account (laneMate) and rests spread
the load, so every account was in use at once.

A provider's MaxAccounts (the editor's Advanced → "Accounts at once",
beside Concurrency; `magpie provider at-once <id> [n|off|default]`) is
how many of its accounts or keys take requests at the same time.
provider.AtOnce() is the user's own value, else what its plugin
declares (maxAccounts on the auth hook or package.json magpie, read by
host.js atOnceOf), else no limit; the user's 0 is no limit over the
plugin's. perKeyBarred keeps the first N in the user's own order
(rank), preferring ones not resting, and keepAtOnce puts the rest after
everything as asides with candidate.reserve (Weighed.Reserve). So in any
routing mode a reserve is asked only once the kept ones failed or rest,
and a kept one that rests gives its seat to the first reserve next time.
Guards: laneMate never spills onto a reserve; a full queue (laneErr)
drops the provider's reserves (dropReserves) and turns the request away
with the 429; session affinity moves a conversation off a reserve once
the kept ones can take it (affine "reserve"; Strict still holds).
Routing says "in reserve · {n} at once" on the row and why in the
request's story. zcode 0.1.40 (plugins 26864ec, on npm) declares 2, and
its mover min is raised to 0.1.40 two commits on.

Known leak, in docs/subsystems/gateway-routing.md: a failure that rests
nobody (a 5xx on one try) still passes that one request to the reserve,
as it does to any next candidate.

Tests: TestAtOnceKeepsFirstInUserOrder (every routing mode, a dragged
order, a resting key handing over its seat), TestAtOnceFullLaneWaitsForTheKept,
TestAtOnceReserveTakesOverAndGivesBack, provider TestAtOnce, plugin
host maxAccounts (hook and package.json), gui TestAtOnceSave, cli
TestAtOnceCmd, provider-at-once.test.cjs (both engines, five languages,
900 and 360px).

Broken by hand, each red then restored: laneMate's reserve guard
removed (FullLane times out); affine's reserve case removed
(ReserveTakesOver answers on k3); keepAtOnce disabled (all three red);
dropReserves disabled (FullLane gets no reply); the Routing row's
reserve branch removed (provider-at-once's Routing test red in all 10
engine/language runs).

Core budget: the field adds ~530 bytes to app.js; the neighbouring
editor comments are cut to fit, so TestCoreScriptBudget passes with no
raise.

Run on mote, Go 1.26.8:
- full suite, -timeout 45m, at a7d4c662d (on origin/main e4384fc3c):
  gofmt and vet clean; every package ok but internal/gui, whose reds are
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners
  (#3949) and TestColdTurnsTaken (#4510), each red on that main too, and
  TestCoreScriptBudget, fixed by the comment cut above.
- at this tree on bbdd9eb55 (the pushed head less 51f2f22ce and
  73b957069, gateway and provider): gofmt, go vet (darwin, and
  linux and windows with -tags nogui), and internal/gateway, provider,
  gui, cli, plugin and settings: all ok but internal/gui's
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners
  (#3949), both red on main; TestCoreScriptBudget passes
- at the pushed head (on 51f2f22ce): go vet of gateway and provider,
  and -run AtOnce|Nameless|ModelAPI|Reserve|FullLane over gateway,
  provider, gui and cli: ok
GUI, Playwright 1.62.0, both engines:
- the whole suite on Linux (WSL) at an earlier head; every red file run
  again at head and at main on mote, the same reds on both (filed:
  #4641 is new, the rest open already, e.g. #4600, #4461, #4082, #4210).
- at a7d4c662d on WSL: every editor-*, provider-* file, i18n-keys,
  gui-ja and seven routing files, 1185 pass, 34 red; all but four red
  on main e4384fc3c too (#4580, #3292, #4394 to #4397, #4600). The four:
  routing-many-keys (#4082) is red on main in two of three reruns as
  well; provider-gemini webkit ja's thumb (#4210) was red in 2 of 3 runs at head beside
  other files (318px off), 0 of 3 at main; alone, 4 of 4 green at both.
  The test reads the thumb 350ms after a click, a fixed wait (#4210,
  numbers added there).
- provider-at-once.test.cjs: green in both engines, five languages, at
  900 and 360px; editor-advanced-align 20 of 20 alone with the next
  commit.

Not tried: real ZCode accounts (none used, per the task) and a real 405,
so whether two at once always stays under ZCode's limit is the
reporter's finding; the user can set 1.
2026-11-01 07:39:08 +08:00
ggbdpq 5032d3ade7 gateway: a reasoning item magpie hands Codex with its text in it becomes one of its own, a summary and nothing sealed (#2855)
What changed

A Responses reasoning item that carries the model's reasoning as content
parts (reasoning_text) — another vendor's shape; OpenAI's own items carry
summaries — no longer reaches a client of magpie's as the upstream wrote
it. It is made over into the item magpie makes of any other upstream's
reasoning: its text (and its summaries) as one summary, an rs_ id, no
content and no seal — in a reply translated for the client
(magpieMadeReasoningRaw at the encoder's sealed item and the whole reply's
renderer) and in one relayed as it came (reasoningTidy, a passthrough
filter on Responses streams and whole replies, the item in
output_item.added/done and in response.completed's output). The
subsystems doc's rule is amended to say so.

Why

A Codex conversation that used OpenAI, went through magpie to DeepSeek,
then had magpie disconnected again, was stuck: every later turn, the
remote compact too, answered 400 "Invalid 'input[43].content': array too
long. Expected an array with maximum length 0, but got an array with
length 1 instead." The reporter's rollout forensics narrow it: the
DeepSeek phase had left 25 reasoning items, each with its text in content
parts and a 38-character encrypted_content of the vendor's own (not the
gAAAA the thread's own GPT-phase items carry, which have no content),
which Codex stores and replays to OpenAI. OpenAI takes a reasoning item
sent back only with its content empty (#1411) and cannot open another
vendor's seal, so such an item poisons the thread for OpenAI wherever it
was planted — and once Codex holds it, no retry of magpie's can strip it:
client keeps, and #2855 came with magpie out of the path entirely. A
Chat-API upstream's turn has always translated to an item of magpie's own
(an rs_ id and a summary, TestTranslatedChatReasoningCarriesNoContent
pins it); the items the reporter held are a Responses wire's own, which
both the translated and the relayed reply handed over as they came. What
magpie hands a client must be re-sendable to a strict Responses upstream:
the text is kept in the summary, so an upstream that wants its reasoning
back still gets it (withReasoningText), and magpie's own OpenAI
destinations keep the item out as they did (#1008, #1044, #1411).

Run

- TestForeignSealedReasoningGivenCodexCarriesNoContent (translated) and
  TestForeignSealedReasoningRelayedCarriesNoContent (relayed) fail on
  upstream/main with the issue's item handed over whole — content, empty
  summary and the vendor's seal in both output_item.done and
  response.completed — and pass with the change;
  TestTranslatedChatReasoningCarriesNoContent (a Chat upstream's
  reasoning, translated) is green without and with the change.
- Restoring the three product files alone to upstream/main (tests kept)
  fails the two again; restoring them back passes.
- Attaching content to the made item fails both again ("carries its
  text"), and dropping the made summary fails both ("carries no
  summary").
- go test -tags nogui -count=1 ./internal/gateway: ok 312.4s;
  -run 'TestTranslated|TestReasoning|TestSealed': ok 7.9s;
  go test -race -tags nogui -count=1 -run 'TestTranslated|TestReasoning':
  ok 9.4s. gofmt -l internal/gateway empty. go vet -tags nogui and
  go build -tags nogui -o /dev/null . on darwin, GOOS=linux and
  GOOS=windows: pass (a pre-existing cgo -Wenum-conversion warning in
  internal/gui/trayimage_darwin.go on darwin, untouched).

Not tried against real OpenAI or DeepSeek accounts; the reporter's
rollout reading is taken from the issue, not re-derived from a live
thread.

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

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 07:06:19 +08:00
yetoneandEdward4226 cbefb65987 gateway: a compaction summary answered 502 for ending short compacts locally too (#3526)
#3526's patch compacts locally when the summary ask ends short with an
error. The same cut can come back as a recorded 502 whose error says it
ended short (errEndedShort), with no error returned, and that still went
to the client as a 5xx. The local fallback now runs before the status
check, for both shapes (summaryEndedShort), and says why from the
recorded error. A 502 that says anything else still goes to the client
as it did. Edward4226 pointed at the 502 shape in the thread.

TestCodexCompactCutShapesCompactLocally covers a stream error, a 502
saying it ended short (compacts locally) and a 502 saying more (stays
502).

Landing record (yetone):
Run at the pushed batch head (tree a6b084d0b, on origin/main 616405061),
go1.26.8:
- go test -count=1 -timeout 45m on Linux (wsl-run) of internal/gateway,
internal/redact, internal/provider and internal/plugin (this batch's
packages and those main changed since the full run): all ok. gofmt -l
clean; go vet ./... (darwin), GOOS=linux and GOOS=windows go vet -tags
nogui ./... clean. internal/gui on macOS (mote-run):
TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners
(#3949), both red at main too.
- The full go test ./... -timeout 45m -count=1 ran one rebase earlier,
at tree 66a7a4c17 on origin/main 3a3bdb9f2 (main then gained 5bfa9f076's
group stand-in, b19d08593, f856d381a and 616405061). It ran on Linux
(wsl-run): 82 packages ok. internal/agent has 4 reds, all red at
origin/main on that box as well: TestInstalledVersion,
TestGrokInstalled, TestOmpDetectedWithPiDir and
TestCopilotFolderFromAnIDEPluginIsNotTheCLI (#4033, #3548). The root
package and internal/cli need gtk4 to build, so they ran on macOS
(mote-run): ok. TestColdTurnsTaken (#4510) was red there once. An
earlier full run at base d307aa648 was red once in
TestUnroutedHeldReportSaved (#4300), which passes 5 of 5 alone at both
the head and main.
- Each landed patch's diff matches the head ggbdpq posted last on its
issue (patch-id).
- No GUI file is touched, so no GUI test file was run.
Broken by hand: summaryEndedShort made to return false: the "HTTP 502"
subtest goes red; restored, green.
Not tried: a real ChatGPT summary ask answered 502.

#3526's patch compacts locally when the summary ask ends short with an
error. The same cut can come back as a recorded 502 whose error says it
ended short (errEndedShort), with no error returned, and that still went
to the client as a 5xx. The local fallback now runs before the status
check, for both shapes (summaryEndedShort), and says why from the
recorded error. A 502 that says anything else still goes to the client
as it did. Edward4226 pointed at the 502 shape in the thread.

TestCodexCompactCutShapesCompactLocally covers a stream error, a 502
saying it ended short (compacts locally) and a 502 saying more (stays
502).

Landing record (yetone):
Run at tree 7d7955eb9 (this batch on origin/main 3cfba2e37), go1.26.8:
- go test -count=1 -timeout 45m on Linux (wsl-run) of internal/gateway,
internal/redact, internal/provider, internal/agent and internal/usage
(this batch's packages, plus those main changed since the full run): all
ok except internal/agent's TestInstalledVersion, TestGrokInstalled and
TestOmpDetectedWithPiDir, red at origin/main on that box too (#4033,
#3548). gofmt -l clean; go vet ./... (darwin), GOOS=linux and
GOOS=windows go vet -tags nogui ./... clean. On macOS (mote-run), the
root package and internal/cli ok; internal/gui red in
TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners
(#3949) and TestColdTurnsTaken (#4510), the first two red at main too.
- The full go test ./... -timeout 45m -count=1 ran two rebases earlier,
at tree 66a7a4c17 on origin/main 3a3bdb9f2, on Linux (wsl-run): 82
packages ok, internal/agent's 4 reds as above, plus
TestCopilotFolderFromAnIDEPluginIsNotTheCLI (#4033, red at main). The
root package, internal/cli and internal/gui need gtk4 to build, so they
ran on macOS as above. An earlier full run at base d307aa648 was red
once in TestUnroutedHeldReportSaved (#4300), which passes 5 of 5 alone
at both the head and main.
- Each landed patch's diff matches the head ggbdpq posted last on its
issue (patch-id).
- No GUI file is touched, so no GUI test file was run.
- Rebased after these runs onto origin/main c1457f2ee. Its two commits
since 3cfba2e37 (3f2faef62 gui, c1457f2ee agent) touch neither
internal/gateway nor internal/redact, nor any file this batch changes,
and were not run again here.
Broken by hand: summaryEndedShort made to return false: the "HTTP 502"
subtest goes red; restored, green.
Not tried: a real ChatGPT summary ask answered 502.

Co-authored-by: Edward4226 <234070868+Edward4226@users.noreply.github.com>
Co-authored-by: Edward4226 <234070868+Edward4226@users.noreply.github.com>
2026-11-01 06:38:01 +08:00
yetone 45385f0eed redact: a secret's field name masks only in a tool's arguments and result, with secrets on (#2946)
#2946's patch masked any JSON value whose field name looks like a
secret's (api_key, password, *_token) anywhere in a request body outside
tool definitions. That is an exemption, and a mask, keyed on a field's
name: it rewrote what the agent itself sends (mcp_servers'
authorization_token, a top-level api_key, metadata.session_token) as
well as the user's data. The name check now runs only where the user's
data sits in the protocol: a tool call's arguments (Anthropic tool_use
input, OpenAI arguments, Gemini functionCall args) and a tool's result
(Gemini functionResponse.response is added to the places scan reads),
and only with secrets masking on.

The Authorization/Cookie rule masked the word after the header name in
prose too ("Authorization: required for this route"). It now masks only
a value with a credential's shape: one token, or a scheme word and a
token, of 8 or more characters with a non-letter and not a ${VARIABLE};
or name=value cookie pairs.

Tests: TestMaskJSONNamedSecrets puts its values in tool_use input,
functionCall args and functionResponse response;
TestMaskJSONSecretNamesOnlyInToolArgs holds the agent's own fields as
written and nothing masked with secrets off; TestMaskAuthHeaders gains
prose rows (no mask) and a Cookie row.
docs/subsystems/gateway-routing.md says where the name check runs.

Landing record (yetone):
Run at the pushed batch head (tree a6b084d0b, on origin/main 616405061),
go1.26.8:
- go test -count=1 -timeout 45m on Linux (wsl-run) of internal/gateway,
internal/redact, internal/provider and internal/plugin (this batch's
packages and those main changed since the full run): all ok. gofmt -l
clean; go vet ./... (darwin), GOOS=linux and GOOS=windows go vet -tags
nogui ./... clean. internal/gui on macOS (mote-run):
TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners
(#3949), both red at main too.
- The full go test ./... -timeout 45m -count=1 ran one rebase earlier,
at tree 66a7a4c17 on origin/main 3a3bdb9f2 (main then gained 5bfa9f076's
group stand-in, b19d08593, f856d381a and 616405061). It ran on Linux
(wsl-run): 82 packages ok. internal/agent has 4 reds, all red at
origin/main on that box as well: TestInstalledVersion,
TestGrokInstalled, TestOmpDetectedWithPiDir and
TestCopilotFolderFromAnIDEPluginIsNotTheCLI (#4033, #3548). The root
package and internal/cli need gtk4 to build, so they ran on macOS
(mote-run): ok. TestColdTurnsTaken (#4510) was red there once. An
earlier full run at base d307aa648 was red once in
TestUnroutedHeldReportSaved (#4300), which passes 5 of 5 alone at both
the head and main.
- Each landed patch's diff matches the head ggbdpq posted last on its
issue (patch-id).
- No GUI file is touched, so no GUI test file was run.
Broken by hand: the name check's scope put back to everywhere but tool
definitions: TestMaskJSONSecretNamesOnlyInToolArgs goes red; headerValue
made to accept anything: TestMaskAuthHeaders' prose rows go red;
restored, green.
Not tried: a real agent's request through the gateway with masking on.

#2946's patch masked any JSON value whose field name looks like a
secret's (api_key, password, *_token) anywhere in a request body outside
tool definitions. That is an exemption, and a mask, keyed on a field's
name: it rewrote what the agent itself sends (mcp_servers'
authorization_token, a top-level api_key, metadata.session_token) as
well as the user's data. The name check now runs only where the user's
data sits in the protocol: a tool call's arguments (Anthropic tool_use
input, OpenAI arguments, Gemini functionCall args) and a tool's result
(Gemini functionResponse.response is added to the places scan reads),
and only with secrets masking on.

The Authorization/Cookie rule masked the word after the header name in
prose too ("Authorization: required for this route"). It now masks only
a value with a credential's shape: one token, or a scheme word and a
token, of 8 or more characters with a non-letter and not a ${VARIABLE};
or name=value cookie pairs.

Tests: TestMaskJSONNamedSecrets puts its values in tool_use input,
functionCall args and functionResponse response;
TestMaskJSONSecretNamesOnlyInToolArgs holds the agent's own fields as
written and nothing masked with secrets off; TestMaskAuthHeaders gains
prose rows (no mask) and a Cookie row.
docs/subsystems/gateway-routing.md says where the name check runs.

Landing record (yetone):
Run at tree 7d7955eb9 (this batch on origin/main 3cfba2e37), go1.26.8:
- go test -count=1 -timeout 45m on Linux (wsl-run) of internal/gateway,
internal/redact, internal/provider, internal/agent and internal/usage
(this batch's packages, plus those main changed since the full run): all
ok except internal/agent's TestInstalledVersion, TestGrokInstalled and
TestOmpDetectedWithPiDir, red at origin/main on that box too (#4033,
#3548). gofmt -l clean; go vet ./... (darwin), GOOS=linux and
GOOS=windows go vet -tags nogui ./... clean. On macOS (mote-run), the
root package and internal/cli ok; internal/gui red in
TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners
(#3949) and TestColdTurnsTaken (#4510), the first two red at main too.
- The full go test ./... -timeout 45m -count=1 ran two rebases earlier,
at tree 66a7a4c17 on origin/main 3a3bdb9f2, on Linux (wsl-run): 82
packages ok, internal/agent's 4 reds as above, plus
TestCopilotFolderFromAnIDEPluginIsNotTheCLI (#4033, red at main). The
root package, internal/cli and internal/gui need gtk4 to build, so they
ran on macOS as above. An earlier full run at base d307aa648 was red
once in TestUnroutedHeldReportSaved (#4300), which passes 5 of 5 alone
at both the head and main.
- Each landed patch's diff matches the head ggbdpq posted last on its
issue (patch-id).
- No GUI file is touched, so no GUI test file was run.
- Rebased after these runs onto origin/main c1457f2ee. Its two commits
since 3cfba2e37 (3f2faef62 gui, c1457f2ee agent) touch neither
internal/gateway nor internal/redact, nor any file this batch changes,
and were not run again here.
Broken by hand: the name check's scope put back to everywhere but tool
definitions: TestMaskJSONSecretNamesOnlyInToolArgs goes red; headerValue
made to accept anything: TestMaskAuthHeaders' prose rows go red;
restored, green.
Not tried: a real agent's request through the gateway with masking on.
2026-11-01 06:38:01 +08:00
ggbdpq 78632d4b84 gateway: a Codex compaction cut short with no candidate left compacts locally (#3526, Edward4226)
A summary wanted whole whose stream every candidate broke off reached
codexCompact as an error none of its fallback conditions name: not a
404, not an unreadable item, not "Upstream request failed", not
"response protection is unavailable". The relay ends such a stream with
a response.failed event saying "the reply ended before it was complete"
(#2274), and with nobody left to fail over to, that error fell out of
the 404/protection family and went to Codex as a 502. Codex asked the
same huge summary over, three times, each paying for the whole
conversation, until compactFails answered 400 and held it: the
conversation could neither compact nor go on. That is the no-candidate
case #2274 left, after it made a cut summary fail over where there was
someone to fail over to.

The summary is magpie's own then, as when no model can be asked at all
(#866, #1008, #1270 end so). The summary as text isn't tried either:
the cut was in what the model wrote, not in what it was asked, and that
would be another ask of the same huge prompt. The words before the cut
are never taken: the local summary is built from the request's own
items. A summary that failed halfway, or ended incomplete — the output
limit's own event — is still told to Codex as it came and still counts
the guard; only the bare break-off turns local. 401, 403, 429 and
request-shape refusals are untouched.

Run: TestCodexCompactCutAloneCompactsLocally (new) is red on the parent
with the issue's 502 ("the reply ended before it was complete, so there
is no summary") and green here — 200, one magpie compaction holding the
local handoff, the cut stream's words in none of it, the last ask the
fake saw still the original summary request (no plain-text retry). The
#2274 tests keep their shape: TestCodexCompactCutSummaryFailsOver (a
whole fallback summary still wins) green unchanged;
TestCodexCompactCutSummaryIsNoSummary now covers the halfway and
incomplete shapes alone (the cut one moved to the new test);
TestCodexCompactKeepsFailingIsHeld holds on the incomplete shape, which
still fails and rests nobody. Ablation: only codex_backend.go put back
to the parent, tests kept — the new test is red again, restored, green.
go test -tags nogui -p 2 -count=1 ./internal/gateway: ok (350.8s).
Targeted TestCodexCompact with -race -count=2: ok. ./internal/usage:
ok. gofmt -l clean; go vet -tags nogui on darwin, linux and windows
clean; CGO_ENABLED=0 go build -tags nogui on all three ok.
docs/subsystems/gateway-routing.md says the new terminal state.

Refs #3526

Landing record (yetone):
Run at the pushed batch head (tree a6b084d0b, on origin/main 616405061),
go1.26.8:
- go test -count=1 -timeout 45m on Linux (wsl-run) of internal/gateway,
internal/redact, internal/provider and internal/plugin (this batch's
packages and those main changed since the full run): all ok. gofmt -l
clean; go vet ./... (darwin), GOOS=linux and GOOS=windows go vet -tags
nogui ./... clean. internal/gui on macOS (mote-run):
TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners
(#3949), both red at main too.
- The full go test ./... -timeout 45m -count=1 ran one rebase earlier,
at tree 66a7a4c17 on origin/main 3a3bdb9f2 (main then gained 5bfa9f076's
group stand-in, b19d08593, f856d381a and 616405061). It ran on Linux
(wsl-run): 82 packages ok. internal/agent has 4 reds, all red at
origin/main on that box as well: TestInstalledVersion,
TestGrokInstalled, TestOmpDetectedWithPiDir and
TestCopilotFolderFromAnIDEPluginIsNotTheCLI (#4033, #3548). The root
package and internal/cli need gtk4 to build, so they ran on macOS
(mote-run): ok. TestColdTurnsTaken (#4510) was red there once. An
earlier full run at base d307aa648 was red once in
TestUnroutedHeldReportSaved (#4300), which passes 5 of 5 alone at both
the head and main.
- Each landed patch's diff matches the head ggbdpq posted last on its
issue (patch-id).
- No GUI file is touched, so no GUI test file was run.
Broken by hand: gua's ablation (codex_backend.go back to its parent: the
new test goes red). The 502 shape is broken by hand in this batch's
#3526 follow-up.
Not tried: a real Codex compaction whose every candidate is cut short;
the cut is the fake upstream's.

Landing record (yetone):
Run at tree 7d7955eb9 (this batch on origin/main 3cfba2e37), go1.26.8:
- go test -count=1 -timeout 45m on Linux (wsl-run) of internal/gateway,
internal/redact, internal/provider, internal/agent and internal/usage
(this batch's packages, plus those main changed since the full run): all
ok except internal/agent's TestInstalledVersion, TestGrokInstalled and
TestOmpDetectedWithPiDir, red at origin/main on that box too (#4033,
#3548). gofmt -l clean; go vet ./... (darwin), GOOS=linux and
GOOS=windows go vet -tags nogui ./... clean. On macOS (mote-run), the
root package and internal/cli ok; internal/gui red in
TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners
(#3949) and TestColdTurnsTaken (#4510), the first two red at main too.
- The full go test ./... -timeout 45m -count=1 ran two rebases earlier,
at tree 66a7a4c17 on origin/main 3a3bdb9f2, on Linux (wsl-run): 82
packages ok, internal/agent's 4 reds as above, plus
TestCopilotFolderFromAnIDEPluginIsNotTheCLI (#4033, red at main). The
root package, internal/cli and internal/gui need gtk4 to build, so they
ran on macOS as above. An earlier full run at base d307aa648 was red
once in TestUnroutedHeldReportSaved (#4300), which passes 5 of 5 alone
at both the head and main.
- Each landed patch's diff matches the head ggbdpq posted last on its
issue (patch-id).
- No GUI file is touched, so no GUI test file was run.
- Rebased after these runs onto origin/main c1457f2ee. Its two commits
since 3cfba2e37 (3f2faef62 gui, c1457f2ee agent) touch neither
internal/gateway nor internal/redact, nor any file this batch changes,
and were not run again here.
Broken by hand: gua's ablation (codex_backend.go back to its parent: the
new test goes red). The 502 shape is broken by hand in this batch's
#3526 follow-up.
Not tried: a real Codex compaction whose every candidate is cut short;
the cut is the fake upstream's.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 06:38:00 +08:00
yetone 3f2faef620 gui: the Providers page has its own Hide accounts switch
Routing's Hide accounts (账号打码) also masked the Providers page,
where nothing showed it was on or let you turn it off (Discord
#feedback, 1566189346665799752). The Providers page now has its own
switch beside its search box, placed and drawn like Routing's
(.rt-mask moved from routing.css to app.css), and each page follows
its own switch: Routing, Usage and the tray panel follow
magpie.maskEmails, Providers follows magpie.maskProviders.

The user's own choice is kept: when maskProviders was never stored,
it is seeded from maskEmails and written at once, so someone who had
masking on stays masked on both pages after the update, and someone
who turned it off stays unmasked. A switch with a stored choice is not
changed by Mask personal data's follow(); turning Mask personal data
on still masks both (hideAccounts.set(true, true), in app.js and
plugins/redact/page.js). show() asks hideAccounts.page() to re-mask
when the page in sight follows the other switch. No new strings: the
button reuses Routing's translated label and title. app.js
1,310,438, core under its budget, no raise.

Run:
- New internal/gui/tests/provider-mask.test.cjs, both engines, all
  5 languages, at 1000 and 420 wide, plus the touched window-mask,
  account-eye, privacy-hides-accounts, mask-emails,
  plugin-name-unmasked, masking-demo-unblurred: 134/134 on mote. At
  the rebased head (origin/main 573b21f4b) with gui-zh, gui-ja and
  i18n-keys: 140/141, the red is gui-ja's ja string from a7b47d57e
  (#4580), red on main.
- provider-mask on origin/main's assets: 60/60 red (no #pvMask).
- Broken by hand (chromium en), each red: cur() always Routing's
  switch ("Providers shows the account while its own switch is
  off"); the seed taken out (the upgrade on/off cases); show()'s
  page() call taken out.
- gofmt -l clean; go vet, GOOS=linux -tags nogui and GOOS=windows vet
  ok; the three builds ok; go test -tags nogui -timeout 45m ./... on
  mote at base 6712e367e: every package ok but internal/gui's
  TestSettingsSaveKeepsWhatItDoesNotSend, red on main too (#4514).
  At the rebased head: internal/gui's budget tests ok.
- Whole GUI suite on Linux (WSL magpie-desktop, concurrency 6, host at
  100% CPU), files a to l so far, the rest on mote: each red file was
  run alone at this head and at origin/main 6712e367e. Red alone at
  both, already filed: agent-panel-name-width (#4203), context-map
  webkit 420 (#3488), gateway-caller-keys (#3797), gateway-key-models
  (#4081), header-centre webkit ResizeObserver (#3479), key-replace
  webkit 420 (#4126), gui-ja (#4580). Red only under the whole run,
  green alone at this head: agent-plugin-agents (#4481), agent-prefs
  (#4552), allow-ips (#3699), api-key-theme (#3307), click-scroll,
  codex-predictions, currency (#3101), editor-advanced-align, fonts,
  gateway-key-limit, group-from-model-add, group-member-fast,
  group-member-off, group-morph, icon-url, inner-scroll-contain,
  keep-awake, lan-docker, ledger-hscroll, library-chip-fan,
  library-items, library-mcp-hub, library-mcp-tools, list-sort (the
  load class, #4400,
  #4471).

Not tried: the real desktop app's webview (Wails), and the GUI suite
on macOS beyond the files above.
2026-11-01 06:30:17 +08:00
a6de2a15ea gateway: an allowed_tools choice reaches the Grok plugin's fetch, end to end (#3153)
Follow-up to ggbdpq's grokShaped change: its test reads grokPluginBody
alone. skygunner's TestAllowedToolsReachesGrokPlugin (852182f6 on their
fork, from the #3153 thread) posts a /v1/responses request with an
allowed_tools choice through the gateway to the fake Grok plugin and
checks its fetch gets that object as sent, which is where the plugin
decides on x_search. Taken as written; provider-plugins.md names it.

Broken by hand: with internal/provider/grok.go at d307aa648 (before
the fix) it is red ("sent" with no tool_choice), green with it. The
plugin side was read in magpie-community/plugins at 26864ec (grok
0.2.3, the mover's min): rewrite decides x_search on the choice as it
came (null or "auto" only) and deletes an object whose type isn't in
TOOLS before Grok, so no min raise is needed.

Run at the pushed head on mote: go test ./... -timeout 45m on mote with this branch on 41b5c0f19: 83 packages ok. internal/gui is red on TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners (#3949), both red alone at 41b5c0f19 too, and on TestColdTurnsTaken (#4510). internal/update is red on TestRelaunchOpenTriedAgain (#3881). The last two pass alone at 41b5c0f19 and here. Rebased on f856d381a: agent, gateway, plugin, provider and sessions ok, gui red on #4514 and #3949 only, gofmt -l clean, go vet ok for linux (nogui), windows and darwin. Rebased on bb478f0e5: agent and gateway ok, gui the same. The last rebase, onto 573b21f4b, brings in only internal/gui/providers*.go and internal/provider/models.go, which this branch doesn't touch.

Co-authored-by: vincent <webmaster@palmit.com.au>
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-01 06:21:39 +08:00
ggbdpq ca183561f7 gateway: an allowed_tools tool_choice reaches the Grok plugin (#3153)
grokShaped dropped a tool_choice object whose type isn't among grokTools
on the plugin's path too, the same as for the built-in: a Responses
request relayed to the Grok plugin in its own protocol reached the
plugin's fetch with no tool_choice, so with the X search option on (grok
0.2.0) the plugin added x_search over a client's allowed_tools and a
tool outside the allowed list went out. The plugin reads the choice and
leaves an unsupported one out before Grok itself (every version since
the TOOLS filter, the mover's min 0.1.18 among them), so grokPluginBody
now keeps such an object, as it keeps the lone "none" (#3110);
grokShaped's keepNone is forPlugin, since keeping is no longer only
about "none". The built-in, which is Grok's last stop, still drops it.

Run:
- gofmt -l on the changed files: clean
- go vet ./...: darwin and GOOS=windows clean; GOOS=linux vet needs
  -tags nogui (the GUI's wails doesn't vet without it), clean with it
- go build: darwin, GOOS=linux -tags nogui and GOOS=windows: ok
- go test -tags nogui ./internal/provider: ok 167.3s, no FAIL
- go test ./internal/gateway -run 'TestToolsOffWithoutTools|TestGrok': ok
- TestGrokPluginBodyKeepsUnsupportedToolChoice fails without the change
  ("plugin: tool_choice {Type: Mode: Tools:[]}"), passes with it; broken
  by hand, each way red then green on restore: deleting the choice
  whatever the path (plugin red), deleting only a supported type
  (built-in red)

Landed (yetone): the next commit adds the end-to-end test through the
gateway to the fake Grok plugin. Run at the pushed head on mote:
go test ./... -timeout 45m on mote with this branch on 41b5c0f19: 83 packages ok. internal/gui is red on TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners (#3949), both red alone at 41b5c0f19 too, and on TestColdTurnsTaken (#4510). internal/update is red on TestRelaunchOpenTriedAgain (#3881). The last two pass alone at 41b5c0f19 and here. Rebased on f856d381a: agent, gateway, plugin, provider and sessions ok, gui red on #4514 and #3949 only, gofmt -l clean, go vet ok for linux (nogui), windows and darwin. Rebased on bb478f0e5: agent and gateway ok, gui the same. The last rebase, onto 573b21f4b, brings in only internal/gui/providers*.go and internal/provider/models.go, which this branch doesn't touch.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 06:21:39 +08:00
ggbdpq c26d16018f gateway: a plugin model that refuses temperature is asked without it, relayed or translated (#2492)
What changed: the plugin host carries a model's temperature where it is
said - the config model's temperature (Factory 0.1.31's configModels,
plugins#154), models.dev's own, or a models hook's model field - into
plugin.Model and pluginCatalog's catalog model, where
RejectsTemperature reads it as it reads a built-in's. A Chat or
Responses request relayed as it came to a model whose list refuses
temperature and top_p now leaves them out (passthrough), as the
translation of one (build) already did. A model nothing says so of
keeps what the client sent. OpenCode's capabilities.temperature is not
read: its false is what it reads a models.dev silence as, not a refusal
said.

Docs: the sampling row of gateway-routing, and provider-plugins' new
"A plugin model's sampling".

Run at ea3dee96 + this change, sandbox HOME:
go test -tags nogui -p 2 -run TestPluginModelRefusingTemperature
./internal/gateway/ - red at ea3dee96 without this change (the plugin's
fetch got temperature 0.7, top_p 0.9 relayed, temperature 0.7
translated; the model that says nothing keeps them), green with it;
ablation removed the four product files and went red the same way.
go test -tags nogui -p 2 -timeout 45m ./internal/gateway/ ok (291s);
go test -tags nogui -p 2 ./internal/plugin/ ok; -run
'TestRejectsTemperature|TestPluginModel|TestPluginCatalog|PluginParity|TestPlugin'
./internal/provider/ ok; -run
'TestSampling|TestUpstreamBytes|TestPassthrough|TestRelay'
./internal/gateway/ ok.
gofmt -l internal/ clean; go vet ./... (darwin, the
trayimage_darwin.go cgo warning as before), GOOS=linux go vet -tags
nogui ./... and GOOS=windows go vet ./... clean; go build and
GOOS=linux/windows go build ok.

Landed (yetone). Broken by hand on mote: with gateway.go, host.js,
internal/plugin/providers.go and internal/provider/plugins.go at
origin/main, TestPluginModelRefusingTemperature is red. passthrough
strips temperature and top_p for a provider whose catalog says
temperature false on Chat and Responses alike, the same rule build
applies. Run at the pushed head: go test ./... -timeout 45m on mote with this branch on 41b5c0f19: 83 packages ok. internal/gui is red on TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners (#3949), both red alone at 41b5c0f19 too, and on TestColdTurnsTaken (#4510). internal/update is red on TestRelaunchOpenTriedAgain (#3881). The last two pass alone at 41b5c0f19 and here. Rebased on f856d381a: agent, gateway, plugin, provider and sessions ok, gui red on #4514 and #3949 only, gofmt -l clean, go vet ok for linux (nogui), windows and darwin. Rebased on bb478f0e5: agent and gateway ok, gui the same. The last rebase, onto 573b21f4b, brings in only internal/gui/providers*.go and internal/provider/models.go, which this branch doesn't touch.

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

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

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

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 06:21:39 +08:00