449231c19f9863d011c0c7d9e714c95fc2dcc094
5134
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
449231c19f |
masking: the Masking page turns masking off as it turns it on
ZekeXiao on X: "脱敏好像只有一个打开开关,不能关?". Insights › Masking's header had "Turn on masking" while masking was off and nothing at all while it was on; the off switches were only in Settings › Privacy. - Masking on, the header has a "Turn off masking" text button where "Turn on masking" sits when off. It sets redact and redactPersonal off, and the card then says "Masking is off" with Turn on masking. - Turn on masking from this page after that brings personal data back on if it was on before (and Hide accounts with it, as Settings does); otherwise it turns secrets on, as before. - With the user's own Masked words, masking stays on with both switches off (masking.Wanted), so a button that turned the switches off would leave the page saying on, or lie. Then the button reads "Turn off in Settings" and opens Settings › Privacy, with a tooltip saying the words mask until they are taken out there. Words are never deleted from here. - Strings in plugins/redact/i18n.js for zh, zh-TW, ja, de. Run (worktree at origin/main |
||
|
|
c3462d5fe8 |
gateway: a held stream gets its 200 after 3s, and a comment every 5s, so a proxy's 10s header cut no longer ends it 499
mrten_95615 (Discord, Windows): Codex through magpie to a relay ended 499
about 10s in once a turn's first token took longer than that. It happened
with a Clash-style app in system-proxy mode, not in TUN mode.
Cause:
- Codex (reqwest, hyper-util Matcher::from_system) sends its request for
127.0.0.1 through the Windows system proxy. ProxyOverride is read only as
IPs/CIDRs, so "127.*;localhost;<local>" doesn't keep it off. This was
checked on xiaomi-gpu with Codex 0.165.0: mihomo logged 127.0.0.1:18431
through the proxy.
- magpie held a stream's headers for up to holdLongest (15s) before
keepAlive sent the 200 and its first `: keepalive`. A proxy that stops
waiting for response headers after about 10s cut the request first, and
Codex's context ended, which shows as 499.
Fix: keepHeldAfter is 3s, not 15s. Once the 200 is out, keepHeldEvery
(5s) is the most a held stream goes without a comment. Another candidate
can still answer in the same stream, and a failure before 3s is still a
status with its Retry-After. gateway-routing.md is updated.
Run:
- TestHeldStreamHeardBeforeAProxyCuts (new) is red on the old code with
"headers 200 after 15.004s" and green after. It is green on mote together
with the keepalive, queue and held tests (-run
'TestHeldStreamHeardBeforeAProxyCuts|TestSilentHeld|Queue|Keepalive|KeptAlive|Held',
ok 68.6s).
- End to end on xiaomi-gpu (Windows 11): Codex 0.165.0 goes through the
system proxy, which is a Go proxy that cuts after 10s without headers,
then magpie serve in a sandbox HOME, then a relay that holds its headers
for 15s.
- Old build: the proxy logged "CUT after 10.001s" on every try, the relay
logged "client gone after ~10s", and Codex kept "Reconnecting... n/5".
- New build: "headers 200 after 3.005s", then done at 15.0s, and Codex
printed pong (exit 0).
- The registry proxy settings were restored afterwards (ProxyEnable 0, no
server or override), and none of the test processes were left running.
- On mote: gofmt -l is clean, and GOOS=windows/linux go vet -tags nogui
./internal/gateway/ is ok.
- On mote: go test -tags nogui -count=1 -timeout 45m ./... is ok except
internal/gui TestCoreScriptBudget (1531531 > 1530861). That is red on
main already, filed as #4133, and is not touched here.
Not tried:
- The reporter's own proxy app. mihomo's HTTP inbound doesn't cut by
default, so which part of their setup cuts at 10s isn't known.
- A proxy that cuts on idle bytes rather than headers, end to end. Only the
test's gap check covers the 5s cadence.
- Why turning the system proxy off didn't help until the app quit.
|
||
|
|
3142a55594 |
usage: the fine-clock hash test times each read from the append's stamp, not the wall clock (#3511)
TestUsageReadAfterAppendHashesNothingOnAFineClock/whole-second_stamp was red on CI on macOS and ubuntu at |
||
|
|
f02390544d |
edit: a JSONC delete takes the last member's trailing comma, so the MCP hub never leaves OpenCode's mcp as {,}
chenxiang0010 (Discord #general, Windows): turning the Library's MCP hub on
for OpenCode and off again left a comma at the end of opencode.jsonc's
"mcp", and OpenCode said "opencode.jsonc: invalid"; deleting the comma by
hand fixed it, and a second try didn't reproduce.
Cause: delJSONBytes looked for the deleted member's trailing comma in the
tidwall/jsonc copy, which blanks every comma before a closing bracket.
So when the member was the last one and had a trailing comma (as OpenCode,
editors and users allow), the comma was left behind; when it was the only
member, it was left with nothing before it: "mcp": {\n,\n}. The hub sync
then inserted the magpie entry in front of it ("magpie": {...},\n,) — a
double comma. OpenCode parses with jsonc-parser allowTrailingComma
(packages/opencode/src/config/parse.ts at v1.19.5, packages/core/src/config.ts
on dev): a trailing comma after a value is fine, a lone one is an error.
magpie's own validity check went through the same tidwall copy, so it
passed the broken file. Once the comma was deleted by hand there was no
trailing comma left, which is why it didn't happen again.
- delJSONBytes takes the last member's own trailing comma (nextToken, as
delItem already did for arrays), and its line with trailing blanks.
- insertKey adds no comma after the first member of an object that holds
comments only (it used to, leaving a trailing comma only some apps read).
- edit.ValidJSONC reads JSONC as jsonc-parser with allowTrailingComma does.
SetJSON, DelJSON, PatchJSON, SetJSONItem and DelJSONItem refuse an edit
that would turn a file the app reads into one it can't (checkJSONC):
nothing is written, and the error names the file.
- A lone comma an older magpie left is dropped by the next object edit of
that file (dropLoneCommas), so users already hit are mended by the next
sync that writes it. A file nothing writes again keeps it until then.
Every JSON/JSONC object writer goes through SetJSON/DelJSON/PatchJSON
(library MCP for OpenCode, Zed, VS Code, Claude, etc., agent wiring for
DevEco, MiMo Code, OpenCode, ...), so all of them get it.
Tests (red on the old json.go/jsonarray.go, put back by hand, green now):
- TestHubToggleLeavesValidJSONC: 12 file shapes (LF, CRLF, tabs, compact,
trailing commas, comment-only, comment after, comma after a comment) x 7
add/delete orders; old code: invalid in the trailing-comma and
comment-only shapes.
- TestDelOnlyMemberTakesItsTrailingComma, TestInsertIntoCommentOnly-
ObjectNoTrailingComma, TestLoneCommaMendedOnNextEdit: red on old code.
- TestValidJSONC, TestInvalidEditNotWritten.
- internal/library TestHubToggleKeepsOpenCodeJSONCValid: the real
SetMCPHub on/off twice for OpenCode, LF and CRLF; old code: invalid at
the first "hub on" ("magpie": {...},\n,\n}).
|
||
|
|
628ac36fc9 |
agents: Add magpie says when nothing here opens the app's import link (sungt)
sungt (Discord #feedback, Windows, magpie 0.1.1976, Cindy 0.1.119, Cindy
open): on the Agents page Cindy's 添加 magpie "spins, no response".
What magpie got wrong: Cindy, AionUi and Lody take magpie only through
their import link, which magpie hands to rundll32 / open / xdg-open and
never waits on. A link nothing opens did nothing, the button never awaited
/api/open nor caught its error, and `magpie cindy add` printed "opened"
whatever happened.
- agent.OpenAppLink asks the system, without opening anything, whether
something opens the link's scheme: Windows' HKCR\<scheme> (what
Electron's setAsDefaultProtocolClient writes) and then the user's
UrlAssociations UserChoice; macOS Launch Services (cgo builds); Linux
`xdg-mime query default`. Only "none", or a registered program whose
full path is gone, refuses the link (NoLinkHandlerError); anything
unknown hands it over as before.
- /api/open (Cindy, AionUi, Lody after OpenLody) answers
code no_link_handler with app, exe and said, an i18n.js key from
linkSaid that api() puts through t() as it does bunSaid's.
- The import button now waits for /api/open and shows the result: "Sent
to {name}: confirm adding magpie there", or the reason in the
reader's language.
- The CLI's add returns the same error.
This is not verified as sungt's cause. Cindy was open, and Cindy
registers cindy:// at every start, so the check most likely passes on
their machine. If so, the spinner is Cindy's own import dialog
(previewProviderImport / fetching magpie's /v1/models). Cindy 0.1.119
wasn't available here. We still need Cindy's log around "received deep
link" from sungt.
Run (worktree at origin/main
|
||
|
|
eee8ea027b |
docs: why magpie writes OpenCode's provider, not 2.x's providers
chenxiang0010 (Discord #general) asked why opencode.json still gets `provider` rather than OpenCode 2's `providers`. Nothing changes in code: `provider` is the one key both OpenCode lines read. - OpenCode 2.2.0 migrates `provider` in memory (migrateProviders in packages/core/src/config/normalize.ts) and its "Migrate from V1" page says the V1 format stays supported and converting is optional. - OpenCode 1.19.5 (npm latest) ignores `providers` with a warning (ConfigV2Compat.lower, packages/opencode/src/config/v2-compat.ts), and both read the same opencode.json. Run on mote in a sandbox HOME against a fake server: @opencode/cli 2.2.0 listed magpie/gpt-5.5 from magpie's `provider` entry and sent `#high-fast` as reasoning_effort high + service_tier priority; opencode-ai 1.19.5 used the same file; 1.19.5 with the entry moved under native `providers` listed no magpie model and its run errored. Not tried: Windows/Linux OpenCode builds. Docs only, no tests run. |
||
|
|
2eee5d6d1e |
redact: a folder or a program's word is no one's name or address (kekek711 on X)
kekek711 on X, 10-29: "node_modules给识别成姓名了". With the local
model on, node_modules went to the vendor as a placeholder of personal
data, and the agent couldn't read or list the folder.
Where it came from: the model's PERSON spans were already held to a
name's shape (personFits: no underscore, a capital; modelTakes: no
snake_case word), so a person's name can't take node_modules on main.
Its ADDRESS spans were not: modelFits only turned away an ASCII value
with a slash and no space, so node_modules, site-packages, __pycache__,
dist, vendor, "ls node_modules" and "node_modules 太" (the span running
on into the sentence) all went as {{ADDRESS_…}}, which Settings lists
under the same model as names ("姓名、地址"). A lone SECRET span over
"node_modules/" or "__pycache__" also went, as b9f1fcddd's wordsOnly
didn't read a folder's slash or Python's underscores.
- programWords: a value with an underscore, or Latin letters in lower
case with no digit, is a program's words; an ADDRESS that is one goes
as written. A real address has its number or capitals (42 Wallaby
Way), a Chinese one its characters.
- wordsOnlyRe takes underscores around a word and a slash after it
(node_modules/, __pycache__), so a secret the model alone found there
goes as written unless assigned to a secret's name, as
|
||
|
|
a14f5c9c9d |
gateway: a whole reply with a masked value isn't lost when it names the member (#4129)
versun's non-streamed /v1/chat/completions came back 200 with Content-Length: 0 whenever masking replaced a value, while the stream was whole. Cause: with Settings' "reply names the member" (MemberModel) or a request's X-Magpie-Response-Model: member, serve wraps the reply in two writers that each hold a whole body until the handler is done: memberWriter outside, redact.Writer inside it. Their finishes were deferred in the wrong order: memberWriter's ran first and wrote what it held (nothing yet), and redact.Writer's ran after it and wrote the restored body into memberWriter's buffer, which no one wrote. A stream goes through both writers as it comes, so it was whole. The provider, protocol, response_format and engine didn't matter; a warn (n=0) wraps no writer, so it was fine. - serve: the values are put back first, then the member is named (one deferred func, unmask then named). - memberWriter: a write after its finish goes through to the agent (named when it is a whole JSON body; a stream's held tail too), instead of into a buffer no one writes. - docs/subsystems/gateway-routing.md says the order. Restoring itself can't turn a non-empty body into an empty one (restoreJSON falls back to a text restore), so there is no failure left to turn into an error status here; the loss was the writer order. Tests: TestMaskedWholeReplyNamesMember sends the reporter's literal request (复述这句话:我的手机号是 13800138000。, non-stream, his redactActions) through a real httptest server to a fake vendor that says the placeholder back, on /v1/chat/completions (group/subagent as reported, direct, json_object, the header instead of the setting, an Anthropic vendor, a Gemini vendor), /v1/messages (Anthropic vendor and a chat vendor), /v1/responses and /v1beta generateContent. It checks the number is back, no placeholder, the member named, Content-Length equal to the body. TestMemberWriterWrittenAfterFinish holds memberWriter to the late write. Run (on mote, at this tree): - old code: all 10 subtests red, each "200, Content-Length "0" ... """. - broken by hand: memberWriter's late-write guard taken out (order kept): TestMemberWriterWrittenAfterFinish red. The defer order put back (guard kept): TestMaskedWholeReplyNamesMember stays green, since the guard alone delivers the body; the two together are what the old code lacked. - go test -count=1 -timeout 45m ./internal/gateway/: ok (478s) - GOOS=linux and GOOS=windows go vet ./internal/gateway/: ok; gofmt -l: clean. - Real run: magpie built and run with `magpie serve` on 127.0.0.1:3481 in a sandbox HOME on mote, a fake OpenAI/Anthropic vendor on 3482, the reporter's settings plus MemberModel. Old binary: group/subagent, fake/m1, an Anthropic vendor and /v1/responses non-stream were each 200 Content-Length: 0. Fixed: Content-Length 230/401/596 with "我的手机号是 13800138000。" and the member's model; streams unchanged. - Rebased on |
||
|
|
536a98316d |
sessions: a poll over unchanged files gets the stats the last one read (#2278)
The Usage page asks for its range every 10 s and the Sessions page for 7, 30 and every day every 15 s. Each read put every session of every range together again, though between two polls the files mostly haven't changed: statsReadAll allocated ~1.1 GB per 80 s of polling, a fifth of all magpie allocated. statsKept keeps each range's Stats (at most 8 ranges) and the native keys, with what they were read from: every listed file's path, key, agent, size, mod time, main/read-only, WSL distro and its parse pointer (a published parse is never written; a changed file gets a new one), today, and the cache generation. It also keeps the answers the read got from the prices, Codex's thread names and Claude Desktop's names, and asks them again before it hands anything out. When any of these differ, everything is read again. The listing and the refresh of changed files still run on every poll. MergeExternalStats wrote into the Stats it was given (a day's usage rows, an append into spare room in Sessions, sorts in place). It now copies whatever it changes, so a kept range is never written. What this doesn't help: while an agent is writing a session, every poll sees a changed file and reads everything again. Reading only the changed sessions is the next change. Run at the pushed head on mote: - GOOS=linux/windows/darwin go vet -tags nogui ./internal/sessions/ ./internal/gui/: ok. - go test -count=1 -timeout 45m ./internal/sessions/ ./internal/gui/ ./internal/usage/: sessions ok, usage ok, gui red only TestMainWindowCorners/macOS_26_SDK (#3949, open, same as main). - New tests: TestStatsKeptBetweenPolls (the same backing array on an unchanged poll; a grown file and a price change are read in), TestStatsKeptNewDay, TestStatsKeptRangesBounded, TestMergeExternalStatsWritesNoInput. TestStatsAllRangesOnePass now forgets the kept ranges before each single read. - Broken by hand, each red: keptFor always missing (TestStatsKeptBetweenPolls, "put together again"); the price check dropped (repriced cost unchanged); MergeExternalStats without its copies (TestMergeExternalStatsWritesNoInput). - Real data (a copy of the owner's history, ~34k sessions), v0.1.1978 against this: /api/sessions/stats?days=0/7/30 and both overviews asked 4 times 12 s apart, each pair byte-identical (1.97 MB for days=0). - A/B, 80 s of GUI polling, v0.1.1978 against this: allocated 5512 to 4480 MB, statsReadAll's share 1108 to 261 MB (the listing); GC 3.90 to 3.42 s, madvise 1.05 to 0.61 s, CPU 28.6 to 25.3%, avg RSS 1061 to 1019 MiB. mote's load was 20-40, so latencies aren't compared. The A/B binary was built before the 8-range bound was added. - Rebased onto |
||
|
|
a4e929212f |
context: a part of a few tokens on the map is a tile one sees, not a strip under the gap (AIGCFREE on Discord)
The floor under a part's tile was an area (700px²), so a part laid in a long row beside large ones met it as a strip: 49 tokens of memory beside 72K, the window unknown, came out 193×3.6px, under the tiles' 3px gap, and hidden. A part's tile is now 16px across both ways: one thinner has its value raised by as much and the parts are laid again. |
||
|
|
b9f1fcddde |
redact: words in lower case the model took for a secret go as written unless assigned to a secret's name (dniray on Discord)
dniray, on v0.1.1976 after |
||
|
|
926ef769ff |
usage: a priced gateway block is kept 30s past its last query, so the next poll reads it (#2278)
The queries reading at once already shared each gateway block's priced copy (sharedPriced), but let it go when the last of them was done. Its rows' sync.Pool was emptied by the collections between polls, so every Usage poll decoded and priced the whole history again: priceBlock was ~960 MB, the pool's New ~720 MB, of 6.1 GB allocated in 80s of polls. A block no query holds now stays pricedLinger (30s, past the 10s and 15s polls) and is then let go by a timer; ReleaseScratch, which the window calls once its reads rest, lets them all go at once. The key is the same as for the sharing (requestState root|meta, the frozen block), so what a block is priced as is no less current than when two queries share it. Measured on mote (~/r2278 run2278d, 10 endpoints every 5s, gateway feed from 60s), against |
||
|
|
0e2739743b |
codex: a reset set to go when the week runs out is spent before the credits
tongzhenbao on X: a Codex Pro account with "when its week runs out" on,
its week at 0% left, one reset held until 11-06 (after the week's own
reset on 11-03) and Use credits on. Overnight ~10k credits went and the
reset stayed; the card said "not auto-used" beside the switch on.
Cause: the week's auto-use ran only on a vendor refusal. autoReset in
routing needs a 429 usage_limit_reached on the last candidate, and the
relay's autoResetSignedIn the same on its 429. An account let spend its
credits is never refused for its week: ChatGPT answers on the credits,
and routing never benches it (full() and onCredits). So the week's reset
could only ever be spent with credits off.
Decision (product call delegated): a reset is free, credits cost money,
so a reset the user set to go when the week runs out goes before any
credits. resetBeforeCredits runs before a try is sent to a Codex account
on its credits whose last reading has its week used up, with the week's
switch on; AutoUseCodexReset reads the week again and keeps one a week
at most, so a second time in the same week goes on the credits. Hooked
in the routing loop and in codexUpstreamOn (the relay, signed-in or an
account). With no reset held, or the week's switch off, nothing changes.
The card's summary: with only the week's switch on it now says "auto-used
when the week runs out" (zh 周额度用完时自动使用), not "not auto-used",
with its title in all five languages. CLI help and auto-reset messages
say "or before its credits are spent". gateway-routing.md names it.
Siblings: the expiring switch already spends regardless of credits
(usedUp ignores them); the credits-off path (planned.held) is unchanged.
Run (mote, through mote-run, at this tree):
- go test ./internal/gateway -run 'TestCodexResetBeforeCredits|TestCodexAutoReset|TestCodexCredits|TestCodexNoCredits': ok
- broken by hand: gateway.go and codex_backend.go at origin/main:
TestCodexResetBeforeCredits/relayed and /routed red (200, spent ""),
the two negative cases green
- node --test codex-auto-reset, i18n-keys, codex-auto-reset-settings,
codex-resets-used, panel-options-fold, quota-curve: 96/96 (chromium +
webkit, en/zh/zh-TW/ja/de); codex-auto-reset red with origin/main's
app.js ("· not auto-used")
- full suite, before the rebase onto
|
||
|
|
300b7eee08 |
redact: a package's name goes as written where it was masked before, and in manifests and errors (dniray on Discord)
dniray, on v0.1.1965 after v0.1.1932's fix: "问题还在", with
import { and, eq } from ' drizzle-orm ' still going out as
from ' {{SECRET_o2tu7vej}} '.
v0.1.1932 let the module an import loads go as written only where the
local model found it on that line (moduleAt in modelFits). A value
masked once is known (knownSpans) and masked wherever it is, with no
look at what is around it. So once the model took drizzle-orm for a
secret anywhere in a request (package.json's dependencies, a tsc
error, a sentence: none of those was exempt), the import line was
masked as known: in the same request (MaskJSON walks the texts in
order) and in every later one.
- knownSpans skips a known value where packageAt says it is a
package's name.
- packageAt: moduleAt, plus a manifest's dependency pinned at a version
("drizzle-orm": "^0.36.4", workspace:*, TOML x = "9";
dependencyAt), a folder under node_modules or site-packages, the
module an error could not find (Cannot find module 'x', No module
named 'x', Can't resolve 'x'; missingModuleAt), a package an install
names (pnpm add x, npm i -D x, pip install x, cargo add x;
installedAt, not after a --token-like flag), one pinned with @
(x@0.36.4, lower case, not an IPv4 address; pinnedAt). A piece of a
name (drizzle-orm of drizzle-orm/pg-core, of @acme/drizzle-orm) is
judged as the whole name.
- moduleAt reads past an editor's line number and a diff's mark
(codeHead): Claude Code's Read gives " 1→import drizzle from
'drizzle-orm'", and a default import there wasn't an import line.
Tests: package_known_test.go.
TestKnownPackageNameGoesAsWrittenWhereCodeLoadsIt has the reporter's
literal line in a Claude Code tool_result after a sentence with the
name, in one Anthropic body, then alone (Mask, no model) and in a
second body: red on the old code at all three
(from ' {{SECRET_…}} '). TestModelPackageNamesInManifestsAndOutput: 22
shapes, red on the old code. TestPackageShapesKeepSecrets: a JSON key
with a non-version value, a password before @ip, a quoted secret on a
numbered line, prose with "install", a known secret in prose and on a
numbered line are masked still.
Run, at
|
||
|
|
936bdccfab |
gui: the page reads hand memory back only after 30s at rest, past every poll (#2278)
An open Usage or Sessions window polls every 10s and 15s. With a 3s rest, every poll's pages were handed back (ReleaseScratch + FreeOSMemory) and taken back by the next poll: in the CPU profile, 1.88s of 1.95s madvise was runtime.sysUsed re-committing them, and the matcher's scratch was made again on every poll. 30s outlasts both polls, so the pages go back once a window stops polling, not between an open window's polls. Measured on mote (~/r2278 run2278d: 10 endpoints every 5s, gateway feed from 60s, real ~/.codex and ~/.claude copy), 60s CPU profile, 3s vs 30s: GC mark workers 6.92s -> 4.76s madvise 1.81s -> 1.18s avg RSS after 60s 893 -> 925 MiB (+32 MiB while polling) Latency was not comparable (mote load 40-73 during the run). The binary measured was this constant at |
||
|
|
91a2f603cd |
gui tests: list-sort reads the Library's servers without the MCP hub's row (#2679)
|
||
|
|
310efb635c |
masking: a record from before a restart says its text was in memory only
brianeee2 on X: in Docker, the masked content can't be seen after the
container restarts; is a mounted folder missing?
No folder is missing. Reproduced on xiaomi-gpu with the image built from
|
||
|
|
f193c3865f |
sessions: a stats share keeps its days and models in slices, not maps (#2278)
statsOfRange made each session three maps per range on every poll (its models, the dates it counted and its per-date shares) and a list of the range's files first. A session has few models and few days, so they are small slices now, and the files are filtered as they are read. The output is the same: models are summed in name order and listed by tokens, then name, as before. Measured on mote (Usage stats polled every 5s with gateway feed, heap diff 120s to 200s, A/B against v0.1.1971 |
||
|
|
fae438b4a5 |
agent: Codex switched on again is joined, and its own models say where a pick goes
NancyTom18 on X: Codex on a routing group, Disconnect and restore, switched on again, then an OpenAI model picked: every OpenAI row said 直连. After a routing group again they said 经 magpie. Reproduced in a sandbox HOME (ChatGPT sign-in, a group): reconnect put the group back by Apply alone, so Codex was beside its sign-in and not joined (codex.joined went with the Disconnect). Picking one of its own models then took magpie out (set → unroute, #940): config.toml had no openai_base_url and no model_provider, so Codex went straight to OpenAI and the 直连 tags were true. Back on the group, the rows said via magpie from routed(), while a pick would again go straight to OpenAI, with no ask: that label was false. - reconnect calls Join first where the agent has one, so a Codex switched on again comes back as the switch first connects it: joined, its own models staying through magpie. - modelOptions: beside its sign-in, not joined (with ChatGPT), and failover off, Codex's own models say Direct "OpenAI", so the picker tags them 直连 and asks before a pick takes Codex off magpie. Tests: TestCodexReconnectStaysJoined (red on the old applied.go: "connected again, not joined"), TestCodexBesideOwnModelsSayDirect (red on the old codex.go: "gpt-5.5 says via"). Each fix reverted by hand, its test went red. Run on mote at this tree: go test -timeout 45m ./... all ok except internal/gui TestMainWindowCorners/macOS_26_SDK, mote's macOS 27 red filed as #3949 (window chrome, untouched here). go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., go build ./..., gofmt -l clean. GUI files unchanged; agent-leave-magpie and agent-path-same pass in Chromium and WebKit (4/4 each). Not tried: a real Codex binary with a real ChatGPT sign-in sending a turn; the route is read from config.toml as Codex's own provider rules read it. A Codex already beside a group from before this release stays so: its OpenAI rows now say 直连 and ask; switching it off and on joins it. |
||
|
|
2f55483718 |
sessions: a stats share makes its tools and skills maps only when a day has some (#2278)
statsOfRange made four maps (tools, skills, skillLast and a day's tools) for every session of every range on each poll, and most sessions' days use no tools or skills. They are made now on the first day that has one. Measured on mote (Usage stats polled every 5s with gateway feed, heap diff 120s to 200s, A/B against |
||
|
|
905166d786 |
sessions: Codex identities are kept while no rollout changes (#2278)
Every Sessions and Requests poll built the Codex thread identities again
over every rollout (CodexIdentities, CallSourcesAndCodexIdentities, List,
Stats, ListAgent, Get), though nothing had changed since the last poll.
codexIdentitySnapshot now keeps the identities it built for the last four
file lists, with what each Codex rollout gave them from: its key, the
cached identity's value and whether it conflicts. A list whose rollouts
give the same is handed the kept map. The maps are now shared, so only
read: CodexIdentities' comment says so, and the old test that deleted from
one is replaced by TestCodexIdentitiesKeptWhileNoRolloutChanges.
Run at this head (
|
||
|
|
5637cca141 |
settings: a notification when masking swaps a value for the first time (Must2333 on X)
Must2333 on X: "我还希望能即时的知道发生了替换,但不是通过随时监控网关的方式".
They want to know when magpie masks something without watching the
gateway or the 脱敏 page.
Settings › Usage has a new row, "Masking alert" (zh 脱敏提醒), after the
task done alert. Off/On, off by default. When on, a value masked for the
first time gives a system notification through the same notifier as the
other alerts. It says only how many new values, each kind and its count,
and the agents that sent them (two named, "+N" for more). It never says
the value, any piece of it, or the Head hint the 脱敏 page keeps. A click
opens the 脱敏 page on the latest record (clickView, "masking&key=<key>").
Why off by default: every other notification in this group is off until
turned on; turning one on asks macOS for notification permission; for
most users a notice each time masking works is noise, since masking's
expected behaviour is quiet protection. It is one row, in the group that
already holds the alerts, hidden while masking is switched off
(data-feature="redact") and in gateway mode.
Staying quiet:
- First time only: maskrec.Fresh says which values a record has that no
record before it had. A conversation sends its whole history each turn,
so a value is masked again every turn after its first. The index is by
placeholder (HMAC-stable across restarts), filled from memory and from
the days kept on disk, so a restart doesn't make a history new again.
The days are read off the lock, since Hold takes it on the request's
way. Values sent as written (Action "warn") are left out.
- A burst is one notification: records gather for 3s (maskGather).
- At most one every minute (maskGap); what comes in between is said
together after it. At most 5000 records wait.
- With the setting off, nothing is kept.
The gateway tells the app through gateway.OnMasked, after maskrec.Hold,
with Snips and Back taken out; nil under `magpie serve`.
Strings: en, zh, zh-TW, ja, de, in i18n.js (the row) and in
mask_alert.go (the notification's title and kind names, the 脱敏 page's
own words for the kinds). docs/subsystems/gateway-routing.md has the
bullet. The core script budget isn't raised: main's 10-29 budget leaves
room for the row's 287 bytes.
Tests, each broken by hand and seen red:
- TestMaskAlertFirstTimeOnly: masks through redact.Mask as the gateway
does; the history masked again says nothing, a new email in turn 4 is
said alone. Red when flush counts r.Values instead of the fresh ones.
- TestMaskAlertNeverSaysTheValue: no 4-character piece of the key, email
or phone, and no Head, in any of the 5 languages. Red with the Head
added to the kind's name.
- TestMaskAlertCoalesces: a burst of 5 from 3 agents is one wait of
maskGather and one notification ("+1"); two more 10s later wait
maskGap-10s and are said as one; off keeps nothing. Red without the
waiting check (5 waits) and without the maskGap wait ("waits 3s want
50s").
- TestFreshOnlyTheFirstTime, TestFreshHeldWhileReading (maskrec). Red
with loadFirst skipping the disk read (the history new after a
restart), and with the index broken (both).
- TestDismissedAlertOpensNothing covers the mask notice's click.
- mask-alert.test.cjs: every language at 900 and 380px, both engines:
the row after the task done alert, Off at first, On saves maskAlert,
another save keeps it, Off saves false, no click moves the page, no
left border, gone with masking switched off. Red with maskAlert taken
out of prefsKeep, and with data-feature taken off the row.
Run:
- This change on main
|
||
|
|
c93d9e0c0b |
usage: an unchanged Codex effort ask is told the kept answer, not a copy (#2278)
CodexModelEffort copied every thread's consumption for each ask (cloneEffort), though the kept answer is only replaced by a later build, never written, and its callers (the Sessions list, overview and a session's details) only index it and copy their thread's slice (addCodexModelEffort, addCodexSummaryModelEffort). On the #2278 bench (15G .codex) the copies were ~230 MB allocated every 80 s of an open Sessions page. Asks are now told the kept map itself; the doc comment says it is read-only. TestCodexModelEffortReadsLedgerOnlyWhenCallsChange wrote into the answer to check a caller's copy was its own. That guarantee is now the GUI's: TestCodexModelEffortCopiedPerSession checks a session and a summary get their own slice. TestCodexModelEffortAsksShareTheKeptAnswer checks two unchanged asks get the same map. Run at this tree on mote (macOS 27, Go 1.26.8): - go test -count=1 ./internal/usage ./internal/sessions ./internal/gui: usage ok, sessions ok; gui red only in TestMainWindowCorners/ macOS_26_SDK, which is #3949 (filed, red on macOS 27 on main). - GOOS=linux,windows,darwin go vet -tags nogui ./internal/usage ./internal/gui: ok. Broken by hand: maps.Clone back in the kept-answer return makes TestCodexModelEffortAsksShareTheKeptAnswer red ("told a copy"); dropping the GUI's slices.Clone makes TestCodexModelEffortCopiedPerSession red ("written through a session's copy: 999"). Not run: the full ./... suite, and the bench A/B (the 230 MB is from the v0.1.1967 heap profile, not yet re-measured). |
||
|
|
2b6ff0fbf9 |
usage: the gateway's sessions count only the log's blocks since the last
The gateway's projection of all time (gatewayProjection) was built again from every call in the log whenever the log grew, every poll with calls coming in: buildGatewaySessions was ~8% of CPU on the #2278 bench. It is now counted on from the sessions its full blocks counted, which never change: a session the new blocks touch is copied from the prefix and counted on, the rest are reused as they are, and the list is sorted again. The prefix is kept per price meta (usagePriceCacheKey, which holds aliases and clients) and zone, and dropped when the log is read afresh. Ranges and native exclusions still read out of the projection, and buildGatewaySessions stays for a since. finishGatewayModels now sorts a session's models before it sums their cost, so the sum has one order however the models were gathered (it was map order before). TestGatewaySessionsCountedOnAreCountedAfresh DeepEquals every session counted on with buildGatewaySessions afresh, after appends over a block's edge, a new session and a call older than the rest, a zone change and the log written over, and checks it was counted on. Broken by hand (a prefix session's days dropped): red at "first". Run at this tree on mote: go test -count=1 ./internal/usage/... ./internal/usageapi/... ./internal/tui/... ok; ./internal/gui/ red only on TestMainWindowCorners/macOS_26_SDK (#3949, open); GOOS=linux,windows, darwin go vet -tags nogui ./internal/usage/... ./internal/gui/ ok. The #2278 bench on mote (15G .codex, 10 endpoints polled every 5s, 4 calls/s appended, 240s), v0.1.1966 then this tree, back to back: - CPU profile 60s: 24.17s -> 20.83s samples; buildGatewaySessions (1.07s) and buildVias (0.79s) gone - poll mean 0.57s -> 0.51s; /api/sessions 1.47 -> 1.04s, overview 0.93 -> 0.63s, stats 0.49-0.52 -> 0.26-0.32s, heatmap 1.48 -> 1.19s - cpu after feed 43.6% -> 41.7%; RSS peak 982 -> 1125 MiB, footprint peak 742.5 -> 744.1M (the cold-start peak swings run to run; not this) Not tried: a real account's log (the bench log is generated). Refs #2278 |
||
|
|
2be04305fd |
usage: a session's model lists count only the log's blocks since the last
The whole log's model lists (cachedVias) were counted again from every call in the log whenever it grew, which with calls coming in is every poll: buildVias was ~3% of CPU on the #2278 bench. They are now counted on from what the log's full blocks counted, which never change, and only the blocks after are counted again. A session's counts are copied from the prefix before they are added to, so the prefix is never written. Rows are counted in the log's order either way. The prefix is kept for the same clients and renames key as the lists, and is dropped when the log is read afresh (its blocks differ). Window lists (a since) are built as before. TestViasCountedOnAreCountedAfresh DeepEquals the lists counted on with buildVias afresh, after appends over a block's edge, a new session and model, and the log written over, and checks that lists were counted on. Broken by hand (a prefix session's list cut in half): red at "first". Run at the next commit's tree (this one plus the gateway projection's fold, in other files): go test ./internal/usage/... ./internal/usageapi/... ./internal/tui/... ok; ./internal/gui/ red only on TestMainWindowCorners (#3949); GOOS=linux,windows,darwin go vet -tags nogui ./internal/usage/... ./internal/gui/ ok. Bench numbers are in the next commit. Refs #2278 |
||
|
|
28c89afcef |
usage: a period's summary counts only the log's blocks since the last
Each call the gateway logged changed the log's version, and every
/api/usage ask for Week or Month counted the whole period again: on
the #2278 bench (a busy gateway, 4 calls a second, the GUI's polls every
5 s) topSummary was 11% of CPU, beside GC at ~30%.
A period's summary now keeps what it counted over the log's full blocks
(512 rows each, never written again once full) and counts only the
blocks since, then the last block. It counts afresh when anything a
count depends on changed: a block it counted was replaced, a rewrite,
prices or names (meta), cleared calls, the period's bounds or series, or
the keying (hosts, accounts, keyed providers) changed. In the last case
an account that newly answers for a provider splits that provider's
earlier calls too. Rows are counted in the same order as before, so
every float comes out bit-identical. The group maps are copy-on-write
over the kept prefix, and only what was touched is copied.
Run at this tree, 213a31b4d before this message (the parent is origin/main
|
||
|
|
7795f55731 |
gui: the three typed-in-place number pills share pillNumber; app.js budgets back to before b4267de59
|
||
|
|
85d159a288 |
library: Connect an app is two tabs, agents in groups with a switch each (#2679)
The sheet behind Connect… is redesigned, closer to how Composio's MCP
router reads, and holds up with 25+ agents.
Agents tab: agents → magpie → servers drawn as icon stacks with
magpie's own bird in the middle (no accent block), one line of where
things stand ("19 of 23 agents use…", or the lone agent named), then
the agents in three groups: not connected, connected, keeping each
server's own entry. Each row is a switch (servers/agents-all
{agents:[id], on}); a kept agent shows a short word for why with the
full reason behind (i). Connect all in the bar connects the rest in
one post. With more than 8 agents a search narrows every group, and
the connected and kept groups fold to one row each ("Claude Code,
Cursor and 17 more") so the sheet fits the window.
Other apps tab: the address, then a row per app (Cursor when it isn't
an agent, VS Code, Windsurf, any JSON app) saying where its entry goes,
with Copy entry; Cursor and VS Code get Add in the app (hub-open).
Behaviour change: the switch's off takes every Library server away from
that agent (as By agent's Turn all off does), so turning it on again
gives it all of them, not the ones it had before.
"Why", "Connected" and "Not connected" moved to the core i18n.js: Go
files say them too, so i18n-keys refuses them as plugin words. zh says
已连接 / 未连接.
docs/subsystems/mcp-hub.md's GUI row describes the new sheet (and loses
a duplicated cell).
Run at 239981794 (rebased on origin/main
|
||
|
|
fa2dfc1458 |
sessions: the page's 7, 30 and all-time stats are read again in one pass (#2278)
statsFor keeps each ?days range the Usage page asks for and reads it
again behind the page once it is 10s old. Each of the three ranges
(7, 30, 0) was its own combinedSessionStats: a listing of every Claude
Code and Codex file, a refresh, the Codex identities and task titles,
every session assembled for the native keys, and the ccCopies, all
identical whatever the range. With 25k Codex rollouts that was ~4.2s of
CPU a minute on a polled page.
Now a stale range takes every other stale range with it, and
statsReadAll does the shared part once and sums each range from it
(statsOfRange). The sessions assembled for the native keys are reused
for each range's list instead of assembling them again.
Rebased onto b4267de59; the tests and vets below ran again on mote at
the rebased head, same results. The A/B ran before the rebase:
- TestStatsAllRangesOnePass (new): ranges 0, 1, 7, 30 from one pass
are each DeepEqual to statsRead of that range alone, and the files
are listed once.
- GOOS=linux/windows/darwin go vet -tags nogui ./internal/sessions
./internal/gui: clean.
- go test ./internal/sessions ./internal/usage: ok. ./internal/gui: ok
but for TestMainWindowCorners/macOS_26_SDK, the macOS 27 red in #3949
(titlebar, untouched here).
- A/B on mote, sandbox HOME with a copy of the real 115MB usage.jsonl
(240k rows) and 25k Codex rollouts, the page's 10 reads every 5s and
4 appends a second, 240s each, v0.1.1959 (
|
||
|
|
b4267de595 |
gateway: a provider's fallback can be a routing group, routed as the group
01huadalang on Discord: "还有备用模型增加路由组的选择,现在只能选模型". A
provider's Fallback list held models only; a "group/<id>" entry resolved
to the group's first member alone. Now such an entry is served through the
group, as a request to the group would be:
- plan → planPaused: a fallback naming a group (provider.FallbackGroup,
the group as routed, Live) hands its members to planLevel
(planFallbackGroup): the group's own routing, its sink and asides, and
its pause rules (serve passes provider.PausedOut for the agent's folder).
Its trace rows are marked Fallback with the group in Via.
- No loop, each provider/model once a round: a member that is the primary,
a model named earlier, or another fallback group's member is left out
where it comes second. Groups have no fallbacks of their own and a
member's fallbacks are not followed, so nothing leads back. A group that
is gone or off is passed over, as a model none serves is.
- Every sibling that reads p.Fallback now reads a group's members through
provider.FallbackModels: redaction (unredactedRoute: an unmasked
provider with a fallback group holding a remote model is masked),
careful accounts (carefulOf), native compaction, Codex's own turns
(codexFallsBack) and Claude's auto-mode review (claudeReviewed, which
moves from provider.Resolve to ResolveRoute, as the gateway reads
fallbacks).
- CLI: `magpie provider fallback` already took group/<id> (Resolve knows
groups); its usage and error now say so. Pinned by
TestFallbackCmdTakesGroup.
- GUI: the provider editor's Fallback picker lists the routing groups
(providers.gateway.groups) beside the models as chips with the Routing
fan and a muted "routing group" tell; a picked group's row has the same
fan and tell, and a gone one says "No routing group {id} now; it is
skipped". A filter matches a group's name, id and its members'
providers. New strings in zh, zh-TW, ja and de.
- app.js budget raised 187 bytes on main (1,311,922; core 1,531,060), the core's
own editor, no room added; the addition was cut from ~900 bytes first.
- docs/subsystems/gateway-routing.md: the Candidates row says all this.
Not done: a fallback group's turn rules (ruleFor/ruleOver, which can ask
a classifier) are not applied. The plan is made before the primary is
tried, so they would cost a classifier call on every request the primary
answers. Its routing order, sink and pause rules are applied.
Run (at f6e7214af; after the rebase, the last bullet):
- gofmt -l: clean. mote: go build ./...; go vet on the touched packages;
GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...: ok.
- mote: go test -timeout 45m ./...: every package ok except internal/gui:
TestCoreScriptBudget (fixed above, then ok) and ten AppKit window tests
(TestDockJoinLeadsCommandTab, TestPanelCloseHidesIt, TestMainWindowCorners
…) killed at their 30s bars while four other sessions' GUI suites held
mote at load 70-110. Run alone, all ten
pass (TestDockJoinLeadsCommandTab skips) except TestMainWindowCorners,
red at base
|
||
|
|
0daf363325 |
gateway: a key resting after an outage is asked again in the background
heatonz on Discord: a key or provider paused after a failure stayed out
for its whole rest, even after its vendor was back. Only Try now got it
back early. probeOne asks only the resting candidate that comes back
soonest, so a key behind ready ones was never asked again early.
What changed:
- gateway/rest_probe.go: the background ask, with no setting.
- Which rests it asks: a key's own rest from a failure that names no
time (a 5xx, a 408, no connection), resting by backoff, at a vendor
whose model list is asked over the network (provider.ListAsks).
- How it asks: the vendor's model list, with the key and its p.Via
proxy. A list costs no allowance.
- When: 1m into the rest, then 2m, 5m and every 10m, each ask at least
half a step before the rest ends. The rest is lifted as soon as the
list answers, the way Try now lifts it (unsink, trace).
- Cost: one list per resting key per step, so at most 4 lists in a
10-minute rest.
- The loop runs from ListenAndServe. A Server whose loop isn't running
(a test's) queues nothing. A loop that ends waits for the asks under way.
- Not asked: a Retry-After or ratelimit reset header, quota or credit, a
rate limit, a refused key, a 4xx, one model's rest, a subscription's
account, a plugin. Those still end on time.
- Rate limits are left out on purpose. A model list answers while chat
still gets 429, so lifting early would undo Sink and go around the
vendor's limit.
- A list answers for the vendor, not for every model behind it. A key
that fails again within 30 minutes of a lift is not asked again until
it answers a real request (probeAnswered in served).
- Rest.Probed / KeyRest.Probed. The provider's key row and Routing's
words for the try add "checked in the background, back as soon as it
answers", in en, zh, zh-TW, ja and de.
- app.js stays under its budget with no raise: a shared hhmm helper, and
resetUsedWhen folded into the identical stamp.
- docs/subsystems/gateway-routing.md describes it.
Tests:
- rest_probe_test.go:
- lifted after one failed ask and one answered, asked with the resting
key;
- no ask again after a missed lift;
- each excluded rest: never queued, 0 asks;
- no loop, no queue; the loop waits for its asks, and a cut-short ask
doesn't lift.
- gui/tests/rest-probed.test.cjs: 5 languages x 1100/420px x chromium and
webkit, 40/40. Red on origin/main's assets.
Broken by hand on mote, each red:
- no lift: test 1 times out;
- no status check: refused key and bad request get asked;
- Retry-After ignored;
- no miss guard;
- no asks.Wait() in the loop's exit.
Run:
- go test -race -count=5 -run TestRestProbe ./internal/gateway: ok.
- mote: internal/gateway ok (636s); internal/provider ok.
internal/gui TestMainWindowCorners/macOS_26_SDK is red on macOS 27,
unrelated, #3949.
- Linux Go full suite (wsl-run, -timeout 45m) at 6cbd77608 (the same
change on
|
||
|
|
3c6b7d585f |
agent: OpenClaw is wired up like the other agents
arthur041691 (Discord #help) runs OpenClaw for WhatsApp and asked for it in
Agents. Connecting writes magpie as a custom provider of OpenClaw's own, in
openclaw.json, and makes the picked model agents.defaults.model's primary.
What is written, from OpenClaw's source at 5bab0c14 (npm 2026.10.8, dc2523e):
- the file: OPENCLAW_CONFIG_PATH, else $OPENCLAW_STATE_DIR/openclaw.json,
else ~/.openclaw-<profile> for a named OPENCLAW_PROFILE, else
~/.openclaw; ~ is OPENCLAW_HOME when set (src/config/paths.ts,
src/config/state-dir.ts, src/cli/profile-utils.ts). OPENCLAW_PROFILE is
a name, not a path (agentenv.NotPaths); the other three expand a
leading ~, as resolveUserPath does (appdir.usable).
- models.providers.magpie: baseUrl (the gateway's /v1), apiKey (the
OpenClaw-named gateway key), api "openai-completions", and every model
magpie serves with id, name, input, reasoning and contextWindow
(src/config/zod-schema.core.ts, docs/gateway/config-tools/custom-providers.md).
A user's own keys on a model entry (headers, maxTokens…) stay on Sync.
- agents.defaults.model keeps its shape (string or {primary, fallbacks});
agents.defaults.models gets the ref's {} entry as `openclaw models set`
adds it (src/commands/models/shared.ts), only when that map exists; a
non-empty modelPolicy.allow gets "magpie/*" when nothing there lets
magpie's models in (src/agents/model-selection-normalize.ts).
- Model changes are hot-reloaded (docs/gateway/configuration/hot-reload.md);
a chat that already has a model keeps it (docs/concepts/models.md), so
the notice says to send /model default there. Translated in every
language.
- The file is written through temp-and-rename; a new one is 0600 in a
0700 folder, as OpenClaw makes it (src/config/io.write.ts). A file that
isn't JSON after comments are blanked (JSON5's bare keys) is left alone
with an error, never read as empty.
- Disconnect puts back the model there was, removes magpie's provider,
its {} entries, the allow entry and any object magpie made, and the
file itself if magpie made it.
Icon: a mask drawn from OpenClaw's ui/public/favicon.svg (MIT).
Run, on mote at this tree:
- go test -tags nogui ./internal/agent -run OpenClaw plus the every-agent
tests (drift, port move, sync on another machine, reverse proxy, LAN,
pinned key per writer, notices translated), ./internal/appdir,
./internal/agentenv: ok.
- Broken by hand, each red then green again: no stash restore
(TestOpenClaw, Shapes, AllowList), user keys dropped
(SyncKeepsTheirs), no allow entry (AllowList), no JSON5 guard
(JSON5LeftAlone), profile ignored (Paths), OPENCLAW_PROFILE back as a
path variable (Paths).
- Real OpenClaw 2026.10.8 from npm, Node 24.22.2, sandbox HOME on mote:
onboard --non-interactive made the file (its bytes are the test
fixture); magpie's code connected it; `openclaw config validate` ok;
`openclaw models list` shows magpie/kimi/k2 as default; `openclaw agent
--local` sent POST /v1/chat/completions with Bearer magpie-openclaw and
model kimi/k2 to a fake gateway on 3425 and showed its reply; no
agents/*/models.json override was written; Disconnect gave the file
back byte for byte and it validates.
- GUI: i18n-keys, agent-notice-lang, icon-tile, about-notices,
agent-connect (Chromium and WebKit): 53/53.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok.
- Full suite, go test -tags nogui -timeout 45m ./... at
|
||
|
|
d7e9c37454 |
usage: a call pairs again only the heatmap's last days, not its year (#2278)
Each call through magpie changes the gateway's newest block, so the heatmap's 30 s reuse missed and HeatmapOf paired a year of gateway rows against every session file again: 15% of magpie's CPU on real history (HeatmapOf -> pairRows 5.2 s of 32.7 s sampled), ~2.3 s a refresh, and a large share of the allocation the GC marks. heatSplit keeps the days before cut (00:00 two days ago) from the last full pairing, with the serials of the chunks that can't reach past cut (newest row more than heatReach = 48 h before it). A call then pairs only the recent chunks, from cut on (pairRowsIn), and adds their days to the kept ones. Every chunk is paired again when: - a settled chunk changed or went (its serials differ), or - the recent chunks' rows before cut changed: a session file copied in or a rollout forked from an old one holds calls of then (heatBefore, a count, time and token sum of those rows), or - cut moved (a new day), or the kept pairing is heatOldFresh (10 min) old. heatReach covers a call paired across cut: a full gateway block whose newest call is before cut is still paired with the session row after it. TestHeatmapAfterACallAddsUpOnlyWhatChanged's gateway now has a call of the last days before its first build, as a gateway in use does: with only a call of 40 days ago its block went from settled to recent at the call, which is a full pairing by design. Run on mote, heat2278 at this head (based on |
||
|
|
b2d005bf38 |
gateway: a MiniMax API key makes videos with H3 (_tigerqueen_05867)
A MiniMax API-key provider (api.minimax.io, api.minimaxi.com, api.minimax.cn) now lists MiniMax-H3, -H3-Highspeed, -H3-Lite and -H3-Max as video models. They are never in chat lists. generate_video and /v1/videos start a task at <host>/v2/video_generation, poll /v2/query/video_generation/<id> and hand back the MP4. The prompt, seconds (raised to each model's minimum and capped at 15), resolution (from Extra or size, clamped to the model), ratio, first and last frame and up to 9 reference images go through. /v1/videos now reads last_frame; MiniMax and a remote magpie pass it on, other videomakers ignore it. The MCP schema is unchanged. Failures say which one it is: a turned-away key (1004/2049/401), no pay-as-you-go balance (1008/402), refused input or output (1026/1027), a Token Plan key without H3 (2061/2068/2057, which moves on to the next key), or the rate limit. AutoVideomaker puts MiniMax last, so generate_video, which has no model argument, uses MiniMax-H3 only when nothing else makes videos. All of it is gated on a MiniMax host, so no other vendor changes. Run on mote at 798c8fd48 (base |
||
|
|
fb59595530 |
usage: TestClearedUsageLeavesThePages leaves no clear behind for the next test
The test ends by clearing everything up to now. readCleared keeps what it read in clearedAs, and a test that builds a page straight from chunks (buildRequestBlocksWithCodex) never reads the clears again, so it judged its rows by that stale clear and hid them all: with -run "Heatmap|Pair|Scratch|Request|Page", TestCodexRequestPageDoesNotMutateSharedCompactionChunks (3 subtests), TestCodexRequestPageFoldsCopiesBeforeResponseMatching and TestRequestDiskNamesItsSource failed on origin/main |
||
|
|
a0ba8e1f2e |
grok: each model's context_window follows Long conversations, and one set by hand stays through a sync (uk.jent)
uk.jent (Discord #feedback) reported that magpie writes every Grok Build model's context_window as the model's whole window. They wanted about 300K without editing dozens of models, and they lost hand edits on each sync, because SetTOMLTables replaces the [model."magpie/..."] tables whole. Grok Build now uses Long conversations, the mechanism Codex and Claude Code already use. grokWindow gives: - min(window, Compact) when the model or provider has its own threshold; - otherwise settings.Working(window): 272K by default on longer windows, the typed size, or the whole window with Full context. What magpie wrote is stashed under grok:<path>:windows, and grokOwnWindow uses it to tell a hand edit apart: - A value that differs from what magpie last wrote is the user's, and it stays. - In a config written before the record, a value other than the model's whole window is the user's. - Disconnect forgets the record. The agent sheet's Long conversations row now shows for Grok Build (AGENT_PREFS). Its texts, the provider editor's hint, the Context tab's note and `magpie model compact` now name Grok Build, in en/zh/zh-TW/ja/de. setCompact and setAsync now share prefWrite. That dedupe keeps app.js under its budget, which is not raised. Behaviour change: a Grok Build model whose window is over 272K now gets 272K by default, as Codex does, unless Full context is on. Run on mote, at this head (c893c2229, rebased on |
||
|
|
49d4d0f7ab |
usage: the request matcher keeps its maps for the next call, and gives them back once the window rests (#2278)
Every poll while an agent works matches a year's history again: matchedBlocks and codexChunkResponsePairs grew their maps (byID, reserved, used, groupOf, picks, picked, ...) and slices from nothing on each call. They were ~3.0 GB of the ~40 GB a poll-heavy 80 s allocated on the real-history harness (d1951 heap diff, 120 s to 200 s). A sync.Pool was tried first and kept nothing in real use: under tightenGC a poll collects 4-5 times a second (1029 GCs in 230 s), each collection empties the pool, and the matcher's flat allocation went only from 2241 to 1840 MB. So one scratch of each is kept in an atomic.Pointer, emptied after a call (clear() keeps the maps' buckets, and drops every chunk the call saw), and let go by usage.ReleaseScratch, which releaseIfPagesRest calls before FreeOSMemory: once the window's reads have rested 3 s, what the matching kept goes back with the rest. A call that finds the scratch taken makes its own, sized as before. matchedBlocks' result map is now made once the id matches are known, not grown from the response pairs alone. Measured on mote (Apple M5 Pro), at |
||
|
|
fe05f0a721 |
library: a skill can be turned off on this computer alone, and a sync neither carries that nor turns it on
hanslin1666 on Discord (#general 1565016936344191096) wanted a library
skill off on one computer only ("只在这台电脑上关掉"). The only way to do
that was to untick its agents, and the ticks are what a sync carries, so
every other computer lost it too. A sync from a computer that had it on
also gave it back here.
Skill.OffHere (library.json "offHere", omitempty) turns a skill off on
this computer. No agent here gets it, whatever Agents says. Every reader
that gives a skill to an agent now asks gives():
- syncSkills, including the shared ~/.agents/skills check;
- desktop_skills.go;
- skill_changed.go;
- skill_edits.go;
- behind;
- Targets.
Agents stays what a sync carries, and the page shows those chips faded.
Collect never carries OffHere, so turning a skill off changes no part a
sync uploads. Put keeps this computer's OffHere for a skill it puts, so
a sync from a computer that has it on (or that gives it to more agents)
leaves it off here.
Where to turn it off:
- GUI: a power button on the skill row (aria-pressed). When off, an
"Off on this computer" tag sits on its own line under the name; it
says why and turns the skill on when clicked.
- CLI: `magpie library skill off-here|on-here <name>`.
- TUI: the row says the skill is off.
The strings are in en, zh, zh-TW, ja and de.
Existing users: nothing changes. An older library.json has no offHere,
so every skill stays on, and a skill that was never turned off writes no
key (TestSkillOffHereOldLibraryIsOn).
Not covered:
- a project's skills;
- a library skill whose own folder is inside ~/.agents/skills, which
agents read in place;
- a skill another computer removes (the flag goes with it).
The skill's files in the library folder still update while it is off.
Docs: docs/subsystems/library.md and sync-backup.md.
Run at the parent
|
||
|
|
ec3dad75ae |
provider, gateway, gui, cli: Claude's accounts can be kept to Claude Code's own sign-in, magpie serving nothing on them (myduso)
myduso on Discord asked for an exclusive mode on Claude's subscription: switch the credentials locally and proxy no traffic, since Claude Code is used on its own and the SDK run magpie's bridge makes spends more of the allowance than the interactive client. The switch-only setting Codex has (#1907) now also takes claude. On it, Provider.KeptToAgent is true and On() false, so the gateway, catalog, groups, fallbacks, search, draw and embeddings serve nothing on the Claude accounts, and a request naming them is refused 404 saying they are kept to Claude Code's own sign-in and how to undo it (switchedOff). Switching Claude Code's sign-in when an account is used up, and reading usage, go on: both are gated by leftAlone on the raw Off, which this doesn't set. Groups magpie found keep their Claude members (heldOffEntries). Nothing is sent as Claude Code: magpie only writes and restores Claude Code's own credentials as it already did. GUI: the tick under Claude's accounts, shown with one account too, drawn by the block Codex's tick had (one block now, its strings picked by agent). app.js stays under its budget with no raise (1,311,711 of 1,311,735). CLI: magpie accounts switch-only <codex|claude> [on|off]. Docs: reference.md, subsystems/providers-accounts.md. Run on mote at this tree on 06950fbbb; then rebased on |
||
|
|
aeacc6358a |
gui: app.js back under its budget after 06950fbbb landed on f00407200
|
||
|
|
06950fbbbb |
gui: Codex's two subagent settings say which is the default and which holds every subagent
HoGee_xxl on X read Codex's "subagent model" as the default for a
subagent the lead names none for, and found every subagent held to it.
The two read alike ("subagents" / "subagent model"), so each now says
what it is, in en, zh, zh-TW, ja and de. Wording and notes only:
- subagent model, unset: the lead picks each subagent's model, one it
names none for runs on the lead's model, a resumed subagent stays on
the model it started on, and a pick here holds every subagent even
when the lead names another.
- subagent model, set: every subagent on it even when the lead names
another; Same as the lead gives the pick back.
- subagents (Codex's default_subagent_model): the model a subagent
starts on when the lead names none; the lead may still name another.
- Codex's settings row "Codex subagent model" shows that line as a .sub
note under its name, as the rows beside it do, not only on hover (the
empty note is in index.html).
app.js stays under its budget with no raise (1,311,673 of 1,311,681):
the comments beside these strings were condensed.
Run (mote-run, Chromium and WebKit, every language):
- node --test codex-subagent-model, codex-subagents-lead, i18n-keys,
codex-memories, codex-memories-settings, codex-start-model-field,
context-tune, gateway-mode, subagent-effort, agent-tweak-fold,
claude-auto-mode, claude-subagent-effort-row, claude-subagents-pick,
desktop-subagent-model: 227 of 248 ok on the first run; 20 reds were
"browserType.launch: Timeout 180000ms" with mote at load 71 and 43
Chrome processes from other runs, one a desktop-subagent-model zh
420px routing wait. The five files with reds, rerun one at a time:
76 of 76 ok.
- After the budget trim: codex-subagent-model + codex-subagents-lead
40 of 40 ok (concurrency 1; at concurrency 2 under load 52 the first
chromium en case of each was red, #2645's class), i18n-keys ok.
- go test ./internal/gui: TestCoreScriptBudget ok. AppKit window tests
killed at their deadlines at load 71-105 (#2645) pass rerun, except
TestMainWindowCorners/macOS_26_SDK, red the same way on origin/main
|
||
|
|
25bf394a72 |
gateway: a resumed Codex subagent goes back on the model it was spawned on
HoGee_xxl on X: a Codex subagent brought back with resume_agent ran on
the lead's model, not the one the lead spawned it on.
Codex's multi-agent V1 (the one magpie's own models ask for) builds the
resumed subagent's config from the lead's current turn:
codex-rs core/src/agent/child_config.rs build_agent_resume_config ->
build_agent_shared_config sets config.model to turn.model_info().slug,
and core/src/agent/control/spawn.rs resume_single_agent_from_rollout
starts the thread on that config without reading back the thread's
stored model. Neither the spawn_agent model nor [agents]
default_subagent_model is asked again. V2's ensure_v2_agent_loaded does
put a thread back on its stored model, so this follows Codex's own rule.
The gateway now notes the model each Codex subagent thread (thread_id in
x-codex-turn-metadata / client_metadata; session_id only on a Codex old
enough not to share it) first asked for, and puts a later request of
that thread asking for another back on it. Kept in codex-subagents.json
beside providers.json (0600, temp file and rename, the 512 latest, 30
days), so a resume after a restart is known. A model set for every
subagent (codexSubagentPick) still wins. No prompt or base_instructions
is touched.
Run (mote-run): go test ./internal/gateway -run 'TestCodexResumed|
TestCodexSubagentThreadOf|TestCodexSubagent|TestCodexFollow|
SessionMetadata|TestCodexSide' -count=1: ok.
Broken by hand: skipping the restore in codex_backend.go turns
TestCodexResumedSubagentKeepsItsSpawnModel red ("worker-1 asking gpt-5.5
went on gpt-5.5, want gpt-6-astra"); skipping the save turns its
after-restart step red.
Not tried: a real Codex resume_agent run against a real ChatGPT account.
|
||
|
|
f004072007 |
agents: More in Plugins is in sight with Install another agent folded
The owner: 插件中还有更多,不应该折叠在安装更多Agent里. |
||
|
|
06469694b7 |
usage: pairing a poll's calls allocates 40% less, in a few slabs (#2278)
Under polls, with calls coming in, GC was ~35% of magpie's CPU and
madvise another 16%, both driven by how much a poll allocates. The
pairing that the heatmap and every page run did most of it: in an 80 s
heap diff on a year's history, matchedBlocks allocated 3.2 GB and
codexChunkResponsePairs 2.6 GB.
- matchedBlocks: a match key holds a call or two, so each key's ends
and range counts were two slices of their own. They are now one ends
slab and one counts slab, a group an offset into them, and groupOf is
made the size of the calls it keeps. The candidates and unique maps
are a slice and a []bool over slab positions.
- codexChunkResponsePairs: picks and their slab are made the size of
the gateway's response ids, and a gateway call is judged from its
packed strings (codexGatewayCall) instead of being made a whole Row.
What a call pairs with is unchanged.
BenchmarkPairRows (new; 2,000 session files of 100 calls, half Codex by
response id, half Claude Code by session and tokens), on mote:
|
||
|
|
e0ea15b8e8 |
library: an MCP hub, one magpie server in place of every library server (#2679)
With Library → MCP → "MCP hub" on (off by default), each agent that takes an MCP server over HTTP is given one entry, magpie, at /mcp/magpie/hub/<agent>, in place of the library servers ticked for it. magpie runs those servers itself, once for every agent: a command starts on its first call and ends after 10 idle minutes, a URL server is reached with its headers and MCP sign-in. Tools are <server>__<tool>; a tool off in the library is neither listed nor run. Any other app connects at /mcp/magpie/hub, which serves every library server. Both are guarded as /mcp/magpie/tools is (local or a gateway key, no foreign page, 4 MiB, the key's limit per call). An agent that reaches no server over HTTP (Claude Desktop), has a magpie entry of its own, or sits beside a library server called magpie keeps each server's own entry, and the page says why. Off gives every agent its servers back and ends every process the hub started. GUI: a switch under the MCP list, a line of what it serves, the address, and a Connect… sheet. The sheet lists every agent magpie detects that takes MCP (not a fixed four), each with where it stands; one given none of the hub's servers has a Connect that ticks it for every server it can reach (servers/agents-all), so it gets the entry, and the sheet stays open. Then any other app: Cursor (when it isn't a detected agent), VS Code, Other, with the JSON and, in the app, "Add to …" through the app's own install link built in Go (servers/hub-open; the page never sends a link). CLI: magpie library mcp hub on|off. Design: docs/subsystems/mcp-hub.md. With #3885 ( |
||
|
|
62045475b4 |
library: Codex on magpie reaches a command's MCP server through the gateway, run only while a thread uses it (#3885)
Codex starts every stdio server in its config once for each thread it has loaded and keeps them as long as the thread: YPYT1 counted 204 node processes, 21 GB, beside one Codex. While Codex is on magpie (Wired, not disconnected, this machine's gateway key, not WSL) the library now gives it a server run by a command as url = <gateway>/mcp/run/<name>, which magpie serves over streamable HTTP and runs the command for itself (internal/library/mcp_run.go): - a session (Mcp-Session-Id) starts its own child only when it sends something past initialize, the first page of tools/prompts/resources lists and ping; those are answered from what the first child said for the same command, args and env, and a list_changed from a child drops that list; - a (re)started child gets the session's own initialize replayed, so a server that keeps state per client still keeps it per thread; - a child idle for 15 minutes is stopped (a later call starts it again), DELETE stops it, and a server changed or removed from the library has its children stopped at the next sync; - server-initiated requests and notifications go to the session's newest open stream (GET, or a POST answered as SSE). The gateway route lets only this machine in: no Origin, a loopback Host, no forwarded or LAN address (TestRunMCPThisComputerOnly). A server with an env var magpie hasn't, a remote one, and Codex off magpie, in WSL or on another machine's key keep the command as before. agent.Rewired re-syncs the library when Codex is connected or disconnected, so it is handed the commands back when it leaves magpie. Tests (internal/library/mcp_run_test.go, a fake server): starts on a call and not on initialize/lists, idle end and DELETE, a server's own request round-trips, list_changed, a changed/removed spec, an unknown session, and the Codex entry in a sandbox (url when wired, the command back when not, a keyed env var kept as a command). Each was red with its part broken by hand: the init cache removed, the sweep off, runsFor forced false, forget a no-op, the Origin/Host guard dropped. Real runs: - mote, sandbox HOME, real codex 0.162.1 + @modelcontextprotocol/ server-memory: config.toml gets url = "http://127.0.0.1:3581/mcp/run/ mem"; codex app-server's mcpServerStatus/list lists its 9 tools through the bridge. - this Mac, sandbox HOME with only the DeepSeek provider copied, codex 0.162.1 on deepseek/deepseek-flash: a real turn called mem create_entities and read_graph through the bridge and answered with the stored observation. Three codex exec turns at once that used no tool started 0 memory-server node processes (before: one each). - Windows 11 (xiaomi-gpu), sandbox profile, codex 0.161.0: url entry written, app-server lists the 9 tools, 0 memory-server node.exe left after Codex closed. Run at the pushed head (mote): GOOS=linux/windows/darwin go vet -tags nogui ./internal/library/ ./internal/gateway/ ./internal/agent/: ok. go test -count=1 -timeout 45m ./internal/library/ ./internal/gateway/ ./internal/agent/ ./internal/gui/: library ok (167s), gateway ok (596s), agent ok (279s); gui FAIL only TestMainWindowCorners/macOS_26_SDK ("a toolbar doesn't change the corners ... yet the main window's was taken off"), #3949, red on mote's macOS 27 on main too; no gui or AppKit file is touched here. Windows (win-run): go test -run 'TestRun|TestFakeRunServer|TestMCPProxy' ./internal/library/ ./internal/gateway/: ok. Not tried: the Codex desktop app (the same config.toml), a server that asks the client for sampling or elicitation in a real agent. Codex picks up the new entries when it restarts. Reported-by: YPYT1 |
||
|
|
ddf31ca305 |
gateway: a large translated body is written into itself, its items not kept beside it (#4004)
marshalBody marshalled every item of a translated request's list (the messages, the input items) and kept the bytes, so it could size the body exactly before copying them in: at the body's peak the written items were a whole copy of the conversation beside the body. Past bodyKept (4 MiB) of kept items, an item is now only measured, encoded through a json.Encoder into a writer that only counts, and once the body is made it is encoded again straight into it, then let go when its list is spent. A body under 4 MiB is written as before, with no second encoding; a larger one pays its encoding once more (on mote the 47 MiB case of TestMarshalBodyAllocatesTwoBodies went 0.09 -> 0.11 s for both marshals together). The bytes are json.Marshal's either way. Measured on mote, scratch harness (not committed): a 45 MiB Codex conversation sent Responses -> Chat through the gateway, GOGC=10, HeapInuse sampled every 2 ms, 3 runs each, base heap 54 MiB: |
||
|
|
8eb7f5565b |
gateway: a translated body lets its built conversation go as it fills (#4004)
marshalBody wrote a translated request's list (Chat's and Anthropic's messages, Responses' input) an item at a time, but the list itself, the conversation the builder made, strings joined from the request's parts among it, stayed held in the body's map until the whole body was written: at the body's peak it sat beside the written items and the body. The builder names that list as spent, and each item is set to its zero value once written. Every caller's map is its own and dropped after the call (buildChat, buildAnthropic, buildResponses); buildGemini spends nothing. Keys are checked before anything is spent, so the json.Marshal fallback for an odd key still sees the whole map. Measured on mote, TestZZPeak4004-style scratch harness (not committed): a 45 MiB Codex conversation sent Responses -> Chat through the gateway, GOGC=10, HeapInuse sampled every 2 ms, 3 runs each: base |
||
|
|
f6e7214af7 |
minimax: api.minimax.cn is MiniMax China, for the usage card and the thinking sent back
MiniMax moved its China API host to api.minimax.cn (MiniMax-AI/cli
8746d48f, 2026-09-28: mmx agent setup now writes it into Claude Code,
Codex, OpenCode and pi). api.minimaxi.com still answers, but a provider
pointed at the new host got no usage card, because the plan-quota source
knew only api.minimaxi.com and api.minimax.io. Chat requests to it also
lost the <think> block MiniMax wants back on the turns after.
Every place in magpie that matches MiniMax by host is covered:
- planquota.go: api.minimax.cn reads /v1/token_plan/remains on its own
host. Probed without a key, api.minimax.cn answers this path with the
same base_resp 1004 as api.minimaxi.com.
- gateway/chat.go: inlineThink also matches minimax.cn.
Pricing and the catalog go by the provider's Catalog id ("minimax"),
not by host, so nothing changes there. The presets keep api.minimaxi.com.
Tests: a TestPlanQuotaSource case and a TestMiniMaxThinkingGoesBackInTags
case for api.minimax.cn. Both are red on the old code (code reverted by
hand, test kept; mote-run) and green with the fix.
Run on mote (mote-run):
- At 96bfdd57c (base
|
||
|
|
2fc2d53583 |
routing: the head's line keeps its height live, so a pick doesn't pull the list up
|