ac4af582301a4e8a29245dbba767eba31334ddf9
7089
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
0d2a101160 |
gateway: the Codex app's titles, descriptions and summaries go to the magpie model picked, not ChatGPT (atom_Ray on X)
atom_Ray on X: with a third-party model picked in the Codex app through
magpie, an hour of use still took 2% of the ChatGPT account's 5-hour
window, and at 0% left it could not be used at all.
The cause is the app's hidden side turns. ChatGPT.app 26.1013.40934 asks
for a thread's title, description and one-line summary
(ThreadMetadataGenerationService.generateTitle/generateDescription/
generateSummary in .vite/build/main-CLu1A25j.js; R0/z0/B0 via H0 and Jq
in src-DsLVGakC.js) on ephemeralGenerationModel, gpt-6-luna by default,
whatever model the conversation is on. A summary is asked after each
user and assistant message (bAu in app-initial). With magpie's model
beside the ChatGPT sign-in (openai_base_url), these reach
/backend-api/codex as gpt-6-luna. codexTitlesTo and codexDescriptionsTo
left an unset setting on the model Codex asked for, and thread_summary
had no route at all, so all three went to ChatGPT on the user's sign-in.
Now, with Codex's config model one of magpie's and magpie not Codex's
provider (agent.CodexSideModel, through gateway.CodexSideModel),
codexSideTo sends titles, descriptions and summaries on the Codex
backend path to that model. On Codex's own model nothing changes, and a
model the Titles or Descriptions setting names still wins. Summaries get
the same wrapper as descriptions (codexShaped): the plain answer is
handed back as the {"summary": ...} the schema asks for, with
compactSummary filled and cut to its maxLength (summaryJSON). This also
covers a summary on magpie's own API, where a Chat model's plain answer
was dropped by the app. No prompt, instructions or base_instructions are
changed: the request is sent to another model as Codex wrote it.
Run (this change on origin/main
|
||
|
|
0e643b14e4 |
sessions: a screenshot's line is read thinned, not gathered whole (#3318)
A cold read of the sessions gathered every long line it read whole
(takeLong), to take a timestamp, a folder and a session id off it. In a
10GB Claude projects folder and a 50GB Codex sessions folder the lines
behind that were Claude Code tool results holding a screenshot twice
(message and toolUseResult), Claude Code's api-request-blob lines (up to
15MB) and 154 Codex prompts with screenshots (5 to 15MB a line). Spread
over the read's workers they held 130 to 154MB live at its peak.
scanThin hands such a line on thinned, a chunk at a time, never whole:
- Claude (summary and calls): a user line whose message is a tool result,
or a line of Claude Code's own other than a title or summary (both read
only for keys, timestamp, folder and session id), has every string cut
to 4KB.
- Codex (summary): a line the head lets through has only its data: URLs
cut; a prompt's text is kept whole.
Every byte outside a string is kept, an escape is kept whole or not at
all, and a cut never splits a rune, so the line stays JSON and a search
for a quoted key finds what it found before. Lines over maxLine are still
passed over.
Run:
- TestThinnerKeepsJSON: 200 rounds of random chunk splits (1 to 7 and up
to 9000 bytes) over a line with escapes, \u surrogate pairs and CJK;
red when escapes are ignored.
- TestThinToolResultReadsTheSame: claudeLine (main and not) and
claudeCallLine give the same state thinned as whole over two 3MB tool
results; a thinned read allocates under 3MB (red at 7.9 to 8.4MB with
the thinning off).
- TestThinCodexKeepsPromptText: codexHead+codexBody give the same state
with a 3MB image cut, the 21KB prompt kept whole; red when every
string is cut.
- go test ./internal/sessions ./internal/gui ./internal/usage
-timeout 45m: sessions and usage ok; gui red in
TestRestartHandsTheGatewayOver (12 of 13 requests answered, a reset),
which is #3451; alone -count=3 ok.
- GOOS=linux and windows go vet -tags nogui ./internal/sessions, gofmt.
- Real use: magpie web --gateway under a sandbox HOME whose
.claude/projects and .codex/sessions are the owner's real ones (10GB
and 50GB), caches cold, /api/sessions?limit=50 then the 7 and 30 day
overview (load ~40 on the machine):
before (
|
||
|
|
3a47e377e0 |
usage: a call whose vendor counts no cache is left out of every hit rate (#3464)
#3464 (zeewell on X): Kiro caches on its side, but its replies give only credits and a context share, never cache tokens. Every hit rate outside the Routing page read those calls' CacheRead of 0 as a miss. A Kiro-heavy day showed "hit rate 6%" when the counted calls hit 90%. The plugin already says so (opencode-kiro-auth 0.1.16 sends usage.magpie_cache_unknown), and the gateway already kept it as RouteUsage.CacheUnknown for Routing. This carries it the rest of the way: - gateway: Usage.cacheNotCounted() (the vendor said so and no try reported a cache token) goes into usage.Record.CacheUnknown on every path that records a call: the gateway's own record, the OTel attempt path in observe.go, and trace's routeUsage. - usage: Record.CacheUnknown is kept as ledger row flag 8192 (rowCacheUnknown; grepped, no other flag uses that bit). Totals sums such calls' prompt into cache_unknown and counts them in cache_unknown_calls. Totals.HitRate leaves that prompt out of its denominator, and gives no rate when nothing is left. - Old records: calls kept before the plugin said so carry no flag. A Kiro call (provider kiro or kiro-plugin) with no cache counted is read as uncounted (usage.CountsNoCache): in the ledger's row read, in Totals, and for Routing's history in internal/gui/trace.go (cacheCounted). The rule is scoped to Kiro's two ids, so another vendor's 0 stays a miss (tested). - GUI: cacheHitOf in app.js drives the tray panel's card, the Usage page's agent rows and cache tile, the requests' Cache hit rate card and each ranking row. When only uncounted calls are left it shows "—" or nothing instead of 0%. Otherwise it says "{n} requests left out: their vendor doesn't count the cache". A request row's cache cells show "—", and its details say the vendor doesn't count the cache. The Context page (context.go, context.js) shows no cache for such a call and doesn't score it as a miss. - No budget raised. This adds 625 bytes to app.js (1,320,224 to 1,320,849, under its 1,321,336); |
||
|
|
e57e785633 |
gateway: a rewritten body is written back by marshalJSON, not json.Marshal (#3394)
withReasoningText runs on every replayed request to DeepSeek and the
like (#1104), and wrote the whole body back with json.Marshal twice:
once for the input list, once for the body around it. encoding/json
writes a json.RawMessage through its scanner, a call a byte, so a long
conversation was compacted twice a request. marshalJSON (marshalRaw,
#1532) writes the same bytes, checked by jsonCheck and copied, and
falls back to json.Marshal for any other value; TestMarshalRawIsEncodingJSON
holds the two equal. The same body rewrites in affinity.go,
anthropic.go, codex_backend.go and limit.go took json.Marshal of a
map[string]json.RawMessage too, and use marshalJSON now. Nothing a
body goes out as changes.
Run:
- Real DeepSeek account in a sandbox HOME, magpie serve on 3482, 12
streamed /v1/responses requests of a synthetic 1.5MB conversation with
Codex 0.162.0's real tools and a codex_cli_rs/0.162.1 User-Agent, CPU
time from ps, two rounds each:
|
||
|
|
b97e0aa2a2 |
gateway: spawn_agent is widened without writing the whole Codex body again (#3394)
Codex sends spawn_agent with every request, so spawnAgentModels ran on each one: it decoded the whole body into a map, decoded every input item into a map, and encoded the body again, so a long conversation was walked three times a request, and went upstream with its keys sorted. It now takes tools (and input, only when it holds a tool_search_output) with topMember, widens them as before, and puts the new values back in place (withMembers); every other byte goes on as Codex sent it. Only a tool_search_output item is decoded and written again (moreSpawnItem); an input with an item that isn't an object no longer stops the others being widened. Run: - A 1.6MB body (Codex 0.162.0's tools from testdata, 300 tool outputs), 30 calls in a scratch test not committed: 16.4ms a call before, 2.3ms after. - Real DeepSeek account in a sandbox HOME, magpie serve on 3482, 12 streamed /v1/responses requests of a synthetic 1.5MB conversation with Codex 0.162.0's real tools and a codex_cli_rs/0.162.1 User-Agent (so the spawn path runs), CPU time from ps, two rounds each: |
||
|
|
d3fb381afe |
gui: Masking's bird sits in the middle of its ring; agents and providers show their logos
The flow's rule for its hairline layer, `.mo-mid svg { position:
absolute; inset: 0 }`, also matched the bird's svg inside .msk-hub, so
the 20px bird was pinned to the 30px ring's top-left corner (5px left
and 5px up). The rule is now `.mo-mid > svg`, and the hub's flex
centring places the bird.
Each agent and provider in the flow has its logo, from the same icon()
and maskWho icon the request rows already use: an agent's after its
name, a provider's before it, both on the side where the lines are. An
"N more" row keeps an empty slot so the names line up.
The test fixture's agent icons were "claude" and "codex", which aren't
icon files. They are now claudecode-color and codex-color, as the real
agents have.
Run at
|
||
|
|
71fd92ddf7 |
saves: a routing group or provider saved answers before the agents' files are synced
CyberCaius on Discord (native Windows): "路由组和供应商编辑保存有时候保存会卡 很久才保存成功", at least 3s, while an agent's request runs. Cause: every write of providers.json ends in catalog.Touched -> Changed, which was agent.SyncCatalog, run inside the HTTP request. It rewrites every agent's model list that differs. On Windows, a file another program holds open refuses the rename over it, and steady.Rename retries for 0.5s before giving up. So each such file costs a group save half a second, and a provider save, which stores several times, costs more. In WSL the same sync goes through wsl.exe and \\wsl.localhost. Fix: catalog.Changed is agent.SyncCatalogSoon, which runs SyncCatalog in the background (it already folds overlapping runs into one more round). A CLI command waits for those rounds at the end of run() (SyncCatalogSettled), so `magpie group add` still ends with the files written, and run() puts catalog.Changed back for tests. The GUI's direct SyncCatalog calls in providers.go (arrange, keeplogin, switchonly, login actions, sign-in import) use SyncCatalogSoon too. Run at the pushed head (parent |
||
|
|
d792e7ce4d |
gateway: a Codex request's client_metadata is read without decoding the whole body (#3394)
requestSessionMetadata is asked four or five times for every Codex
request (the title, description and prediction checks, the subagent
pick, serve). Each time it ran json.Unmarshal over the whole body to
read one top-level member, so a long conversation was walked again
and again. It now takes client_metadata with topMember, which checks
and splits a long body once, and decodes only that member. What a
body gives is unchanged: a body that isn't an object, or whose
client_metadata isn't an object or null, still falls back to the
x-codex-turn-metadata header. One difference: Go's struct decoding
matched the name without regard to case, topMember matches it
exactly; Codex sends it lower case.
Run:
- BenchmarkRequestSessionMetadata (5.8MB body): 12.7ms/op before,
0.50ms/op after (-count 3 each).
- Real DeepSeek account in a sandbox HOME, magpie serve on 3482, 12
streamed /v1/responses requests of a synthetic 1.5MB Codex body with
client_metadata (codexload.py, 2 at a time), magpie's CPU time read
with ps, two rounds each:
|
||
|
|
a84d2ec80f |
provider: two Codex windows no longer write client-shapes.json on every request (#3394)
SawClient keeps the headers a client last came with, and writes
client-shapes.json (read, unmarshal, marshal, synced temp, rename) when
they differ from what it last wrote. Each Codex window sends its own
X-Codex-Window-Id, which was taken as part of Codex's shape, so with two
or more Codex sessions on a keyed provider nearly every request rewrote
and fsynced the file. The window id and a retry's count
(X-Stainless-Retry-Count) are now left out, like the session and turn
ids already were.
Run (sandbox HOME, real deepseek account, three real `codex exec`
0.162.1 sessions through a -tags nogui build on :3482, 60s each,
counting the file's mtime/inode changes every 50ms):
origin/main
|
||
|
|
d08b6118bd |
agents: Restart a desktop app that started before magpie's change, after asking
微雨南山 and stones on Discord: Claude Desktop, WorkBuddy and the Codex
app read magpie's settings only as they start, so a change made in
magpie did nothing until they quit and reopened the app themselves.
The agent's row now carries a Restart when the app is installed, running,
and started before its config last changed (agent.AppBehind):
Claude Desktop, WorkBuddy and WorkBuddy AI on macOS (bundle executable
via pgrep), Claude Desktop and WorkBuddy on Windows (process tree, main =
earliest process whose parent is outside it). A press opens magpie's own
dialog first (confirmAction); Cancel and Escape send nothing. On accept
POST /api/agents/restart/{id} quits the app gracefully (AppleScript quit
on macOS; taskkill without /F on Windows, then /F /T after appCloseWait
for a tray that holds on), waits, and opens it again. On macOS an app
that won't quit is reported (StillOpen) and never forced. The Codex
app's existing Restart now asks first too. CLI agents get none.
changedAt: a stash digest that changed with no file written since the
app started now counts the change as now, so a change magpie made while
the app ran is seen (it was dated to the old write and missed).
app.js budget, not raised: archivePanel moved into plugins/usage/page.js
(its own comment called it the Usage page's; Routing's trace calls it at
draw time, after page.js has loaded), maskWho, maskProv and stillMotion
into plugins/redact, and usageHidOpen into plugins/usage. app.js is
1,108 bytes smaller than on main, budget unchanged.
Run (the first five at the pre-rebase head, same code):
- GUI agent-app-restart + agent-stale-copies: 120/0, chromium and webkit,
en/zh/zh-TW/ja/de, window 980 and 440 and panel 440, no sideways scroll,
no placeholder in aria-label or title.
- Broken by hand: without the confirm the GUI test is red; without the
changedAt fix TestChangedAtWithoutAWrite is red; without the since gate
TestWorkBuddyRestartOnMac and TestWorkBuddyRestartOnWindows are red.
- macOS, real fake-app processes in a sandbox HOME with a stubbed
launcher: quit in 100ms and reopened; a held quit returns StillOpen
after 4s, not forced.
- Windows box, console session (schtasks /IT), fake app and stub
launcher: graceful close in 407ms; a tray that holds on is ended after
5.66s; reopened through the stub.
- gofmt -l clean; go vet darwin (agent, gui), GOOS=linux and
GOOS=windows; builds.
- At 2c5327925 (on origin/main
|
||
|
|
aa3112f4e8 |
gui: the tray panel's fit() is back under app.js's budget
|
||
|
|
20d63621d1 |
gateway: once it rests 30s, what its requests left goes back to the system (#3472)
The tray showed 725 MB private working set with a 1088 MB heap and
315 MB live (#3472): Go's scavenger hands idle heap back slowly, so a
burst of large requests kept its peak long after it ended. When the
last counted request finishes, a timer runs debug.FreeOSMemory once
the gateway has had no request for idleRelease (30s); a request in
flight or one finished since pushes it back. GETs, /_magpie/ and /mcp/
are not counted, so polls do not arm it.
Run (real deepseek account, sandbox HOME, -tags nogui builds of
origin/main and this change, port 3482): 24 streaming requests of
600 KB each, 8 at a time, all 200. footprint -p (phys_footprint):
base: 77 MB after, 77 at +20s, 77 at +40s, 77 at +60s
new: 79 MB after, 79 at +20s, 55 at +40s, 55 at +60s
An earlier run of the new build had heapReleased 70.7 of 74.6 MB idle.
TestRestingGatewayHandsMemoryBack: green under -race -count=10; with
the arm in counted removed it is red ("released 0 times, want 1").
go test -race -run 'Resting|Busy|Restart|Handover|HandsOver|InFlight|
Panic|Concurrency|Heap' ./internal/gateway ok, and -count=3 of
Resting|Busy at
|
||
|
|
14b10f1166 |
library: an MCP server signed in to in Claude Code, in WSL too, says so instead of "needs sign-in" (CyberCaius on Discord)
CyberCaius signed in to a remote MCP server with Claude Code's /mcp in
WSL, and the Library still said 需要登录. The check connects as magpie,
without the agent's tokens, so an OAuth server answers it 401, and magpie
read no agent's own sign-in anywhere: not on Windows, not in a distro.
The check now reads each Claude Code target's .credentials.json, beside
the settings.json the target already has (readOwnSignIns,
mcp_agent_signin.go). A distro's Claude Code is a target under the
distro's home (wslTargetOf), so its file is read there through
\\wsl.localhost with no new setting. An mcpOAuth entry of the server's
name and URL with an access or refresh token, as Claude Code 2.1.310
counts one, names the agent in ServerHealth.AgentSignIn; the row says
"signed in in Claude Code (Ubuntu)" with the ok dot, and the tooltip says
magpie can't list its tools without signing in itself. An entry without
a token, another URL by the same name, and a file that can't be read or
parsed name nobody, so the row stays "needs sign-in". The tokens are
never sent or kept. A stopped distro has no target and isn't started.
On a Mac only the file is read, never the Keychain. The sign-ins are part
of the check's cache key, so a sign-in in the agent since isn't answered
from the session's earlier check. Strings in zh, zh-TW, ja and de.
Run:
- TestCheckNamesAgentsSignedInThemselves (internal/library): agent.FakeWSL
forces the Windows+WSL switch (Ubuntu running, its home a temp root),
sandbox HOME/USERPROFILE/XDG_CONFIG_HOME, CLAUDE_CONFIG_DIR cleared, a
real httptest server answering 401 with WWW-Authenticate.
- Broken by hand, each red with a FAIL naming the behavior:
- the old behavior (the reader names nobody): reading only this
computer's Claude folder (claudeDir()) instead of the target's:
"signed in in claude@wsl:Ubuntu, the check says {State:auth ...
AgentSignIn:[]}".
- counting an entry with no token: "a sign-in with no token counted".
- leaving the sign-ins out of healthKey: "signed in on both sides, the
check says ... AgentSignIn:[claude@wsl:Ubuntu]" (stale cache).
- library-mcp-health-wsl.test.cjs, chromium and webkit, en/zh/zh-TW/ja/de:
red on the old client.js (expected "signed in in Claude Code (Ubuntu)",
got "needs sign-in"), 12 of 12 after.
- gofmt -l (nothing); go vet on darwin, GOOS=linux -tags nogui and
GOOS=windows for ./internal/library ./internal/gui; go build darwin,
GOOS=windows and GOOS=linux -tags nogui ./...; go test -tags nogui
-count=1 -timeout 45m ./internal/library ./internal/gui: ok (187s, 63s).
- GUI: library-mcp-health, library-mcp-health-wsl, mcp-signin-health,
mcp-signin, mcp-oauth-app, library-mcp-tools, library-mcp-tool-switch,
library-mcp-unshown, library-items, i18n-keys, gui-zh-tw, gui-ja,
gui-de: 161 of 161 pass.
These ran first at a base before origin/main
|
||
|
|
35fbc60d0b |
gui tests: library-mcp-health-wsl expects the Japanese the GUI says now (#3350)
|
||
|
|
1f589e3f4f |
usage: read today's usage ahead at startup
CyberCaius (Discord, Windows): "今天 N 次调用" is slow on the first
panel open after a start. The first usage?period=today parses
usage.jsonl: 0.33s for 2MB, 0.43s for a 40MB sandbox log here, more
on a slower disk. startBackend now runs usage.ReadAhead() in the
background, which works out today's summary into the summary cache,
so the panel's first ask finds it.
Parallel parsing was not done: with the read ahead, a request 1s
after start answers in 1-2ms, so there is nothing left to win there.
Test: TestReadAheadLeavesTodayNothingToRead. After ReadAhead, a
SummarizeTopIn(Today) parses nothing and works nothing out. Red with
ReadAhead's body emptied ("parsed the log 1 more times and was
worked out 1 more").
Run at tree 53ae48f72 (on origin/main
|
||
|
|
2a8a177466 |
gui: the tray panel fits its tallest tab whole, and Routing's first open holds its height
CyberCaius (Discord, Windows): the tray panel jitters or shows a
scrollbar, and today's call count is slow on the first open.
- fit() measured the sections alone, so the view's padding, the gap
under the tabs and what sits around a section were left out: 10px
short on Routing, 31px with 8 agents. It now lays out every section
at once (no data-ptab for the measure), sums each tab's sections by
their margin box, skips what is display:none, and adds what lies
outside the view. It never shows one tab after another: hiding the
open tab ends its running transitions (panel-fold's unroll,
tray-cell-click's refresh).
- Routing's placeholder was three short bars, and the panel grew when
the trace landed. It is now a hidden copy of the stage and six
request rows, so it is as tall as what comes.
- Today's line (usage?period=today) is asked for when the page is
built, not after the first trace.
Test: internal/gui/tests/panel-fit-tabs.test.cjs, chromium and webkit
x en, zh, zh-TW, ja, de. 8 and 2 agents: no tab overflows the fitted
panel. Trace held: today's 42 shows before it, the fit is the same
after it, Routing doesn't overflow. Scrolled by wheel in a 220px
panel: fit(40); fit() leaves scrollTop where it was, with no scroll
events.
Run at tree 53ae48f72 (on origin/main
|
||
|
|
7034378669 |
zcode: the Start Plan's 405 code 3012 says ZCode blocked the account, and rests it as restricted (plugins#348)
Since 10-24 many ZCode Start Plan accounts get 405 {"code":3012,"msg":
"request has been blocked due to unusual activity."} on every request.
On several of them ZCode's own app (3.16.3) gets the same 405, and
ZCode's support bot calls 3012 risk control on the account. magpie said
"though magpie sends it as the ZCode app does; it can be a network block
of this IP", rested the account as an unknown failure, and asked it again
soon after.
- provider.ZCodeRestrictedHint: the words @magpie-community/opencode-
zcode-auth 0.1.27 puts after ZCode's own ("ZCode's risk control blocked
this account for unusual activity (code 3012); it rests, and the
group's other providers are used. If the ZCode app fails on this
account too, only ZCode support can lift the block").
- gateway: restrictedSaid reads those words as failRestricted, as
WorkBuddy's 11140: the account rests restrictedRest (2h), the next
member is asked, and the Routing page's lift button brings it back.
- Routing page: the hint replaces the old one, in zh, zh-TW, ja and de.
- zcode mover min 0.1.27 (npm view --prefer-online: 0.1.27).
Not proven: why ZCode flags these accounts. Diffed against ZCode 3.16.3's
glm/zcode.cjs: the Start Plan goes unsigned there too (client request
signing is off for zhipu-account start-plan), and the headers match the
plugin's. Not tried with a real blocked account.
Run (sandbox HOME, at this tree): go test ./internal/provider ok;
go test -tags nogui ./internal/gui/... ok; go test ./internal/gateway
-run 'ZCode|Restricted|Blocked|EdgeBlocked|Moved' ok, and the new
TestZCodeStartPlanBlockRestsRestricted is red with routing.go reverted;
go vet darwin, linux, windows on provider and gateway ok; gofmt clean.
GUI (Playwright 1.62.0, chromium + webkit): routing-zcode-blocked,
i18n-keys, routing-blocked, routing-wb-restricted, gui-de, gui-ja,
gui-zh-tw: 41 pass, 0 fail. Not run: the full ./... suite (the machine
had a queue of full suites at load ~120).
|
||
|
|
d301dbce45 |
Merge origin/main into the #3493 summary-window fix (v0.1.1417 is tagged at ccf403bda)
|
||
|
|
1cdc3a59fe |
gui: Codex has one subagent model, Same as the lead or one model for every subagent
The owner, looking at Codex's New sessions line: two squares, subagents
and subagent model, read alike and nobody could tell them apart ("这两个
用户压根分辨不出来区别"). One was Codex's own [agents]
default_subagent_model, a model a subagent starts on only when its lead
names none; the other magpie's, which puts every subagent on one model
whatever the lead asks for. They are one setting now:
- Codex's card shows the subagent model alone. Unset it says "Same as
the lead" (跟主代理一样): each subagent runs on the lead's model, or on
another the lead picks for it. A model picked: every subagent runs on
it, whatever the lead asks for. Its picker opens on Same as the lead,
the lead's model in the note. With no model of magpie's to pick there,
Codex's own square stays as it was.
- Codex's sheet has the same setting as a row with a name, Codex
subagent model, beside Codex subagents on any model, as the memories
model got one when its square wasn't found (Hu9956).
- A model Codex's config still has in [agents] default_subagent_model
is said on the square, which is lit: "Codex's config still starts
subagents on {model} when the lead names none; picking here replaces
it."
For users who set default_subagent_model themselves: a pick in the
subagent model, Same as the lead too, removes it from Codex's config
(and a subagent effort the subagents' model no longer has), so the one
setting shown is the one that holds. Until they pick, it stays and is
said on the square. The CLI and profiles keep the subagents field.
Claude Code's, omp's and Claude Desktop's subagent squares are unchanged.
Every new string has zh, zh-TW, ja and de. app.js grows 4,011 bytes,
the Agents page's, which the tray panel draws too: the core budget is
raised to it, with no room added, and says why.
|
||
|
|
ccf403bda9 |
sessions: the Sessions list keeps a Claude file's window in sessions.json, read on after a restart (#3493)
The summary's Claude revision window (state.Claude) was json:"-", and a Claude file's parse with no window starts again from byte 0. So after every restart, which is every update, the Sessions list read each grown Claude session from its first line: the live 2 GB session on the owner's machine took seconds of the first list. state.Claude now goes into sessions.json as its bounded window (claudeUsageState MarshalJSON/UnmarshalJSON, the entries in eviction order; window() and claudeWindowOf are shared with the calls .rev sidecar). It is bounded by claudeRevisionEntries and trimSummaryRevisions as in memory. A sessions.json from an older magpie has no "claude" and reads from the start as before; an entry without a contribution is skipped, so a bad window never loses the whole index. #697 kept message maps out of the index because they were unbounded; the window is bounded now, so TestClaudeNativeReplayAcrossReadersAndRestart checks the kept window's weight instead of its absence, and TestQoderUsageAfterWindowLoss's restart case strips "claude" from sessions.json to stand for an older index. Real data (a sandbox HOME with the owner's real ~/.claude and ~/.codex, read only): cold Sessions list after a restart with the live sessions grown, 6.3s with the 2 GB file reparsed -> 0.77-0.96s over three runs, only small subagent files reparsed. sessions.json: 7 windows, ~1 MB of 21.7 MB. Run at this tree: go test -count=1 -timeout 45m ./internal/sessions ./internal/usage ./internal/usageapi ./internal/gui ok (sessions after the two test updates); go test -race ./internal/sessions ok; GOOS=linux and windows go vet -tags nogui ./internal/sessions ok; gofmt clean. TestClaudeSummaryReadOnAfterRestart is red with the tag back at "-" (the summary is read again from its start, its marker lost). |
||
|
|
ff6f3188bd |
sessions: a grown Claude file is read on after a restart, with the window it had (#3493)
A Claude Code session's revision window lived in memory alone, so after
magpie started again (every update), or let a ninth live session's
window go, each Claude file that had grown was read again from its
first line. On the owner's real ~/.claude a live 2 GB session and a
372 MB one were read whole for the first Requests page: 2.4 GB, 7.4s.
The window is bounded (claudeRevisionEntries), so readCalls now keeps
it beside the file's shard (<hash>.rev, temp and rename, ~60 KB), with
the Off and ContentHash of the read that made it. A read whose old
state has no window takes it from there when both match, and reads on.
A file no longer being worked on drops its window as before, and its
.rev with it; pruneCalls takes away a .rev whose shard is gone.
Measured (internal/gui handler, sandbox HOME with the owner's real
~/.codex and ~/.claude, 15,553 sources): the first ledger week after a
restart 7.4s -> 1.7-2.4s across three restarts; 14 .rev files, 8-67 KB.
Run at this tree: go test -count=1 -timeout 45m ./internal/sessions
./internal/usage ./internal/usageapi ok; GOOS=linux and windows go vet
-tags nogui ./internal/sessions ok. TestClaudeFileReadOnAfterRestart is
red with withCallRevisions turned off ("read again from its start"),
and checks the calls read on equal a read from the start, a revised
recent message included.
The Sessions summary's own Claude window, in memory alone the same way,
is kept by the next commit.
|
||
|
|
3b5a2f612d |
dsh: Max reaches GLM-5.3 as max, asked adaptively with its level
01huadalang on Discord (10-24): DSH Desktop on magpie-anthropic, zcode
GLM-5.3 at Max; magpie's Routing log showed 77 of 78 requests at low,
one at high, never max.
What DSH sends, from the real app (DSH Desktop 0.2.1-rc.3's app.asar,
pi-ai 1.1.0 and dsh-llm-pi-ai, run read-only through node with
magpie's GLM-5.3 entry): at Max and at High alike, max_tokens 128000
and thinking enabled, budget_tokens 16384. pi-ai's clampReasoning turns
xhigh and max into high before thinkingBudgetForLevel, so no
thinkingBudgets setting can give Max a budget of its own. At Low it
sends 2048; with reasoning off, no thinking field.
What magpie did with it: 16384 is read as high (effortOfBudget) and
sent as output_config.effort high, so Max could never reach max. The
"low" rows were not reproduced: no request DSH builds at Max reads as
low here, and Z.ai refused none of the shapes (live, below), so no
refusal memory lowered it. A 2048 budget (a session or a subagent DSH
runs at Low; dsh-tool-subagent lets the model pick reasoning_effort)
reads as low, and that is the likeliest source. It is asked of the
reporter.
The fix, zero-config: Z.ai's GLM-5.2 and GLM-5.3 (the GLM half of
effortInOutputConfig) are written into dsh's magpie-anthropic route
with compat.forceAdaptiveThinking (gateway.AdaptiveWithEffort, beside
AdaptiveThinking). MiniMax-M3.1-Flash, the other half, is left on its
budget: adaptive wasn't tried on MiniMax (no key), so it is on #3496. pi-ai then sends thinking adaptive and
output_config.effort from magpie's thinkingLevelMap, max as max
(checked against the real asar: low/high/max each go as themselves).
The gateway already passes adaptive thinking with output_config.effort
through for these models (fitted to their levels, withOutputEffort;
TestGLMEffortInOutputConfig pins it), so the gateway only gains
AdaptiveWithEffort. No client name is keyed on, and a budget alone is
read as before. An adaptive-to-budget rewrite in withOutputEffort was
tried first and dropped: TestGLMEffortInOutputConfig pins adaptive
passing through, and Z.ai takes it.
Live, Z.ai GLM-5.3 with the zcode key (sandbox script, key never
printed): adaptive and enabled+effort both accepted; effort max
thought 1237-1427 chars against 426 at high, so max is a real tier.
Run, at this head rebased on origin/main
|
||
|
|
40b5c2daf0 |
agent: say why Claude Desktop's 3p mode can't keep a Chinese language (Dx25 on Discord)
Dx25 (Windows) set Chinese and found %LOCALAPPDATA%\Claude-3p\config.json
back at "locale": "en-US" after every Desktop start. magpie doesn't write
it: config.json is touched only by desktopCarryLocale, at switch-on, and
only when it has no "locale" (TestClaudeDesktopKeepsThe3pLanguage,
TestClaudeDesktopUserEditsThenReapply). Desktop writes it.
Read from Desktop 3.6556.2's bundle (current RELEASES.json, 10-22): in 3p
mode the window is the bundled UI, Resources/ion-dist, with 11 catalogs
(en-US de-DE fr-FR ko-KR ja-JP es-419 es-ES it-IT hi-IN pt-BR id-ID) and
no Chinese; its locale is its localStorage, else navigator.languages
mapped onto those 11, else en-US. On mount it calls
electronIntl.requestLocaleChange(its locale), and the main process's
handler writes that value with store.set("locale", ...). The main process
has zh-Hans and zh-Hant catalogs (for the signed-in window), but the 3p
window asks for en-US on every start, so a Chinese locale, carried or
set by hand, is replaced each time. 2.7032 (this Mac) and 2.9939.2 (the
Windows box) have the same 11 in ion-dist. Nothing magpie can write
keeps Chinese in 3p mode; it is Desktop's missing translation.
This commit changes no behaviour: desktopCarryLocale's comment and
docs/subsystems/agent-wiring.md now say the above, where they implied the
carry kept a Chinese language.
Run at
|
||
|
|
3be1f14ebb |
usage: a re-read source asks Swapped once per model pair (#3493)
Swapped's regexps ran for every call of every file read again: a few hundred sent/served pairs over ~289k calls on the owner's real history, about a third of the re-read's pricing cost in a CPU profile. queryPage now keeps each pair's answer for the read. Measured at internal/usage with the owner's real ~/.codex and ~/.claude in a sandbox HOME: a heatmap read whose key changed, 3.0s -> 1.4s together with the heatmap's own page. Run at this tree: go test -count=1 -timeout 45m ./internal/usage ./internal/usageapi ok; GOOS=linux and windows go vet -tags nogui ./internal/usage ok. |
||
|
|
cf8b1e9338 |
usage: the heatmap works out only its days, kept 30s while only session files change (#3493)
The Requests tab asks for the year's heatmap on every ledger refresh. A live agent writes its session file all the time, so the page's key changed for every ask and the whole year was worked out again: groups, shares and series the heatmap never reads, over ~289k calls on the owner's real history. - buildRequestBlocks returns at once for the heatmap's period with only HeatmapOf's days, from the rows the chart filter keeps. - queryPage keeps a heatmap page 30s (heatFresh) while the gateway log's snapshot version is the same; a meta change (prices, names, wires) drops it, and a call through magpie shows at once. Measured at the handler (internal/gui, sandbox HOME with the owner's real ~/.codex and ~/.claude, 15,553 sources, 59.9 GB): heatmap steady refresh 2.99s -> 0.15s, cold 5.5s -> 4.5s. Run at this tree: go test -count=1 -timeout 45m ./internal/usage ./internal/usageapi ok. TestHeatmapKeptWhileOnlySessionsChange is red with the throttle taken out (builds counted twice). |
||
|
|
57a70aaf10 |
usage: a new Codex thread keeps the chunks read before (#3493)
Codex's thread identities were in the request index's meta, so every new
Codex thread, each subagent's included, dropped every chunk, and the next
Usage page read the whole history again: 7s on the reporter-sized
history here (15,553 session files, 418k calls). A chunk's rows don't
hold the identities; the page gives them to its rows as it is built
(cloneCodexChunks, codexIdentities). They now go in the key alone, which
drops only the built pages.
TestCodexNewThreadKeepsReadChunks writes a child thread, reads the page,
then writes its parent: only the parent's file is read again, and the
child's row names the parent's session. Red with the identities put back
in meta (both files read again).
Run at this head (origin/main
|
||
|
|
8c62702442 |
whatsnew: Settings lists every release up to the waiting update, not its notes alone
小八 on Discord (10-24): on 0.1.1398 with 0.1.1409 out, Settings › About ›
What's new showed 0.1.1409, then 0.1.1398 and older; 0.1.1399 to
0.1.1408 were missing.
Cause: openWhatsNew (app.js) took /api/whatsnew?all=1, which lists the
running version's notes (or those since the last upgrade), and put the
waiting update's own notes (/api/update's u.notes) on top. Nothing asked
for the releases between the running version and the update. The site's
/api/notes had them (checked live: after=0.1.1398&upto=0.1.1409 returns
all ten, 0.1.1407 was never released).
Fix: /api/whatsnew?all=1 now puts first, while an update waits (ready,
available, downloading, found), the notes of every release after the
running version up to it (withWaiting, through fetchNotes as the restart
dialog's update/notes has them), each marked pending ("Not installed
yet"); the site out of reach leaves the update's own notes, as before.
update.Note gets Pending. The page shows what the app sends, so
openWhatsNew no longer asks /api/update or merges (app.js 265 bytes
smaller). Not changed: the restart dialog (confirmUpdate) already asks
update/notes for the range; the popup after an upgrade lists after..now
through Between, which was right; the site's degraded path (API refused:
the Atom feed's newest 10 plus the last whole list) can still leave a gap
when more than 10 releases came out since the list was last whole.
Run (worktree at origin/main
|
||
|
|
63c0c354af |
gui: Discover is quieter: one unofficial mark, one button style, a reason in your language
Kiko03O1 on X asked for a better-looking Plugins › Discover page
("ui 设计能不能好看点"). Five things on it said one thing twice or said
it raw:
- A GitHub card had an "Unofficial" chip. A GitHub card is only ever
drawn in the 非官方插件 · GitHub section, so the chip repeated the
section's head on every card. It is gone from the card; the plugin's
page keeps its full warning.
- Sign in on a card and on an Installed row is tinted like Install,
not filled. It stays filled only in the plugin's sheet, so each level
of action has one look.
- The GitHub line said Go's English in the middle of a zh page ("no
answer in 8s"). internal/plugin's GitHub read now wraps its timeout in
ErrNoAnswer; /api/plugins/github passes `why`: "slow" for that or any
timeout, "limited" for GitHub's rate limit (ghtoken.Limited), and the page says "GitHub 响应超时" (zh, zh-TW, ja, de); the raw
error is the line's hover. The line is smaller and muted, and Retry
takes the accent colour.
- The second filter row's All had a count. It always equalled
Installed + Not installed and the first row's picked count, so
"全部 · N" showed twice side by side. It has no count now.
- Found on the way, same page: the filter box's placeholder was cut off
in en at 1280/1100/980 and in de at every width but 420. It fits at
every width now; the filter bar wraps where it did.
Looked at and left alone: the 8px inset on the borderless Signed in,
and the monospace version numbers.
plugins.js nets -25 bytes (the Unofficial chip's code went), so the
core script budget is unchanged: TestCoreScriptBudget passes at the
pushed head with no raise.
What was run, at this change on origin/main
|
||
|
|
0df6a3aba9 |
gui: Insights › Masking's request kinds and day names move into its plugin, and the core budgets go back to what they were
|
||
|
|
23cec6c4fb |
warm-up: an official reset after a spent reset card, nothing used between, is warmed (shangyuan0818)
shangyuan0818 on Discord (10-24): "Warm up on reset" on for the Codex
week. magpie spent a Codex reset card about to run out, the warm-up
after it started the week, nothing was used, then OpenAI reset
everyone's limits. No warm-up went for that second reset.
Cause: warmDue saw a reset only when the window's use fell (by 1 or
more) or its kept reset time passed. After the card and its warm-up
the window was running at 0% used, so the official reset had no use
to fall from, and the reset time kept (a week from the warm-up) was
still days off. The read after it shows the window not started (0%,
its reset a whole window from now), which nothing compared with what
was kept.
Fix: warmDue also counts a window as started over when it is not
started now (idle) and its reported reset is at least warmSlack later
than both the reset it was seen running to and the end of the window
magpie's last warm-up started (movedOn), or no reset is reported at
all. The second bound keeps a read that still carried an old reset
before showing the warm-up's own window from looking like a reset.
After the upgrade an account already in this state is warmed on the
next look: nothing for the user to do.
Siblings: the same warmDue runs for every ChatGPT account, the 5-hour
window ("all"), and Claude's warm-up (claude_warmup.go, same
codexWarmer), whose not-started windows Anthropic leaves out of the
read; each has a subtest. No other provider has a warm-up.
Tests: TestWarmAfterResetCardThenOfficialReset drives fake usage reads
through the reported sequence (card spent, warm-up, a third of the
window unused, official reset, then 12 more looks) for the Codex week,
the Codex 5 hours and a Claude week left out of the read, with a
second account running all along that must never be sent one.
TestWarmDue gets three cases. TestCodexWarmOncePerReset's last step
set two weeks warmed 10 and 35 minutes before to reset a full week
from now, which is what a not-started window reports; they now reset
a week from their warm-ups, as the backend reports a started window.
Broken by hand:
- old codex_warmup.go with the new tests: TestWarmDue "reset early,
nothing used before" and "... left out" due false, want true;
TestWarmAfterResetCardThenOfficialReset all three subtests "after
the official reset, sent [a@example.com]".
- movedOn's nil-reset branch returning false: the Claude subtest and
the "left out" case go red.
- movedOn without the warm-up bound: TestCodexWarmOncePerReset goes
red ("all: [a@example.com:5 hours b@example.com:7 days]").
Run at
|
||
|
|
dcfda5f166 |
gateway: a relayed Responses stream's tidies pass its events in place (#3383)
idTidy and phaseTidy each copied every event of a relayed Responses stream twice, once out of their buffer and again onto an output grown event by event, and dropped their buffer's bytes at each write so the next write took new ones. eventData copied each event's data even when it is one line, as nearly every upstream's is, and phaseTidy decoded a reply's whole last event into a map to find no message without a phase. - tidyEvents goes through a write's whole events into one output sized for them; an event that goes as it came is copied once, and the part of an event still coming moves to the buffer's front. - eventData gives a one-line event's data as ev's own bytes; its callers only read it. - phaseTidy.ended reads the output in place (anyUnphased, which agrees with unphased item by item) and decodes only when a message needs a phase. Measured with BenchmarkZZCodexStream (a 680 KB Codex /v1/responses stream through serve, kept out of the tree): 14.16 -> 12.53 MB/op, ~53,450 -> ~49,700 allocs/op. Run at this head: - go test ./internal/gateway -timeout 45m: ok (439s, at 848b3bf7e rebased on |
||
|
|
4b9694c34c |
gateway: a prompt's estimate reads the request's items in place (#3383)
promptBuilder decoded every item of a request through decodeJSON, which
copies each content and output RawMessage out of the body unless it is
at least 1/16 of a held body. On a long Codex conversation that is every
item, copied once per request on promptOf's goroutine. What the builder
keeps of the body lives no longer than the builder, and the body
outlives it (promptOf's request; promptPieces' kept body, whose pieces
are read out before PromptText returns), so its 18 decodes now use
decodeJSONView, which shares capped slices of the body.
Measured with BenchmarkZZCodexStream (a 680 KB Codex /v1/responses
stream through serve, kept out of the tree): 14.92 -> 14.16 MB/op,
~54,200 -> ~53,450 allocs/op.
Run at this head:
- go test ./internal/gateway -timeout 45m: ok (399 s)
- go test ./internal/gateway -run Prompt: ok
- gofmt -l clean; go vet ./internal/gateway on darwin, and GOOS=linux and
GOOS=windows with -tags nogui: ok
- Real DeepSeek (deepseek-flash, sandbox HOME with only that provider
copied), five Codex-shaped /v1/responses streams through a recording
proxy, built at
|
||
|
|
1184862583 |
agent: Codex background compaction writes the bare async_compaction = true where a Codex older than 0.163 reads the config (多喝热水)
多喝热水 (Discord #help, Windows, v0.1.1384, Codex desktop with ChatGPT
sign-in): Codex wouldn't open, "config.toml:154:1: invalid type: map,
expected a boolean". That line is the [features.async_compaction] table
|
||
|
|
1859da57bd |
gateway: readers of a rewritten request see its input in place (#3383)
Only the body a request arrived with is held (holdBody), so decodeJSON
shares a raw value with it and copies one from any other body. Once a
route rewrites a Codex request (its model, its fields), the new body is
held by nobody, and each reader that only looks at it copied the whole
input to do so: conversationID, hasSealedAgentMessage,
orphanedToolOutputs, joinToolRuns, pairToolItems, withReasoningText,
and affinity's seal and kind strippers. Each such copy was ~0.4 to
0.5 MB on a 680 KB request.
decodeJSONView is decodeJSON whose raw values always share the bytes
they came from, capped, for a reader that keeps nothing it decodes and
writes none of it. Those readers use it. Each one only reads, or builds
a new body with json.Marshal or marshalPlain (which copy), or returns
the body it was given. promptBuilder keeps raw parts past its return,
and parseResponses keeps its result, so both stay on decodeJSON.
Measured on the 680 KB Codex request benchmark (30x, 3 runs):
16.37 MB/op, 54,703 allocs/op -> 14.96 MB/op, 54,222 allocs/op (-8.6%).
What was run:
- TestDecodeJSONViewShares: q["input"], q["tools"] and an item's
content from decodeJSONView point into the body and are capped, and
decodeJSON still copies from a body that isn't held. With `share ||`
taken out of fillJSONIn it is red ("tools []: not body's own bytes,
capped"); restored, green.
- fjCompare checks decodeJSONView against json.Unmarshal on every seed
as it does decodeJSON.
- Real DeepSeek A/B through a recording proxy in a sandbox HOME, Codex
UA, 5 requests with a tool-call history:
|
||
|
|
2d21034d81 |
gateway: a decoded struct's keys are read without a string made for each (#3383)
fillJSONIn made a string of every member key of every object it decoded into a struct (unquoteJSON), then a []byte of that string to look the field up, and a []bool for each struct to see a key twice. A Codex request's history is thousands of small objects, so these were a quarter of its allocations. keyName gives a plain ASCII key's bytes between its quotes and leaves any other key to unquoteJSON as before, and the fields seen are bits of a uint64 unless a struct has more than 64 of them. Run at |
||
|
|
d7ad3f2a3e |
gateway: input scanners read a request's items in place, not copied (#3383)
Seven readers of a Responses request's input (the seal stripper and withoutKinds in affinity, hasSealedAgentMessage, joinToolRuns, orphanedToolOutputs, pairToolItems, withReasoningText) and the prompt builder decoded `input` into a []json.RawMessage. fillJSONIn clones each RawMessage under a sixteenth of the held body, so every item of a long Codex history was copied once per reader, per request. None of them keeps an item past its return (they marshal new output or assign into the slice), so inputList hands them elementsOf's capped subslices of the raw input instead. hasSealedAgentMessage reads an item's content the same way. Run at |
||
|
|
1537817e0d |
provider: a partners.json that doesn't parse is kept aside before a try writes over it (#3362)
loadPartners reads a partners.json that is there but doesn't parse as
an empty cache: no list, and no Seen. Before 603408f38 only a fetch
that got the list wrote the file, so the loss waited for one. Now every
try writes it before the fetch is sent (Tried), offline too, so the
first try after a start wrote the empty cache over it: Seen holds the
presets of partners no longer listed, which providers added from them
still use (their endpoints, regions and key page), and those were gone.
A failed read is unknown, not empty (docs/code-standards.md).
savePartners now goes through lastgood.KeepUnparsed first, as
balance_history, credits_daily and codex_switch do for files their
readers take as empty when they don't parse: such a file is copied
aside as partners.json.bad-<time> before it is written over, and a
file that can't be read at all (or a copy that can't be kept) is not
written over. A file not there, or empty, writes as before.
Old data: a file already written over by 603408f38 is not in any
release (603408f38 lands in the same push), so nothing is lost before
this; a partners.json damaged earlier was written over by the next
successful fetch, as it still is, now with its copy kept.
Run (tree of this stack, on
|
||
|
|
c5e71f7a0b |
netproxy: a system proxy read that answers within readWait is what the request waiting for it goes through (#3421)
Review of 3370a79f7 (JoeyWu-tech's #3421). Breaking its "a request waits for a read until since+readWait" by hand (wait = 0, so every request went on at once with the proxy held, Proxy{} on a first start) turned its tests red only through an incidental read count, not through what the wait is for: magpie started where only the system's proxy reaches the vendors sending its first requests through that proxy, not direct. TestQuickSystemProxyReadIsWaitedFor holds a read, starts a request, and answers the read at once with http://127.0.0.1:7890: the request must take it. Run (tree of this stack, go1.26.8, darwin/arm64): - wait = 0 by hand: red, "the first read answered at once, but the request waiting for it took {URL: Mode:...}" (no proxy). Restored: green. - go test -tags nogui -race -count=20 ./internal/netproxy: ok (72s). The stack's full-suite record is in the #3362 fix's body. |
||
|
|
93435f27dc |
docs: the partner list is fetched on a process's first ask and hourly, and by the gateway's magpie unasked (#3362)
providers-accounts.md still said the list is fetched every 6 hours. |
||
|
|
b18a6a080b |
gateway, cli: magpie goroutines writes the running magpie's goroutine stacks to a file (#3362)
#3362's second ask: an app stuck at something could only be read by killing it, which ends what was stuck. magpie heap and magpie cpu already ask the running gateway for a profile over loopback; magpie goroutines asks it for every goroutine's stack. That works on Windows too, where there is no SIGUSR1. GET /v1/magpie/goroutines (goroutines.go) answers the callers /v1/magpie/heap answers (profileRefused: a program on this computer over loopback, no browser mark, a loopback Host; a gateway key lets nothing else in) with runtime/pprof's goroutine profile at debug=2, the form a crash prints: each goroutine's state and wait ("[select, 4320 minutes]"), its frames with source lines, and who started it. It is text/plain and no-store, and X-Magpie-Goroutine-Stats names the process (pid, program, version, window, uptime, goroutine count). Arguments are words in hex, never what they point at, so the dump holds no keys, prompts or messages; it does name magpie's source files and the program's path, which the usage says. magpie goroutines [<file>] writes it to <file>, else magpie-goroutines-<date>-<time>.txt in this folder, 0600 and never over a file there, then prints the file and the process. --help, -h and help print the usage and ask nothing; a flag it doesn't take, "-", a blank name or a second file are refused before the gateway is asked. A magpie older than this one answers 404 and is told to update; with none answering, it says so. The refused callers TestHeapProfileOnlyToThisComputer listed move into profileCallersRefused, which the CPU test and the new one share. Run on |
||
|
|
a2cef8bf4f |
provider: partners.json keeps when the list was last tried and how it ended (#3362)
"partners":null} for three days, and nothing told a fetch that failed every time from one that never came back, or from none being asked. A failed fetch wrote nothing and logged nothing. refreshPartners now keeps two fields with the list: - tried: when the last fetch started, written before it is sent; - error: how it failed (whitespace folded, cut at 500 runes), cleared when the next one starts. Read together: error set, the last try failed; tried after at with no error, a try is still out; tried long ago, nothing has asked since. A failure is logged once until its error changes or a fetch gets the list again, and the fetch that gets it after a failure is logged too. The desktop app's log goes nowhere a user can read, so for the app the file is what tells. Checked for #3362 on the way: v0.1.1296's fetch, keep and save, given the bytes /api/partners serves now (Kimi Code, listed from 10-23 00:00 +08:00) over the 10-20 file, writes the file, with the icon fetched or not. So it isn't the save or the list. Run on |
||
|
|
f252b403d3 |
provider: the icon prune leaves a listed partner's logo, so the add sheet keeps drawing it (#3424)
partnerIcon keeps a partner's logo in the icons folder beside providers.json and, while its iconUrl stays the same, uses the file it kept as it is ( |
||
|
|
4725c772bb |
netproxy: a hung system proxy read holds no request; a failed one keeps the last proxy (#3421)
System() ran readSystem under sysCache's lock, and on macOS that is scutil --proxy, started with proc.Command and no timeout. When neither magpie's settings nor the environment name a proxy, every request's proxy comes from there (For, through Func: http.DefaultTransport, the gateway's upstream transport, MCP, updates), so a scutil that never answered held each of them on that lock for as long as it hung, past its own deadline too: net/http looks at a request's context before it calls Proxy, not while. With no system proxy set, scutil runs again every 2 s it is asked. And a read that failed was taken as no proxy: where vendors are reached only through the system's proxy, a scutil that failed once sent the next 2 s of requests direct. The code standards' "nothing that can block runs under a lock its reader needs" and "a failed read means unknown". Found while chasing #3362, an app whose partner fetch never came back. Nothing there shows scutil was what hung; it is the one wait on that path with no end. Now: - One read runs at a time, outside the lock. A request waits for it until readWait (2 s) after it began, then takes what was read before. Before the first read that is nothing, so direct, as a failed first read was. A read already past readWait holds nobody. - A read that fails keeps what was read before, and the read after it holds nobody either: requests go on with the proxy read before until a read answers. - scutil gets toolWait (10 s) and is then ended (readTool, through proc.CommandContext), and that read fails. - Windows' registry: a key or value that isn't there is no proxy, as before; any other error is a failed read. Elsewhere there is no system proxy to read, and nothing changes. ggbdpq's patch on #2562 has testenv stand in for scutil with exit 1. Under this change that read fails with nothing read before it, which is still no proxy, so it does what it did. What was run (tree 6f5e4b92, on |
||
|
|
ba4b754b22 |
gateway: a relayed Chat stream's tool call with no index is given its call's (#3386)
xianfeng-zhu (#3386): Cursor's Private Inference on magpie's /v1/chat/completions, a Gemini model behind it, failed every turn that made a tool call with AI_TypeValidationError at choices[0].delta.tool_calls[0].index ("expected number, received undefined"), then a 499 loop; turns without tools went fine. Gemini's OpenAI-compatible API sends its calls with no index (Linka's frames in gemini_compat_cut_test.go have none either), where the OpenAI contract has one on every fragment, and a relayed stream went on without one. The AI SDK's OpenAI provider, which the report names as what Cursor reads Chat with, checks every chunk and turns that one away, so the call is never made. OpenAI's own node SDK, through its stream helper, keeps no call at all. chatTidy, which already mends a relayed Chat stream's empty ids, empty names and "stop" after calls, now gives a fragment with no index (none, or null) the index of its call (streamCallIndexes.give). A fragment with an id other than the open call's, or after the first in its delta, starts the next call, as chatDecoder reads a new id; any other goes on with the open one. So two calls in chunks of their own are 0 and 1. Given both 0, as their place in the delta would give them, OpenAI's node SDK merged them into one call with both arguments run together. A fragment with an index keeps it, and a stream whose calls have theirs goes as it came. It runs before the ids are mended, so a call with no id either (#3386's chunk) gets both. Not changed: the translations write an index already (chatEncoder, chatWholeEvents), and a whole reply's message needs none. Nor is a call given a type: Gemini's frames have "type": "function". The report's chunk has neither an id nor a type, and is taken as cut short: magpie gives a call with no id one (#2611, v0.1.1277), so the chunk it sent would have had one. What was run (tree e6023c66, on |
||
|
|
9a2106220c |
gateway: a background sub-agent's notification after tool results reaches the Claude run (stones_2026 on Discord)
Claude Code 2.1.310 runs Agent sub-agents in the background by default.
When one ends while the main agent is mid-turn, Claude Code tells its
model with a <task-notification> in a {role: "system"} message after the
tool results (several that end together share one text block), or as a
text block of the results' message. On the Claude subscription path
saidWithResults drops every system message that isn't the user's own
mid-turn words (#2060,
|
||
|
|
83234fe920 |
gateway, gui: the skills an agent lists are their own part, not memory
The owner (10-24, on the Routing context map's "技能 / 记忆 · 9.6K"):
为什么这里又叫技能,又叫记忆?Skill 跟 Memory 应该是不一样的东西. The
gateway put Codex's <skills_instructions> in the memory part beside the
instruction files and reminders, so the tile said Skills of Memory.
Claude Code's skill list wasn't seen at all: it sat in its environment
message, counted as the system prompt.
- gateway: PartSkills ("skills") comes after tools. Codex's
<skills_instructions> goes there. So does Claude Code's list, from
"The following skills are available for use with the Skill tool:" to
the next blank line, taken out of whatever text holds it: its own
prompt, a harness message or a reminder.
- Routes kept before this (routing history) are read with an item
tagged skills moved out of memory into the skills part, so old
requests read the same way. The text view re-reads the body and finds
them under skills too.
- Usage's context baseline counts skills, as it did inside memory.
memory-heavy is now instruction files and reminders alone.
- gui: the card has a Skills part (slate, --c7), with its note in en,
zh, zh-TW, ja and de. The text view's "no longer kept" line is one
helper instead of two copies of the sentence, which makes the room for
it under the core script budget, with no room added.
Run (darwin):
- go test ./internal/gateway -run 'Text|Prompt|Context|History|Skill|Route'
ok; go test ./internal/gui ok; go vet both, gofmt clean.
- New: TestPromptOfClaudeCodeSkills (on testdata/workdir's real Claude
Code 2.1.296 body: 1502 tokens of skills out of the 2130-token
environment item), TestSplitSkillsEnds, TestSkillsApartOfKeptPrompt.
Broken by hand (splitSkills and skillsApart made no-ops): all three
red.
- GUI, chromium and webkit: context-map 22/22 (new: the skills tile's
tip names Skills and not Memory in every language, and it isn't
memory's colour), context-window 24/24, context-text 20/20,
context-scroll-end 14/14, routing-context-fold 24/24,
routing-ctx-still 16/16, i18n-keys 4/4.
Not run: the whole GUI suite (load ~400 on the box); a live Codex or
Claude Code request through the real app.
Not changed: the "system prompt, tools and memory" wording of the
baseline's tags, which now count skills too.
|
||
|
|
e219f699ca |
gateway: with no S3 bucket the request archive keeps calls on this computer, oldest removed past 1 GiB (CyberCaius)
CyberCaius on Discord: "请求存档只能存在 s3 存储桶里,不能保存在本地吗". The Usage page's Request archive switch refused without an s3:// sync. Now, with no bucket, the same switch keeps each call in <settings.Dir()>/request-archive/<date>/<id>.json: the same file the bucket gets, masked the same way (Archived, archiveRequest), written to a temporary file beside it, synced and renamed, 0600 in a 0700 folder. Past its size (RequestArchiveLocalMB, 1 GiB unless set) the oldest calls go first, down to a tenth under it; the call just written is never removed, empty day folders go, and a .part file an hour old is removed on the next scan. The running total is counted once and then added to, so a write walks the folder only once it is over. On by default or a switch: a switch, still off unless turned on. Bodies can hold secrets, so nothing is written to a disk where the user didn't ask. The local switch is its own field, RequestArchiveLocal, in KeepOwn with its size, so sync never turns it on at another computer, and RequestArchive synced from a computer with a bucket keeps nothing on one without (archiveDest). The GUI switch writes RequestArchive while sync has a bucket and RequestArchiveLocal while it has none; the tooltip names the folder and the size, and a failed write reads "Not saved" (en, zh, zh-TW, ja, de). GET /api/archive reads this computer's copy first, then the bucket. The Settings page's save keeps both fields (api.go). Docs: sync-backup.md and gui-shell.md say where the archive goes and why the switch is per computer; the privacy pages (en, zh, ja) say what the folder holds, that it is off by default, and how large it grows. The READMEs' Privacy is about what is sent and is unchanged. app.js stays under TestCoreScriptBudget (its comment was shortened, and one t() call folded); no budget raised. Run (worktree diff on |
||
|
|
f6a96b2f0b |
usage: a change time with a fraction settles in 100ms, so a read after an append hashes no log (#3394)
readLogSnapshot checks its snapshot against a SHA-256 of the log's whole prefix whenever the log's change time is under a second old. Under steady traffic every read came within a second of the gateway's last append, so each one hashed the whole usage.jsonl again: 1.8 times the log for each append and read. A stamp with a nonzero fraction of a second comes from a clock that ticks in milliseconds (APFS in ns, Linux's coarse clock 1-10 ms, NTFS ~15.6 ms), so it settles in logFineSettle = 100ms. A stamp in whole seconds (HFS+, FAT, a share) keeps the one-second settle. Run: - go test -count=1 -timeout 45m ./internal/usage/ ./internal/budget/: ok. - TestUsageReadAfterAppendHashesNothingOnAFineClock (20000-row log, 5 appends, each followed by two reads): fine stamp 0 bytes hashed; whole-second stamp 50.7 MB. Broken by hand (logFineSettle = time.Second): 54 MB hashed, red. - Real account, sandbox HOME, a deepseek-only providers.json and a 98 MB usage.jsonl (the owner's own log, repeated 50 times). magpie serve took 30 real /v1/responses calls with a Codex user agent to deepseek/deepseek-flash, all answered, while /v1/magpie/usage?period=today (the Usage page's read) was polled every second. Process CPU time, two runs each: before 3.11 s and 3.05 s, after 1.95 s and 2.25 s. The same calls with /v1/magpie/quotas polled cost 0.2 s on both binaries, since that path never reads the log. - gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui ./internal/usage/ clean. Not tried: an HFS+ or FAT volume (the test skips when the file system gives whole-second stamps, and covers that case by truncating the stamp); the full suite at this head runs after the push. |
||
|
|
2dfaf75539 |
redact: a masked body is held at its size, not in a buffer grown by doubling (#3383)
With masking on, the masked body is what a request holds while it
streams (MaskJSON, 285 MB live in the report's heap). walk built it in a
bytes.Buffer grown by doubling, up to twice the body. It now makes room
for the body and a sixteenth at the first value it masks, and copies the
result to its size when placeholders grew it past an eighth spare.
Run:
- the heap probe, 8 requests of 9.7 MB held mid-stream with Privacy
masking on: 138 MB before, 86 MB after (Anthropic to Anthropic);
translated to Chat 235 MB before, 183 MB after.
- TestMaskedBodyHeldAtItsSize: green; red with both changes off
("the masked body of 4356589 bytes is held in 7077888").
- go test ./internal/redact/ ./internal/masking/ ok; gateway -run
'Mask|Redact|…' ok (see the commit before).
|
||
|
|
106a245502 |
gateway: a request's body goes once it is answered, not when its stream ends (#3383)
The transport holds a request until its reply's body is closed, a
stream's whole length, and with it the bytes.Reader body and the GetBody
NewRequest made over it. So every streaming request kept the body it
sent upstream alive to its end: for a Claude Code request translated to
Chat, the marshalled body (marshalRaw/appendHTMLEscaped in the report's
heap, 503 MB live).
provider.SetBody gives a request a body whose reader drops its bytes
once read and whose GetBody reads them again until provider.LetGo.
forwardOnce lets go once its retries (RetryOneAuth, RetryZhipuCoding)
are done; Codex's zstd turn, Copilot Auto's model swap and Gemini's Code
Assist envelope set their bodies the same way, so LetGo reaches them.
Run (worktree perf-stack, on the four commits before it, over
origin/main
|