Commit Graph
822 Commits
Author SHA1 Message Date
Yang Yu a1cce7faa1 gateway: the decision model's timeout is a setting (#2934, reyoung)
A routing group's intent classifier (askChat) and System One (askJev)
were each given a fixed 8s. A slow subscription classifier can now be
given longer in Settings > Models > Replies > Intent classifier timeout.
settings.json's classifyTimeout takes 1..60 seconds; 0 or missing keeps
8s. save() refuses below 0 or above 60, and ClassifyWait clamps a value
edited by hand (below 1 gives 8s, above 60 gives 60s). A settings file
that can't be read gives Shared()'s defaults, so 8s, never no timeout.
Both askChat and askJev read it per call. The GUI row is the app's own
segmented control (8, 15, 30, 60, plus a value set by hand), and other
saves carry the value on (prefsKeep, api.go). zh, zh-TW, ja and de
strings; the routing reference and the en, zh, ja docs say it.

Ported from reyoung's classify-timeout-2934 (author kept). On top:
- askJev's defer reworded any error once ctx had expired, so a refusal
  (decideRefused) or an answerError read as the wait ran out lost the
  type askDecideTries rests an account by. Now only errNoAnswer, which
  systemOne returns when postDecide failed with ctx done, is reworded
  to "<provider> gave no answer in <wait>".
- ja intent.html: a stray space in "遅いモデルだと 設定した".
- app.js: the Image generation timeout row and the new row share
  waitRow (~350 bytes less). TestCoreScriptBudget was red (app.js
  1,337,982 > 1,337,000); budgets raised to the exact sizes, app.js
  1,337,633 and core 1,529,393, no room added.

Run (macOS, Go env pinned, sandbox HOME):
- Full go test -tags nogui -timeout 45m ./... at 766cf1cf9: 68 packages
  ok; internal/gui red on TestCoreScriptBudget only, fixed above.
- At ed008ca9f and again after rebasing on 65e80405b: internal/gateway,
  internal/settings, internal/gui ok; gofmt -l clean; go vet (darwin),
  GOOS=linux go vet -tags nogui, GOOS=windows go vet all ok.
- Whole GUI suite at ed008ca9f, chromium and webkit, 4 wide at load
  ~30: 11,930 tests, 52 red, none in the files this change reaches
  (classify-timeout-setting, image-timeout, i18n-keys all pass). The
  red files rerun alone: 44 red in 10 files, the same 44 on origin/main
  65e80405b. All have issues (#2228, #2399, #2150, #2448, #2276, #3091,
  #2549, #2163, #3099, #3104) except library-mcp-health-wsl's ja case,
  filed as #3350.

Broken by hand, each red then restored:
- classifyTimeout fixed at 8: TestClassifierTimeoutSetting and
  TestJevGivenTheClassifierTimeout red.
- askJev fixed at 8: TestJevGivenTheClassifierTimeout red.
- save()'s bound removed: TestClassifyTimeoutKeptAndBounded (-1
  accepted) and TestSettingsClassifyTimeout (61 gives 200) red.
- ClassifyWait's clamp removed: red (600 waits 10m0s).
- api.go's keep removed: TestSettingsClassifyTimeout red.
- prefsKeep's classifyTimeout removed: the GUI test's "sent on with
  other saves" red in chromium and webkit.

Not tried: a real slow classifier or account; Linux and Windows at
run time; the native Linux desktop build; a test that pins the askJev
refusal-at-deadline race (it is timing-only, so no deterministic red
was written for it).
2026-10-23 15:03:08 +08:00
yetone a6efe07cd7 davsync: a GitHub backup too large for one request goes up in parts (Zhang-Wei, Discord)
Zhang-Wei (Discord, v0.1.1327) saw every GitHub sync fail with "GitHub
sync: HTTP 422: Sorry, your input was too large to process. Consider
creating the blob in a local clone of the repository and then pushing it
to GitHub." Their exported backup is 50.8 MB; with the library's sync off
it works. 93b87d000 sends a backup as one base64 blob in one POST
/git/blobs, so 50.8 MB is about 68 MB of request body. GitHub documents
100 MB per blob (on read) but no request size for creating one; a 19 MB
file's Contents PUT (about 25 MB of body) did go through.

A backup over 16 MiB (githubPart) now goes up in parts, in the same one
commit: magpie.magpie-backup.parts/1, /2, ... beside it, and at the
backup's own path a short list (format magpie-backup, version 2, split
github-parts, total size, each part's blob SHA and size). The version is
the list's blob SHA, and the list names each part by blob SHA, so one
version pins one whole set. get() reads the list, downloads each part by
that SHA (as large single files already were), checks each part's git
blob SHA and the sizes, and returns the backup whole; a list that doesn't
add up or a part that isn't the one named is an error. A write removes
the parts the list at the head named and the new backup doesn't use, in
the same commit (only paths known to be there, so the tree never names a
missing path). Blobs already sent are kept across a non-fast-forward
retry. The errChanged check at the head, the ref update without force and
the three rebuilds are unchanged. Backups up to 16 MiB stay one file; the
64 MiB total (four parts) stays, the bound the library's skill budget is
sized for. An empty repository's first backup in parts skips the Contents
API and follows the README note commit.

Why parts, not compression: the sealed bundle is uncompressed JSON with
skill files base64 inside, so compressing would shrink it, but that is a
backup format change for every backend and every export, every other
computer would need the new magpie even for WebDAV and S3, and it still
bounds nothing on GitHub's side. Parts keep the format and touch GitHub
only.

Older magpies: the list opens in backup.Open (unchanged since efbe5660b)
as format magpie-backup with no kdf and version 2, so it says "this backup
was made by a newer magpie; update magpie to open it" and stops: not
ErrCorrupt or ErrNotBackup, so no rebuild over it and no replace offered.
A backup in one file, from any magpie, still reads.

Library: nothing found that shouldn't be carried, so no second commit.
readSkills already skips .git and caps skill files at 32 MiB (about
57 MiB sealed). The skills on this machine (~/.claude/skills, 64 skills,
43 MB; ~/.agents/skills) hold no node_modules, __pycache__ or .venv; the
large files are real assets (images). Leaving node_modules out could break
a skill that ships its dependencies. Zhang-Wei's folders weren't seen.

Tests (fixture only, no network): the fixture refuses a blob POST over
24 MiB with GitHub's text, and serves any blob by SHA. New in
github_parts_test.go: TestGitHubSplitBackup (50.8 MB in four parts, one
commit, byte for byte back, errNotModified, stale put errChanged, then
two parts and back to one file with no part left),
TestGitHubOneFileBackupStillReads (old small and 30 MB single files read;
parts replace one), TestGitHubPartsOlderMagpie, TestGitHubPartsDamaged,
TestGitHubPartsBranchMovedMeanwhile, TestGitHubEmptyRepositoryPartsBackup
and TestGitHubSyncLargeLibrary (a ~38 MB instruction text syncs to a
second computer through Now). TestGitHubLargeBackup now uses 15 MB, to
keep covering one blob over the Contents API's limit.
docs/subsystems/sync-backup.md says how parts work and names the tests.

Record, at base origin/main e435b8867 plus this change (Go 1.26.8,
GOMODCACHE/GOCACHE pinned):
- gofmt -l internal/davsync: nothing. go vet ./... (darwin): clean.
  GOOS=linux go vet -tags nogui ./internal/davsync/...,
  GOOS=windows go vet ./internal/davsync/...: clean.
- go test -tags nogui -count=1 ./internal/davsync/... ./internal/settings/...
  ./internal/cli/... ./internal/backup/... ./internal/library/...: all ok
  (davsync 58s, settings 30s, cli 47s, backup 8s, library 127s).

Red on the old github.go (new tests, a shim for the new names): every new
test fails, the split ones with the reporter's 422 text, OlderMagpie with
"not a magpie backup" (the old code wrote the backup as is).

Broken by hand on the new code, each red:
- stale parts kept: TestGitHubSplitBackup
- part SHA not checked: TestGitHubPartsDamaged/a_part_changed
- blobs sent again on retry: PartsBranchMovedMeanwhile/another_file
- version check at the head skipped: SplitBackup, PartsBranchMoved/
  the_backup, and the older Remote, LargeBackup, BranchMoved tests
- no split (threshold at 64 MiB): SplitBackup, OneFileBackupStillReads,
  PartsOlderMagpie, PartsDamaged
- sizes not added up: PartsDamaged/sizes
- list's format "magpie-backup-parts": PartsOlderMagpie
- empty repository tries the Contents API first: EmptyRepositoryPartsBackup
- list's version 1: OlderMagpie still passes, since old Open also stops
  on the missing kdf; version 2 is a second guard, not the only one.

Not tried: the real GitHub API (no test repository here); the 16 MiB part
is chosen under the largest body seen accepted, not a documented limit.
The full go test ./... and internal/gui's tests were not run: the disk had
under 500 MB free. -race not run; no goroutine was added.
2026-10-23 10:35:44 +08:00
yetone f81913994a gateway: a Responses Lite compaction's summary request offers no tools, and a reply without a summary says what it held (WuSix on Discord)
WuSix (Discord) got "compaction: codex/gpt-6-astra failed to summarise
this conversation 3 times in a row (last: the model wrote no summary)".

codex/gpt-6-astra's catalog entry is Codex's own (codexcat.ownEntry), and
Codex's entry puts gpt-6 on Responses Lite: its tools go as an
additional_tools input item, none in tools. codexInputAs set "tools": []
for magpie's summary request but left that item in, so the model was
asked for the summary with every Codex tool still offered (tool_choice
auto, which codexBody sets anyway). A reply that is a function_call and
no message is "the model wrote no summary". codexInputAs now leaves the
additional_tools item out when it turns the trigger into the summary
prompt; calls in the history stay as they came.

The 502 and the held message now say what the reply held instead
(answeredWith: "(it answered with function_call shell)", "reasoning",
"nothing"), so the next report says which it was.

Hypothesis, not confirmed on a real reply (see below): the fake backend in
TestCodexLiteCompactionOffersNoTools answers a call whenever any tool is
offered, as an agentic model mid-task may. What the test holds is that
the request offers none.

Run at base 398803e3f (origin/main), in this worktree:
- TestCodexLiteCompactionOffersNoTools red before the fix (502
  "compaction: the model wrote no summary"), green after
- gofmt -l internal/: clean
- go vet ./internal/gateway/, GOOS=linux go vet -tags nogui, GOOS=windows
  go vet: ok
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway/: ok
  (366.6s); only comments and docs changed after it started

Real ChatGPT backend, the owner's Codex sign-in (access token read
from ~/.codex/auth.json, not refreshed), 2026-10-23: the exact body
magpie sends upstream, captured from the gateway with a fake backend
(before and after this change), then POSTed to
chatgpt.com/backend-api/codex/responses with Codex's headers and
X-OpenAI-Internal-Codex-Responses-Lite: true. gpt-6-astra, effort low,
reasoning.context all_turns; a developer prompt, a user ask, a
function_call shell (namespace "functions") and its output, then the
compaction prompt. Three tries each:
  (a) old: additional_tools kept, tool_choice auto  200 x3, message
      (978/1010/1037 chars)
  (b) this change: additional_tools left out        200 x3, message
      (1176/1003/991 chars)
  (c) additional_tools kept, tool_choice none       200 x3, message
      (972/1009/1026 chars)
So the backend takes a Lite request whose history calls the "functions"
namespace with no additional_tools item: the fix doesn't 400. The old
request also summarised on this short history, so the cause of WuSix's
reports isn't reproduced on the real backend; with a long tool-heavy
conversation at a higher effort it may still be, and answeredWith will
say.

Not tried: a long conversation, efforts above low, and WuSix's own
conversation.
2026-10-23 09:20:23 +08:00
yetone 398803e3f5 gateway: a model slow to start again and again rests on its account (小八)
小八 on Discord (2026-10-23): a WorkBuddy plugin account answered magpie's
own 504 "no first token in 30s" 58 times on kimi-k3-1 and glm-5.3 (the
vendor's per-model token limit, which it never names, it just stalls).
The group went on each time, then asked the same account first on the
next request: 15 slow starts in 17 minutes in one session.

Cause: gateway.go's hw.slow branch (the group's FirstToken let a member
go) never rested anything, by design ("a long prompt being slow to start
anywhere"), and nothing counted slow starts. So every request waited out
the whole FirstToken on the stalled member before falling back.

Now restSlow (routing.go) counts slow starts per restID (provider,
account or key, model). Once rests nothing, as before. The second in a
row, within slowForget (30m) of the last, rests that model on that
account: 1 minute, doubling each time after, capped by the provider's
RestCapOr(longestRetry), never for a provider whose rest cap is off. An
answer clears the count (servedCandidate). A client-cancelled request
never reaches the slow branch, so it counts nothing. A longer rest
already there is kept. The rest carries Rest.Model, so the Routing page
shows it on that model's rows only. The Routing story of a rested slow
try says so, and the group editor's slow-to-start hint no longer says
"It doesn't rest" (en, zh, zh-TW, ja, de).

Tests: TestSlowStartsRestTheModelOnItsAccount (once: no rest; an answer
in between restarts the count; twice: the model rests on k1 with Key
a#k1/m, Model m, under a minute; k1's whole key and k2/m don't rest; the
next request asks k2/m first; a/n still goes to k1; a third slow start
backs off longer; an answer ends it). TestCanceledSlowStartRestsNothing
(three client cancels during the first-token wait: no rest, no count).
routing-went-on.test.cjs gains a rested slow try in five languages;
group-first-token.test.cjs's i18n list has the new strings.

Broken by hand: restSlow's result ignored in gateway.go -> the first test
red at "twice in a row" (Rest nil); servedCandidate not clearing
routed.slow -> red at "an answer in between starts the count again";
restSlow called in the cancel branch -> the cancel test red at "cancel
2: k1/m wasn't asked (rested?)". All restored, green.

Run at the worktree on base 7aad6a50e: gofmt -l clean; go vet darwin,
GOOS=linux -tags nogui, GOOS=windows: ok. The two new tests -race
-count=3: ok. TestGroupFirstTokenFailsOver, TestNestedGroupFirstToken:
ok. GUI: the 125 routing-*, group-* and i18n-* files, Chromium and
WebKit: 1428 of 1429; the one red, routing-rule-remove de (menu focus
after ArrowUp, the #3094 symptom), passed 20 of 20 alone. Full suite:
set -o pipefail; go test -tags nogui -timeout 45m ./... : 69 packages ok, none failed (gateway 544s, agent 430s, provider 234s).

Not tried: a real WorkBuddy account stalling on its token limit; the
fixture stalls by holding its stream after the role chunk.

Rebased on origin/main ecd983500 (no gateway or routing plugin change in between) and run again there: gofmt, the three go vets, internal/gui (budgets) ok, the four first-token gateway tests ok, i18n-keys, routing-went-on and group-first-token in both engines 43 of 43.
2026-10-23 04:03:39 +08:00
yetone ecd9835005 agent: Claude Code's subagent effort writes nothing without a subagent model (KorenKrita)
KorenKrita on Discord (cause confirmed by them): with Claude Code's
subagent model unset ("Claude Code picks") and a subagent effort set,
claude.go wrote spell(tierWith(main model, effort)) into
env.CLAUDE_CODE_SUBAGENT_MODEL. That pinned every subagent to the main
model, so Claude Code's own pick (the Agent call's model, the subagent's
frontmatter) never ran.

Agent wiring (internal/agent/claude.go):
- With no subagent model, magpie writes no effort, and
  CLAUDE_CODE_SUBAGENT_MODEL stays unset.
- The saved effort is kept, not deleted (the user set it). It lives in
  the stash under claude.subagent_effort, and the subagent effort's Get
  reads "" while there is no model. A model picked later takes it
  ("v/glm:high").
- A value an older magpie wrote that way (the main model at an effort,
  not own, while routed: subagentFollowing) is moved into the stash and
  taken out of the env by writeTiers and by Sync on start.
- subagentOwn no longer counts that value as the user's own model.
- Doc: docs/subsystems/agent-wiring.md, the Claude Code "subagents" entry.

GUI (window, opened Claude Code row):
- The subagent effort moves from its square under the session defaults
  to the right of the Subagents row. It uses the tier rows' markup and
  code (effortBtn in connectPanel, ag-eff), so it lines up with
  Opus/Sonnet/Haiku's effort.
- While the subagent model is unset it shows Default, is disabled, and
  its title says "Set a subagent model first". The new string is in zh,
  zh-TW, ja and de.
- The old square is removed from the opened row. No other layout changes.
- The tray panel's own square is left alone: #3308.

Tests:
- New internal/agent/claude_subagent_effort_test.go
  (TestClaudeSubagentEffortNeedsAModel). On the old code it is red:
    an effort with no subagent model wrote
    CLAUDE_CODE_SUBAGENT_MODEL="v/glm:high"
  With the Sync branch broken by hand it is red at "Sync left an older
  magpie's CLAUDE_CODE_SUBAGENT_MODEL="v/flash:high"". It also checks
  that a set model plus effort still writes "v/glm:low".
- claude_tiereffort_test.go now expects no env for an effort with no
  model.
- New internal/gui/tests/claude-subagent-effort-row.test.cjs (16 cases):
  chromium/webkit x en/zh x 1100/560px x with/without a subagent model.
  It checks:
  - the control sits in the Subagents row at the tier efforts' x and
    height;
  - with no model it is disabled at Default and opens no slider;
  - with a model it posts subagent_effort, with no scroll;
  - the old square is gone.
  It is red against the old app.js ("the old square is still there").
- tier-effort.test.cjs is updated for the moved control.

Run at this tree (parent f985d6bdb):
- go test -count=1 ./internal/gui/ ./internal/agent/ ./internal/provider/:
  ok.
- GUI: claude-subagent-effort-row, tier-effort, i18n-keys,
  subagent-effort, claude-subagents-pick, desktop-subagent-model,
  agent-prefs, agent-tweak-fold, claude-signin and agent-field-names:
  147/147.
- gofmt clean. go vet darwin, linux -tags nogui and windows: ok.

Run at the same change before its last rebase:
- Full Go suite (`go test -count=1 -timeout 45m ./...`, sandbox HOME,
  through the suite lock) at 11b9d671c (on 45593cc1d): every package ok
  but internal/gui's TestCoreScriptBudget. app.js was 1,337,535 bytes,
  over its 1,337,000 budget, after the rebase brought in upstream growth.
  This commit trims its own additions to 1,336,991 (one shared effortBtn,
  shorter comments, a shorter new string) and raises no budget.
  TestCoreScriptBudget now passes.
- Full Go suite at 41737d214 (on 802fb6e61): all 69 packages ok.
- Whole GUI suite at 41737d214 (11,741 tests, 5.8h at load ~250): 48 red,
  none from this change.
  - Red the same on origin/main 45593cc1d, all filed: quota-count-wrap
    and quota-name-translated (#2228), quota-reads (#2150), s3-sync
    (#2448), usage-agents-hide (#2276), usage-checkin (#2549, #3091),
    usage-fold (#2163), usage-ledger (#3104, #3001).
  - Red under load only and green alone: agent-notice-lang (#2960),
    agent-stale-copies (#1949), modal-morph (#3179), plugin-card-update
    (#3079), plugin-github (#3218), and agent-field-names and
    api-key-theme (filed as #3307).
  - Also seen red once under load: codex-subagent-model's fixed 300ms
    wait (#3277).

Not tried:
- a real Claude Code run reading the written settings;
- the Windows box;
- the whole GUI suite again after the string was shortened (only the
  files above were run);
- the tray panel (#3308).
2026-10-23 03:44:55 +08:00
yetone 4f6498f822 routing, usage: an account renamed in magpie reads by its new name (magpie-community/plugins#310, molvqingtai)
molvqingtai renamed a Kiro (plugin) account from "example@gmail.com (foo)"
to "example@gmail.com (bar)", and the Routing page kept saying "(foo)" on
every request made after. Cause: the Routing page never looked up the
user's name at all. A trace's `who` is the vendor's account name
(Weighed.Who), and plugins/routing/client.js showed it as it was. Usage
records (ProviderAccount) keep the vendor's name the same way, and the
Usage page's Accounts, the request log's Account filter, `magpie usage`,
a gateway key's accounts (AccountNames, /api/caller-keys) and Routing's
"Several accounts" pools (onOf) all showed it raw too. This affected
built-in and plugin providers alike.

Records still keep the vendor's name. It is the key the user's name is
stored under (providers.json AccountNames, in lower case), so it stays
the identity: Routing still groups and ranks by `who`. The name is looked
up when it is shown: provider.AccountShown / AccountShownOf /
AccountRef.Shown in Go, and userShown (accountNameOf over /api/providers'
accountNames) on the Routing page. So requests from before the rename
read by the current name too, and a cleared name goes back to the
vendor's. A key's name and an unnamed account read as before.
Already right before this change: quota cards and the menu bar (Alias),
`magpie accounts`, and the editor's account row.

Record for this push: 13 commits on origin/main ca4a1cde0, head tree
539c84e92. Go 1.26.8, sandbox HOME, GOMODCACHE/GOCACHE pinned. The full Go
run and vet were at tree d6393dfc8, the same Go code as this head: only
app.js comments (cut under the core script budget) and one ja string
changed after it.
- gofmt -l: nothing. go build ./...; go vet ./... (darwin), GOOS=linux
  go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -timeout 45m ./..., through tee, one suite on the machine:
  68 packages ok. The one red was internal/gui's
  TestCoreScriptBudget: app.js 1,335,314 > 1,335,000, since main grew
  app.js under the stack. The autoscroll commit's own comments were cut
  (to 1,334,629) rather than the budget raised, and go test -count=1
  ./internal/gui is ok at this head (113s). Packages the run took from
  Go's test cache had the same inputs.
- GUI: the 18 files this stack touches or names, both engines,
  202 of 204 pass (tree 068acf128, this push less the last commit). The
  two reds: gui-ja, red on main since c2636b7b5 and fixed by this push's
  last commit (gui-ja and i18n-keys 6 of 6 there), and usage-fold's
  chromium "several accounts" (#2163, red on main the same way).
- Red on the old code: TestAccountNameOfAPluginAccount, with
  AccountNames put back to a.User, fails with "a gateway key's accounts
  read [fakeco/31****36@qq.com]". The new GUI test
  routing-account-name.test.cjs, with the old client.js, fails with
  "renamed, the account reads by its new name: Kiro example@gmail.com
  (foo) Pro".
- routing-account-name passes, en and zh, both engines. internal/provider,
  internal/usageapi, internal/cli and internal/gateway ok.
- The five usage files this change's first run found red: usage-agents-hide
  (#2276), usage-checkin (#3091), usage-fold (#2163) and usage-ledger
  (#3104) are red alone at the stack and on main the same way.
  usage-overview-fold now passes alone at both.
  The whole GUI suite ran at 1c1fc7183 (this stack's first 12 commits on
  0ddcf28a1): 11713 of 11769 pass. Each of the 21 red files was then run
  alone at the stack and at origin/main 8278fd9b0. Eight are red the same
  way on main: plugin-card-update (#3079), quota-count-wrap and
  quota-name-translated (#2228), s3-sync (#2448), usage-agents-hide
  (#2276), usage-checkin (#3091), usage-fold's chromium "several
  accounts" (#2163), usage-ledger (#3104). The other 13 pass alone on both
  and were red only under that run's load (50 to 335): currency #3101,
  plugin-github #3218, provider-fetch-again #3292, rest-try-now #2564,
  routing-auto-reset #3293, routing-keys-fold #1612, routing-steady #1804,
  routing-wb-restricted #1905, sessions-folder-delete #2218,
  sessions-manage #3294, switch-only #3295, text-size #1866, usage-pack
  #3296.

Not tried: a real Kiro account. The fixture is the reporter's case, with
their names.
2026-10-23 01:58:01 +08:00
yetone cba59b05e1 gui: the middle button's autoscroll scrolls a page instead of twitching (#2767)
#2767 (znbsf, with AvatarGanymede's recording on the Discover page) and
多喝热水 on Discord, on Windows: pressing the wheel and moving the mouse
made a page twitch instead of scrolling, or pulled it back. znbsf's patch
found the same cause.

Chromium and WebView2 give the autoscroll a pointerdown of button 1 and
then no wheel, touch or drag of the reader's. The "where the reader is"
rule put back each of its scrolls as it came, so the page twitched
between where it went and where it was.

What changed (internal/gui/assets/app.js, the click guard):
- From a trusted middle press on a view that can scroll (`panning`),
  that view's scrolls count as the reader's, and what a click held is let
  go. This lasts until the autoscroll ends as Chromium ends it: on the
  next press (seen only as a pointerup with no pointerdown), on a key, on
  blur, or on the lift after the mouse moved more than 15px while held.
- A field the guard brings back into view after putting a scroll back
  must have been focused since the reader last scrolled that view
  (`scrolledFrom`). Before, the button the middle press focused, which
  the autoscroll or the wheel took out of sight, was brought back by the
  next scroll that was put back, and the page jumped to it.
- docs/subsystems/gui-shell.md says both.

Guarded by internal/gui/tests/view-middle-autoscroll.test.cjs: a real
middle press and move in Chromium, en and zh, a scroll by code still put
back after the autoscroll ends, and WebKit (no autoscroll) left as it
was.

Broken by hand:
- app.js put back to its base: Chromium 0/3 ("the autoscroll scrolled
  the page: at 0, passed 0,0,0,…"). WebKit passes, as expected.
- Only the panning line taken out: Chromium 0/3, same message.
- Only the scrolledFrom check taken out: Chromium 0/3 ("after the
  autoscroll: a scroll by code is put back (was 374, asked 1212, at
  126)").

Record for this push: 13 commits on origin/main ca4a1cde0, head tree
539c84e92. Go 1.26.8, sandbox HOME, GOMODCACHE/GOCACHE pinned. The full Go
run and vet were at tree d6393dfc8, the same Go code as this head: only
app.js comments (cut under the core script budget) and one ja string
changed after it.
- gofmt -l: nothing. go build ./...; go vet ./... (darwin), GOOS=linux
  go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -timeout 45m ./..., through tee, one suite on the machine:
  68 packages ok. The one red was internal/gui's
  TestCoreScriptBudget: app.js 1,335,314 > 1,335,000, since main grew
  app.js under the stack. The autoscroll commit's own comments were cut
  (to 1,334,629) rather than the budget raised, and go test -count=1
  ./internal/gui is ok at this head (113s). Packages the run took from
  Go's test cache had the same inputs.
- GUI: the 18 files this stack touches or names, both engines,
  202 of 204 pass (tree 068acf128, this push less the last commit). The
  two reds: gui-ja, red on main since c2636b7b5 and fixed by this push's
  last commit (gui-ja and i18n-keys 6 of 6 there), and usage-fold's
  chromium "several accounts" (#2163, red on main the same way).
- view-middle-autoscroll and click-scroll pass, both engines.
- plugin-github's "a click scrolls nothing" (1px) was red under the
  whole run's load and passes alone at the stack and on main (#3218).
  The whole GUI suite ran at 1c1fc7183 (this stack's first 12 commits on
  0ddcf28a1): 11713 of 11769 pass. Each of the 21 red files was then run
  alone at the stack and at origin/main 8278fd9b0. Eight are red the same
  way on main: plugin-card-update (#3079), quota-count-wrap and
  quota-name-translated (#2228), s3-sync (#2448), usage-agents-hide
  (#2276), usage-checkin (#3091), usage-fold's chromium "several
  accounts" (#2163), usage-ledger (#3104). The other 13 pass alone on both
  and were red only under that run's load (50 to 335): currency #3101,
  plugin-github #3218, provider-fetch-again #3292, rest-try-now #2564,
  routing-auto-reset #3293, routing-keys-fold #1612, routing-steady #1804,
  routing-wb-restricted #1905, sessions-folder-delete #2218,
  sessions-manage #3294, switch-only #3295, text-size #1866, usage-pack
  #3296.

Not tried: the real Windows app (WebView2) on the Windows box; only
headless Chromium's autoscroll. Linux WebKitGTK has no middle-button
autoscroll, so it is left as WebKit is.
Not done: znbsf's patch doesn't start this on a middle press on a link
(which opens a tab, not an autoscroll). Here it does start, and lets a
scroll by code in that view stand until the next press or key. Left on
#2767, which stays open for the reporters.
2026-10-23 01:58:01 +08:00
yetone c417b1f4e3 library: a skill removed from its source is said so, and every such skill goes in one click, asked first
スライム on Discord (#help, 10-22): taste-skills took some of its skills
out, Update all reported each of them as a failure, and the only way
out was to delete them one by one.

An update or a check that reads the source whole and finds the skill's
folder (or its SKILL.md) gone now calls it removed upstream, not a
failure. GitHub tarballs and other git repositories both work this way.
- UpdateSkill returns *GoneError.
- UpdateSkills and UpdateSomeSkills list it in Result.Gone, not
  Unupdated.
- A check gives status "gone".
- Each marks Skill.Gone. The mark is cleared when a check or an update
  finds the skill there again.
- A fetch that failed, a skill left out of a fetch as too big, and a
  folder that can't be read stay unknown, never gone (goneFrom).

Nothing is deleted by itself. RemoveGoneSkills takes the named skills
out, or every marked one when none are named, through RemoveSkills, so
the folders go to the backups. A skill found in its source again is
kept and said so.
- GUI: a "Removed upstream" tag replaces Update available and the
  update icon. Update all says gone skills apart from failures. "Clean
  up N" sits in the group heading, or in the bar when there is one
  group, and opens a sheet naming each skill. One changed here carries
  "Changed here". Strings are in en, zh, zh-TW, ja and de.
- CLI: `magpie library skill rm --gone [--yes]` asks at a terminal and
  refuses without --yes otherwise. It names the ones changed here.
  update and status print the hint.
- TUI: the row says "removed from <repo> · d takes it out".
- API: POST /api/library/skills/remove-gone {names}.
- Docs: the Skill updates row and Verification in
  docs/subsystems/library.md.

Record for this push: 13 commits on origin/main ca4a1cde0, head tree
539c84e92. Go 1.26.8, sandbox HOME, GOMODCACHE/GOCACHE pinned. The full Go
run and vet were at tree d6393dfc8, the same Go code as this head: only
app.js comments (cut under the core script budget) and one ja string
changed after it.
- gofmt -l: nothing. go build ./...; go vet ./... (darwin), GOOS=linux
  go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -timeout 45m ./..., through tee, one suite on the machine:
  68 packages ok. The one red was internal/gui's
  TestCoreScriptBudget: app.js 1,335,314 > 1,335,000, since main grew
  app.js under the stack. The autoscroll commit's own comments were cut
  (to 1,334,629) rather than the budget raised, and go test -count=1
  ./internal/gui is ok at this head (113s). Packages the run took from
  Go's test cache had the same inputs.
- GUI: the 18 files this stack touches or names, both engines,
  202 of 204 pass (tree 068acf128, this push less the last commit). The
  two reds: gui-ja, red on main since c2636b7b5 and fixed by this push's
  last commit (gui-ja and i18n-keys 6 of 6 there), and usage-fold's
  chromium "several accounts" (#2163, red on main the same way).
- skill-gone passes, chromium and webkit, en and zh, 860 and 400px.
- internal/library, internal/cli and internal/tui ok, the Gone tests and
  TestLibrarySkillRm among them.
- The rebase onto main met c2636b7b5's Verification line in library.md;
  both sides' tests are kept in it.
  The whole GUI suite ran at 1c1fc7183 (this stack's first 12 commits on
  0ddcf28a1): 11713 of 11769 pass. Each of the 21 red files was then run
  alone at the stack and at origin/main 8278fd9b0. Eight are red the same
  way on main: plugin-card-update (#3079), quota-count-wrap and
  quota-name-translated (#2228), s3-sync (#2448), usage-agents-hide
  (#2276), usage-checkin (#3091), usage-fold's chromium "several
  accounts" (#2163), usage-ledger (#3104). The other 13 pass alone on both
  and were red only under that run's load (50 to 335): currency #3101,
  plugin-github #3218, provider-fetch-again #3292, rest-try-now #2564,
  routing-auto-reset #3293, routing-keys-fold #1612, routing-steady #1804,
  routing-wb-restricted #1905, sessions-folder-delete #2218,
  sessions-manage #3294, switch-only #3295, text-size #1866, usage-pack
  #3296.

Broken by hand, each red, then restored:
- prepare not returning GoneError
- apply not clearing Gone
- leftOutAt ignored
- every Stat error read as absent
- the git check not saying gone
- RemoveGoneSkills taking a skill that isn't marked

Not tried:
- the real taste-skills repo over the network
- the Windows box
- a skill CC Switch installed (Origin, adopt path), which still reports
  as a failure
- a GitHub check with a known commit, which keeps an existing gone
  mark but only marks gone after an update
2026-10-23 01:58:00 +08:00
yetone 93b87d0004 davsync: a GitHub backup too large for the Contents API goes up as a blob (Zhang-Wei, Discord)
Zhang-Wei (Discord, v0.1.1318, 102 skills) saw every sync fail with
"GitHub sync: HTTP 422: Sorry, the file is too large to be processed"
on magpie/magpie.magpie-backup; the last backup that went up was about
19 MB. The Contents API's PUT refuses files well under the 100 MB a blob
can hold.

A repository with commits is now written through the Git Data API:
the ref's head, the file's version at that head (it must still be the one
sync read, or errChanged), a base64 blob, a tree on the head's tree, a
commit with the head as its parent, and a ref update without force. Still
one commit per write or removal, and the version is the blob SHA as
before. A ref update that is not a fast-forward is built again on the new
head (the blob is kept), up to three times, then errChanged; if the new
head changed the backup it is errChanged at once, so another computer's
backup goes through the normal merge. A branch deleted meanwhile is an
error, not created. Usage files and their removal take the same path.

An empty repository has no head to build on, so its first write still
goes through the Contents API (one commit, unchanged). If that is refused
as too large (422 "too large" or 413), a short README.md in magpie's
folder makes the first commit and the backup follows as the second.

Reading was already right for large files: the object media type gives
encoding "none" over 1 MB and bytes() downloads by blob SHA; the new
test covers it at 21 MB.

The fixture now serves the Git Data API (blobs, commits, trees, a
fast-forward-only ref update) and refuses a Contents PUT over
contentsLimit with GitHub's 422 text. docs/subsystems/sync-backup.md says
how writes go and names the new tests.

Record for this push: 13 commits on origin/main ca4a1cde0, head tree
539c84e92. Go 1.26.8, sandbox HOME, GOMODCACHE/GOCACHE pinned. The full Go
run and vet were at tree d6393dfc8, the same Go code as this head: only
app.js comments (cut under the core script budget) and one ja string
changed after it.
- gofmt -l: nothing. go build ./...; go vet ./... (darwin), GOOS=linux
  go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -timeout 45m ./..., through tee, one suite on the machine:
  68 packages ok. The one red was internal/gui's
  TestCoreScriptBudget: app.js 1,335,314 > 1,335,000, since main grew
  app.js under the stack. The autoscroll commit's own comments were cut
  (to 1,334,629) rather than the budget raised, and go test -count=1
  ./internal/gui is ok at this head (113s). Packages the run took from
  Go's test cache had the same inputs.
- GUI: the 18 files this stack touches or names, both engines,
  202 of 204 pass (tree 068acf128, this push less the last commit). The
  two reds: gui-ja, red on main since c2636b7b5 and fixed by this push's
  last commit (gui-ja and i18n-keys 6 of 6 there), and usage-fold's
  chromium "several accounts" (#2163, red on main the same way).
- internal/davsync and internal/cli ok, the GitHub large-backup tests and
  TestGitHubCmd among them.
- s3-sync.test.cjs (WebKit en) is red alone on main too: #2448, the
  header over the form's tick. This commit doesn't touch the GUI.
  The whole GUI suite ran at 1c1fc7183 (this stack's first 12 commits on
  0ddcf28a1): 11713 of 11769 pass. Each of the 21 red files was then run
  alone at the stack and at origin/main 8278fd9b0. Eight are red the same
  way on main: plugin-card-update (#3079), quota-count-wrap and
  quota-name-translated (#2228), s3-sync (#2448), usage-agents-hide
  (#2276), usage-checkin (#3091), usage-fold's chromium "several
  accounts" (#2163), usage-ledger (#3104). The other 13 pass alone on both
  and were red only under that run's load (50 to 335): currency #3101,
  plugin-github #3218, provider-fetch-again #3292, rest-try-now #2564,
  routing-auto-reset #3293, routing-keys-fold #1612, routing-steady #1804,
  routing-wb-restricted #1905, sessions-folder-delete #2218,
  sessions-manage #3294, switch-only #3295, text-size #1866, usage-pack
  #3296.

Red on the old github.go (the new tests with the old code):
TestGitHubLargeBackup and TestGitHubEmptyRepositoryLargeBackup fail with
"HTTP 422: Sorry, the file is too large to be processed", TestGitHubRemote
too at its 1.26 MB put, and TestGitHubBranchMovedMeanwhile's three
subtests fail.

Broken by hand on the new code, each red:
- version check at the head skipped: TestGitHubRemote, LargeBackup's
  stale put, BranchMovedMeanwhile/the_backup
- no rebuild on a non-fast-forward: BranchMovedMeanwhile/another_file
  and /the_backup
- large read by base64 only: TestGitHubRemote, TestGitHubLargeBackup
- no README initialization: TestGitHubEmptyRepositoryLargeBackup (409)

Not tried against the real
GitHub API: the fixture follows GitHub's documented Git Data API, and
GitHub's exact Contents API size limit is not documented.
2026-10-23 01:58:00 +08:00
yetone efd4770015 agent: a reasoning effort picked in VS Code's Copilot Chat survives magpie's sync (chim3744 on Discord)
chim3744 (magpie 0.1.1318) picked "max" for a magpie model in Copilot
Chat's model picker, and requests went out at "low".

Cause: VS Code 1.142 keeps that pick inside the provider group, as
settings["<model id>"].reasoningEffort (languageModels.ts
setModelConfiguration). magpie's setGroup built its group with
vscodeGroupJSON, which has no settings key, compared the whole object
with sameJSON, and edit.SetJSONItem replaced the whole group. Every Sync
(catalog.Changed on start, a vendor list fetch, a provider edit) and
every magpie model pick in VS Code wiped the pick, and Copilot Chat fell
back to the model's first level ("low" of [low, high, max]).

Fix: vscodeGroupKept lays magpie's group over the one in the file with
mergeTheirs, as theirsKept does for the other agents (#2030). Every key
magpie doesn't write stays: settings, and anything else VS Code or the
user puts there, such as an apiKey reference. The models list stays
magpie's whole, so a model gone from the catalog still leaves it. The
settings of a model magpie no longer lists are kept, since they are the
user's values. When nothing magpie owns changed, the compare is a no-op
and the file is not written. This covers VS Code, VS Code Insiders and
VSCodium (customendpoint and customoai), every profile, since all go
through setGroup. agent-wiring.md lists what is kept.

Siblings checked:
- chatLanguageModels.json is written only by vscode.go. Cursor
  (cursorlocal.go) writes nothing of Cursor's. magpie writes no
  language-model groups for Windsurf, Trae or Kiro IDE.
- Every other syncJSON caller in internal/agent already merges through
  theirsKept, piBlockKept, openCodeKept, mothxBlockKept, qoderKept or
  t3Merged (2eee900dc, #2030's siblings). That covers Pi, Crush, Ante,
  Aside, MothX, StepCode, OpenCode, Qoder, Cline, Command Code, Pencil
  and T3 Code. The exception is Zed's available_models. That is
  magpie's model list, an array, and Zed keeps the model the user picked
  in agent.default_model, outside it.

Test: TestVSCodeKeepsThePickedEffort. It writes the group as VS Code
does after a pick (settings for a listed model and for one no longer
listed), then runs a Sync with nothing changed (the file must stay byte
for byte), a Sync after the catalog gained a model, a magpie model pick,
and a Sync after a model went (the list shrinks and both settings stay).
With the fix broken by hand (want = v, the old whole rewrite) it fails:
"vscode_test.go:550: a sync with nothing changed: the picked effort is
"", want max". With the fix restored it passes.

Record for this push: 13 commits on origin/main ca4a1cde0, head tree
539c84e92. Go 1.26.8, sandbox HOME, GOMODCACHE/GOCACHE pinned. The full Go
run and vet were at tree d6393dfc8, the same Go code as this head: only
app.js comments (cut under the core script budget) and one ja string
changed after it.
- gofmt -l: nothing. go build ./...; go vet ./... (darwin), GOOS=linux
  go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -timeout 45m ./..., through tee, one suite on the machine:
  68 packages ok. The one red was internal/gui's
  TestCoreScriptBudget: app.js 1,335,314 > 1,335,000, since main grew
  app.js under the stack. The autoscroll commit's own comments were cut
  (to 1,334,629) rather than the budget raised, and go test -count=1
  ./internal/gui is ok at this head (113s). Packages the run took from
  Go's test cache had the same inputs.
- GUI: the 18 files this stack touches or names, both engines,
  202 of 204 pass (tree 068acf128, this push less the last commit). The
  two reds: gui-ja, red on main since c2636b7b5 and fixed by this push's
  last commit (gui-ja and i18n-keys 6 of 6 there), and usage-fold's
  chromium "several accounts" (#2163, red on main the same way).
- internal/agent ok in that run, TestVSCodeKeepsThePickedEffort with it.
- No GUI file reaches this change; the GUI suite's reds below are none of
  its.
  The whole GUI suite ran at 1c1fc7183 (this stack's first 12 commits on
  0ddcf28a1): 11713 of 11769 pass. Each of the 21 red files was then run
  alone at the stack and at origin/main 8278fd9b0. Eight are red the same
  way on main: plugin-card-update (#3079), quota-count-wrap and
  quota-name-translated (#2228), s3-sync (#2448), usage-agents-hide
  (#2276), usage-checkin (#3091), usage-fold's chromium "several
  accounts" (#2163), usage-ledger (#3104). The other 13 pass alone on both
  and were red only under that run's load (50 to 335): currency #3101,
  plugin-github #3218, provider-fetch-again #3292, rest-try-now #2564,
  routing-auto-reset #3293, routing-keys-fold #1612, routing-steady #1804,
  routing-wb-restricted #1905, sessions-folder-delete #2218,
  sessions-manage #3294, switch-only #3295, text-size #1866, usage-pack
  #3296.

Not tried: real VS Code/Copilot Chat.
2026-10-23 01:58:00 +08:00
yetone ca4a1cde0d dsh: maxTokens leaves dsh half its window, or a quarter for output where that is more (#3298 item 3)
822f2b304 (#2823) held the maxTokens magpie lists for dsh to a quarter
of the window, because dsh reserves it, plus 65536 of headroom, before
it compacts (compaction-basic's resolveCompactSpec: threshold = min(0.8W,
W - maxTokens - 65536)). On a large window the quarter cut more than
compaction needs: DeepSeek's own deepseek-flash, 1000000/393216, was
listed at 250000, though all 393216 leaves dsh 541248 (54%).

Now the cap is max(W/4, W/2 - 65536): the output may take what leaves
dsh half the window to compact in, or a quarter of the window where that
is more (every window under 262144, where there is no half to spare
beside the headroom). A Max output the user set is still written as set
(outputOr), and contextWindow and /v1/models don't change.

dsh 0.2.0-rc.2's own resolveCompactSpec, run on the installed
compaction-basic over each figure (threshold tokens):

| window / output | vendor | quarter (main) | now |
| 524288 / 524288 | no message budget | 131072 -> 327680 | 196608 -> 262144 |
| 500000 / 393216 (#2823) | 41248 | 125000 -> 309464 | 184464 -> 250000 |
| 131072 / 65536 | no pressure budget | 32768 -> 32768 | 32768 -> 32768 |
| 1000000 / 393216 | 541248 | 250000 -> 684464 | 393216 -> 541248 |
| 400000 / 128000 | 206464 | 100000 -> 234464 | 128000 -> 206464 |
| 200000 / 393216 | no message budget | 50000 -> 84464 | 50000 -> 84464 |
| 128000 / 393216 | no message budget | 32000 -> 30464 | 32000 -> 30464 |

#2823's case stays fixed: 250000 is half its 500000 window (its
reporter's own plan A), against 41248 before 822f2b304; it is lower than
the quarter's 309464, which is the trade. The 128K and 200K windows
#3298 names don't change: any output above the quarter there takes it
straight out of what dsh compacts at, and a user who wants more sets Max
output.

Tests: TestDshOutputLeavesCompactionRoom's table takes the new figures
and adds DeepSeek's 1000000/393216 (393216), 200000 and 128000 windows;
its check now holds dsh's threshold at half the window where the window
has one, never under what a quarter leaves. TestDshModelLimits'
400000/128000 is now 128000; TestMaxTokensWithinContextWindow's dsh
figure follows the formula (its windows are all under 262144). Broken by
hand: the quarter alone (main) is red on 4 cases ("maxTokens 250000;
want ... 393216"), W/2 - 65536 alone on 3 (131072 gets 1), no cap
(pre-#2823) on #2823's own cases (524288/524288, 524288/1048576,
500000/393216, 131072/65536) and the 200K and 128K windows. docs/subsystems/agent-wiring.md says the new rule.

Run at 5adad1877 (this commit on top of item 4's): gofmt -l (nothing),
go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./... (all clean), go build for darwin, linux (nogui) and windows (ok),
and go test -tags nogui -timeout 45m ./...: all 69 packages ok, exit 0
(gateway 505s, agent 401s, provider 197s).

Not tried: a real DSH session against a 1M DeepSeek model through
magpie; the thresholds above come from dsh's resolveCompactSpec run
directly. Windows under ~87K (64000/384000 -> 16000) still leave dsh no
pressure budget, on main too; that needs a policy of its own and isn't
changed here.
2026-10-23 01:20:37 +08:00
yetone c2636b7b5b library: an MCP command given to agents in WSL is checked in their distro
loong on Discord, Windows host with agents in WSL: a stdio server whose
command is a WSL program (`node /home/loong/tools/xxx.js`), given only to
WSL agents, showed "exited (1) … Node.js v24.9.0" on the Library's MCP
page. The check started it on Windows, where his agents never do; a
sibling written as `wsl -d Ubuntu … node …` checked fine.

What changed:
- checkSides (mcp_check_wsl.go) reads each agent id's `@wsl:<distro>`.
  No WSL agent, not Windows, a Windows path for the command
  (windowsPath: magpie's own image server, `C:/x/npx.cmd`) or Settings'
  Detect agents in WSL off: this computer, as before. Otherwise each
  distro is a side, after this computer when an agent here has it too.
- In a distro the command is found as the agents' shell finds it
  (new wslrun.In: the same login-then-interactive probe Find uses, so
  nvm's node is found; cached for findAge) and started through
  wslrun.Tool.Command, the existing `wsl.exe -d D --exec /usr/bin/env
  PATH=… MAGPIE_WSL_RUN=… <path> args` path, so no new quoting. Its
  env goes over WSLENV (Tool.Env); its Cancel stops the run inside the
  distro.
- A distro that isn't running is never started for a check: Why
  "wsldown", naming it, painted as not checked (ring), like novar.
  Beside a side that was checked it is left out.
- Mixed: each side in turn, the first failure ends it. ServerHealth
  gains Checked (where it started, "" for this computer); the row says
  " · WSL Ubuntu" / " · Windows" on a failure, the tooltip "Failed in" /
  "Checked in". New strings in zh, zh-TW, ja, de.
- healthKey (Go and client.js) includes the sides, so agents moving into
  WSL is a check anew.
- docs/subsystems/library.md says all this.

Tests:
- TestCheckWSLOnlyServerInItsDistro: ok in Ubuntu with the exact wsl.exe
  argv; a stopped Arch is wsldown with no probe and no run; a command
  the distro lacks is notfound there.
- TestCheckWindowsServerHere: a Windows-only server checked here, WSL
  never asked; Windows-path commands stay here.
- TestCheckMixedServerEachSide: ok in both; WSL exit named Ubuntu's;
  Windows failure stops before WSL; stopped distro = checked here only;
  healthKey differs when agents move into WSL.
  All force wslrun.On and fake wsl.exe (Run) and the distro run
  (wslCommand runs this test binary as the fake server).
- library-mcp-health-wsl.test.cjs: chromium + webkit, en/zh/zh-TW/ja/de.

Broken by hand, each red:
- checkSides always this computer: WSLOnly and Mixed red.
- windowsPath exemption removed: WindowsServerHere red.
- mixed drops this computer: Mixed red.
- healthKey without sides: Mixed red.
- stopped distro reported as a failure: WSLOnly and Mixed red.
- client.js without the " · <place>" on a failure: the GUI test 12 of 12 red.

Run:
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok.
- GUI: the 94 library-*/mcp-*/i18n-* files, both engines: 780 of 783;
  library-loading (webkit) and library-pick-remove (chromium zh-TW) red at
  --test-concurrency=4, load ~45, pass alone 3 of 3; filed #3300, #3299.
- Full suite at 3831de1a3 (base 1d1c5cf9c), go test -tags nogui -timeout 45m ./..., alone on the machine: every package ok, no FAIL (library 334s, gateway 515s, agent 394s).

Not tried:
- A real Windows + WSL run: the Windows box (10.0.0.132) didn't answer
  ssh. The argv is magpie's existing WSL launch path, unchanged.
- In a distro the command's cwd is what wsl.exe gives it (the Windows
  home under /mnt/c), not the Linux home an agent starts in.
- A Windows program reached from WSL by interop (npx.cmd under /mnt/c)
  given to WSL agents is skipped by the probe and can show notfound.
- A command the probe can't take as a plain name (spaces, quotes): an
  absolute path runs with the default PATH, anything else is notfound.
- A stopped distro beside an ok Windows side isn't shown on the row.
2026-10-23 01:00:44 +08:00
yetoneandskygunner 8278fd9b0c gateway: Volcengine Ark's monthly 429 rests the key until the reset it writes (+0800 CST), not 15 minutes (#3251 CNife, #3276 wyx1818)
Ark's 429 for a used-up month says "You have exceeded the monthly usage
quota. It will reset at 2026-10-25 23:59:59 +0800 CST." with no
Retry-After. resetsWhen read an offset only after UTC or GMT, so nothing
read it, the key rested quotaRest and was asked again every 15 minutes
until the month turned. Two more limits stood behind that one: a written
reset over 7 days off (longestWritten) isn't read, and a quota rest is
held to 8 days (longestQuota), so wyx1818's reset 9 days off would still
have fallen to the 15-minute loop.

- resetsWhen also reads the time as Go prints one (Ark's): four offset
  digits, a space and the zone's name in capitals, then punctuation or
  重置. The offset is read, the name isn't (CST is more than one zone).
  The UTC/GMT form is unchanged; a bare offset with no zone's name, or
  "+08:00" without UTC, isn't read, as Ark doesn't send them.
- monthlyWords (monthly, 月度, 每月, 本月): a refusal that says its
  allowance is a month's has its written reset believed up to
  longestMonthly (35 days) instead of the week (longestSaid). That covers
  Zhipu's 1310 "Weekly/Monthly Limit Exhausted" too (resetsZhipu), the
  sibling held to the same week.
- In failQuota the 8-day cap is lifted to 35 days only when the rest
  came from the vendor's own reset ("resets") and the refusal is a
  month's. A window read full, a Retry-After and the user's own quota
  rest are held to 8 days as before.

Ported from skygunner's branch skygunner:fix/volcengine-resets (e6c2b6fb,
posted on both issues). Taken: the monthly trust window, longestMonthly,
monthlyWords, the reporters' bodies as fixtures and the shape of
TestMonthlyWrittenResetRestsTheMonth. Changed:
- its regex made UTC|GMT optional and took any 2 to 5 letters,
  case-insensitively, after any offset, for every vendor, so "reset at
  <date> +8 now." would read. Scoped here to Go's layout, the zone's
  name matched case-sensitively.
- it lifted the cap to 35 days whenever the body said monthly, whatever
  the rest came from (a window read full, the user's own rest); here
  only for the vendor's written reset.
- its resetsZhipu kept the week; here it shares longestSaid.
vincenty on Discord: no link to another fix is on either issue
(skygunner's commit is authored as "vincent").

Not changed: Ark's plan windows read by its AccessKey (volcPlanQuotas)
still reach only the usage card, not routing (layer 2 of #3251: the
quota is the account's, not one inference key's, and a provider has one
plan, #2849). #3251 stays open for it.

Tests (fixtures: #3251's and #3276's bodies byte for byte, #3276's as
its pretty-printed JSON):
- TestResetsWritten: ark (3 days), ark 9 days off, ark escaped, 35 days
  read and 36 not, past, cut after the offset / in the offset / before
  the full stop, without the zone, +9900, Ark's form without "monthly"
  9 days off (0: the week holds), WorkBuddy's en 9 days off (0: another
  vendor unchanged), "retry after … +0800 CST." (0). Every existing
  WorkBuddy and UTC/GMT case passes unchanged.
- TestResetsZhipu: 1310 9 days off read, 36 days not; 1308 over a week
  off still 0.
- TestMonthlyWrittenResetRestsTheMonth (new): Ark's 429 3d7h and 9d12h
  off reads failQuota and rests by "resets" till then, raw and as the
  agent's error with keepRetry's note; the same body without "monthly"
  rests quotaRest; a month's refusal with no time on an account whose
  window reads full 20 days off rests 8 days by "window".

Broken by hand, in the worktree:
- old routing.go with the new tests: TestResetsWritten (ark: 0s, want
  79h7m59s; 9 days, escaped, 35 days), TestMonthlyWrittenResetRestsTheMonth
  (79h0m0s off: rests 14m59.99s by quota) and TestResetsZhipu (1310, 9
  days off: 0s) red.
- cap not lifted: 228h0m0s off rests 191h59m59s by resets, red.
- longestSaid always the week: ark 9 days / 35 days and Zhipu 1310 red.
- zone's name made optional: "ark without the zone" reads 79h7m59s, red.
- skygunner's cap (any monthly body): window 20 days off rests 479h59m,
  want 192h, red.
Each restored, green.

Run at 268c1d34c (this change on origin/main 95be6bb75, unchanged at
push): gofmt -l prints nothing; go vet ./..., GOOS=linux go vet -tags
nogui ./..., GOOS=windows go vet ./... clean; go build, GOOS=linux go
build -tags nogui, GOOS=windows go build pass. set -o pipefail; go test
-tags nogui -timeout 45m ./... (no other suite on the machine): 69 ok,
no FAIL in the log (internal/gateway ok 571s).

Not tried: a real Ark key (none here), so not against the live API; the
bodies are the reporters' curl output. Not run: the GUI suite (no GUI
change).

Co-authored-by: skygunner <84759+skygunner@users.noreply.github.com>
2026-10-22 23:47:12 +08:00
yetoneand卡提希娅可爱捏 efb7cb11d4 gateway: a safety refusal said in a stream is a refusal for a client answered whole too, and rests nobody (#3274, CartethyiaQwQ)
CartethyiaQwQ (#3274): Codex's "safety filter: cyber_policy" refusal
(the Daybreak note) set healthy accounts aside; two such turns benched a
five-account pool for about 17 minutes.

Cause: the HTTP 400 cyber_policy is already a refusal (policyRefusal reads
its code: next account asked, nobody rests), and so is one said in a
stream relayed as a stream. A Codex account is always streamed upstream,
so a stream:false Responses, Chat or Messages request is answered from
that stream whole. There, a response.failed or error event whose error
has a code (cyber_policy) but no invalid_request_error type got no status
from the decoder, and the whole path answered it 502 api_error: retried
on the same account, then every account asked, each one but the last
resting by backoff. A refusal after a few words went to the client as a
finished 200 turn, and the failure after it rested the account.

Fix, at the decoders and the whole path:
- filterRefused (fallback.go): a stream error event refusedCode reads as
  the safety filter's gets status 400 and Said {"error":{type
  invalid_request_error, code}}. Used by every decoder that set
  Code: refusedCode -- Responses (both error sites, after requestRefused),
  Chat, Anthropic and carriedError.
- The whole path (gateway.go) answers a reply the filter cut part way as
  the refusal, not its words so far, and notes it in refusedHeader, since
  Anthropic's error shape drops the code that settle reads.
- restAfterMarked: a 400 whose error object policyRefusal reads as a
  refusal rests nobody and counts no failure (By "off", Why refused), as
  the ZDR refusal does, for any route that reaches it.
- docs/subsystems/gateway-routing.md says so.

Review of the submitted patch (dc6c695db, not taken as is): it matched
`safety filter|cyber_policy|Daybreak access` anywhere in a 400's words,
so a 400 that echoes the user's prompt in its message skipped the rest
too; its fixture was magpie's own refusedError text, which restAfter is
never handed for a 400; and it gated on status 400, while the path that
rested (above) answered 502, so it would not have stopped the rests.
Its restAfter unit tests' shape is kept in TestRestAfterPolicyRefusal.

Run at 21f7f9df2 (origin/main then) plus this change, unless said:
- New TestStreamRefusalAnsweredWholeRestsNobody: {response.failed, error
  event, refusal after text} x {Responses, Chat, Messages answered whole}
  x {next answers, nobody left}; fixture is the reporter's quoted message
  without magpie's 300-char cut. Asserts the client gets 200 from the
  next account or a 400 naming cyber_policy, every try failRefused with
  no Rest, nothing resting.
- New TestRestAfterPolicyRefusal: cyber_policy 400 rests nobody and
  counts 0 failures; a plain 400, and two 400s echoing the reporter's
  words in the message (code string_above_max_length / code null) still
  rest by backoff.
- Red on the old code: all 18 TestStreamRefusalAnsweredWholeRestsNobody
  subtests and TestRestAfterPolicyRefusal/cyber_policy. Broken by hand,
  each went red: filterRefused returning no status (all 18); the
  part-way clause dropped (6 "after some text"); refusedHeader not set
  (6 Messages subtests).
- A scratch matrix before the fix (also streamed Responses/Chat/Messages
  and Codex's own path, HTTP 400 and response.failed): only the whole
  routes rested; the streamed ones and the HTTP 400 already passed.
- gofmt -l clean; go vet ./... (darwin), GOOS=linux and GOOS=windows
  go vet -tags nogui ./... clean.
- go test -race -timeout 45m ./internal/gateway/: FAIL on two tests
  this change doesn't reach, each ok alone with -race -count=3 and
  filed: TestPluginStreamLongActiveReader (client deadline after 36MB,
  #3286) and TestQuietKeptAliveOnlySoLong (0 keepalives in a 3s pause,
  #3287). Load was 180-280 from other sessions' GUI runs.
- Rebased on ba1dc7f97: gofmt, go vet ./internal/gateway/ and the two
  new tests again: ok.
- go test -timeout 45m ./... at ba1dc7f97 plus this change: ok, 69
  packages, no FAIL (internal/gateway 783s).

Not tried: a real Codex account. Whether the ChatGPT backend sends
cyber_policy as an HTTP 400 or inside a 200 stream, and with or without
an error type, isn't known from the issue; every shape is covered by
tests, not by a live refusal.

Co-authored-by: 卡提希娅可爱捏 <134358478+CartethyiaQwQ@users.noreply.github.com>
2026-10-22 22:53:47 +08:00
yetoneandLoKi 21f7f9df23 checkin: the Qoder plugins' check-in is asked again within the day, as the built-in's was (#2696)
The native Qoder and Qoder CN plugin check-in (pluginCheckinProvider) built
its checkiner without recheck, while the built-in qoderCheckiner set it.
So an inactive or done result was kept for the whole Beijing day, and a
press of "Check in now" was answered from that record too. Qoder CN's
campaign runs 10:00 to 09:59 the next day (mufanmu), so an early read
describes yesterday's campaign and said nothing about today's.

What changed:
- provider: pluginRechecks(id) is true for "qoder" and "qoder-cn" only,
  and sets recheck on their checkiner. A press asks at once. The loop asks
  again after wbCheckinEvery (30m) for inactive and done. Every other
  plugin stays settled for the day.
- GUI (checkinRow): a Qoder account (built-in or plugin) whose check-in
  found no campaign today keeps "Check in now". A press reports "Check-in
  status refreshed" instead of "Checked in", since it may still find
  none. The unused "Checked in" key is replaced in all four languages.
- docs/subsystems/provider-plugins.md names the exception and the tests.

Taken from LoKi's (lokic7123-star) patch on the issue: the recheck on the
Qoder plugin ids, the Check in now button for an inactive Qoder card, and
the neutral press status. Their GUI test was adapted into
qoder-checkin-recheck.test.cjs.
Left out, as the earlier review asked: the blanket 30-minute message, the
UTC timestamps and the client-computed next check. Also left out: the
"Already checked in today" wording and the "· credit" display. That is
not this bug, and the TUI and CLI would need the same change.

Run:
- Red on the old code:
  - All 8 subtests of TestPluginCheckinQoderRechecksCampaigns
    ({qoder,qoder-cn} x {inactive,done} x {loop,press}) fail without
    the fix.
  - Forcing recheck on for every plugin turns
    TestPluginCheckinOthersSettledForTheDay red.
  - qoder-checkin-recheck.test.cjs is red on the origin/main assets (no
    .ci-now on the card).
- At 91bb01e65 (base 9572a3576):
  - Full suite: set -o pipefail; go test -timeout 45m ./... |
    tee. EXIT=0, 68 packages ok, run alone on the machine.
  - qoder-checkin-recheck.test.cjs passes 20/20: chromium and webkit,
    en/zh/zh-TW/ja/de, 900 and 440px.
  - 76 GUI files reachable from the change were run: check-in files,
    gui-*, i18n-keys and tray-usages. Reds:
    - login-import, chromium en/zh: red on main too (#1307).
    - quota-reads webkit de 360: red on main too (#2150, commented
      with its c.toFixed page error).
    - usage-checkin webkit en/zh, Qoder tab: red on main too (#2549).
    - update-wait chromium en and usage-alert webkit en: red only
      under load, pass alone (#3275).
- At this tree, rebased on 87d703c5c (b91bcf260, library only, came
  after). The 8 new main commits since
  9572a3576 bring app.js, i18n.js and provider plugin changes; none of
  them touches check-in code.
  - gofmt -l: clean.
  - go vet ./...: clean on darwin, linux (-tags nogui) and windows.
  - go test ./internal/provider/ ./internal/gui/ ./internal/plugin/
    ./internal/cli/: all ok. internal/gui includes TestCoreScriptBudget.
  - GUI, both engines: qoder-checkin-recheck, i18n-keys,
    plugin-checkin, checkin-account, account-models and
    plugin-keyless-signin pass 119/119.

Not tried:
- No real Qoder or Qoder CN account, and no campaign that opens
  mid-day.
- The full GUI suite: another session's full GUI run held the machine,
  so 76 files were run instead.
- Linux and Windows at runtime.

Reported by mufanmu and LoKi; patch by LoKi.

Co-authored-by: LoKi <317300729+lokic7123-star@users.noreply.github.com>
2026-10-22 21:18:13 +08:00
LoKi 5871f02dd6 plugins, provider, gui: a keyless plugin sign-in needs no key, and a single-identity plugin has one account (#2695, LoKi)
LoKi's patch (lokic7123-star), picked onto origin/main ef6f3749d. A plugin's api
method that has an authorize step and no prompts is reported as keyless:
PluginAPIKey accepts an empty key for that method only, the CLI and the
GUI skip the key field, and a plugin marked auth.single signs in again
on its first account instead of adding another one. Zen Free needs
magpie-community/plugins#205 (keyless and single on zen-free), merged and
published, before its users see this.

Added in review (yetone): TestPluginEmptyKeyOnlyKeyless, which checks that
an empty key is refused for a non-keyless api method, an oauth method
marked keyless, an out-of-range method and an unknown plugin.

Run at the stacked tree (this commit plus #2554 and #2862, on ef6f3749d):
- gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui, and
  GOOS=windows: ok.
- set -o pipefail; go test -count=1 -timeout 45m ./... under the suite
  lock: every package ok (SUITE_EXIT 0).
- GUI: plugin-keyless-signin, account-models, i18n-keys and
  models-select-all-api, chromium and webkit, every language they cover:
  all pass.
Red on the old code: TestPluginKeylessSingleIdentity "keyless metadata lost"; the
GUI test 10/10 red; without signInKey's single line, "single identity
duplicated"; TestPluginEmptyKeyOnlyKeyless red with the Keyless check
replaced by false.
Not tried: a real Zen Free sign-in (needs plugins#205 published).
2026-10-22 20:50:59 +08:00
yetoneandggbdpq 240f3eb4c5 gateway: a name a fake-IP resolver answers is fetched through its TUN or a local proxy (#2593)
With Clash's TUN fake-ip (Clash Verge Rev on Windows, TomXPRIME), Surge's
enhanced mode (h4rk8s) or Loon on, the system resolver answers every name
in 198.18.0.0/15, which the download guard (image_fetch_guard.go) listed
as special. So web_fetch, a caller's image (fetchPicture), a vendor's
image or video by URL and generate_image's download (imagemcp) refused
every URL as "a private address". All of them go through publicTransport;
nothing else uses it.

What changed:
- The address rule moved into internal/netguard (Public, FakeIP,
  LoonPaired), shared by the gateway's guard and a provider's icon
  (icon.go's publicIP is now netguard.Public or FakeIP, as #252 meant).
  The icon guard gets the gateway's stricter list with it (Teredo, 240/4,
  NAT64 and 6to4 forms of a private address are refused there too).
- publicTransport: a name (never an address literal) whose every answer
  is in 198.18.0.0/15 is fetched. With no proxy (pure TUN) the fake
  address is pinned and dialled, and the dial guard lets that one address
  in, no other. Through a proxy on this computer (loopback or localhost)
  the proxy is given the name, never the fake address: h4rk8s showed a
  real Surge CONNECT by name works and by the 198.18 address doesn't. A
  plain http:// request's Host to that proxy is the checked name, never
  the caller's own Host. Through a proxy elsewhere it is refused.
- An answer with any other address beside the fake ones (private or
  public) is judged as before, so fake + 192.168.x is refused; loopback,
  RFC 1918, link-local with 169.254.169.254, CGNAT, unspecified,
  multicast and documentation stay refused; every non-fake answer is
  still pinned; redirects are re-checked as before.
- Loon's synthesized AAAA (fd27:712::/96 holding an A answer of the same
  reply) is left out and the A answer judged in its place, as icon.go
  already did, so a Loon answer isn't refused as fc00::/7.
- docs/subsystems/gateway-routing.md says all of this, and the trust it
  asks for: where a fake-IP name really goes is decided by the fake-IP
  resolver, which magpie can't see, so a name pointing at the user's
  network is reached if that resolver's rules send it there. The icon
  path already accepted this (#252).

Credit: ggbdpq found the cause and wrote both patches on the issue
(hunt/2593-webfetch-fakeip, then hunt51-a-fakeip-proxy: the fake-only,
loopback-proxy, name-not-literal predicate and its test shapes, which
this follows); h4rk8s's real Surge comparison showed the pin had to go
for a proxy; TomXPRIME's Windows report showed pure TUN needs the direct
dial.

Run (darwin/arm64, worktree rebased on origin/main 226551d0d):
- New tests in internal/gateway/fakeip_test.go, with a fake resolver, a
  local proxy recording what it is asked and a local server standing in
  for the TUN (dialPinned seam); nothing reaches the network:
  TestFakeIPNameGoesToALocalProxyByName (web_fetch reads the page; proxy
  asked "http://example.com:80/", CONNECT example.com:443, a foreign Host
  ignored, Loon pair, redirect to a mixed answer refused),
  TestFakeIPNameDialledThroughTheTUN (198.18.0.7:80 dialled, guard
  refuses 198.18.0.8, 198.19.1.1, 127.0.0.1, 192.168.1.10),
  TestFakeIPRefusesTheRest (13 URLs refused with no proxy, a 127.0.0.1
  proxy and a localhost proxy; a proxy elsewhere refused; neither proxy
  nor TUN asked). internal/netguard: TestPublic, TestFakeIP,
  TestLoonPaired.
- Red on the old behaviour: fakeAnswer forced false (what main does)
  fails ByName and DialledThroughTheTUN with the private-address refusal.
  Mutations, each red: no byName (proxy asked 198.18), literals allowed,
  any-fake answer counted, proxy elsewhere allowed, dial guard letting any
  address in, the caller's Host to an http proxy, Loon not dropped.
- Existing guard tests (TestPublicAddr, TestEditImage*, TestWebFetch*,
  TestPrivateDialer*, TestFetchPrivate*) and provider's icon tests pass.
- gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows -tags nogui.
- Full suite at 30611fe68 (this change on 226551d0d): set -o pipefail;
  go test -timeout 45m ./... exit 0, 69 packages ok, no FAIL (14 min).

Not tried: a real Clash, Clash Verge, Surge or Loon (none on this
machine); the proxy and the TUN are local stand-ins, so whether a real
fake-IP core routes the name as h4rk8s saw is their evidence, not this
run's. A SOCKS proxy on loopback is not covered by a test (Go sends the
name in the SOCKS request the same way). Kept open for the reporters.

Co-authored-by: ggbdpq <67929842+ggbdpq@users.noreply.github.com>
2026-10-22 19:53:16 +08:00
yetone 226551d0d8 gateway: MiniMax M3.1-Flash is sent its effort in output_config (shin4 on plugins#316)
An OpenAI client's reasoning effort (Responses' reasoning.effort, Chat's
reasoning_effort) for MiniMax Code's MiniMax-M3.1-Flash or -Preview, built
into an Anthropic body for the minimax plugin, went as a thinking budget
alone. Under the reporter's 8192 cap medium, high, xhigh and max were all
budget_tokens 7168, so the level was lost before the plugin saw it.

The two models join GLM-5.2/5.3 in effortInOutputConfig: buildAnthropic
sends output_config.effort next to the budget, and an Anthropic client's
budget gets its nearest level there too (withOutputEffort, passthrough).
MiniMax Code's catalog marks M3.1-Flash forced_on at low..max. The budget
stays as it was (the owner's plan on plugins#317); dropping thinking for
the managed-login route, as MiniMax Code 3.1.4 does, stays the plugin's
call. Nothing goes into prompt text. Claude, MiniMax-M3 and other vendors'
models keep the budget alone. MiniMax's public Anthropic API doesn't list
M3.1-Flash (platform.minimax.io text-anthropic-api), so the rule reaches
MiniMax Code's subscription and any relay serving those two models.

Tests (internal/gateway/minimax_effort_test.go, fake plugin $FAKE_MINIMAX):
- TestMiniMaxPluginGetsTheNativeEffort: the reporter's Responses request
  and its Chat form, low..max, both models, on minimax-code and
  minimax-code-global through the plugin host (bun), plus an Anthropic
  client's budget 10000 -> medium; MiniMax-M3 keeps no output_config.
- TestNativeEffortLeavesOthersAlone: claude-sonnet-4-5, kimi-k3 and
  MiniMax-M3 on an Anthropic relay get budget 7168 and no output_config.

Run at e31e3699a + this change, sandbox HOME, pinned caches:
- with the regex change reverted, TestMiniMaxPluginGetsTheNativeEffort
  fails with the reporter's table ("/v1/responses MiniMax-M3.1-Flash
  medium: output_config <nil>, thinking map[budget_tokens:7168
  type:enabled]"); restored, passes.
- the regex widened by hand to minimax|claude|kimi: TestNativeEffort-
  LeavesOthersAlone fails for all three models; restored, passes.
- go test ./internal/gateway -run 'Effort|Adaptive|Think|GLM|MiniMax|
  Budget|Reasoning|Level': ok. go test ./internal/plugin/...: ok.
- gofmt -l: clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.

Not run before this push: the full suite (the machine is at load ~210
with several sessions queued for it; it runs after, in turn). Not tried:
a real MiniMax Code account. Whether MiniMax's subscription endpoint
honours output_config.effort beside a budget (rather than with thinking
left out, as shin4's live run sent it) is not verified.
2026-10-22 19:36:50 +08:00
yetone ccbc727818 agent, gateway: a Claude model magpie can only ask translated no longer keeps auto mode's server review on (nexnull on Discord)
nexnull (Claude Code 2.1.308, magpie v0.1.1318, DeepSeek 4.1 flash) saw
Claude Code's notice that auto mode's classifier "isn't eligible because
your requests go through 127.0.0.1:3425". The wiring leaves
CLAUDE_CODE_AUTO_MODE_SERVER unset while any model Claude Code can reach
through magpie is reviewed (claudeReviewed), and it judged that by
AutoModeReviewed, which counts a Claude model by its name. A relay that
lists claude-* beside DeepSeek with only a Chat (or Responses) URL, or a
Claude model the user pinned to chat, is asked translated: a probe showed
such a request goes to /v1/chat/completions with no safeguards and no
safeguard_results. So the review stayed on and the notice showed.

AutoModeReviewable (gateway/automode.go) is AutoModeReviewed on a route
that reaches the Messages API: the Claude subscription, or a provider
with an Anthropic URL whose APIs for the model (a user pin first) include
Anthropic. claudeReviewed asks it for the provider and each fallback, so
Claude Code and T3 Code get CLAUDE_CODE_AUTO_MODE_SERVER=0 there. It is
still magpie's own stashed value (claude.auto_mode_server): a user's own
value is left alone, and disconnect or restore takes magpie's off.
serverReview, already on the Messages route, keeps AutoModeReviewed.

Chosen on purpose: any reachable model that is really reviewed keeps the
review on. Writing 0 by mistake would lose server review on Claude
silently, while leaving it on by mistake costs the notice, which Enter
dismisses for 24h. A relay with an Anthropic URL (OpenRouter, AiHubMix)
still counts as reviewable, since some pass the field through. No
client mimicry and no prompt or identity text changes.

Pass-through on Anthropic routes (asked in the same task): no defect.
Probes against a fake upstream showed the anthropic-beta (with
dangerous-tool-use-2026-09-03) and anthropic-version forwarded, the
safeguards body byte-identical, a stream:false reply relayed byte for
byte with safeguard_results and an unknown key intact, and the SSE relay
keeping an unknown key, an unknown event type and toolu ids. The probe
file was removed and is not committed.

Full run at 983425662, the same change one commit back:
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- set -o pipefail; go test -timeout 45m ./...: EXIT 0, 68 packages ok,
  no FAIL (internal/agent 386s, internal/gateway 507s), run alone after
  another session's suite ended.
- TestAutoModeReviewableAsksOnMessages and
  TestClaudeReviewedOnlyWhereMessagesReachClaude are red on the old code
  ("cr/claude-sonnet-5: true, want false"; "a relay without an Anthropic
  endpoint: \"\", want 0").

Rebased then onto 61b92529e (#2932 sessions, #2942 budget; none of
this change's files): go vet ./internal/... ok, and go test for
internal/agent, internal/gateway, internal/budget and internal/sessions
ok at the pushed head.

Broken by hand: dropping the Anthropic-URL check made the gateway test
red; ignoring the user's pin (apis != nil || true) made the agent test
red ("Claude set to be asked on chat: \"\", want 0"). Restored after
each break.

Not tried: real Claude Code 2.1.308 against a sandbox gateway with a
real DeepSeek key, so the notice going away in a live auto-mode session
is not seen. No GUI files are touched, so the GUI suite was not run.
2026-10-22 18:19:00 +08:00
yetone 0ddcf28a1d redact: a backend's id (a UUID, 32+ hex digits) goes as written, never a piece of it
The owner found UUIDs masked, and a backend looks an id up by every
character: a masked one, or half of one, finds nothing or the wrong row.
A probe with every kind on and the model labelling each value found five
ways a UUID went masked:

- a piece of one: PHONE took 13800138000 at the end of
  …-a13800138000, BANK_CARD took 4111-1111-1111-9007 across a UUID's
  groups, and the id went half a placeholder;
- the SECRET rule in a field named for an id, a cursor or a request:
  secret_id, token_id, api_key_id, access_key_id, next_page_token,
  nextPageToken, csrf_token, trace_token, secret_hash;
- the bare "key" rule ("key": "<uuid>", Idempotency-Key);
- the serial rule (sn:, Serial Number:);
- the model labelling a UUID a name, an account and so on (only
  "secret" was held back before), and a phone number masked earlier
  being found again inside a UUID.

noIDs (internal/redact/ids.go) drops, after every finder, a span that is
a piece of an id, and a whole id unless the user's own words or rules
found it, a PASSWORD/API_KEY/TOKEN/PRIVATE_KEY rule did, the SECRET rule
did in a field named for a credential (password=, api_key=, X-Api-Key,
refresh_token, session_token, token), or it was masked before in full.
32 hex digits without hyphens the model calls a secret in prose ("the api
key is 9f8e…") stay masked; a UUID it calls one does not, as before.

Run in ~/workspace/projects/magpie-wt/mask-act at this tree:
- TestIDsGoAsWritten: 7 id shapes × 22 contexts kept, 7 credential
  contexts masked, the model's every label kept, a known phone not found
  inside an id, a phone and a card number of their own masked, the user's
  word masked. With noIDs taken out of mask(): 108 failures; restored: ok.
- The first full redact run caught two of my own mistakes, now fixed:
  idAround didn't check the run's inside, so a 33-character IPv6 address
  counted as an id (TestMoreKinds), and the model's 32-hex API key went
  unmasked (TestModelSecretIsNoID).
- go test ./internal/redact ./internal/maskrec ./internal/gwmw
  ./internal/settings ./internal/gateway (-timeout 45m, -count=1): all ok (gateway 439s)
- gofmt -l: none; go vet ./internal/redact for darwin, linux, windows: ok.

Not tried: a real request through a running gateway with the local model
on; the model's labels are simulated with fakeModel.
2026-10-22 15:42:54 +08:00
yetone c036d6c34a gui: what the window shows can be selected and copied, its controls can't
Outvi V on Discord: the page is user-select: none as a whole, so nothing
could be selected or copied into a bug report, only the few places that
opted in. Two rules at no specificity after body in app.css now make
content selectable: paragraphs, pre and code, a detail's values (dd,
td), hints, notes, every error class (.err, .error, *-err, *-error), a
conversation (.sess-talk, a subagent's too), a request's story and log
on Routing (.rt-log, .rt-steps, .rt-time). Controls stay unselectable
with what is in them, as in a Mac app: buttons, labels, summary,
select, the navigation, menus (.pop), tabs, switches, segments, grips,
draggable rows. With no specificity, a view's own rule still decides
(a list being sorted, a blurred value), and a field stays a field.
An account's or a key's name was selectable by accident through its
row (a button inside .accts > [data-account-id]); .acc .rename now says
so itself, and account-arrange keeps checking it.

user-select.test.cjs: on Routing, a mouse drag across a vendor's error
in a request's story selects it; a drag across a request's row selects
nothing, and the row still opens on a click with text selected
elsewhere; no nav, button, tab, segment or option is selectable, and no
field is unselectable. Both engines, en/zh/ja/de, 1100 and 420 wide:
16/16, twice. Red on HEAD's app.css (16/16 fail: 'none' !== 'text').
Ran: click-scroll 22/22, agent-grip 10/10, provider-order 6/6,
search-order 16/16, account-arrange 2/2 (red in chromium before the
.acc .rename line), account-alias 20/20, panel-arrange 8/8,
sessions-talk 4/4, sessions-subagents 40/40, usage-ledger-detail 6/6.

Not tried: the app's own webviews (WKWebView, WebView2, WebKitGTK); only Playwright's Chromium and WebKit.

Run for this batch of seven commits (devin, routing zh, qoder, masked words
any case, Long conversations, Claude subagents, user-select), in a worktree,
sandbox HOME, never against live configs:
- At e352cc823 (tree ea497c9f5, on origin/main 7dd965ed2): go test
  -timeout 45m ./... with pipefail, tee'd: 68 packages ok, exit 0, no
  ENOSPC. gofmt -l clean; go vet ./... for darwin, GOOS=linux -tags nogui
  and GOOS=windows: clean.
- The whole GUI suite at e352cc823 (node --test --test-concurrency=3
  internal/gui/tests/*.test.cjs, Chromium and WebKit, every language):
  11725 tests, 11679 pass, 46 fail, none ENOSPC. Each red file run alone at
  both 7dd965ed2 and e352cc823 gives the same counts on both, so none is
  from this batch: usage-agents-hide 5/16 (#2276), usage-ledger 28/34
  (#3104), usage-fold, quota-count-wrap, quota-name-translated (#2399),
  usage-checkin 26/28 (#2549), plugin-github 14/18 (#3218), s3-sync 3/4
  (#2448), modal-morph (#3179), fonts (filed as #3227, 1 in 9 alone on
  main). tray-usages (#2453), plugin-card-update (#3079) and
  proto-menu-overflow (filed as #3229) were red only under the full run
  and pass alone on both.
- Rebased onto origin/main 4a87c4476 (only Zed's mover min changed), tree
  8944b5dbb: go test ./internal/provider ./internal/gui (TestCoreScriptBudget
  and the app.js budget) ./internal/redact ./internal/settings
  ./internal/agent: all five ok; gofmt -l clean.
2026-10-22 10:52:04 +08:00
yetone 2ea148b103 gui: Claude Code's unset subagents read "Claude Code's own pick", not "same as model"
KorenKrita on Discord wanted Claude Code's subagent model left unset so
Claude Code picks. magpie already leaves env.CLAUDE_CODE_SUBAGENT_MODEL
out when the field is unset (writeTiers deletes it, setSubagent too),
but the GUI called unset "Same as model", which says the subagents run
on the main model. They don't: Claude Code 2.1.306 (read from the
installed binary) takes the Agent tool call's model, then the subagent's
frontmatter model, then the variable, then the lead's model; the
built-in Explore inherits, capped at opus.

The unset option is now "Claude Code's own pick", its note "{model}
unless the lead or the subagent names another", and the field's title
says what a model set there does. Translated in zh, zh-TW, ja and de.
Codex keeps its own lead's-pick wording.

Tests:
- TestClaudeSubagentsUnsetWriteNothing: routed, pick a model, take it
  back, move the main model; the variable stays absent. Red when
  writeTiers writes the main model for an unset sub (broken by hand).
- claude-subagents-pick.test.cjs: 5 languages x 2 widths x 2 engines,
  20/20. Red on HEAD's app.js and i18n.js (chromium 0/10).
- Ran: codex-subagents-lead 20/20, claude-auto-mode 8/8, desktop-tiers
  4/4, tier-effort 8/8, i18n-keys 3/3; go test -run TestClaude
  ./internal/agent ok.
Not tried: a real Claude Code session picking a subagent model with the
field unset.

Run for this batch of seven commits (devin, routing zh, qoder, masked words
any case, Long conversations, Claude subagents, user-select), in a worktree,
sandbox HOME, never against live configs:
- At e352cc823 (tree ea497c9f5, on origin/main 7dd965ed2): go test
  -timeout 45m ./... with pipefail, tee'd: 68 packages ok, exit 0, no
  ENOSPC. gofmt -l clean; go vet ./... for darwin, GOOS=linux -tags nogui
  and GOOS=windows: clean.
- The whole GUI suite at e352cc823 (node --test --test-concurrency=3
  internal/gui/tests/*.test.cjs, Chromium and WebKit, every language):
  11725 tests, 11679 pass, 46 fail, none ENOSPC. Each red file run alone at
  both 7dd965ed2 and e352cc823 gives the same counts on both, so none is
  from this batch: usage-agents-hide 5/16 (#2276), usage-ledger 28/34
  (#3104), usage-fold, quota-count-wrap, quota-name-translated (#2399),
  usage-checkin 26/28 (#2549), plugin-github 14/18 (#3218), s3-sync 3/4
  (#2448), modal-morph (#3179), fonts (filed as #3227, 1 in 9 alone on
  main). tray-usages (#2453), plugin-card-update (#3079) and
  proto-menu-overflow (filed as #3229) were red only under the full run
  and pass alone on both.
- Rebased onto origin/main 4a87c4476 (only Zed's mover min changed), tree
  8944b5dbb: go test ./internal/provider ./internal/gui (TestCoreScriptBudget
  and the app.js budget) ./internal/redact ./internal/settings
  ./internal/agent: all five ok; gofmt -l clean.
2026-10-22 10:52:04 +08:00
yetone 9691997bb0 gui: Long conversations stays in Settings when no Codex or Claude Code is here to hold it (Linka)
Linka on Discord runs magpie in Docker, with no agent installed. f1e4516da
(10-20) moved Long conversations (#fullContextRow: Compact at / Full
window) into Codex's and Claude Code's settings on the Agents page. In
gateway mode agentPrefsOf is null, and with neither agent present nothing
shows the row, so the compaction threshold couldn't be changed at all.
The setting still applies there: settings.Compact() sets the windows the
gateway serves, which agents on other computers read.

renderAgentPrefLinks now puts the row in Settings › General (before the
search-link rows) when no present agent owns it, and sends it back to
#agentPrefRows when one appears. With Codex or Claude Code present,
nothing changes. No new page. The backend is unchanged, so a compactAt
saved before is read and shown as it was.

Tests:
- agent-prefs.test.cjs: in gateway mode and with only Pi present, the row
  is in General. It shows the saved 200K, a typed 150k posts
  settings/full-context {on:false, at:150000}, and no other agent row is
  in Settings.
- settings-general.test.cjs: its no-agent fixture now leaves
  fullContextRow out of the "not in Settings" check.

Broken by hand: with HEAD's app.js the two new cases are red in Chromium
(the row never appears in General).

Not tried: magpie in a real Docker container; the GUI test fakes gateway mode.

Run for this batch of seven commits (devin, routing zh, qoder, masked words
any case, Long conversations, Claude subagents, user-select), in a worktree,
sandbox HOME, never against live configs:
- At e352cc823 (tree ea497c9f5, on origin/main 7dd965ed2): go test
  -timeout 45m ./... with pipefail, tee'd: 68 packages ok, exit 0, no
  ENOSPC. gofmt -l clean; go vet ./... for darwin, GOOS=linux -tags nogui
  and GOOS=windows: clean.
- The whole GUI suite at e352cc823 (node --test --test-concurrency=3
  internal/gui/tests/*.test.cjs, Chromium and WebKit, every language):
  11725 tests, 11679 pass, 46 fail, none ENOSPC. Each red file run alone at
  both 7dd965ed2 and e352cc823 gives the same counts on both, so none is
  from this batch: usage-agents-hide 5/16 (#2276), usage-ledger 28/34
  (#3104), usage-fold, quota-count-wrap, quota-name-translated (#2399),
  usage-checkin 26/28 (#2549), plugin-github 14/18 (#3218), s3-sync 3/4
  (#2448), modal-morph (#3179), fonts (filed as #3227, 1 in 9 alone on
  main). tray-usages (#2453), plugin-card-update (#3079) and
  proto-menu-overflow (filed as #3229) were red only under the full run
  and pass alone on both.
- Rebased onto origin/main 4a87c4476 (only Zed's mover min changed), tree
  8944b5dbb: go test ./internal/provider ./internal/gui (TestCoreScriptBudget
  and the app.js budget) ./internal/redact ./internal/settings
  ./internal/agent: all five ok; gofmt -l clean.
2026-10-22 10:52:04 +08:00
yetone 9a0df964e4 gateway: a relayed Chat reply that made calls and ended "stop" ends "tool_calls", streamed and whole
喜欢一个人 on Discord (v0.1.1299, deepseek-v4.1-flash through a relay,
usage row stop "stop"): the agent loop ended mid-turn. Their first ask:
when a reply calls tools, finish_reason must be tool_calls on every
path.

Checked each path on origin/main 9b0f48612:
- calls read out of text: tool_calls on Chat stream and whole,
  tool_use on Anthropic, function_call items on Responses (existing
  TestTextWritten*, TestDSMLBlockClosedWithCalls);
- calls the upstream made, ended "stop": the translations' collector
  already ends them "tool" (collector.finish, 蓝猫 on Discord), but a
  relayed Chat reply went on with "stop", streamed and whole, so a Chat
  client reading finish_reason ended its turn with the calls not run.

chatTidy now marks a choice that made a call and turns its "stop" into
"tool_calls"; chatWhole does the same for a whole reply's message with
tool_calls. A reply with no call keeps "stop", and other reasons
(length) stay.

Test: TestChatCallsEndToolCalls (chattidy_finish_test.go): stream with
and without tools offered, whole with text and with null content, a
length end kept, no-call replies kept "stop". Red on the old code (stream:
finish "stop"); broken by hand, each half red alone (the chatTidy line
off: stream red; the chatWhole check off: whole red).

TestGeminiCompatRelayEndedShort pinned the old "stop" after Linka's
Gemini call (gemini_compat_cut_test.go's "whole" cases). Its guarantee
is that a whole reply goes with its one finish_reason and none added;
it now expects that one as "tool_calls". Found by the full suite at
770c5fc48 (the only red).

Docs: gateway-routing.md, beside the call-id entry.

Run at the tree pushed (go test -timeout 45m ./... in a sandbox HOME at
308f693df, tree cfd91bbea, on origin/main c358e7660; only messages
changed since): 68 packages ok, exit 0. The one red at an earlier run
(770c5fc48), TestGeminiCompatRelayEndedShort, is answered in the finish
commit. gofmt -l clean; go vet ./internal/gateway for darwin, linux
-tags nogui and windows clean.

Not tried: a real relay or the reporter's client.

Reported by 喜欢一个人 on Discord.
2026-10-22 04:54:05 +08:00
yetone d1173c8c16 gateway: DeepSeek's calls close left in a reply's text (</||DSML|| calls>) is dropped, after a call the upstream made too
喜欢一个人 on Discord (v0.1.1299, macOS arm64, a Responses client
translated to Chat, deepseek-v4.1-flash through a relay, 232312 in /
645 out, stop "stop"): the client got the text "\n</||DSML|| calls>"
and the agent loop ended mid-turn. Their history has ||DSML|| calls>
712 times against 133 <||DSML||invoke.

Reproduced on origin/main 9b0f48612 (v0.1.1316+1) with those bytes. A
whole block of invokes closed with </||DSML|| calls> was already the
call on every route (the junk regex takes any DSML tag; 7ea8aeaba and
d0c587aee). What leaked was the close with no block before it in the
text:

- after a call the upstream made itself (a relay that made the calls of
  DeepSeek's invokes and left the wrapper's close as text):
  textCallSee and textCallTidy stopped reading text once a native call
  came, and wholeTextCalls left such a message alone, so the close went
  to the client on every route, the Responses translation the reporter
  uses included (a final_answer message after the function_call);
- with no call: textCallAt found only DSML opens (dsmlMark closing
  false), so a lone close was never held and went out as text.

Now textCallAt finds a DSML close as it finds an open, and held text
that is tags and nothing else goes, with the spaces before it after a
native call (spaceBack, settled). No call is read out of a native
reply's text; text that isn't only tags goes on as it came (prose about
</|DSML|invoke> keeps it).

Not rewritten by magpie: nothing in magpie turns tool_calls into
" calls". The only Go source with | is textcalls.go; redact's Writer
restores only {{KIND_xxxxxxxx}} placeholders, and #3143 (88119d4f6,
10-21) changed masking of the request, not reply text. The reporter's
earliest is 10-13, and OKURBITO's capture on #2623 (10-17, workbuddy
deepseek-flash, observedPipes) already has <||DSML|| calls> as the
model wrote it: DeepSeek's own spelling.

Tests (textcalls_close_test.go), from the reporter's bytes:
- TestDSMLCloseLeftAfterCalls: a native call, then "\n</||DSML|| calls>"
  cut at every valid byte, with no opener, <||DSML|| calls> or
  <||DSML||tool_calls> before the call; Chat stream, Chat whole,
  Responses stream and whole, Anthropic stream and whole.
- TestDSMLCloseAlone: "Done.\n</||DSML|| calls>" with no call, every cut,
  Chat stream and whole, Responses both; prose with a close kept.
- TestDSMLBlockClosedWithCalls: the full invoke/parameter block closed
  with " calls>", opened three ways, every cut on Chat, every 5th on
  Responses stream and whole. Green on the old code too (a guard).

Red on the old code: TestDSMLCloseLeftAfterCalls and TestDSMLCloseAlone
FAIL with origin/main's textcalls.go. Broken by hand, each red alone:
textCallSee.settle without settled (responses stream=true keeps the
close), wholeTextCalls' native branch off (chat whole keeps it),
textCallAt back to opens only (chat stream and alone keep it).

Docs: gateway-routing.md's text-calls entry.

Run at the tree pushed (go test -timeout 45m ./... in a sandbox HOME at
308f693df, tree cfd91bbea, on origin/main c358e7660; only messages
changed since): 68 packages ok, exit 0. The one red at an earlier run
(770c5fc48), TestGeminiCompatRelayEndedShort, is answered in the finish
commit. gofmt -l clean; go vet ./internal/gateway for darwin, linux
-tags nogui and windows clean.

Not tried: a real relay or the reporter's client; the bytes are the
reporter's, from their usage row and client history. A close spelled
another way than DeepSeek's DSML marks is not covered.

Reported by 喜欢一个人 on Discord.
2026-10-22 04:54:04 +08:00
yetone b00c82acfa masking: each kind is masked, sent with a warning or held back; a Never mask list and Try it (#1977)
Settings › Privacy gets two sections under What to mask:

- When a value is found: Mask, Warn or Block per kind (redactActions;
  a kind left out is masked). Warn sends the value as written and records
  it with a placeholder nobody remembers, not counted as masked. Block
  masks it as before and the gateway answers 400 naming the kind and the
  value's hint, never the value, with nothing sent (maskBlocked); the
  record is kept as Blocked. The secret kinds come first, the personal
  ones behind Show all kinds. A Never mask list (redactAllow) lets a whole
  value go as written in any case; a longer value it is part of is masked.
- Try it: POST /api/masking/preview masks a text as a request would
  (redact.Preview) and remembers nothing: no placeholder stands for it
  afterwards and its values aren't masked later as seen before. The page
  shows the vendor's text, what was found and what would be done, and
  keeps the text in no storage.

The masking card counts requests held back and values sent as written; a
call whose values only went as written gets an amber badge on Recent calls
and the Routing log. zh, zh-TW, ja and de throughout. Docs: gateway-routing
and gui-shell.

Broken by hand: the new GUI badge assertion fails on the old maskedBadge
(no .warn badge drawn); TestSettingsSaveKeepsWhatItDoesNotSend went red
until the two settings were in its fixture; "{n} held back" turned
i18n-keys red against the routing plugin's "{n} held" and was renamed.

Run at this tree (base origin/main 9b0f48612):
- gofmt clean; go vet on macOS, GOOS=linux -tags nogui, GOOS=windows.
- go test -count=1 -timeout 45m redact, maskrec, settings, gwmw, gui,
  gateway: ok.
- GUI, both engines: every Privacy file, mask-actions, masking-records,
  routing-bodies, i18n-keys, old-webkit: 263/263.
- Whole GUI suite earlier at 083b1c8e7's base, beside 7 other runs:
  53 red; alone, the ones left red fail the same on origin/main
  6fc532198 and are filed (#3179, #2228, #2448, #2276, #2549, #2163,
  #2399), except privacy-usage-stats and account-discovery, which this
  change's taller page moved off screen; both fixed here.

Not tried: a real vendor request held back by Block from a real agent.
2026-10-22 04:07:55 +08:00
yetone 9b0f48612b gateway: a plugin's model that searches by itself can be the web searcher
01huadalang (Discord #feedback, 10-20): Settings › Web search offered only
Antigravity; Trae's search model couldn't be picked, "可能也有别的模型能搜索
但是识别不到". partSearcher and modelSearches answer false for every
provider with an account behind it, so no plugin-served provider was ever
offered, and a plugin had no way to say which of its models searches.

A plugin now marks such a model with `searches: true` (in its config
models or the list its models hook gives). host.js passes it on,
plugin.Model carries it, and pluginCatalog makes it WebSearch "native".
partSearcher offers a plugin provider with such a model, with those models
only, at rank 4 (as Command Code's search models); remoteSearch asks it in
plain words, the way it asks Command Code's. A client's own web_search
sent to that model still goes to magpie's searcher (searchesModel is
unchanged): the plugin's upstream takes no web_search tool.

Behaviour change: a marked plugin model ranks ahead of Antigravity and
Google (rank 5) when magpie picks the searcher itself.

Run:
- TestPluginSearchModelIsASearcher (new; a fake plugin's model marked
  searches answers a weather question with a URL): red on the old code
  (the picker offers [], want the plugin's fake-search alone), green now.
- Broken by hand: host.js without the `searches` passthrough; the test
  goes red at the picker.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows on gateway,
  plugin, provider, catalog.
- set -o pipefail; go test -timeout 45m ./... at this tree: 68 ok, no FAIL.

Not tried: the Trae plugin itself. It declares nothing about search yet;
marking Trae CN's search_agent there needs a Trae account to try it with,
which this machine doesn't have. No GUI files changed.
2026-10-22 03:18:11 +08:00
yetone f5b0157420 gateway: a tool Claude Code's tool search loads goes to OpenAI's Responses API where it was loaded (#2660)
Through /v1/messages translated to a Responses provider, every deferred
tool ToolSearch loaded joined the top-level tools on the next request, so
the prompt changed from its first bytes and the cache missed on each load
(maximia's probe: cached tokens dropped on every request after a load).

Now, where Request.LoadedInPlace is set, a deferred tool (defer_loading,
Tool.Deferred) that a tool_result's tool_reference names (toolRefs,
Part.Loads) goes in an {"type":"additional_tools","role":"developer",
"tools":[...]} item right after the run of tool outputs that loaded it,
once, and not in tools (buildResponses). Parallel results and one result
naming several share one item; a tool named again isn't repeated; the
output's text is as before. A history whose loading result is gone
(compaction, edits) puts the tool back in tools: a new prefix, expected.

Scope (loadsInPlace): OpenAI's own API with a key (api.openai.com,
*.api.openai.com), whose tool search guide documents the item and says
its tools load at the end of the context so the cache is kept; and a
provider the user sets with `magpie provider set <id> additional-tools=on`
(Provider.AdditionalTools, kept by the GUI's save like codexAsSent).
Nothing else: xAI answers the item 422 (#350), the ChatGPT backend has
been seen taking it only for Codex's Responses Lite, Azure, plugins and
relays are untried. An upstream that refuses a request holding the item
with a 400/422 naming additional_tools is asked again with every tool in
tools, logged ("turned away additional_tools ... loaded tools go in tools
from now on") and not sent the item again while magpie runs.

Not handled: a tool a tool_addition block in a system message loads (MCP
late tools, the advisor) stays in tools. Not tried against a real
upstream: no OpenAI key or custom Responses relay was used; the item's
shape and position follow OpenAI's docs, and the fixtures follow
maximia's three-request probe (Claude Code 2.1.302) and the
tool_reference shape Claude Code 2.1.306's binary writes.

Tests: TestLoadedToolsKeepThePrefix (top-level tools and instructions
identical across the three requests, each input a prefix of the next),
TestLoadedToolsInOneItem (parallel, batch, repeat), TestLoadedToolsWhereNotTaken
(unsupported upstream unchanged; compacted; non-deferred),
TestLoadsInPlaceScope, TestLoadedToolsThroughTheGateway (off by default on
a relay, on with the flag, refusal retried without the item and not sent
again), TestAdditionalToolsPair (CLI). Broken by hand: with the
buildResponses placement disabled, the first two and the gateway test go
red; with the refusal retry disabled, TestLoadedToolsThroughTheGateway
goes red.

Run at cff7dc67d (this change on 82fb0702f), sandbox HOME, one suite on
the machine: gofmt -l internal/ clean; go vet ./... (darwin),
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... all clean;
go test -timeout 45m ./... every package ok (gateway 890s, agent 871s,
provider 447s), no FAIL. Rebased onto 52209522a (gui assets, redact and a
gateway-routing.md line of others; no overlap in code): go build ./...,
go vet of gateway, cli and redact, the tests above with TestToolSearch*
and TestCodexAsSent, and go test ./internal/redact, all ok. GUI (playwright) suite not
run: no GUI asset changed (internal/gui/providers.go is Go, in the suite).
2026-10-21 19:58:52 +08:00
yetone 62a3e79b7b redact: more file names that read as addresses stay as written (willz on Discord)
willz (#feedback) asked to tell image names like image@2x.png apart from
emails. b855cfee9 (#3029) already leaves …@2x.png/.jpg/.webp/.pdf and
the other image extensions, for the rule and the local model. This
widens the same check (fileExt in realEmail, which modelTakes calls too)
to what it still masked:
- other files named so, whose extension is no domain either (IANA's list,
  checked 2026-10-21): strings@base.json, styles@2x.css, txt, csv, yaml,
  js/ts, fonts, office files, archives, audio;
- a scale before an extension that is a domain too: icon@2x.zip,
  intro@1.5x.mov, @2x.md, @2x.map (scaleExt). Without a scale,
  ops@files.zip and me@notes.md are addresses and still masked; .ai and
  .io never were file extensions here.
(@2x.mp4 and the like never matched: the rule's last label is letters
only.) There is no allow-list for redaction: Settings → Privacy has
words and rules to mask more, and per-kind switches, but email is part
of "Mask personal data" and can't be turned off on its own.

TestMoreFileNamesAreNoEmail: the names above unmasked, in Mask and in a
request's tool_result through MaskJSON, and a.b@acme-corp.com,
x@company.ai, dev@startup.io, me@notes.md, ops@files.zip,
jane@studio.mov, sales@2x.com, hi@png.dev still masked. Broken by hand:
with b855cfee9's list only it fails on strings@base.json, icon@2x.zip,
intro@1.5x.mov and the request; with zip/mov/md/ai taken as file
extensions whole it fails on x@company.ai, me@notes.md, ops@files.zip,
jane@studio.mov.

Run at this head (on origin/main d3db461bb), sandbox HOME:
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... clean; go build for darwin, linux (nogui)
  and windows ok (at 27a1f428c, the same change on 049040283).
- go test -timeout 45m ./...: 68 packages ok, exit 0 (load ~85-140);
  the same at 049040283. Rebased after onto origin/main 82fb0702f
  (six gateway-only commits, none in redact or its doc):
  go test ./internal/redact ok, go vet redact and gateway clean.
  An earlier run of this change at ba319a758 timed out internal/agent
  and internal/library at 45m (load ~25-77; #2544/#2723, #2853) and had
  TestMainWindowCorners/RightToLeft killed (#2645); alone, library
  (2207s), agent (-timeout 120m, 1887s) and those gui tests passed.
Not tried: a real agent request through a running magpie.
2026-10-21 19:38:31 +08:00
yetone d3db461bbb redact: the local model's secrets leave UUIDs, digests and paths, and client_metadata goes as written
The owner's masking records showed Codex's turn metadata with every id as
{{SECRET_…}}: installation_id, session_id, turn_id, window_id,
context_window_id, root_turn_id, and a skill's file path in the
instructions. The local model (OpenAI's Privacy Filter) labels a UUID a
secret: run on Codex's x-codex-turn-metadata it took each id, and on a
log it took a request id and "sha256 9b74…". The vendor and magpie's own
sessions match a turn by those ids, so masking them can break what
depends on them, and hides nothing worth hiding.

- modelTakes: a secret the model finds is not taken when it names a
  thing (namesThing): a UUID, with window_id's ":0" after it too; a
  digest with its algorithm's name; a file's path. A password or a key
  it finds is still masked, and the rules' secrets (sk-…, password=…,
  API_KEY: …) are unchanged.
- client_metadata is in defKeys: the client's ids, which no model
  reads, go as written, as tools and stream_options do.

docs/subsystems/gateway-routing.md says both.

TestModelSecretIsNoID uses what the real model labelled "secret" on these
texts (pf-serve with the q8 model, run here): the UUIDs, the request id,
the sha256 digest, plus the reporter's path; the password and the
32-hex key beside them are still masked. Broken by hand: without
namesThing 5 values are masked, without client_metadata in defKeys a
user word in it is.

Run:
- At 3fff6c011 (on origin/main e65688886): gofmt -l clean; go vet clean
  on macOS, GOOS=linux -tags nogui and GOOS=windows; go test ./...
  -timeout 100m: 66 packages ok, and internal/agent and internal/library
  printed PASS but were marked FAIL when the disk briefly filled ("can't
  write testlog.txt: no space left on device"); run again alone, both ok
  (993s, 596s).
- Rebased on origin/main 141470515 (its 12 commits touch agent, cli,
  gateway, gui, provider, sessions, settings, tui, not redact): at this
  head gofmt and vet three ways clean, go test ./internal/redact
  ./internal/gwmw ./plugins/redact ok. The rest runs on CI before the
  tag.
2026-10-21 19:13:49 +08:00
yetone 1bd99194ea provider: Claude Code stays listed, signed out, when every saved account's sign-in is gone
LeeHom on Discord: two Claude Pro accounts vanished from Providers, and
signing one in again showed the other as "needs sign in again". While
Claude Code is signed out, the claude provider is built on
claudeStandIn's account. claudeStandIn skips an account whose sign-in
Claude Code let go of (claudeLoggedOut's claudeLogoutLapse) or that is
still Held. With every saved account like that, it returned "", no claude
provider was made, and the subscription and both accounts left the GUI,
the TUI and `magpie providers` at once.

claudeStandInAccount and Logins now ask claudeListed: the stand-in, else
the signed-out account seen last. A Held account is never listed this way,
because the sign-in Claude Code left on disk would then be served
(TestClaudeSignedOut still holds). The listed account's token still fails
with the lapse reason (claudeSavedDir), so nothing is served on it.
claudeStandIn itself is unchanged, since addLogin and logins_on rely on
it.

The app's row already said "{user} is signed out" when every login in use
had lapsed. Provider.SignedOut is that rule in Go. With it, `magpie
providers` says "○ <user> is signed out · sign in again" and the TUI says
"○ <user> is signed out", instead of a green "signed in". The CLI's key
column moved into keyColumn so it can be tested. The providers-accounts
doc row says this.

Tests:
- TestClaudeAllSignedOutStaysListed: signed in, a second account
  logout-lapsed, then Claude Code signed out. It fails on the old code
  ("Claude Code left the Providers list with every account signed out:
  false") and with SignedOut returning false (both broken by hand).
- TestProvidersSaySignedOut, in cli and tui: a signed-out account reads
  as signed out and a signed-in one still reads as signed in.

Run: gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags
nogui ./..., GOOS=windows go vet ./...; go build for all three.

Then go test -timeout 45m ./... under a sandbox HOME at base ba319a758
(load ~25). Every package was ok except two:
- internal/agent timed out with a 2s-old test running (rerun alone: ok
  1866s).
- internal/gateway failed TestRateLimitIsWaitedOut, "an hour away: passed
  on after 1.32s" against its 1s bound. That is #1971, open, a wall-clock
  bound under load and not this change; rerun alone: ok 1433s.

Rebased on d771138c4 (13 commits, including c79400556 in
agent/provider.go). At the pushed head: gofmt clean, go build for darwin,
linux nogui and windows, go vet of provider/cli/tui, and go test
./internal/provider ./internal/cli ./internal/tui all ok. No GUI file
changed, so the GUI suite was not run.

Not tried: a real Claude account signed out in Claude Code. The sandbox
test drives the same files (.credentials.json, .claude.json, logins.json).
2026-10-21 19:00:33 +08:00
yetone 3c38fe5c99 agent: Zoo Code (VS Code) through its autoImportSettingsPath (wani on Discord)
wani on Discord (#feedback) asked for Zoo Code (zoocode.dev), a fork of Roo
Code for VS Code and JetBrains.

Route: Zoo Code keeps its provider profiles in VS Code's SecretStorage,
which magpie can't write. The one file it reads is the one its
zoo-code.autoImportSettingsPath setting names. On every activation
(src/utils/autoImportSettings.ts, Zoo Code 3.90.0) it imports that file as
Settings → Import does (importSettingsFromPath). magpie writes
<User>/globalStorage/zoocodeorganization.zoo-code/settings/magpie-import.json
with one profile, "magpie": apiProvider openai on the gateway's
/v1 Chat Completions, key magpie-zoo-code, the chosen model, and an
openAiCustomModelInfo built from the catalog (contextWindow, else Zoo's own
128000 default; maxTokens only when an output limit is known). It points
the setting at that file in the default settings.json and in each VS Code
profile's. A value the user set themselves is stashed and restored by
Disconnect. The file sits outside magpie's folder so that a sync keeps an
address the user moved (kept.away skips magpie's own folder). Requests say
"ZooCode/<version>", and usage names them zoo-code.

Limits (also in docs/reference.md → Zoo Code):
- Zoo reads the file only at start: the notice asks for Developer: Reload
  Window.
- While connected, each start switches Zoo back to the magpie profile.
- Disconnect stops the import but can't delete the imported profile
  from SecretStorage. The user switches away from it or deletes it in Zoo.
- VS Code Stable only.

JetBrains is not wired. Zoo Code for JetBrains runs the extension in its own
extension host, which is handed an empty configuration on every start
(RPCManager.startInitialize in Zoo-Code-JetBrains), so the setting never
reaches it. Its secrets sit in ~/.zoo-code/secrets.json, an internal store
with no lock and no documented format. Neither is a clean route.

Tests (internal/agent/zoocode_test.go):
- TestZooCode: connect, model switch, a stale key that Check reports and
  Sync fixes, and disconnect putting the user's own import path back byte
  for byte with the file removed.
- TestZooCodeFresh and TestZooCodeProfiles: VS Code profiles, including one
  made after connecting.
- TestZooCodeDetectAndUA: Roo alone is not detected; ZooCode/3.90.0 maps to
  zoo-code.
Broken by hand (the restore disabled): TestZooCode and TestZooCodeProfiles
went red.
The generated file was checked with bun against Zoo's own zod schemas
(providerSettingsWithIdSchema, isProviderName; zod 4.6.7 from its repo):
valid, every field kept, current profile in apiConfigs.

Run, set -o pipefail, GOMODCACHE pinned, sandbox HOME:
- First full run, with this change on ba319a758 at 49bec8c4f:
  - gofmt -l clean.
  - go vet darwin, GOOS=linux -tags nogui and GOOS=windows: clean.
  - go test -timeout 45m ./...: 67 packages ok, including gateway 2543s,
    gui 509s and library 2326s.
  - internal/agent was red: TestSyncKeepsAnAddressOnAnotherMachine. The
    import file was then in magpie's folder, which kept.away skips, so a
    NAS address was lost. The file was moved into Zoo's globalStorage
    folder. The package also hit the 45m deadline under load (#2544).
- After the fix: -run 'ZooCode|TestSyncKeepsAnAddressOnAnotherMachine|
  TestReverseProxyIsStillMagpie' ./internal/agent was ok in 112.9s.
- At 0aa9c53ce: gofmt -l clean, internal/agent vet clean three ways, and
  go test -timeout 90m ./internal/agent ./internal/library ./internal/gui
  ok (agent 1912s, library 1299s, gui 420s).
- GUI suite in both engines: 283/283 in chromium and 283/283 in webkit
  (playwright 1.62.0). It covers the 44 files the change can reach:
  gui-de, gui-ja, gui-zh-tw, i18n-keys, agent-notice-lang,
  models-add-and-icons, mono-icon-redraw and every agent-*.

After rebasing onto origin/main 049040283 (which changed internal/agent/claude.go):
- go vet ./internal/agent clean three ways; linux nogui and windows
  builds ok.
- -run 'ZooCode|Compact|TestSyncKeepsAnAddressOnAnotherMachine|UserAgent|AgentOf'
  ./internal/agent ok in 35.9s.
- The darwin go build of the binary hit a full disk at link (this
  machine's, 369M free), not a code error.

Not tried: real VS Code (not installed on this machine), Windows and Linux.
2026-10-21 18:43:06 +08:00
yetone 049040283e codex: a searched conversation under Codex's web.run isn't sent the hosted web_search beside it (Savin on Discord)
Savin (#help, magpie 0.1.1296, Codex 0.163.0-alpha.10.2, signed in with
ChatGPT): the turn failed with the ChatGPT backend's "a single request
can't contain both a client-declared function web.run and the hosted tool
web_search".

Who adds which:
- web.run is Codex's own. codex-rs/ext/web-search (tool.rs) declares it
  as a function "run" in the "web" namespace, and spec_plan.rs's
  hosted_model_tool_specs leaves the hosted web_search out whenever
  web.run is registered: on a Responses Lite model (whose requests take
  no hosted tools at all), or with the standalone_web_search feature on.
  Codex never sends both itself.
- The hosted web_search was magpie's. provider.DeclareSearch (#1270)
  adds the cached-only {"type":"web_search","external_web_access":false}
  to any ChatGPT-bound request whose input replays a web_search_call
  without declaring search. declaresSearch looked only for a web_search*
  type, so a conversation that had searched with the hosted tool and
  went on under web.run (a Lite model, a newer Codex, or magpie's own
  searcher's web_search_call items) got web_search added beside web.run,
  in the additional_tools item for Lite or in the tools. The backend then
  refused the turn.

What changed: declaresSearch counts web.run as the conversation's search.
It matches the namespace "web" holding a function "run", and a function
named "web.run". DeclareSearch then leaves the body as Codex sent it.
This covers both routes that call it: codexBody (a ChatGPT account in
magpie) and codexUpstreamOn (Codex's own sign-in relayed). Nothing the
client declared is dropped. web.run is the tool the backend serves this
client (through /alpha/search), so magpie no longer adds the tool that
conflicts with it. A namespace other than "web" with a "run" function
still gets web_search declared.

Not verified: whether the ChatGPT backend accepts a replayed
web_search_call under web.run with no hosted tool. That is the request
the official Codex client sends to it directly. It was not probed on a
real account, and the test fake assumes it is accepted.

Tests:
- TestDeclareSearch: new cases cover web.run in Lite's additional_tools,
  web.run among the tools, the flat "web.run" function, and another
  namespace's run.
- TestSearchedConversationUnderWebRun: protectedSearch now refuses a
  request that carries both tools, with Savin's error. The test covers
  Lite on Codex's sign-in (relayed byte for byte) and two turns on a
  ChatGPT account (Lite and tools).
- On ba319a758 without the codex_request.go change, both tests fail.
  The gateway test gets the 400 with Savin's error. With the change,
  both pass, along with TestSearchedConversation* and
  TestUnsearchedConversationUnchanged.

docs/subsystems/gateway-routing.md says it next to #1270.

Run:
- gofmt -l: clean. go vet ./... passes on darwin, GOOS=linux -tags nogui
  and GOOS=windows -tags nogui.
- `set -o pipefail; go test -timeout 45m ./...` at base ba319a758: every
  package ok except internal/agent and internal/gateway. Both hit the 45m
  package timeout with no test failing. The tests in flight at the panic
  had run 5s and 0s, and four suites from other sessions were running on
  the machine.
- Rerun of those two at -timeout 90m: gateway ok (2057s), agent ok
  (2418s).
- Rebased onto c79400556, whose 4 new commits touch agent, library,
  redact and provider. Rerun there: gofmt, vet on all three OSes,
  ./internal/provider ok, ./internal/redact ok, and
  ./internal/gateway -run 'Search|Codex|WebRun|Protect' ok.
- Rebased again onto e68a0b1db (4 commits in internal/sessions only).
  go vet on sessions, provider and gateway passes there.
2026-10-21 18:40:51 +08:00
yetone b855cfee9e redact: a file named like an address (…@2x.jpg) is not masked as an email (#3029)
vdxz on Pi with personal data masked: /Users/…/Pictures/261020_14-16-11@2x.jpg
went to the model as /Users/…/Pictures/{{EMAIL_…}}, and Pi could no longer
read the file. A Mac saves an image at twice its size with @2x before its
extension, which the EMAIL rule reads as user@2x.jpg.

realEmail leaves an address whose last label is a file extension no
top-level domain has (fileExt: jpg, png, gif, webp, svg, heic, pdf and
the like; py, md, sh, zip and mov are domains and stay out of it). The
local model's EMAIL spans pass the same check now (modelTakes), so it
can't mask the name the rule leaves. An address beside the file's name
is still masked.

TestFileNameIsNoEmail uses the reporter's path. Broken by hand: with
redact.go as on main the rule's half fails, with model.go as on main the
model's half fails.

Run at this head (on the #3143/#3144 commit, origin/main ba319a758):
- gofmt -l clean; go vet clean on macOS, GOOS=linux -tags nogui and
  GOOS=windows.
- go test ./internal/redact ./internal/masking ./internal/gateway
  -timeout 100m: ok (gateway 2742s at load ~25).
- The commit below this one ran go test ./... -timeout 100m: 68
  packages ok; this one touches internal/redact and its doc only.
2026-10-21 17:20:42 +08:00
yetone 88119d4f67 redact: Codex's tool server names, stream_options and snake_case words go as written (#3143, #3144)
Two reports from hibaliqya-yonma (v0.1.1306, Codex Desktop through
/backend-api/codex), each a 400 on every request until masking was
turned down:

- #3143: a user's word that is part of an MCP server's name went into a
  Responses function_call's namespace as mcp__{{TERM_…}}. Codex checks a
  namespace against ^[a-zA-Z0-9_-]+$, and the call is replayed every
  turn. namespace is kept as name is, and so are the server's name in
  its siblings: a Responses mcp_call's server_label, Anthropic's
  mcp_tool_use server_name.
- #3144: the local model took stream_options.reasoning_summary_delivery,
  "sequential_cutoff", for a name. stream_options is a request setting
  now (defKeys, with reasoning and text), and the model's name is never
  a snake_case word (snakeWord), wherever it is, so an enum or an
  identifier in a tool's arguments or in code is not taken either.

The same word in the user's own message is still masked, and a name
beside it still is. docs/subsystems/gateway-routing.md says both.

Tests from the reporter's bodies: TestMaskJSONKeepsReasoningSummaryDelivery,
TestMaskJSONKeepsToolServerNames (namespace, server_label, server_name),
TestModelTakesNoSnakeWord. Broken by hand: with json.go and model.go as
on main, all three fail; with the change they pass.

Run at this head (origin/main ba319a758):
- gofmt -l clean; go vet clean on macOS, GOOS=linux -tags nogui and
  GOOS=windows.
- go test ./... -timeout 100m: 68 packages ok, exit 0.
- With #3029's commit stacked on it: go test ./internal/redact
  ./internal/gateway ok (gateway 2742s at load ~25), vet the three ways
  clean.
2026-10-21 17:20:37 +08:00
yetone ba319a7587 gateway: the lone tool_choice none goes to the Grok plugin only (#3110)
19527ca8d sent a lone tool_choice "none" (tools turned off, none
declared) to every provider plugin on Responses. No other plugin's
vendor had been tried with one. commandcode, factory, opendesign and
zed don't touch tool_choice in their fetch/rewrite (git grep on
magpie-community/plugins origin/main), so it would have reached their
vendors as is, and a 400 there would be a regression. Only the Grok
plugin reads it, and grok 0.1.18 drops it before Grok.

keepsLoneNone now keeps it for the Grok plugin alone (still not when
the plugin points at xAI or Copilot, #378); forwardTranslated strips it
for every other upstream, as before 19527ca8d.

Run at this commit (on 19527ca8d):
- gofmt -l: clean
- go vet ./...: darwin, GOOS=linux -tags nogui, GOOS=windows: clean
- set -o pipefail; go test -timeout 45m ./...: exit 0, 68 packages ok
  (gateway 475.6s, provider 173.9s), no FAIL
- broken by hand: keepsLoneNone back to "any plugin" turns the new
  TestToolsOffWithoutToolsNotSentToOtherPlugins red; returning false
  turns TestToolsOffWithoutToolsReachesPlugin red; both green restored

Not tried: no vendor was sent a real request; with this change none
but Grok's plugin path can receive the lone "none", and that plugin
drops it.
2026-10-21 10:25:31 +08:00
yetone 19527ca8dd gateway: tools turned off with none declared reach a plugin as tool_choice none (#3110)
Cause: buildResponses wrote tool_choice only inside its tools block, so a
Chat "none", Anthropic {"type":"none"} or Gemini NONE with no tools was
dropped on the way to Responses. A provider plugin that adds a
server-side tool (Grok's x_search, plugins PR #263) couldn't tell
"tools off" from "no choice". The other builders (Chat, Anthropic,
Gemini, Code Assist) send no tool choice without tools, which is what
their vendors accept (OpenAI Chat refuses a lone tool_choice), so they
are unchanged.

Fix:
- buildResponses keeps a lone "none" (only "none"; "" and "auto"
  still go unsaid).
- forwardTranslated strips it again for every non-plugin upstream, and
  for a plugin on api.x.ai or Copilot (refusesLoneToolChoice, the #378
  rule now shared with passthrough). A vendor never sees it.
- The grok plugin's body shaping (grokPluginBody) keeps a lone "none";
  the built-in's grokBody still drops it. grok plugin 0.1.18
  (magpie-community/plugins aee6b9d, on npm) drops any lone tool_choice
  itself before Grok, so the mover's min goes 0.1.17 -> 0.1.18.

Run at this commit (worktree on efd1b697e):
- gofmt -l: clean
- go vet ./...: darwin, GOOS=linux -tags nogui, GOOS=windows: clean
- set -o pipefail; go test -timeout 45m ./...: exit 0, 68 packages ok
  (gateway 660.6s, provider 270.9s), no FAIL
- broken by hand, each went red then green on restore: removing the
  "none" emit (ReachesPlugin, PerBuilder/responses); grokPluginBody with
  keepNone=false (TestGrokPluginBodyKeepsLoneNone, ReachesPlugin);
  dropping the !p.IsPlugin() check (NotSentToVendor)
- plugins: bun test 2018 pass, 0 fail; the new tool-choice test is red
  against the old index.mjs

Not tried: live Grok, xAI or OpenAI with a lone "none". Other Responses
plugins (commandcode, factory, opendesign, zed) now get a lone "none" in
this case; their vendors take Codex's lone "auto", but this is untested.
2026-10-21 10:14:07 +08:00
yetone 55b5eca055 gateway: a provider that searches for some of its models is offered as a searcher, with those models only (01huadalang on Discord)
Reported: 01huadalang has a Command Code plan, but web search offered no
searcher for it, although some of its models (gpt-6-luna) search on
their own. The picker counted a provider only when every model searched,
or when its host was a self-searching API.

Changed (internal/gateway/search.go, search_remote.go):
  - partSearcher(p) holds for a provider with no Account and no
    self-searching API host whose preset is in searchModels or whose base
    host is in searchModelsHosts. modelSearchesAny(p, model) says whether
    that model is one that searches.
  - searchRank ranks such a provider 4 when one of its available models
    searches. searcherReady keeps it. searchableModel offers only the
    models that search, never e.g. claude-opus-5-5.
  - docs/subsystems/gateway-routing.md says so.

Test: TestCommandCodeSearchesForOtherModels (search_models_test.go).
Broken by hand, each one red, then green when put back:
  - search.go and search_remote.go reverted: "the picker offers [],
    want Command Code's gpt-6-luna alone".
  - partSearcher dropped from searcherReady's keep, and the
    searchableModel case dropped: `Command Code searches with
    "claude-opus-5-5"`.

Run, go1.26.8 darwin/arm64, sandbox HOME, private GOCACHE:
  At this stack on origin/main df6bd3efe (head 48522d851):
    gofmt -l: nothing
    go vet ./... (darwin), GOOS=linux go vet -tags nogui ./...,
      GOOS=windows go vet ./...: ok
    set -o pipefail; go test -timeout 45m ./...: ok, EXIT=0
      (68 ok, 19 with no test files; agent 528s, gateway 628s,
      library 482s)
    GUI, playwright 1.62.0, chromium and webkit, concurrency 3: the
      171 files near this change (routing*, panel-routing*,
      window-mask, privacy*, usage*, quota*, providers*): 2217 tests,
      2183 pass, 34 fail. Every red is also red alone on origin/main:
      quota-count-wrap and quota-name-translated (#2228),
      usage-agents-hide (#2276), usage-checkin (#3091), usage-fold
      (#2163), usage-ledger (#3104, red since df6bd3efe, green at its
      parent). window-mask: 20 of 20.
  At this stack on origin/main c922225f1 (head 91baa7adb), before
  df6bd3efe's routing trace change:
    set -o pipefail; go test -timeout 45m ./...: ok, EXIT=0
      (66 ok, 20 with no test files)
    the whole GUI suite (823 files, both engines, concurrency 3):
      11589 tests, 11554 pass, 35 fail. The 9 files red were run again
      alone at --test-concurrency=1 on the head and on origin/main
      a8ecf4020. The same 7 files were red on both: the five issues
      above plus s3-sync (#2448) and library-row-remove (#3099).
      nav-sub-unroll (#1950) and plugin-updates (#3103) were red only
      under the full run. codex-predictions (#2624) was 20 of 20.
2026-10-21 08:40:49 +08:00
yetone a8ecf4020e provider: a check-in file that can't be read or parsed stops the check-in
readCheckins, the reader every daily check-in shares (WorkBuddy, Trae CN,
MiniMax Code, Qoder and the plugins' own), took a file it couldn't read
or parse as empty. The next check-in then asked the vendor again for
every account and wrote its answers over the file: an account could be
checked in twice in one day, and the entries it couldn't read were lost.

readCheckins now returns an error for a file that is there but can't be
read, or doesn't parse into entries (cut short, zeroed, empty, `[]`,
`null`). A file not there is still empty. On the error:
- checkiner.checkinNow asks nothing and writes nothing. Each account it
  would look at is `failed` with the reason (the path and why), so the
  loop tries again after 30 minutes and a press (GUI, TUI, `magpie
  accounts checkin`) says why. The error is logged once while it stays
  the same.
- The readers that only show results (WithCheckins, *Checkins(),
  PluginCheckins) go through shownCheckins, which gives what last read
  from the file in this process, so a card keeps its last good data.
- adoptLegacyPluginCheckins' own strict copy of the read now uses
  readCheckins too.
Docs: providers-accounts.md no longer lists check-in marks among the
caches written over; provider-plugins.md says the plugin file's case.

Test: TestCheckinUnreadableFileLeftAlone writes a cut-short, zeroed,
empty, `[]` and `null` workbuddy-checkin.json, runs the loop and a press
against a fake WorkBuddy, and checks no status or claim request went out,
the file is byte for byte unchanged, and the result says the path; a
folder in place of plugin-checkin.json does the same through a plugin
checkiner. TestCheckinMissingFileIsEmpty and
TestCheckinUnreadableKeepsLastGood cover the other two sides.
Broken by hand (checkinNow taking the error as an empty map again): the
test went red, every case claimed (Asked true), and green once restored.

Run in a worktree at origin/main 62a1df801, sandbox HOME (testenv):
- gofmt -l . : clean
- go vet ./... (darwin), GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... : all exit 0
- set -o pipefail; go test -timeout 45m ./... : exit 0, 68 packages ok,
  none failed (internal/gateway 613s, internal/agent 529s,
  internal/provider 262s)
No red seen, so no issue filed.
2026-10-21 07:23:23 +08:00
yetone 62a1df8010 provider: a plugin's daily check-in reaches every sign-in, also two that share a display name (plugins#254)
AutoClaw's plugin can hold several sign-ins under one default display name,
which AutoClaw doesn't let the user change. plugin_checkin.go keyed each
account's check-in on "<provider>|<AccountID>", the display name, so
checkinNow's per-key dedupe asked only the first sign-in of each name, by
the loop and by Check in now alike; the others stayed 今日未签 for good,
and Settings showed one row, and one Off switch, per name.

Each sign-in is now keyed on the key plugin-auth.json keeps it under
(pluginCheckinKey: "autoclaw|autoclaw", "autoclaw|autoclaw#x1y2z3").
Two sign-ins never share it; a refresh writes the same key, and signing
in to an account already signed in goes back to its key (host.js
settle). The display name is shown only. Cards, Settings rows,
CheckinOff and Check in now all read the same key, so app.js is
unchanged. An account without an AccountID already had this key.

Upgrade (adoptLegacyPluginCheckins, run when the plugin's accounts are
listed): an entry kept as "<provider>|<display name>" goes
- in plugin-checkin.json, to the first sign-in in use of that name (the
  one the old key's check-in asked) and only to it, and the old entry
  is dropped: it isn't asked again today, and its namesakes, never asked,
  are;
- in settings.CheckinOff, to every sign-in of that name: the user turned
  that name off and none of its sign-ins was checked in since, so the
  upgrade switches none on (settings.EditCheckinOff edits that field
  alone from what the file holds).
A plugin-checkin.json that can't be read or parsed is left as it is and
carried over once it reads; writes go through writePrivate
(temp-and-rename). Known gap: a sign-in made the same day after another
was signed out can take the freed key and that day's result.

The fake plugin's check-in now records a signed-in account as
name@fake/uid so two of one name tell apart in the presses.

Tests:
- TestPluginCheckinTellsSignInsOfOneNameApart: four sign-ins, A/u1, A/u2,
  B/u3, B/u4 (the reporter's case). All four pressed once, none again
  that day, four entries kept, four Settings rows, every card marked;
  with A/u2 off, Check in now the next day presses the other three.
- TestPluginCheckinCarriesOverDisplayNameEntries: a plugin-checkin.json
  with fakeco|A@fake and fakeco|B@fake claimed today plus another
  plugin's entry, and CheckinOff ["workbuddy|123", "fakeco|B@fake"].
  A's check-in goes to its first sign-in only, the old entries go, the
  other plugin's stays, both B sign-ins are off and workbuddy|123 is
  kept; the loop then presses only A's namesake, and a second look
  presses nothing.
- TestPluginCheckinCarriesNothingOverAnUnreadableFile.

Broken by hand, each red:
1. key back on the display name: TellsApart pressed only A@fake/u1 and
   B@fake/u3; CarriesOver kept the old entries.
2. adoption not called: CarriesOver ("A's check-in went to ... ok false").
3. record to every heir: CarriesOver ("carried to both") and Unreadable.
4. Off to the first heir only: CarriesOver (CheckinOff lacks one B).
5. old entry kept: CarriesOver and Unreadable.
6. parse error ignored: Unreadable.

Run at 0f044e944 (origin/main) plus this change, macOS arm64, sandbox
HOMEs from testenv, shared GOCACHE:
- go test -race -count=20 -run TestPluginCheckin ./internal/provider: ok
- gofmt -l on the changed files: prints nothing
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
  go vet ./...: clean
- go build, GOOS=linux go build -tags nogui, GOOS=windows go build: ok
- go test -timeout 45m ./...: exit 0, 68 packages ok, no FAIL
- after a comment-only rewrap: go test ./internal/provider
  ./internal/settings: ok
No GUI suite: internal/gui/assets is unchanged.
Not tried with real AutoClaw accounts or a real plugin-checkin.json from
the reporter.
2026-10-21 07:04:19 +08:00
yetone f21dd99f5a privacy: every masking is recorded, and Settings › Privacy shows it
What was masked is now kept, so the user can see it. Settings › Privacy
opens on a summary card: how many values were kept from vendors over 1,
7 or 30 days, by kind, by finder (rules, your words, the local model,
known values) and by where they went, with a day strip. The page is
grouped into What to mask, How it's found (rules and the local model are
layers, not a toggle: the model adds names and addresses rules can't
see) and Sharing. A records view lists each masked request: its kinds,
finders, placeholders and, while magpie runs, the line around each
value. Gateway › Recent calls and the Routing log carry a masked-N badge
that opens the record.

Originals never go to disk. internal/maskrec writes day files under
~/.config/magpie/masking (0600, 30 days, 100MB at most) holding kinds,
finders, placeholders, a first character or key prefix and a length.
The lines around values are kept in memory for the last 400 records
only, and /api/masking/value answers only while the masker remembers a
placeholder. Nothing is written under MAGPIE_TEST_SANDBOX.

A masker says what it masked through gwmw.Teller (JSONHits, TextHits,
Value); a plugin masker that doesn't is counted only, so older redact
plugins keep working. Every route that masks notes it: chat, Responses,
Codex backend and search, embeddings, images, video, transcription,
decide and the search MCP query. Masking still fails closed: a masker
that panics on any path refuses the request (TestMaskingOnAndOff's fake
now panics on JSONHits and TextHits too, since the gateway asks a Teller
through those).

app.js grows to 1,314,432 bytes, so its budget rises to 1,335,000 and
the core's to 1,528,800 (+1.5%): Settings is the core's own page.

Run at this head (rebased on origin/main a3ebed202):
- go vet clean on macOS, GOOS=linux -tags nogui and GOOS=windows;
  go test ./internal/gateway ok (561s).
- On origin/main c922225f1 (one commit back, the packages either side
  touches): agent, gateway, gui, gwmw, maskrec, provider, redact ok.
- On origin/main 592899467: go test ./... -timeout 45m, 65 packages ok;
  agent and gateway hit the 45m timeout under load ~26 (each mid-way
  through a short test, not a hang) and pass alone with -timeout 100m
  (1133s, 890s).
- GUI, on 592899467, the 42 files this change or main's new commits reach (privacy-*,
  redact-*, masking-records, settings-*, gateway-*, routing-bodies,
  routing-request-metrics, routing-log-icons, account-discovery,
  click-scroll, i18n-keys, old-webkit), both engines, every language:
  475 tests, 475 pass. routing-bodies is green here since 2543fb2c1.

Run on the previous base, origin/main c84864ffc (the whole suites):
- go test ./... -timeout 45m: every package ok (66), exit 0. An earlier
  run found TestMaskingOnAndOff/panics (its fake, above) and
  TestCoreScriptBudget (the budget, above); both fixed.
- gofmt -l clean; go vet on macOS, GOOS=linux -tags nogui and
  GOOS=windows clean; node --check on the changed scripts.
- GUI suite, both engines, every language, --test-concurrency=6:
  11533 tests, 11483 pass, 50 fail. Each failing file rerun alone here
  and on origin/main:
  - red the same on main, filed: codex-predictions (#2624),
    usage-checkin (#2549), usage-agents-hide (#2276), usage-fold
    (#2163), s3-sync (#2448), quota-count-wrap and
    quota-name-translated (#2228), routing-request-metrics (#2571),
    routing-bodies (#2559: red at its "second request pressed" step;
    this change's badge checks before and after it pass),
    routing-rule-remove (#3096, filed now: 0 2 1 alone here, 0 0 2 on
    c84864ffc).
  - load, pass alone: group-member-weight (#2387), routing-model-rest,
    context-tune (Chromium didn't launch in 180s at load average ~45;
    0 0 0 alone on both). An earlier whole run's library-chip-fan red is
    #3072 (filed), plugin-card-update #3079, lightweight #2638,
    segs-glide #2683.
  - mine, fixed: old-webkit, three ":hover, :focus-visible" lists
    Safari before 15.4 drops; split, 6/6.
- Broken by hand, each went red: masked values kept on disk
  (TestNoValueOnDisk), a snip that runs past an escaped quote
  (TestSnipStaysInItsString), the shared-line dedup in the records view
  (masking-records, 10 of 12).
- Real app in a sandbox HOME with the local model on: the summary card,
  flow, chips and records view in light and dark; persons and
  addresses, Chinese names among them, recorded by=model; a grep of the
  masking folder and the sandbox config for the masked values found
  none.
2026-10-21 06:12:37 +08:00
yetone a3ebed202e gateway: Codex's compaction back on its own model goes without another vendor's reasoning text, so the turn after DeepSeek isn't refused over input[n].content (jue on Discord)
jue (Codex app, GPT-6.1 Sol) set a DeepSeek model for Codex on the
Agents page, went back to GPT, and the next turn sometimes failed with
"[ArrayParam] [input[8].content] [array_above_max_length] Invalid
'input[8].content': array too long. Expected an array with maximum
length 0, but got an array with length 1 instead."

Cause: when the model changes (or the thread passes its auto-compact
limit) Codex compacts the thread before the turn, and shows a failed
compaction as the turn's error. Codex's /responses/compact for one of
its own models went to the ChatGPT backend (Codex's sign-in, its sk-
key, or a magpie Codex account through compactOn) with its input as
sent. A reasoning item from DeepSeek's Responses API carries its
reasoning_text in content, which OpenAI accepts only empty, so the
whole compaction was refused. A turn on the same routes already went
through codexInput(body, false), which drops such items; the
compaction didn't. "Sometimes" is when Codex compacts first.

Fix: codexBackend's own-model branch runs codexInput(body, false) on
/responses/compact too, before any of the three routes. OpenAI's own
sealed reasoning (encrypted_content, no text) stays; a summary magpie
made goes as its text, as from a turn. DeepSeek still gets its
reasoning text (withReasoningText). Siblings read: the translated
Responses path sends back only sealed reasoning (sealedReasoning);
passthrough strips reasoning text for openai.com, Azure and Codex
accounts and retries on the refusal elsewhere (#1411). Not covered: a
full restore that drops openai_base_url leaves magpie off Codex's path.
Codex's base_instructions and prompts are untouched.

Test: TestForeignReasoningNeverReachesOpenAI sends the reported thread
(input[8] a DeepSeek reasoning item with one reasoning_text, input[3]
OpenAI's sealed reasoning) on seven routes: turn and compaction on
Codex's sign-in, its API key and a magpie account, and /v1/responses
with codex/gpt-6.1-sol. The fake OpenAI refuses a reasoning item with
text with the reported 400 byte for byte. On the old code the three
compaction routes are red with that 400 and the four turns green;
with the fix all seven are green. Broken by hand a second way
(codexInput(body, true) on the compact branch): the same three red.

Run at 592899467 + this change, GOMODCACHE=/Users/yetone/go/pkg/mod,
sandbox HOME and GOCACHE in the worktree:
- gofmt -l on the changed Go files: empty.
- go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...: all clean.
- set -o pipefail; go test -timeout 45m ./...: exit 1 at load from
  other sessions' suites. 61 packages ok. internal/agent, gateway and
  library hit the 45m timeout (#2869's kind).
  TestSetAnswersWhileDevinAndProvidersHang (internal/gui, 10.6s set,
  #1375) and TestTaggedReposSlowRead (internal/plugin, #1889) failed
  their timing bars.
- Rerun alone, go test -timeout 45m -p 2 ./internal/gateway
  ./internal/agent ./internal/library ./internal/gui ./internal/plugin:
  all five ok (gateway 1011s, agent 1235s, library 632s, gui 184s,
  plugin 452s).
- Rebased on c922225f1 (5 commits, gateway.go among them): go vet
  ./internal/gateway for darwin, linux -tags nogui and windows clean;
  go test -timeout 45m ./internal/gateway ok (1253s).
2026-10-21 05:57:34 +08:00
yetone 592899467b gateway: Gemini's reasoning streams as it comes on the last candidate, so Codex isn't left with nothing for the whole of its thinking (LuckymanJC on Discord)
LuckymanJC and kkgg: through magpie the first turn of a Codex session on
a Gemini model was very slow or seemed stalled. Measured with fake
upstreams through the gateway (Codex Responses -> Chat DeepSeek, Gemini;
OpenCode Chat; Anthropic passthrough), first content came within 1-50ms
on every path but one: a Gemini model's reasoning was held even on the
last candidate (`|| last && modelFamily(c.model) != ""` left Gemini out),
so Codex got nothing at all, not even response.created, until the text
began, while Claude's and GPT's has gone as it comes there since
iTianbao's report.

It was held there for #667, a reply that only reasoned being asked
again. That re-ask happens in place in streamTranslated, keeping the
reasoning the agent has, so it doesn't need the hold. But with the try
passing, emptyRetries counted it as past the request's own re-asks and
asked only streamRetries (2) times, and TestGeminiEmptyRepliesAskedAgain
(three empty replies running) went red. A held try that went through on
its reasoning alone (holdWriter.thoughtThrough) is now asked once more in
place (streamRetries+1); a never-answering model still makes at most 4
calls (the test's bound is 6).

Tests: TestThinkingStreamsWithNoOneElse gets "gemini" (Gemini upstream)
and "chat gemini" cases, to Claude Code and Codex. With the old line
restored they go red ("thinking held: first thought only 1.75us before
the text"). With emptyRetries' new branch broken by hand
(streamRetries+0), TestGeminiEmptyRepliesAskedAgain goes red with
"an empty reply"; green with both.
Run: go test -run 'TestGeminiEmpty|TestThinkingStreams|TestThinkingHeld|TestUncountedEmpty|TestReasoningLoop' ./internal/gateway: ok.
Break check repeated at push: the old `|| last && modelFamily(c.model)
!= ""` turns
TestThinkingStreamsWithNoOneElse/{gemini,chat_gemini}/v1/{messages,responses} red ("thinking held: first thought only 1.458µs before the text").
Full suite (go1.26.8 darwin-arm64, rebased on 0fe039f14): go test
-timeout 45m ./... gave 63 packages ok; internal/agent and
internal/gateway timed out at 45m with no test failed (load ~110 from
other sessions; deadline in TestJcode and TestVertexGeminiClients,
#2544 and #2870 seen again) and passed alone at that head: ok
internal/agent 1644.560s, ok internal/gateway 1397.712s. Rebased on
origin/main 4ae6c06dc, every package its new commits touch run in full
there: ok internal/agent 465.353s, internal/gateway 648.172s,
internal/sessions, internal/gui, internal/cli, internal/codexsummary;
gofmt -l on the changed files empty; go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./... clean; go build for
darwin, linux (nogui) and windows ok (at 0fe039f14).
Then rebased on origin/main 2201b6628 (one line in
internal/provider/migrate_qoder.go): ok internal/provider 608.249s; go
vet of internal/provider, internal/agent and internal/gateway clean.
2026-10-21 03:40:27 +08:00
yetone 5206177704 agent: a 1M model Desktop lists by its [1m] id is told by its 1M, not a 272K GPT's beside it (dumplings on Discord)
dumplings (magpie 0.1.1295, Settings > 长对话 "完整窗口"): the provider
model showed 1M and its 1M variant was picked in Claude Desktop, but
Desktop's Code tab still showed 272K. With Desktop on magpie, claudePlan
tells Claude Code the largest window of every model it can run there
(CLAUDE_CODE_MAX_CONTEXT_TOKENS) and holds the smaller ones to their own
with modelSettings.<id>.autoCompactWindow. A model handed by a "[1m]" id
counted toward that largest only when it was Claude Code's main model,
so a 1M model Desktop lists by its 1M id (DesktopLongest) beside a 272K
GPT left 272K the value told, and with it alone nothing at all.

Now every [1m] model counts by its window (1M when unknown), and the GPT
beside it gets its own 272K entry. The `main` field it needed is gone.

Tests: TestClaudeDesktopContextWindow1M (rewritten: glm listed by its 1M
id alone tells 1M; beside a 272K GPT, 1M told and GPT held to 272000),
TestClaudePlan's [1m]-beside-272K case and its 500K->1M expectations.
Broken by hand (`case m.long && false:`): both go red
(TestClaudePlan "magpie's default: 500000", TestClaudeDesktopContextWindow1M
"glm listed by its 1M id alone: \"\""); green with the fix.
Run: go test -run 'TestClaudePlan|TestClaudeDesktop|TestClaudeContextWindow|TestBudget' ./internal/agent: ok.
Break check repeated at push: `case m.long && false:` turns
TestClaudePlan ("magpie's default: 500000") and
TestClaudeDesktopContextWindow1M ("glm listed by its 1M id alone:
\"\"") red.
Full suite (go1.26.8 darwin-arm64, rebased on 0fe039f14): go test
-timeout 45m ./... gave 63 packages ok; internal/agent and
internal/gateway timed out at 45m with no test failed (load ~110 from
other sessions; deadline in TestJcode and TestVertexGeminiClients,
#2544 and #2870 seen again) and passed alone at that head: ok
internal/agent 1644.560s, ok internal/gateway 1397.712s. Rebased on
origin/main 4ae6c06dc, every package its new commits touch run in full
there: ok internal/agent 465.353s, internal/gateway 648.172s,
internal/sessions, internal/gui, internal/cli, internal/codexsummary;
gofmt -l on the changed files empty; go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./... clean; go build for
darwin, linux (nogui) and windows ok (at 0fe039f14).
Then rebased on origin/main 2201b6628 (one line in
internal/provider/migrate_qoder.go): ok internal/provider 608.249s; go
vet of internal/provider, internal/agent and internal/gateway clean.
2026-10-21 03:40:26 +08:00
yetone 4ae6c06dc3 docs: gateway-routing says how magpie's Codex compaction is made portable
The magpie1: item, the message codexInputAs sends for it, and
sessions.PortCodexRollouts: what it changes, the writer-lock protocol, when
it runs, what was tried (Codex 0.162.1 resume against an upstream that
refuses magpie1: as OpenAI does) and what wasn't (a Codex in WSL).
2026-10-21 03:05:24 +08:00
yetone f1e4516da2 gui: Codex's and Claude Code's own settings are in the agent's row on the Agents page, not in Settings
The owner, 10-20: Settings › General held Codex subagents, Long
conversations, Codex background compaction, thread titles, thread
descriptions, composer predictions, the auto-review model and the
memories model, apart from the agents they set; "很割裂、很分散,不直观".

They now sit with their agent (AGENT_PREFS): in its opened row on the
Agents page (a Settings list in connectPanel), in a sheet from the
tray panel's row ("Settings" line, openAgentPrefs) and from the agent's
menu ("{agent} settings"). Each row is the one element moved between
those places, so its handlers and state go with it. Settings' search
still finds them, with a row that opens the agent's sheet
(#agentPrefLinks). A gateway has no Agents page and none of them.
Strings for zh, zh-TW, ja and de; docs (reference, agent-wiring,
gui-shell) point at the new place. app.js 1,277,298 bytes and the core
scripts 1,469,058, so both budgets rise.

Run on 6416d639c (the dialog morph, on origin/main 75e769a9f), macOS,
playwright 1.62.0:
- agent-prefs.test.cjs (new) plus the 10 migrated files (codex-titles,
  codex-descriptions, codex-auto-review, codex-predictions,
  codex-memories-settings, codex-async-compact, compact-at,
  settings-general, bare-ids, gateway-mode) and modal-morph: 152/152,
  chromium and webkit, every language, wide and 420px.
- go test ./internal/gui/: ok after the budget rise.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.

Two GUI tests leaned on the Agents page's old height and are moved with it:
agent-models-loading clicked "elsewhere" at (900, 650), which is now
Codex's Disconnect button in its opened row, so it clicks the page's lead
line; agent-expand-steady clicked Goose's row while Codex's opened row
(~554px with its settings) pushed it out of a 560px view, so it wheels
Goose's link into sight first (reader.cjs reach). codex-subagents-lead
and agent-models-redraw clicked controls below Codex's opened row and
timed out in WebKit ("outside of the viewport"); they wait for the row to
finish sliding open, then wheel the control into sight. With Settings ›
General shorter, segs-press-redraw's sweep left Usage's warm-up tabs
above the view in WebKit; it wheels them back when they are. panel-effort
opened Kimi's row below Codex's opened one the same way. login-allow's
wheel loop read the shorter General page's button 50ms after each wheel and
clicked beside it (de, 440px); it uses reach. mobile-web shut each agent
picker by tapping the Agents tab, which a picker opened low in Codex's
taller row covers on a phone; it taps the header's name (the lead line
can sit under the header's tabs, and a tap there opened Library), wheels
each row and field into sight before tapping it, and says which agent and
field a step timed out on. All seven pass in Chromium and WebKit.

After the rebase onto main (32 commits on), with the test fixes above:
- go test ./internal/gui/ ./internal/plugin/ ./internal/agent/ ok;
  gofmt -l clean; go vet GOOS=linux -tags nogui and GOOS=windows.
- 95 GUI files (every agent-, codex-, claude-, settings- and modal- file,
  and every file either side changed): 1375 pass; the 8 reds were
  segs-press-redraw, fixed above. The 16 other files that click an
  Agents row: 369/370, rail-tip red on main too (#3091).
- The full suite's reds are listed in the dialog morph's commit; each was
  run alone on this head and on origin/main.
- mobile-web's "desktop matches origin/main" compares Settings and the
  Agents page with main's assets, so it is red until this is on main; its
  phone checks pass in Chromium and WebKit.
2026-10-21 02:06:23 +08:00
yetone 0fe039f14d gateway: Ollama's /api/chat and /api/generate, for Zed's Ollama provider (super_lalalalala on Discord)
Zed's Ollama provider chats on POST /api/chat, which magpie answered 404:
it served only /api/version, /api/tags and /api/show. Both routes are now
served on the mux, so lanGuard, counted, corsGuard, callerGuard, withCaller
and keyLimited cover them as they cover /v1/chat/completions. The body is
turned into a /v1/chat/completions body and handed to the same
handle(provider.Chat) on a clone of the request, so routing, a key's models,
usage and errors are the /v1 path's own.

Request (ollamaChatBody, after Ollama v0.12.6's api/types.go and Zed's
crates/ollama):
- messages: images as data-URL parts (type sniffed); a tool message's
  images in a user message after it; an assistant's thinking as
  reasoning_content; tool_calls given ids when Ollama sent none, and
  arguments sent as a JSON string;
- a tool result goes with its call by tool_call_id, else tool_name (what
  Zed sends), else in order; one with no call is a 400;
- /api/generate: system, prompt and images as a two-message chat;
- tools, format ("json" or a schema), think (a level is
  reasoning_effort, false hides thinking in the reply);
- options: temperature, top_p, seed, stop, presence/frequency penalty,
  num_predict > 0 as max_tokens; num_ctx, top_k and Ollama's other own
  options are dropped.

Reply (ollamaWriter): NDJSON lines unless stream:false, then one object;
message.content/thinking (or response) as they arrive, tool calls with
an id and their arguments as an object, and a done line with done_reason
(stop or length) and the token counts. An error is {"error":"..."} with
the status /v1 gives. A request with nothing to say is answered
done_reason "load", as Ollama warms a model.

/api/show took "plan/seer:latest" (what `ollama run plan/seer` asks for)
as unknown and the CLI then tried to pull it; ollamaName now gives the
bare id for show and both chat routes.

Broken by hand, each red: tool_name ignored, tool-call ids not kept,
arguments as a string, num_ctx passed upstream, status 200 on an error,
thinking kept with think:false, no route, and /api/show without
ollamaName (plan/plain:latest 404).
Real client: a sandbox gateway (magpie serve, sandbox HOME and
XDG dirs, MAGPIE_ADDR=127.0.0.1:3592) over a fake OpenAI upstream on
3591, with the ollama CLI 0.6.8: `ollama list` lists plan/seer,
`ollama show plan/seer` prints it, `ollama run plan/seer "hi"` and
`ollama run plan/seer:latest "hi"` print the upstream's streamed
"Hello from the sandbox gateway" (the :latest one failed with a pull
error before ollamaName). curl /api/chat and /api/generate, streamed and
stream:false, and a chat with tools, a nameless tool call and a
tool_name result: NDJSON/whole replies, upstream got ids paired and no
num_ctx. Zed itself not run (it would read the live Zed settings).

Run: gofmt -l (none); go vet ./... on darwin, GOOS=linux -tags nogui and
GOOS=windows: clean. `set -o pipefail; go test -timeout 45m ./...` at
1ebda9026 (this batch on 318697dce, movers then at qoder 0.2.21,
workbuddy 0.1.26, no devin raise): 65 packages ok, exit 0. Rebased onto
a9304efe0 (codex images, codex list tag, sessions decoders): gofmt, the
three vets and go test of internal/gateway, internal/provider,
internal/plugin and internal/sessions ok. Then the mover mins were raised
to qoder 0.2.23, workbuddy 0.1.27 and devin 0.1.21 (the only change
since, three strings): gofmt, the three vets of internal/provider and
go test ./internal/provider/ ok at the head of this batch.
2026-10-21 01:11:05 +08:00
yetone 489d816213 agent: dsh's wiring round does nothing when nothing it reads changed
A user's live heap profile showed 35.7 GB allocated in 48 minutes with
~157 MB live. 12.1 GB of that was one path: KeepDshWired -> keepDshWired
-> dshWiredOnce. It runs every 30 s, and each time it rebuilt the whole
catalog and every route, only to write nothing. Within it:
magpieModels("dsh") 9.5 GB, dshRouteAgain 4.8 GB, dshPutRoute 3.8 GB, and
Exposed/Catalog/heldOf/entriesOf ~7.7 GB under them. heldOf caches only
during a Hold.

What changed:
- provider.StampNow (hold.go) records what the catalog is built from,
  without building it:
  - held.gen, which Changed and a plugin's change move
  - filememo.Gen
  - the environment
  - the stat stamps of providers.json, settings.json and the catalog's
    cache file, which another process's writes move
- keepDshWired keeps a dshRounds between rounds.
  - It builds magpieModels again only when the stamp moved, or when its
    models are dshModelsFor (5 min) old. The 5-minute rebuild covers what
    no stamp sees: another app's account file, or a model retired by date.
  - It skips the round when these are all the same as at the last round,
    and that round wrote nothing and left the files as it found them:
    - the bytes of dsh's files: every profile's cordis.patch.yml, the
      home layer, settings.yaml, .env, .credentials.yaml, config.yaml
    - the gateway URL
    - the hash of the models
  - A read error other than "missing" hashes as unknown, so the round
    runs.
- dshWiredOnce (Sync, Connect, tests) still always does a full round.
- No singleflight and no new lock: the round already runs under dshWrites.
- docs/subsystems/agent-wiring.md says so.

Not done: caching Exposed/Catalog/entriesOf outside a Hold. Their output
depends on time (retiredNow, disabledNow) and on files other apps write,
and nothing signals a change in either, so nothing would bound how stale
the cache gets.

Measured with a throwaway test in a sandbox HOME, on top of 4f044c24c:
12 providers from a real models.json, 270 models, 3 dsh profiles.
- Before, per round: 132.61 MB, 900,624 allocations (~265 MB/min).
- After, nothing changed: 0.26 MB, 119 allocations.
- After, models older than dshModelsFor: 30.77 MB, 88,336 allocations.
  The dsh parse and write are skipped because the models' hash is the
  same.
- Averaged over time: ~6.7 MB/min, against ~265 MB/min before.

New tests:
- TestDshRoundWithNothingChangedBuildsNothing: AllocsPerRun must be at
  most 300; it is 77 now.
- TestDshRoundAfterAChangeWritesAgain covers each change:
  - a provider saved
  - a setting saved
  - the patch list written over
  - providers.json written by another magpie
  - a change no stamp sees, picked up after dshModelsFor

Broken by hand, each went red:
- skip always off: the allocation test, at 2099 allocations
- stamp check removed: the provider, setting and another-magpie cases
- roots left out of the stamp: the another-magpie case
- aging removed: the unseen-change case
- file bytes left out of the sum: the patch-list case and
  TestKeepDshWiredWritesTheRouteAgain

Run at this tree. It is built on origin/main dee5c9d75 plus a cherry-pick
of 4f044c24c, which is not part of this commit.
- gofmt -l internal/agent internal/provider: clean.
- GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean.
- darwin go vet ./...: clean.
- set -o pipefail; go test -count=1 -timeout 45m ./internal/agent/...
  ./internal/provider/...: ok agent 2146.7s, ok provider 709.9s.
- An earlier run that also took ./internal/gateway/ and
  ./internal/catalog/:
  - catalog: ok, 6.5s.
  - gateway: hit the 45m timeout (FAIL 2701.3s). Other sessions' GUI
    suites had the machine at a load average of ~548. The output's tail
    was cut off, so which test was running isn't known. Gateway doesn't
    call StampNow or the dsh round. Not rerun at a normal load.
2026-10-20 20:32:05 +08:00
yetone 42e6aee534 sessions: the stats and id lookups don't build every session's subagents
Why: in a 48-minute heap profile of the user's magpie,
gui.combinedSessionStats → statsFor → StatsAndNative → statsIn
allocated 3.9 GB, and gui.warmSessions → Warm 5.7 GB. Their scans went
through assemble → subagentsOf → ccTask: the stats built every
session's subagents (each one's task read from its file), only to
count tokens and tell which sessions are listed. Every statsFor call
in the profile came from the warm-up's steps.

What changed:

- assemble is split. assembleListed holds the part that decides
  whether a session is listed and gives its agent, id, title, models
  and usage. assemble adds resume, carry, transcript and subagents on
  top.
- These callers now use assembleListed: the stats' native-key and
  summary loops (stats.go), Titles, the Codex provider lookup
  (codex_provider.go) and manage's id lookup.
- List, One and manage's listing still use assemble.
- The docs/subsystems/gateway-sessions.md subagent section says
  which callers build subagents.

Tests:

- TestStatsReadNoSubagentFile writes a subagent with no meta and no
  task in its first lines, then simulates a restart (Saved, Reset,
  memos cleared). It then runs StatsAndNative(0), StatsAndNative(30)
  and StatsFor(7) three times and expects 0 scans of that file. List
  still shows the subagent.
- Broken by hand: the stats back on assemble make it go red with
  "the stats read an unchanged subagent's file 1 times". Green again
  once restored.

Measured on a read-only APFS clone of the user's ~/.claude/projects
and ~/.codex/sessions/2026/10, in a sandbox HOME, at load ~500 from
other sessions. The whole series against origin/main dee5c9d75; this
commit is the change to the stats rows.

| Pass | origin/main | This series |
| --- | --- | --- |
| warm StatsAndNative(0) | 596.7 MB, 157,195 allocs, 6.2–9.0 s | 28.9 MB, 73,976 allocs, 0.08–1.1 s |
| warm StatsAndNative(30) | 594.9 MB, 6.8 s | 28.7 MB, 0.8 s |
| restart StatsAndNative(0) | 3,106.7 MB, 509,239 allocs, 30.0 s | 48.2 MB, 241,721 allocs, 1.9 s |
| restart StatsAndNative(30) | 594.9 MB, 9.6 s | 28.7 MB, 0.5 s |

Run at the final tree of this series:

- gofmt -l internal: nothing.
- GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean.
- go test -count=1 -timeout 45m ./internal/sessions/ ./internal/gui/:
  - sessions: ok, 366.7s.
  - gui: only TestMainWindowCorners failed, "measuring the windows:
    signal: killed". It also fails alone on an untouched origin/main
    export, at load ~500. Filed as #1936 and #2645. Every other gui
    test passed.
- go test -race -count=3 on the new tests: ok.
2026-10-20 20:32:04 +08:00
yetone a23fbaeadf sessions: a subagent's file is read for its task only when its meta names none, once per change
Why: a 48-minute heap profile of the user's magpie allocated 6.3 GB
in sessions.scanAt, 3.5 GB of it from ccTask. The user has 3,174
Claude Code subagent files, 1,798 of them over 1 MB. Two things
caused it:

- subagentsOf titled each one `cmp.Or(m.Description,
  ccTask(f.path))`. Go evaluates both arguments, so every subagent's
  file was read for a first user line that was then thrown away
  whenever the meta file had a description, which is nearly always.
- ccTask kept only a found task. A file whose first 16 lines name
  none was read again on every ask.

What changed:

- Claude Code and Kimi subagent titles read the file only when the
  meta (or the spawn record) gives no description.
- ccTask keeps what it read, a task or none, with the file's size and
  mtime from before the read. An unchanged file isn't read again. A
  grown, rewritten (even at the same size), or touched file is read
  again from its first lines.
- A read that fails keeps the last good result, and a deleted file
  gives "".
- A line appended while the file is being read changes the size, so
  the next ask reads it.
- The docs/subsystems/gateway-sessions.md subagent section says so.

Tests:

- TestSubagentTaskReadOnlyWhenTheFileChanges counts scans through
  scanHook for these cases:
  - first ask: 1 scan;
  - unchanged: 0;
  - grown with a task: 1, then 0 once found;
  - grown after the task: 1;
  - rewritten shorter: 1;
  - rewritten with no task: 1;
  - same size with a new mtime: 1;
  - a task appended past line 16: 1 scan, still "";
  - appended during the read: found on the next ask;
  - deleted: "", 0 scans.
- TestSubagentWithMetaTaskIsNotReadForIt lists a session after a
  simulated restart (Saved, Reset, memos cleared) and expects 0 scans
  of a subagent whose meta names its task.
- Broken by hand:
  - ccTask back to keeping only a found task (`t.task != ""`) makes
    the first test go red: "unchanged, no task yet: 1 scans, want 0".
  - The title back to cmp.Or makes the second go red: "the list read
    a subagent's file 1 times for a task its meta names".
  - Both green again once restored.

Measured on a read-only APFS clone of the user's ~/.claude/projects
and ~/.codex/sessions/2026/10, in a sandbox HOME, at load ~500 from
other sessions. Times are noisy; allocations are not. Restart, then
List(All):

| Code | Allocated | Allocations |
| --- | --- | --- |
| ccTask keep, title still cmp.Or | 153.9 MB | 270,838 |
| this commit too | 25.8 MB | 109,854 |
| origin/main dee5c9d75 | 301.1 MB | 80,004 |

The origin/main row also lacks the buffer pool (a later commit).

Run at the final tree of this series:

- gofmt -l internal: nothing.
- GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean.
- go vet ./internal/sessions/ ./internal/gui/: clean.
- go test -count=1 -timeout 45m ./internal/sessions/ ./internal/gui/:
  - sessions: ok, 366.7s.
  - gui: only TestMainWindowCorners failed, "measuring the windows:
    signal: killed". It also fails alone on an untouched origin/main
    dee5c9d75 export, at load ~500. Filed as #1936 and #2645
    (real-window AppKit tests killed at their deadline under load).
    Every other gui test passed.
- go test -race -count=3 on the new and neighbouring subagent and
  scan tests: ok.
2026-10-20 20:32:04 +08:00