e6bed2f0638cb4e2bfbb96f3ba001600718fd600
822
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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 |
||
|
|
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. |
||
|
|
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
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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 |
||
|
|
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 |
||
|
|
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
|
||
|
|
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 |
||
|
|
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 (
|
||
|
|
ca4a1cde0d |
dsh: maxTokens leaves dsh half its window, or a quarter for output where that is more (#3298 item 3)
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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 |
||
|
|
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
|
||
|
|
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 |
||
|
|
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 |
||
|
|
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
|
||
|
|
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
|
||
|
|
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.
|
||
|
|
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 |
||
|
|
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
|
||
|
|
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. |
||
|
|
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 |
||
|
|
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 |
||
|
|
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
|
||
|
|
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. |
||
|
|
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
|
||
|
|
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. |
||
|
|
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
|
||
|
|
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
|
||
|
|
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 |
||
|
|
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 |
||
|
|
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
|
||
|
|
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
|
||
|
|
ba319a7587 |
gateway: the lone tool_choice none goes to the Grok plugin only (#3110)
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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 |
||
|
|
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 |
||
|
|
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 |
||
|
|
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
|
||
|
|
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). |
||
|
|
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
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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.
|
||
|
|
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
|