5ebceee2dac944f19215ffcb324e4e03062bcf07
5774
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
5ebceee2da |
usage: the tool legend keeps each spelling's own kind (#2969)
Follow-up to ggbdpq's b2a8b74c7 (the tool list grouped case-blind).
That change put every spelling's calls in the legend under the kind of
the spelling seen first, so where two spellings have different kinds
("task" is Other, "Task" is Task) the Categories legend changed with
the order sessions were read in, and no longer matched the weeks
(pd.tools), which count each spelling under its own kind. The legend
now counts each call under ToolCategory of the name it was called by,
as before b2a8b74c7; only the Top rows merge. The tie-break comment
said "the shorter name", where the code takes the first in byte order.
TestToolUseMergesSpellings gains "the legend keeps each spelling's own
kind" ("task" 3 then "Task" 5: legend Task 5, Other 3). Broken by hand:
with b2a8b74c7's stats.go it is red ("categories [{Name:Other Calls:8
Sessions:2}]"), green with this.
Run at the pushed head on mote: go test ./... -timeout 45m on mote with this branch on
|
||
|
|
1c76095e97 |
usage: the tool list groups tools case-insensitively, as its summary does (#2969)
What changed
- toolUse now folds a tool's spellings into one row of the sessions'
"Tool use" detail list: its calls and sessions are summed under one
case-insensitive name, the row is shown by the summary's own spelling
when the tool is its kind save for the case ("bash" as "Bash"), and by
its most called spelling otherwise. A session that called both ways
counts once.
- The summary's per-kind list ("Bash 2.2K") already merged the spellings,
via ToolCategory; the detail list keyed its rows by the raw name, so
the same tool read as two.
Why (issue #2969)
The card's left list split `bash` (1.4K calls, 20 sessions) from `Bash`
(779, 2), `read` (192, 15) from `Read` (123, 1) and `write` (64, 13) from
`Write` (56, 1), while the right legend showed one Bash 2.2K, Read 315,
Write 120 - the sums of each pair. Same card, two answers. The detail
rows now answer with the summary.
Run
- go test ./internal/sessions/ -run TestToolUseMergesSpellings: fails on
the old code (the split above), passes on the new; a session that
called `read` and `Read` counts once, and tools that only share a kind
(two mcp__ tools) stay apart.
- go test ./internal/sessions/: ok.
- gofmt -l on the touched files: clean; go vet ./internal/sessions/: clean;
go build ./...: ok.
Landed (yetone), at the pushed head on mote: go test ./... -timeout 45m on mote with this branch on
|
||
|
|
fcf87a7853 |
test(gui): four pages with a 5s default get the navigation's minute (#4622)
nav-timeout.test.cjs, the #4470 guard, is red on origin/main |
||
|
|
573b21f4b0 |
gui: the Providers answer is written a provider at a time
Each poll encoded /api/providers whole, growing json's buffer to the
answer's size once the GC had emptied its pool. writeProvidersJSON
writes the same bytes with each provider's row encoded alone, as
writeStateJSON does for agents; every handler that answered
writeJSON(rw, providersState()) uses it.
Real accounts (sandbox copy of the owner's HOME, network blocked), 40
polls,
|
||
|
|
ce20d5658f |
provider: Catalog's list is made once with room for every entry
catalogKeeping cloned the groups' entries at their size and grew the
list by append for every provider's model, about twice the list it
gave. It is now made once with room for the groups and every entry.
Real accounts (sandbox copy of the owner's HOME, network blocked), 40
polls of /api/state, /api/providers and drift, pprof alloc_space
between two heap snapshots,
|
||
|
|
bb478f0e50 |
agent: a look that only ranges over magpie's models reads the list kept
magpieModels gives each caller its own copy of the list it keeps per
agent. Most callers only range over it, or count it, and a range copies
each model anyway, so the copy guarded nothing for them (the models'
own lists were shared before too: the copy was shallow). sharedModels
is the list kept, read only; every `range magpieModels(` and
`len(magpieModels(` in internal/agent (39 files) takes it. Callers that
keep the list, append to it or hand it on still get their copy.
Real accounts (sandbox copy of the owner's HOME, network blocked), 40
polls of /api/state, /api/providers and drift, pprof alloc_space
between two heap snapshots,
|
||
|
|
616405061a |
gui: a provider row's models and agents are made once at their size
providerInfoWith grew a row's model list by append for the decision models the vendor list lacks and for the picks it lacked, then grew it again with slices.Insert to put those picks in front, and grew Agents one append at a time. The rows are now counted first and each list is made once at its size, in the same order as before. Real accounts (sandbox copy of the owner's HOME, network blocked), 40 polls of /api/state, /api/providers and drift, pprof alloc_space between the two heap snapshots, v0.1.2484 (mhost) vs this (mrows): providerInfoWith flat 50.7 MB -> 38.5 MB, cum 164.9 MB -> 138.8 MB providersState cum 273.2 MB -> 270.5 MB (the total is noisy +-25 MB from the state encoder's pooled buffers: 621 vs 637 MB) /api/state and drift bodies byte-identical; /api/providers equal but for `fetched` and one login's `lapsed`, set by a refused refresh in the blocked sandbox when a token came due during one of the runs (logins_on.go), a path this change doesn't touch. TestProviderRowListsMadeAtTheirSize: 107 rows from 100 listed models, 7 picks the list lacks plus one it has, 3 agents; picks in front in their order, cap == len for Models and Agents. On the old providers.go (at HEAD) it fails: "models made for 219, 107 rows". Forcing growth by hand in the new code fails it the same way. Run on mote at this tree: gofmt, go vet, GOOS=windows go vet ok; the new test and the model-order tests 3/3 ok; go test ./internal/gui: only the known reds TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners (#3949) failed. Not run: the full ./... suite. |
||
|
|
5bfa9f0762 |
gateway: a group's backup gives the conversation back once the member listed ahead of it is ready again (01huadalang on Discord)
01huadalang on Discord, after |
||
|
|
f856d381ac |
provider: Host finds the first protocol spoken without building a list
Host read Speaks' whole list to take the first protocol with an address. IsBedrock, IsKilo, IsCline, IsOpenCode and IsBedrockMantle each ask Host, for every provider on every poll. Building that list was 8 MB of what twenty polls of the Providers page allocated with real accounts. Speaks' rule now lives in speaking, an iterator. Speaks collects it, and Host stops at the first protocol with an address. The order and the Code Assist, Vertex and Gemini cases are unchanged. Test: TestHostBuildsNoList. For six providers it checks that Host equals the host of the first of Speaks() with an address (else Decide's), and that a look allocates nothing. With range p.Speaks() put back by hand it fails at 3 to 5 allocations a look. Run on mote at this tree: - gofmt, go vet, and GOOS=windows and GOOS=linux vet of internal/provider: ok. - TestHostBuildsNoList, TestNoAPIFindsTheProvidersAPIsOnce, and the Speaks, Vertex and Gemini tests alone, 3 times: ok. - Not run with this change: the whole ./internal/provider suite. It passed on mote with only the market commit, before this change was made. |
||
|
|
b19d085935 |
plugin: a plugin's market icon parses the cached list once per copy
Before the market is fetched, or with no network, plugin.Icon read the cached plugin-market.json and parsed it whole for every look. The Providers page looks once for each plugin's row on each poll: 13 MB of what twenty polls allocated with real accounts. The copy is now read through filememo.Read, which parses it again only when the file changes. The built-in list is parsed once (sync.OnceValue). Both are shared and only read. Test: TestMarketIconParsesTheCopyOnce. It caches the built-in list as the copy and allows at most 20 allocations a look. With the old ReadFile and parseMarket put back by hand it fails at 260 allocations a look. It also checks that a rewritten copy is read again and that with no copy the built-in list answers. Run on mote at this tree: - gofmt, go vet, and GOOS=windows and GOOS=linux vet of internal/plugin and internal/provider: ok. - TestMarketIcon* and TestMarketSources alone, 3 times: ok. - go test -timeout 45m ./internal/plugin ./internal/provider: ok. - ./internal/gui: TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners (#3949) fail, both already filed. Nothing else failed. |
||
|
|
3a3bdb9f23 |
provider: IsOpenCode reads the host without parsing a URL
The Providers page asks IsOpenCode for each model of each provider, and it parsed "//"+host with url.Parse each time: url.parse was 20 MB of what 20 warm rounds of drift, state and providers allocated with the owner's real accounts, OpenCodeURL's share 7.5 MB. openCodeAt takes the host as Host gives it: whatever is before the last '@' aside, an IPv6 literal never OpenCode's, the port aside, then the same openCodeHost check OpenCodeURL ends in. Run on mote (mote-run, Go 1.26.8): - gofmt clean; go vet ok, also GOOS=windows and GOOS=linux. - TestOpenCodeAtReadsTheHostAsAURLWould alone: ok. It checks openCodeAt against OpenCodeURL for 18 hosts (user info, ports, IPv6, a trailing dot, look-alikes such as opencode.ai@evil.com and opencode.ai.evil.com) and that a look allocates nothing. - Broken by hand (openCodeAt answering through OpenCodeURL): red, "a look allocated 3 times, want 0". - go test -timeout 45m ./internal/provider ./internal/gateway: ok (156s, 681s), at 606743831; this head is it rebased on main. Real use: the owner's real-account sandbox, offline (proxy to :9), 20 warm rounds of /api/drift, /api/state and /api/providers, at this head: - net/url.parse 20.5 MB -> 5 MB (what is left is openCodeGateway and others, not IsOpenCode); all allocated 371 MB -> 327 MB. - /api/state and /api/drift bytes identical to 6a7a690be's (cmp); /api/providers differs only in each provider's "fetched" time. |
||
|
|
5a56bc7d73 |
gateway: a CI job trades its OIDC token for a short-lived key (#4531)
xazaj on X asked for GitHub OIDC: a GitHub Actions job should get a
gateway key without a long-lived magpie key in the repository's secrets.
A rule (magpie gateway-key oidc add --key <id> --repo owner/name
[--ref …] [--environment …] [--claim k=v] [--ttl 1h] [--issuer URL]
[--audience a]; oidc list, oidc remove) names an issuer (GitHub Actions'
by default, any https issuer), an audience (magpie-<rule id> by default,
so a token asked for one rule opens no other, and the workflow needn't
know the gateway's address), claims (exact or path.Match globs) and the
gateway key the keys are issued under, which must be let issue. A GitHub
rule names the repository or its owner with no wildcard, or every
repository on GitHub could get in. No rule, no exchange.
POST /v1/magpie/keys/oidc with Authorization: Bearer <token> and an
optional {"ttl","models"} verifies the token (RS256 only, keys from the
issuer's discovery document's https jwks_uri, exp required, nbf/iat with
a minute's leeway, the rule's aud and claims, a jti traded once) and
issues a key through access.IssueKey under the rule's key, named
repo@ref (run N), living no longer than the rule. Everything issued keys
guarantee holds: bounded by the issuer's models and accounts, its spend
counted against the issuer, stopped when the issuer is turned off.
- A token is judged only against rules naming its iss, so it can't make
magpie fetch from a URL of its choosing.
- Keys are cached an hour per issuer, read by one request at a time with
no lock held across the fetch, asked again for an unknown kid at most
every 10s, and kept while the issuer is down; with none ever read,
nothing is let in.
- The route is lanGuard's one exemption from remoteKeyed (that exact
path, POST, no gateway key): only while shared, past the allow list,
and a refused token counts against tooManyAuthFails (429 past the
burst). A read-only key is refused it.
The issue's open questions, decided: rules are generic from the start
(the GitHub repository rule applies to GitHub's issuer); rules are CLI
and file only for now (oidc-rules.json), no GUI.
Docs: docs/subsystems/gateway-routing.md (Trading an OIDC token for a
key, routes table) and site/public/docs remote in en, zh and ja, with
the workflow snippet.
Tests: TestOIDCTokenTradedForKey (no rule, a traded key that works on
chat with its TTL capped and its name, a model past the issuer, another
branch, no token, 51 bad tokens -> 429, issuer turned off, a token on a
model route, loopback, not shared -> 403); TestMatchEachCheck (14 bad
tokens, list aud, replay, the refusal naming the claims);
TestKeysCachedAndKept (8 concurrent tokens one fetch, rotation, a made-up
kid inside and past the gap, the issuer down 2h later, an unnamed issuer
never fetched); TestUnreadKeysLetNothingIn; TestAddRefuses;
TestGatewayKeyOIDCCLI; TestReadOnlyKeyEveryRoute with the new route.
A JWKS from an httptest TLS server, never the network.
Broken by hand, each red then restored: the signature check, the claims
match, the jti check, the exp check, the refetch gap, the GitHub scope
rule, the lanGuard exemption, the throttle and the TTL cap.
Run at this head (rebased on
|
||
|
|
6a7a690be0 |
gateway: the Providers page's drawers come from the list it has
Each /api/providers poll asked gateway.Drawers for each provider's image
models, and Drawers read the provider's model list again (p.Available)
though providerInfoWith already had it in the kept Listing. In a
real-account heap profile (20 warm rounds of drift, state and providers)
Drawers was 14.4 MB of what was allocated.
DrawersOf takes the list as a func, called only on the paths that read
it (a Google sign-in's, a plugin's), and the Providers page passes its
Listing's Available, which is p.Available() kept (Provider.Listing).
Drawers itself is DrawersOf(p, p.Available) for every other caller.
Real use: the owner's real-account sandbox, offline (proxy to :9), 20
warm rounds of /api/drift, /api/state and /api/providers, at this head:
- Drawers 14.4 MB -> DrawersOf 3.1 MB.
- /api/state and /api/drift bytes identical to 6712e367e's (cmp);
/api/providers differs only in each provider's "fetched" time.
Run on mote (mote-run, Go 1.26.8):
- gofmt clean; go vet ok, also GOOS=windows and GOOS=linux.
- TestDrawersOfTheCallersList alone, 3 times: ok.
- Broken by hand (DrawersOf reading p.Available()): red, "drawers [],
want gemini-3.1-flash-image alone".
- go test -timeout 45m ./internal/gateway: ok (669s). ./internal/gui:
FAIL on TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestMainWindowCorners (#3949), both red on main and filed. That run
was at dd7442f28; this head is it rebased on
|
||
|
|
6712e367e8 |
agent: a look at the stash shares one read of it
Each /api/state and /api/drift poll asked the stash (stash.json) for one value hundreds of times, through Detected, Drift and the agents' wiring checks, and each ask read the file and parsed it again. In a real-account heap profile (20 rounds of drift, state and providers) stashLoad was 24-34 MB of what was allocated. stashShared reads it through filememo.Read, so every look shares one parse until the file changes, by magpie or by another process. Every read-only caller uses it now, the 24 files here and QwenPaw's unstashPeek. stashLoad, which callers change and write back, still gives each its own map, cloned from the same parse. Real use: the owner's real-account sandbox, offline (proxy to :9), 20 warm rounds of /api/drift, /api/state and /api/providers: - allocated 477 MB ( |
||
|
|
41b5c0f19a |
accounts: Claude Code stays on the account it moved to till that is spent too (hxy920830 on X)
hxy920830 on X wants Claude Code to use one account to 98%, move to the next and use that one to 98%, not jump back the moment the first resets. No setting gave that. NextLogin (#408) signed the agent back in to the first account as soon as it was under 90% again, under every routing. KeepLogin pins one account, In order goes back too, and switch only went back as well. Where the sign-in is what spends the accounts (Claude Code, whose own requests never pass the gateway, and Codex under switch only), the sign-in now stays on the account it moved to until that one is spent or fails, then moves on to the next ticked account with room. It goes back to the first only where the user said the first comes first: routing In order, or KeepLogin. Codex through the gateway keeps going back, because Smart routing sends its requests to the first account (#209) and the sign-in follows it. This is returnsToFirst in codex_switch.go. The return record is still written, so turning In order on later goes back as before. An old record is ignored otherwise, and its "First again" label (logins.go) is hidden. No user setting is overridden: In order and KeepLogin keep their meaning. GUI: the Routing note for Claude Code (and Codex under switch only) now says it stays on the account till that one is 98% used too. The two switch-only tooltips no longer promise going back. New and changed strings are in zh, zh-TW, ja and de. app.js lost a 3-line comment so the core script budget holds without a raise (core 1,531,108 of 1,533,105). Run on mote at 94cd5edde (base |
||
|
|
d307aa6485 |
gui: /api/state is written one agent at a time, for the page and the kept sum at once
Each poll of the Agents page encoded the whole state (1.3 MB with real accounts) into json's buffer, and the GC between polls empties the pool that buffer comes from, so it grew to the state's size again each poll: 48 MB of what twenty rounds allocated (v0.1.2477 build, real-account sandbox), and 68 MB at v0.1.2463. writeStateJSON encodes the state without its agents twice (as sent, and as keepState keeps it, without the settings), and each agent once, straight to the response and to keepState's sha256, through one encoder. keepState is split so the handler hands it that sum (keepStateSummed). When the splice can't be made (no agents, or a field put before "agents"), it writes and sums the state whole, as before. Measured on this Mac with the real-account sandbox (abr.sh, 20 rounds of drift + state + providers): - v0.1.2477: writeJSON under /api/state 48 MB, 511 MB in all. - this change: writeStateJSON 15 MB, 477 MB in all. The /api/state bytes are identical to v0.1.2477's (cmp). Run on mote (mote-run, Go 1.26.8): - gofmt clean; go vet ok, also GOOS=windows. - TestStateWrittenAsEncoded (same bytes as Encode, same sum as keepState, for a large state, an empty agent list and none) and TestStateWriteGrowsNoBufferItsSize, with TestKeptState* and TestLast*: ok 3 of 3. - Broken by hand (the whole-state path always taken): red, "writing a 1614586-byte state allocated 4207139 bytes, want under half its size". - Not run before this push: the full internal/gui package; it runs next. |
||
|
|
13aa33eac5 |
provider: CatalogFor is kept across polls until something it reads changes
Each /api/state poll and each Codex subagent list rebuilt an agent's catalog from scratch. In a real-account heap profile (m2463, 20 polls) CatalogFor and catalogKeeping were 69 + 36 MB of what was allocated, and CodexSubagentModels' 39 MB came through the same call. CatalogFor now goes through keptOf under "catalog-for\x00"+agent, so it is rebuilt only when the stamp keptOf already watches changes. Callers get their own clones of the shown and hidden lists, so a caller that writes into them never reaches the kept copy or another caller. Run on mote (mote-run, Go 1.26.8): - gofmt clean; go vet ok, also GOOS=windows and GOOS=linux. - TestCatalogForKeptAcrossPolls alone: ok. - Broken by hand (keptOf bypassed): red, "20 polls with nothing changed built the catalog 20 times, want 0". - go test -timeout 45m ./internal/agent ./internal/gateway: ok. ./internal/provider: ok except this test's first version, which wrote s[0] before reading its ids; fixed, and it passes alone. |
||
|
|
93879515a0 |
agent: QwenPaw, each of its agents' active_model one of magpie's (pkh1585 on Discord)
pkh1585 asked for QwenPaw (AgentScope, github.com/agentscope-ai/QwenPaw)
on Discord. Read in its source, 2.2.2.post1, as data:
- Its folder is QWENPAW_WORKING_DIR, else ~/.copaw when that exists (the
old name), else ~/.qwenpaw; WORKING_DIR/.env is loaded without
overriding the environment. config.json's agents.profiles lists the
agents, each with a workspace_dir whose agent.json holds active_model
{provider_id, model}, read again on each message.
- Providers are no plain config: SECRET_DIR (QWENPAW_SECRET_DIR, else
"<WORKING_DIR>.secret") holds providers/{builtin,custom}/<id>.json,
read once at start. A plain api_key there is encrypted to "ENC:" at
start, so that is the place QwenPaw itself keeps keys.
What magpie does now:
- `magpie qwenpaw <model>` and the GUI: a row per QwenPaw agent
(qwenpaw#<id>, the default one as plain qwenpaw), skipping agents whose
backend is ACP (another CLI runs those) and agents turned off.
- Connecting writes providers/custom/magpie.json (mode 600, the gateway's
/v1 and the magpie-qwenpaw key, magpie's models as extra_models with
their window, output and tool use) and sets that agent's active_model
to {magpie, <provider>/<model>}. The old active_model is stashed as it
was and put back verbatim on disconnect, absent and null included.
The provider file is removed only when no QwenPaw agent still uses it.
- A sync after QwenPaw re-saved the provider (encrypted key, discovered
models, its own defaults) keeps what QwenPaw wrote and changes only
what magpie owns, so a second connect leaves the file as it is.
- The notice says QwenPaw reads providers at start-up: restart it once
after connecting and after magpie's models change. New text in every
locale.
- appdir: QWENPAW_WORKING_DIR and QWENPAW_SECRET_DIR take ~/ as QwenPaw's
expanduser does; agentenv clears them in tests.
- README (en, zh), docs/reference.md, agent-wiring.md, the site's agent
list and start pages (en, zh, ja), icon.
Run:
- internal/agent's QwenPaw tests (Connect, AgentsAreRows, SyncKeeps-
WhatQwenPawChanged, Check, NotStartedYet, Folders, OwnModelAfter-
Magpies, SyncAfterQwenPawSaved, NullModelRestored) on mote, and the
all-agent tests (applied, rewire, lan_kept, proxy_kept, spelled) with
a QwenPaw fixture.
- Broken by hand, each red: always rewriting the key
(SyncKeepsWhatQwenPawChanged), removing the provider while another
agent uses it (AgentsAreRows), no backend filter (AgentsAreRows lists
qwenpaw#coder), dropping the keep of QwenPaw's own fields
(SyncAfterQwenPawSaved), IsObject for Exists (NullModelRestored).
- Real QwenPaw 2.2.2.post1 (Python 3.12 via uv) in a sandbox HOME on
the Linux box (WSL magpie-desktop), magpie on 3741, a fake OpenAI
upstream on 3742: first start wrote config.json and agent.json;
`magpie provider add fake …`, `magpie serve`, `magpie qwenpaw
magpie/fake/echo-1`; after a restart QwenPaw encrypted the key (ENC:)
and `qwenpaw agents chat` answered "PAWPAW-OK from the fake upstream",
its log "built agent … model=magpie/fake/echo-1"; the upstream saw
/v1/chat/completions model echo-1 streamed, magpie's usage.jsonl
agent qwenpaw status 200. A second connect and `magpie models` left
the provider file unchanged. `magpie qwenpaw default` took
active_model back out (the only diff in agent.json) and removed the
provider; QwenPaw started clean after.
- gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows -tags nogui.
- Full suite on mote (go test -tags nogui -count=1 -timeout 45m ./...)
at 9554883db on
|
||
|
|
61b536d788 |
provider: MemberGroups and GroupKept are built once while a request holds
The providers' page asked MemberGroups for each provider and GroupKept
for each model, and each call built the groups again from every
provider's entries: 11.6 MB of what twenty window polls allocated with
real accounts (m2463 profile). Both now go through heldFrom, as the
other catalog reads do: built once per Hold, kept across requests
while the stamp stays, shared and only for reading.
Test: TestMemberGroupsBuiltOnceWhileHeld. 20 looks under one Hold,
each asking MemberGroups 12 times, build it once at most; a group
saved after (g5) is in the next look.
Run on mote, at this tree on
|
||
|
|
323159f1cc |
usage: a Codex reset's confirmation picks which of the account's resets is used (01huadalang)
01huadalang on Discord: resets were used only automatically, or by hand
the one that runs out first. Which account was already the user's to pick
(each account's card has its own Use); which of its resets was not.
- Usage card's "Use a reset" and the menu bar panel's "Use one...": when
the account holds two or more resets listed with their ids, the
confirmation has a "Reset to use" pop-up (the app's menu, not <select>),
soonest first and picked unless another is. Once another is picked it
names the account and that reset ("The one used is me@'s reset that
runs out ..."), and says the sooner one is kept and lost if unused.
Escape closes the open menu first, not the confirmation.
- POST /api/usage/codex-reset takes an optional credit. The server reads
the account's resets again and spends that credit only if it is still
held; a gone one is refused and no other is spent in its place. With no
credit it is as before (the soonest). Auto-use is unchanged.
- ResetCard carries the credit id; `magpie quota reset --card n` is the
CLI's sibling, its prompt naming the reset.
- askReset's dialog moved out to resetask.js, imported when Use is
pressed (like signsheets.js), so the core's scripts are 1,530,733 bytes,
under the 1,533,105 budget with no raise (the pick alone took it 2,068
over). Five keys in zh, zh-TW, ja, de.
Run on mote (mote-run), at the base
|
||
|
|
9bb1efdde3 |
gateway: a reply names the model the agent asked for when it went out under another name (issennknight)
issennknight on Discord (#general): an agent asked for deepseek-v4.1-flash, which goes out as deepseek-v4.1-flash-1017 (settings' ModelIDs). The vendor's reply said -1017, magpie passed it back, and the agent warned that the model didn't match. Before, only MemberModel (#822) or X-Magpie-Response-Model: member rewrote a reply's model, and only to the group member's id. Now the default is nameAsked. When magpie sent the request under another name than the agent asked for (a model's own id, a routing group, a provider/model id), the reply names the asked model. That covers Chat and Anthropic `model`, Responses `response.model` (created, in_progress, completed), Anthropic `message.model` (message_start) and Gemini `modelVersion`, streamed and whole, translated paths and plugins included: it all goes through serve's one memberWriter. A vendor that sent back the wire name as asked keeps its own name, a dated -20261017 too. Usage rows, recent calls and the Routing page still record served = the vendor's name: the writer sits outside captureResponseWriter. Claude Code, Claude Desktop and Codex get the asked name (or the vendor's), never the member's id, as before. Streams are rewritten one complete line at a time (memberLines). A run with no "model" in it is written through as the same slice. Only a JSON reply that has a target at decide time is held whole, which is what MemberModel already did. A JSON body that doesn't parse (a reply cut short) goes on as it came. A request to a remote magpie now sends X-Magpie-Response-Model: vendor (passOnCaller). That magpie names the vendor's model, as before, so this one still records what served the call (TestRemoteMagpieGroupNotSwapped went red without it). Existing tests that held a native reply byte for byte now expect only its model renamed to the asked id (namedAs in member_test.go): passthrough_severed, stream_accounting, refusal, refusal_thinking, thinking_signature and vertex. The archive keeps the reply as the vendor sent it, under the vendor's name (archive_test). Also dropped: the openai-model header code. serve never relays that header, so the test for it could not pass. Run (mote, at this head rebased on origin/main |
||
|
|
f99b227c27 |
filememo: a parse is kept under a struct key, not a joined string
read joined kind + "\x00" + path into a new string for every read,
and Look scanned every key with HasSuffix of another joined string.
A read is asked for each model of each provider a poll lists, so the
keys alone were 33 MB of what twenty window polls allocated with
real accounts (m2463 profile). seen is now keyed by
memoKey{kind, path}; a held read and Look allocate nothing.
Test: TestHeldReadAndLookAllocateNothing. 50 files in a long folder,
under Hold: AllocsPerRun of a read found unchanged is 0, and of Look
0; a write then Look reads the new value.
Run on mote, at this tree on
|
||
|
|
0aafcc0fd0 |
provider: which models a provider has no API for is found once per list
NoAPIFor found the protocols the provider speaks for every model it was asked about, and APIs did again through ModelAPI, so a list of N models built 2N Speaks slices. The providers' page, ExposedOf and servable ask it for each model of each provider: 16 MB of what twenty window polls allocated with real accounts (m2463 profile). NoAPI() finds the protocols once and gives a func for each model; APIs and ModelAPI take them through apisAmong and modelAPIAmong. NoAPIFor, APIs and ModelAPI answer as before. Test: TestNoAPIFindsTheProvidersAPIsOnce. 100 models of a relay, half listed on chat: Speaks looked up once (5 at most, for another test's look), the chat half kept, NoAPIFor the same for each. Run on mote, at this tree: - gofmt, go vet (darwin, windows, linux): ok - the new test with TestExposedOnlyOnTheAPIsTheProviderHas and TestListedAPIsCost, 3 times: ok - broken by hand (NoAPI back to a per-model NoAPIFor): red, "100 models looked up the provider's APIs 200 times" - go test ./internal/provider: ok - go test ./internal/gui (before the apisAmong step, which touches internal/provider only): every test ok except the known TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners (#3949) and TestColdTurnsTaken (#4510) Not run: an A/B with the real-account sandbox for this change alone. |
||
|
|
6a23d9d755 |
gui: the kept state and providers are marshaled only when they changed
keepState and keepProviders ran json.Marshal on every /api/state and
/api/providers poll to compare the answer with the one kept on disk.
They now keep a sha256 of what was written and hash the new answer
into it with an Encoder; only a changed answer is marshaled and
written. json.Marshal there was 38.6 MB (keepState 25.9 MB,
keepProviders 12.7 MB) of what twenty window polls allocated with
real accounts (m2463 profile).
Test: TestKeptStateMarshaledOnlyWhenChanged. Twenty identical keeps
marshal nothing, nor does a keep after the file is read again; a
changed state is marshaled once and read back.
Run on mote, at this tree on
|
||
|
|
606743831e |
appdir: on Windows an agent's folder variable follows the registry, and a gone folder it names isn't made again (bm_rabbit on Discord)
bm_rabbit (0.1.2405, Windows x64, Pi 1.4.0) moved Pi's AgentDir from
F:\piData\.pi\agent to F:\HarnessData\Pi\.pi\agent, deleted the old one and
set the User variable PI_CODING_AGENT_DIR to the new path. Changing Pi's
model in magpie then made the deleted folder again with only models.json
and settings.json in it.
Cause: Windows gives a process its variables once, from the registry, and
never passes a changed User variable to one already running. magpie runs
for days in the tray, so appdir.Getenv("PI_CODING_AGENT_DIR") (piDir) kept
the old path, and edit's write did MkdirAll on it. Every agent folder
variable (CODEX_HOME, CLAUDE_CONFIG_DIR, ...) had the same problem.
Fix, where every agent folder is read (appdir.LookupEnv, follow.go): on
Windows a variable in agentenv.Vars that came from the registry (its value
in magpie's environment at start matched the registry's, unset in both
counts too) is read from HKCU\Environment, else HKLM's Session Manager
Environment, with %...% expanded, at most once a second, and set in
magpie's environment so the programs magpie starts get it too. A value
the launcher set itself, or one set inside magpie since (a test sandbox),
stands. The direct os.Getenv reads of agent variables go through appdir
now: claudetui's CLAUDE_CONFIG_DIR, sessions' CODEX_SQLITE_HOME and
PI_DESKTOP_DATA_DIR, cliupdate's GROK_HOME, omp's OMP_PROFILE/PI_PROFILE.
And edit's writeFile no longer makes a missing tree of folders that an
agent's variable names: when the folder the variable names is missing
and so is the folder above it (bm_rabbit's whole F:\piData was gone),
appdir.Gone returns a GoneError naming the variable and the folder. The
named folder itself is still made when its parent is there, as mkdir
would (a CODEX_HOME or ANTE_HOME set before the agent first ran; 12
internal/agent tests rely on it), and an agent's default folder is made
as before. TestAnteHome's ANTE_HOME was <tmp>/elsewhere/ante with
elsewhere missing; it now makes elsewhere first. Writes that call
os.MkdirAll themselves don't ask yet: #4634.
Pi's install-layout.json isn't Pi's: Pi 1.4.0's getAgentDir
(@earendil-works/pi-coding-agent dist/config.js) reads PI_CODING_AGENT_DIR,
else ~/.pi/agent, and no file in the package names install-layout.
magpie doesn't read it.
Tests: TestAgentVarFollowsTheRegistry, TestAgentVarAddedLaterFollows,
TestAgentVarSetByHandStands, TestRegistryReadAtMostEachFollowFor,
TestGoneNamedFolderIsNotMade (internal/appdir, a fake registry), and
TestWriteNeverMakesANamedFolderAgain (internal/edit).
Broken by hand: LookupEnv back on os.LookupEnv, TestAgentVarFollowsTheRegistry
and TestAgentVarAddedLaterFollows FAIL ("after the user moved it,
PI_CODING_AGENT_DIR = .../old, want .../new"); Gone's refusal turned off,
TestGoneNamedFolderIsNotMade and TestWriteNeverMakesANamedFolderAgain FAIL
("= <nil>, want a GoneError", "the folder was made again"); Gone refusing
whenever the named folder is missing, TestGoneNamedFolderIsNotMade FAILs
("a named folder whose parent exists: ..."). All put back, green.
Real Windows run on xiaomi-gpu, sandbox USERPROFILE/APPDATA/LOCALAPPDATA,
at this head: a probe built from this tree started with
PI_CODING_AGENT_DIR=<sb>\piData\.pi\agent in its environment and the User
registry; then the User variable was set to <sb>\HarnessData\Pi\.pi\agent
and <sb>\piData deleted, and agent.Find("pi").Apply("model", ...) ran in
the same process. Pi's dir and os.Getenv are the new folder,
settings.json written there, piData not made. With HarnessData deleted
too: "PI_CODING_AGENT_DIR names <sb>\HarnessData\Pi\.pi\agent, which
doesn't exist and neither does the folder above it: ...", not made. An
earlier run of the old code (LookupEnv on os.LookupEnv, no Gone) wrote
into the old folder and made it again: bm_rabbit's case. The User
variable was removed after; the box had none.
Full run at this change on
|
||
|
|
88372a39d8 |
provider: listing accounts with nothing to change copies none of them
sideLogins and pluginLogins read the saved logins as a copy of the whole list each time, to change it if a sign-in was new. The Providers page and the panel list an agent's or a plugin's accounts a dozen times a poll, and almost always nothing changes: 61 MB of what twenty window polls allocated with real accounts. They now look at the logins as kept (sharedLogins, read only), and a list that has a change makes its own copy (readLogins) before it changes and writes it. TestAccountListsCopyNoLoginsUnchanged: twenty lists of a side sign-in and a plugin's accounts with nothing new copy the logins 0 times; a new plugin account is still written and listed. Run on mote (macOS 27): - gofmt, go vet ./internal/provider (darwin, windows, linux): ok - broken by hand (side_logins back on readLogins): red, "20 lists with nothing to change copied the accounts 40 times" - the new test alone, -count=3: ok - go test ./internal/provider ./internal/gateway: ok Not run: the whole suite; internal/provider and the gateway that reads its accounts are what this reaches. |
||
|
|
178a781ff9 |
library: a skill made again under the same name after its repo's copy was deleted is filed under 本机 (X: AzheRise)
AzheRise on X: a skill downloaded from a GitHub repository was deleted, another of the same name was made in an agent's own folder (~/.dsh/skills), and once brought into the Library it sat under the old repository instead of This computer. Cause: two records outlive the skill and are matched by name only. - The skills CLI's lock (~/.agents/.skill-lock.json, or under $XDG_STATE_HOME) keeps an entry for a skill deleted by hand or from magpie. repoOf filed the library's own copy (a folder moved in) under the lock's repository by its name, and tracer.folder did the same for one in ~/.agents/skills, which importSkill then kept as From. On this machine's real lock, agent-browser is such an entry, with no folder. - CC Switch's folder (~/.cc-switch/skills/<name>) outlives a copy of it deleted from the library. ccSwitchOrigin filed any later own copy of that name under CC Switch's repository, and made it "updatable", so Update would have put the repository's skill in place of the user's. - Sibling: a removed skill stayed in the user's own group (SkillGroups), hidden only while no skill had its name, so a new one of that name came back in the group. Fix: - A lock entry counts for a folder only when the CLI wrote that folder: a file in it is no newer than the entry's updatedAt (else installedAt) plus a minute (lockRepo, madeBy). On this machine's 27 live entries the CLI's files are 0.4 to 2.8s older than updatedAt. A lock without times groups by name as before. Brought in from an agent's folder, a copy the CLI wrote is kept as From at once, so an edit later leaves it grouped. - Existing data is judged again on every read: a moved-in copy has no From and goes through lockRepo, and a From that is the lock's repository for a folder in ~/.agents/skills the CLI didn't write is passed over (staleFrom). So the reporter's skill moves to This computer with no action. - ccSwitchOrigin takes a library-own copy as CC Switch's only when its SKILL.md is CC Switch's own. - removeSkill drops the skill from the user's groups. Not changed: noteFrom's pack rule (a skill traced nowhere, of a name a repository being installed from has, is grouped with it when the library has others from there). That is by name on purpose (White Immortal's edited older copies), and runs only when the user installs from or regroups that repository, not on import. MCP servers, hooks and subagents keep no origin by name (a server's icon is by what it runs). Tests: TestDeletedSkillsLockNotInherited (the reporter's case, one made in ~/.agents/skills, the CLI's --copy copy and linked skill, data as brought in before, an edited CLI copy), TestUndatedLockStillGroups, TestRemovedSkillLeavesItsGroup, TestCCSwitchNameNotInherited. Run at |
||
|
|
a38a0d7794 |
gui: a provider's models are put in order once, not copied for each pick put first
providerInfoWith grew each provider's Models from nothing, and put each model the user picked that its vendor no longer lists at the front with an insert, a copy of the whole list each time. In twenty polls of the Providers page with real accounts that was 13 MB of copies and 22.6 MB of growth. The list is now made at its length, and the unlisted picks are put in front with one insert, in the order they were before. TestUnlistedPicksShownFirst: Available a, b and Exposed a, x, y, z show as z, y, x, a, b with four exposed, as before. Run on mote (macOS 27): - gofmt, go vet ./internal/gui (darwin, windows, linux): ok - the new test alone, 3 runs: ok - broken by hand (the reverse taken out): red, "models shown as [x y z a b], want [z y x a b]" - go test ./internal/gui: ok but for two reds already filed and red on main: TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners (#3949) Not run: the whole suite; this changes one function of internal/gui. |
||
|
|
dd7442f283 |
agent: a look at the via-magpie options shares the kept list
viaMagpie handed every caller its own copy of the options list it keeps per stamp, and a window poll asks for it from most agents' fields and pickers. In a real-account sandbox (abr.sh, 20 polls of drift, state and providers on v0.1.2463) those copies were 33.7 MB of slices.Clone, plus ~8 MB more on the way, of the 713 MB the polls allocated. viaMagpieShared returns the kept list itself, clipped, so an append makes the caller's own array. The 58 callers that only read it, or append onto it, now take it; viaMagpie (a copy) stays for the ones that change it. TestKeptListSharedWithoutACopy checks that 20 shared looks return the kept array, and that an append onto a shared look and a write into get's copy leave the kept list as it was. Run on mote at this tree: - gofmt, go vet (darwin, GOOS=windows, GOOS=linux with gateway), go build ./...: ok. - Broken by hand (shared returns slices.Clone): the test is red, "a shared look copies the kept list". - go test -count=1 ./internal/agent: ok (480s). Not run: internal/gateway and internal/gui packages on this tree. |
||
|
|
544b91ca87 |
dsh: magpie's routes wait for a slow reply as long as the gateway does (tim on Discord)
tim's first "who are you" to gemini-3.8 through the third-party plugin
magpie-gemini-web 0.8.0 took minutes in dsh and ended in 499 ("the agent
canceled the request"). dsh hung up: llm-pi-ai gives a turn up after 5
minutes with no pi-ai event (DEFAULT_STREAM_IDLE_TIMEOUT_MS, every
dsh-llm-pi-ai from 0.1.5 to 0.2.2), and the gateway's ": keepalive"
comments (keepQueued, keepQuiet) are not events. The plugin serves one
request at a time (maxConcurrency 1), dsh's own session title goes to the
same route model in parallel, and the plugin's backend sends no byte
before its first token, so the turn's 5 minutes ran out in magpie's queue
and the backend while the gateway (10 minutes for headers) and the plugin
(240s per wait, then its own 504) were still waiting.
Every one of magpie's dsh routes (patch lists and deepseek-acp's
settings.yaml, all through dshPutProviders) now has streamIdleTimeoutMs:
600000 (dshIdleWait), the gateway's upstreamHeaderWait. A value already on
the route, set in dsh's Models page or by hand, stays. Codex's
comment-blind limit is still met in the gateway (agentQuietMost); dsh's is
a route setting. The plugin's own slowness is its maintainer's and is not
changed here.
Verified:
- New tests TestDshRoutesWaitAsLongAsTheGateway and
TestDshRouteKeepsTheUsersIdleWait (internal/agent/dsh_idle_test.go),
green on mote. Broken by hand: without the field the first fails
("route magpie waits 0ms for the next event, want 600000"); without the
keep the second fails ("sync 1: the user's 120000 became 600000").
- Real dsh 0.2.1-rc.2 (headless, sandbox HOME/DSH_HOME, the route as
magpie writes it, a fake Chat server on 127.0.0.1:3561 that answers
after 8s): streamIdleTimeoutMs 3000 -> "TIMEOUT: pi-ai stream idle
timeout after 3000ms"; 600000 -> "hello there", exit 0. With headers
sent at once and ": keepalive" every second it still timed out at 3000,
so comments don't feed the watchdog. dsh-llm-pi-ai 0.1.5-rc.3,
0.1.7-rc.2, 0.2.0-rc.2 and 0.2.1-rc.5 (npm pack, read) all take the
field per provider, max MAX_TIMER_DELAY_MS.
- gofmt -l clean. On mote: go vet ./..., GOOS=linux go vet -tags nogui
./..., GOOS=windows go vet ./..., go build, GOOS=linux go build -tags
nogui, GOOS=windows go build: all ok.
- Full suite, go test -tags nogui -count=1 -timeout 45m ./..., on the
Linux box (wsl-run, magpie-desktop; mote had two full suites running)
at
|
||
|
|
f598edf6d5 |
providers: a provider's model lists are kept across polls with the catalog
The Providers page's state built each provider's Available,
ExposedOf(Available) and NewestInFamily(Available) lists again on every
poll. Over twenty polls of the real-account sandbox that was 159 MB of
the 371 MB providerInfoWith allocated (Available 72, NewestInFamily 60,
ExposedOf 27). provider.KeptListing keeps the three lists in keptOf, the
cross-request cache that drops them when the catalog, providers.json,
settings or a plugin changes (StampNow) and after keptFor, and only while
a request holds. providersState passes the kept Listing; providerInfo,
for one provider after an edit, still builds a fresh one. The lists are
clipped, so an append makes the caller's own.
TestProvidersListingKeptAcrossPolls: twenty polls with nothing changed
build the listing 0 times and match a fresh Listing; after a Save of the
provider's models the next poll shows the new ones. With keptOf swapped
for a direct call by hand it is red: "built the listing 20 times, want 0".
Run on mote at this tree (on
|
||
|
|
76c130b29c |
edit: a TOML file's table names are listed once a read, not on each look
TOMLTables walked the parsed file and built a fresh sorted list of table
names on every call. The window's polls ask it for every agent's config
several times a poll, and twenty polls of the real-account sandbox spent
46 MB on those lists. The names are now filled when the file is parsed
(the parse is already kept by mod time and size), clipped, and handed out
shared; a caller that appends gets its own copy.
TestTOMLTablesListedOnceARead holds the allocation of repeated looks at
the same file to a small bound. With the old code put back by hand it is
red: 158474 bytes a look.
Run at 554291774's tree (on
|
||
|
|
2597c96365 |
agent: Codex's config.toml is decoded once a read for a sync's own looks
A sync to Codex decoded the whole config.toml again for each thing it checked: codexMultiAgentV2On, putThreadTables, codexEnableEfforts and codexAsyncNow each ran toml.Unmarshal over the file. Codex writes a [projects."…"] table for every folder it was opened in; the owner's config is 1.5 MB with 10,932 tables, and with 10,000 such tables one sync allocated 21 MB. codexTopOf decodes only the top tables these look at (features, model_providers, desktop, profile, profiles) and keeps the result in filememo by the file's mod time and size, so a sync and the polls after it share one decode until the file changes. A missing file is an empty config, as before. TestCodexSyncDecodesTheConfigOnce: 10,000 project tables, one sync to settle, then five more; each must allocate under 12x the file and leave config.toml unwritten. Now ~5 MB a sync. Red on the old code: 51,257 KB a sync over an 868 KB file, past the 10,421 KB bound. Run at this head on mote: gofmt clean; go vet (darwin, GOOS=windows, GOOS=linux) ok; go test -timeout 45m ./internal/agent ./internal/gateway ok. |
||
|
|
05f6ca39b3 |
provider, gui: settings only read go through the shared copy
settings.Load clones the whole Settings, every provider's model prefs included. CompactsOf, OutputsOf, ModelNames, ModelEfforts, settings.SavedAddr and the GUI's providerInfoWith only read it, and providerInfoWith took a copy for each provider: 16 MB of what twenty window polls allocated in a real-account sandbox, more with each model a user has set prefs for. They read settings.Shared() now. ModelEfforts hands back a clone of the slice it finds, so a caller's change never reaches the shared settings. TestModelPrefsReadTheSharedSettings: 3000 other models' prefs; the values are right, a caller's change to ModelEfforts' list doesn't reach the settings, and each look allocates at most a tenth of Load's. Red on the old code: ~6058 allocations a look against 6056 for a Load. Run at this head on mote: go vet (darwin, GOOS=windows, GOOS=linux without the gui package) ok; go test ./internal/settings and ./internal/provider ok; ./internal/gui red only in TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners (#3949), both red on main. |
||
|
|
4d1ec346aa |
edit: a JSON file is made plain JSON once a read, not on every look
GetJSON, GetJSONRaw and GetJSONItem copied the file and ran jsonc.ToJSON over it on every look. The window's polls look up agent settings many times a round, so twenty polls allocated 80 MB in that conversion alone (heap profile of a real-account sandbox). jsonHeld keeps the plain-JSON bytes in filememo, keyed by the file's mod time and size, so a look reads them shared. gjson.GetBytes copies what it returns, so nothing a caller gets aliases the held bytes. A write (SetJSON and the rest) changes the file, and the next look reads it again. TestGetJSONConvertsTheFileOnce: a 290 KB JSONC file with a BOM, 20 looks must each allocate under a tenth of the file, and a value set afterwards is seen. Red on the old code: 296 KB a look. Run at this head: - mote: go vet (darwin, GOOS=windows, GOOS=linux) ok; go test ./internal/edit ok, and ok under -race. - WSL (magpie-desktop): internal/edit ok, internal/provider ok; internal/agent red only in TestInstalledVersion, TestHowInstalled, TestGrokInstalled, TestCursorFolderFromTheEditorIsNotTheCLI, TestQoderSettingsFromAnIDEPluginIsNotTheCLI and TestOmpDetectedWithPiDir, the install-detection reds of #4033. |
||
|
|
15066f84f6 |
appdir: a folder and file name are joined once, not on every read
appdir.Config and Cache, catalog.CachePath and LivePath, settings.Path, provider.Path and the logins path each ran filepath.Join on every call, and they are called on every read of a cached file, many times a request. Those joins were 70 MB of the 1.4 GB twenty window polls allocated. appdir.Join and JoinFile keep each (dir, name, ext) they joined, up to 4096 of them, so a path named again is the same string. A changed HOME or folder is a different key, so a test's sandbox still gets its own path. TestFoldersJoinedOnce and TestLivePathNamedOnce: 0 allocations a call. Broken by hand on mote (the files before this change) they are red at 1 allocation a call, and 3 for LivePath. Run on mote at this tree (on |
||
|
|
019bfc951b |
gui: a page of accounts builds the agent list once, not once a row
accountLabel and the excluded-agents loop called agent.Find for each row,
and Find builds All() again each time: about 3,300 allocations a call.
Over 20 window polls that was 58 MB of the 1.4 GB a magpie allocated.
provider.Held keeps All() for the request that holds it (the gui's held
middleware holds every /api/ request), and agent.FindIn looks the name up
in that list. Outside a hold Held builds it as before, so a caller with
no request in hand gets the same answer.
TestAccountLabelsBuildTheAgentsOnce (sandbox HOME): outside a hold the
label's name and icon are the same; under Hold a row allocates 3 times
against 3302 to build every agent. Broken by hand on mote (agentNamed
back to agent.Find) it is red at 3305 a row.
Run on mote at this tree (on
|
||
|
|
68c413ea05 |
filememo: a file written just now is read again into one buffer
A file whose time is under two seconds old is read again on every read and compared with the bytes parsed, since a second write inside a clock tick can leave the same time and size. Each of those reads made a new buffer. As magpie starts, Codex's sync writes ~/.codex/config.toml, and every read of it for the next two seconds made one. With the owner's real 1.45 MB config.toml, v0.1.2432's startup profile has readCodexStoreSetting reading it ~155 times (226 MB) and the TOML table spans ~89 times (129 MB). That is 381 MB of the 1.37 GB allocated before the window's first poll, and the peak RSS with it. Now a read that finds the same size and time reads into a buffer kept on the entry while its bytes are, and gives the buffer back when they match. A read beside it takes the buffer out first, so it reads into one of its own. Bytes that differ are parsed from that read's buffer, which no one else has. Nothing changes in what is looked at: the file is still read and compared each time until it settles. steady.ReadThereInto is ReadThere into a caller's buffer. TestRecentFileReadAgainIntoOneBuffer (a 1.2 MB file stamped now): 20 reads allocate under a quarter of the file each, it is parsed once, 8 readers at once each get the right length, and a write of the same size and time is seen and kept as its own bytes. Broken by hand on mote, with the buffered path off, it is red (1191002 bytes a read). Run at 8ce36a0ef (on |
||
|
|
bb50f4ad94 |
gateway: a Codex passthrough member OpenAI doesn't know is left out and asked again
xuanwo on X: every new conversation in the Codex app (two agents) ended
at once with the ChatGPT backend's 400 "[ObjectParam]
[input[55].internal_chat_message_metadata_passthrough.content_token_count]
[unknown_parameter]". The member is new in the Codex app's bundled
build; no open-source Codex sends it (main 67f0994, npm 0.166.0), and
openai/codex#52313 was the same refusal of content_item_metadata in
0.163.0-alpha.1. magpie sends the passthrough as Codex wrote it to
OpenAI hosts and ChatGPT accounts (forVendor), so the refusal reached
the app. The reporter's own look at magpie's routing log: the main
conversation failed at input[49] and input[55], and a conversation
with no subagent failed the same way, so subagents aren't the cause.
The member is Codex's own attribution, not the conversation. A turn
turned away over one passthrough member, or the passthrough as a whole,
is asked once more without it on every item, with the other members
and every other byte kept as written. The provider isn't sent that
member again (unfit, as for a tool's strict). The signed-in Codex
relay's retry (withoutUnreadable) takes the same refusal.
Run (mote, go1.26.8):
- TestPassthroughMemberLeftOutWhereRefused, TestPassthroughRefusalWordings,
TestWithoutPassthrough: ok.
- Broken by hand: with the retry turned off, TestPassthroughMemberLeftOut
WhereRefused gets the reporter's exact 400 back.
- At
|
||
|
|
d714c4216d |
catalog: a newer model's line is looked up in the index made once per load
KinEfforts gives a model newer than the catalog its line's levels (gpt- 6.1-sol's from gpt-6-sol). borrowedEfforts asks it for every model with no levels of its own, on each look at the providers. Each ask ranged over every model of every maker's catalog and split and joined each key to compare its versionless shape: 66 MB of the 1.4 GB a main magpie allocated over 20 window polls with the owner's real config. levelIndex ( |
||
|
|
ddc225c964 |
Revert "site: the favicon and iPhone icon fill their tile, no white margin"
This reverts
|
||
|
|
83b2be2b25 |
provider: Hidden reads providers.json as parsed once, not once per account
Hidden lists the signed-in accounts the user removed from magpie. The Providers page asks it on every load, and for each signed-in account it parsed the whole providers.json again (load). With the owner's real config that was 68 MB of the 1.4 GB a main magpie allocated over 20 window polls. It now reads storedFile(), the file as parsed once until it changes, which only reads it; Excluded, its other caller, does too. TestHiddenParsedOnceUntilTheFileChanges: a signed-in Claude account hidden beside 30 providers of 100 models, the file dated an hour back. Hidden costs less than a quarter of a parse over what Accounts costs, and an account shown again since is seen at once. Broken by hand on mote (load().Providers in the loop again): red, 3353 allocations over Accounts' 396 against a parse's 3352. Run on mote at |
||
|
|
25d4058146 |
site: the favicon and iPhone icon fill their tile, no white margin
On a phone a usemagpie.ai link showed its icon inside a white ring (the owner: "包了一层白边"). favicon.png and the apple-touch-icon (img/icon-256.png) were the macOS app icon, a rounded tile with ~10% transparent margin on each side; a phone fills the transparency white and rounds the square itself, so the tile sat inside a white border. - favicon.png: 64px from the GUI's full-bleed apple-touch-icon, opaque, no margin. - apple-touch-icon.png (new, 180px, also the path iOS asks for by itself): the GUI's apple-touch-icon, which already fills its square. Every page's <link rel="apple-touch-icon"> points at it. - img/icon-256.png is left as it was: install.sh takes it as the Linux desktop icon and the READMEs show it, where the macOS shape is right. Run: sips on both files (64x64 and 180x180, opaque); looked at both; grep shows no page still names /img/icon-256.png as its touch icon. Deployed with wrangler and fetched both from usemagpie.ai. Not tried: a real iPhone's home screen or Safari tab after the deploy. |
||
|
|
80bcef18f0 |
provider: PublicRef reads the groups held without copying them
PublicRef is asked for every model a page lists (the Providers page, every
agent's picker). Each call went through Groups(), which copies every group
and its rules so the caller can change them, to read one group's Spelled
and Ref. With the owner's real config that was 115 MB of the 2.6 GB a
v0.1.2432 magpie allocated over 20 window polls.
sharedGroups() is the held slice itself, for callers that only read it:
PublicRef, the families list (visible.go) and DisabledGroup, which still
hands its caller a copy of the one group it found.
TestPublicRefCopiesNoGroups (41 groups with members and a rule, under
provider.Hold and filememo.Hold as a request runs): PublicRef takes far
fewer allocations than a copy of the groups, and DisabledGroup's caller
can't write into the groups held. Broken by hand on mote: PublicRef back
on Groups() is red (165 allocations against 164 for a copy), and
DisabledGroup returning the shared group is red.
Run on mote at the rebased head (go test -timeout 45m): internal/provider
ok 125s, internal/agent ok 207s. go vet of internal/provider on darwin,
windows and linux ok; gofmt -l clean. On the Windows box
internal/provider has the same 14 reds at origin/main
|
||
|
|
3182a66586 |
provider, gateway: OpenRouter's decision model picked with a variant (inception/mercury-decide:free) is a decision model, never sent to chat/completions
coeo91 on Discord (2026-10-31): inception/mercury-decide:free, picked by
hand into a group used as smart routing's decision model, failed with
"OpenRouter: inception/mercury-decide:free is a decisions model and
cannot be used with the chat/completions endpoint. Use the
/api/alpha/decisions endpoint instead."
Cause: magpie already reads OpenRouter's decision models from its own
list (/models?output_modalities=decisions: output_modalities
["decisions"], endpoints ["/api/alpha/decisions"]) and asks them at
/api/v1/systemone. That list names each model once, without variants,
so the hand-picked ":free" id was taken for a chat model. Its group was
a chat group and the classifier asked it in words on chat/completions.
Now a variant of a model OpenRouter's decisions list names (base id
before the last ":", OpenRouter providers only; Ollama's :tag stays a
name of its own) is a decision model (openRouterVariant):
- it is kept from agents' model lists, and its group is a decision
group, asked at /api/v1/systemone (classifier, RouteDecider);
- an agent's chat naming it gets magpie's 400 "only decides", with
OpenRouter not asked;
- count_tokens naming it, or its decision group, gets the same 400
(count_tokens had no decision guard and forwarded upstream);
- test-models sends it the System One yes-or-no, and the provider
editor marks it as a decision model (/api/providers deciders).
Not done: an /api/alpha/decisions client. OpenRouter's /api/v1/systemone
(what magpie uses) answered the same model the same way as the alpha
path in a real probe (200, identical System One shape), so the alpha
endpoint adds nothing but an alpha contract.
Real probe (owner's OpenRouter key, 2026-11-01): chat/completions with
inception/mercury-decide:free gives the reporter's 400 word for word;
/api/v1/systemone and /api/alpha/decisions give 200 for
inception/mercury-decide and 404 for :free ("This model is unavailable
for free... use this slug instead: inception/mercury-decide"). So
after this change the reporter's group is asked the right way, and
OpenRouter's own 404 says to pick the paid slug.
Tests (fixtures are OpenRouter's real list and answer bytes):
TestOpenRouterDecisionModelVariant (provider),
TestOpenRouterDecisionVariantNeverChats (gateway: classifier group asked
at /systemone, chat and count_tokens refused, OpenRouter asked once),
TestOpenRouterDecisionVariantPicker (gui). Each is red on the old code
(provider: "taken for a chat model"; gateway: the reporter's 400 as the
classifier's error; gui: deciders without the variant), checked at
|
||
|
|
1f9f74d1c5 |
provider: the live-model test weighs the same steps on Windows too
TestLiveModelReadWithoutACopy (v0.1.2449) took LiveListed alone as the
cost of a look before the copy. liveByID also asks whether the list is
the provider's and the id it is listed by, which cost more on Windows,
whose stat allocates more: green on macOS, red on Windows ("a look at
one model took 2552 bytes, the list's read 1232"). The baseline now
takes the same steps, and the bar is half a model: the same steps leave
~0 bytes over, a copy 448 and more (on macOS the bar was 16 bytes from
the old code's 1112).
Run on mote and on the Windows box: the test ok -count=10 on each; with
liveByID back on the copying LiveByID it is red 10 of 10 on each. go
vet darwin and windows of internal/provider ok, gofmt -l clean. The
rest of internal/provider on Windows has 14 reds that are the same at
origin/main
|
||
|
|
f045ec1ea5 |
gateway: the extension socket's test takes a 401 from the LAN guard as refused
TestBrowserExtensionOnlyFromItsOrigin ( |
||
|
|
f9ca3dd44c |
provider: a look at one model of the vendor's list reads it without a copy
ListedAPIs, the Kilo and Cline free marks, a model's fast tiers and a remote magpie's price each look up one model of the provider's fetched list (liveByID), for every model a page lists. Each look copied the models of that id out of the list read, to read one field. With the owner's real config the copies were 32 MB of the 2.6 GB a v0.1.2432 magpie allocated over 20 window polls. catalog.LiveByIDShared is LiveByID without the copy (clipped, so an append is the caller's own); liveByID uses it, and still copies a model the user gave its own id, to set that id. Every caller only reads it. TestLiveModelReadWithoutACopy (a 200-model list, under provider.Hold and filememo.Hold as a request runs): a look costs less than a model over the list's read itself, a caller's append doesn't reach the list, and LiveByID still hands back its own copy. Broken by hand on mote: liveByID back on LiveByID is red (1112 bytes a look against 520 for the read; a model is 432). Run on mote (go test -timeout 45m): internal/catalog ok 0.7s, internal/provider ok 112s. go vet of both on darwin, windows and linux ok; gofmt -l clean. |
||
|
|
e6b595e1ab |
claude: Interactive only, a setting under which a model request never runs as claude -p (_yuchanns_ on X)
_yuchanns_ on X, on the interactive mode falling back to -p: for people
who stayed off magpie's Claude subscriptions because of -p, a fallback
is a time bomb. Settings › Models › Replies › Claude Code's interactive
mode now has three choices: Off (always -p), On (the default, falling
back to -p as before) and Interactive only.
With Interactive only (settings.ClaudeTUIOnly; ClaudePrintMode set too
wins):
- a run claudeTUI would make -p is not started; the request fails with
the reason and the setting (claudeOnlyErr, claudeNotTUIWhy);
- the helper is handed MAGPIE_CLAUDE_TUI_ONLY=1 (claudetui.OnlyEnv,
claudeCLI.tuiEnv). Where it would exec -p (no start, sign-in, first-run
notes, untrusted folder, 45s timeout) it exits with the reason
(fallBack in Run), and it ignores the broken mark;
- a helper that never answers initialize ends the turn with an error,
not a -p retry, and `broken` isn't counted (claudeMachineWhy), so the
next run tries the interactive mode again;
- the model test's and warm-up's "hi" (askClaude) runs through the
helper (askClaudeTUI) in stream-json, its stdin closed at the first
result. The helper command and env are built in one place now
(tuiCommand, tuiEnv) for both.
Reading the plan's allowance (/usage) asks no model and stays -p; the
setting's text says so. Docs: claude-subscription-bridge.md.
Provider editor, on e8347401f's "Claude Code runs as" pill
(ClaudeMode.Only): with the interactive mode in use and no last
request, it says a request it can't take fails, and the card's foot says
nothing runs as -p. Where the interactive mode can't run, the pill names
Interactive only, never claude -p, the line says "Claude requests fail:
<why>", and Change in Settings goes to the row. A request refused this
way never ran, so it isn't noted as the last request (noteClaudeRun
comes after the refusal).
app.js: the Replies rows share one helper (segRow, which waitRow uses
too), so app.js is 530 bytes under main's with the third choice; no
budget raise.
Tests: TestClaudeTUIOnlyRefusesPrint, TestClaudeTUIOnlyHungHelperNoPrint,
TestClaudeTUIOnlyTellsHelper, TestAskClaudeTUIOnly (gateway);
TestShimOnlyNeverPrints (claudetui: fake fail/trust/login/notes each
exit with an error and no -p, a marked-broken run still interactive);
claude-tui-setting.test.cjs (three choices, Only saves claudeTUIOnly with
claudePrintMode false) and claude-mode.test.cjs (Only in use, and Only where it can't run).
Broken by hand, each red, then put back: the startRun gate off
(RefusesPrint 200); start()'s Only check off (HungHelper 502 without the
Only reason); tuiEnv's OnlyEnv off (TellsHelper); askClaude's branch off
(AskClaudeTUIOnly); the helper's fallBack ignoring only (4 subtests);
BrokenSince's `&& !only` gone ("marked broken"); the save without
claudeTUIOnly (16 of 16 setting tests) and claudemode.js's m.only
branches gone, rebuilt on e8347401f's file (10 of 10 Only tests,
Chromium).
Run on mote at
|
||
|
|
f1d6f4137c |
gui: a provider's row reads the vendor's list once
providerInfoWith read p.Available() four times for one row: for the picks (Picks), for what is exposed (Exposed, twice: the exposed set and the picks the list doesn't know) and for the newest of each family. Each read builds the list whole with its names, levels and plugin models. In a profile of v0.1.2432 against the owner's real config (20 rounds of the window's polls), providersState was 1.34 GB of 2.62 GB allocated, Exposed 390 MB, Picks 155 MB and the row's own Available 146 MB of it. Provider gains ExposedOf(avail) and PicksOf(avail), Exposed and Picks of a list the caller has read already; Exposed and Picks call them with p.Available(), so every other caller is unchanged. The row reads the list once and hands it to both. TestProviderInfoReadsTheListOnce: a 2000-model catalog provider with three picks, one of them unlisted, read the way the page's request reads it (provider.Hold and filememo.Hold). The row's Chosen equals Picks(), its exposed count equals len(Exposed()) and the unlisted pick goes first. A row takes 28.6 MB against the list's 8.0 MB (each model's own price, window and protocol look-ups besides); on the old code 54.4 MB, red at the 5x bar. Run on mote at 27401edd6 (go test -timeout 45m): internal/provider ok 161s. internal/gui: three reds, each already filed and failing the same on main: TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners (#3949), TestColdTurnsTaken (#4510). go vet darwin and windows ok, gofmt -l clean. |