449231c19f9863d011c0c7d9e714c95fc2dcc094
1233
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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.
|
||
|
|
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. |
||
|
|
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 |
||
|
|
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
|
||
|
|
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. |
||
|
|
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
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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 |
||
|
|
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 |
||
|
|
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 |
||
|
|
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 ( |
||
|
|
425a613224 |
library: a server run with npx -y reaches the agent as node running the package (#3885)
npx stays running as the server's parent for the server's whole life. On Windows that is cmd.exe + npx's node + a second cmd.exe beside the server: measured on xiaomi-gpu with @modelcontextprotocol/server-memory, 4 processes and 143 MB (cmd 8.1, npx node 76.2, cmd 8.2, server 50.8) for one instance. Codex starts an instance a thread; #3885 had 223 node processes under codex.exe. A library server `npx -y <registry package> args` (no other npx flag) is now installed with npm into ~/.config/magpie/mcp-npm/<hash> in the background, and the next sync writes it into each agent on this machine as `node <package bin> args`: node by name for npx by name, or the node beside an npx given by path. Until the install is done, or when npm fails (tried again after an hour), the agent keeps npx. An unpinned spec is installed again after a day, as npx would fetch the newer one; an install no library server runs any more is removed a day after its last. The library's own entry, a server's check, Copy config… and WSL agents keep npx. Taking a server off ends node's run of the program (launchedBy reads the node line), as before for npx. Run at this head (rebased on origin/main 1ff54f079; nothing it brought touches internal/library): - mote: go test -count=1 -timeout 45m ./internal/library ok (116s); GOOS=linux/windows/darwin go vet -tags nogui ./internal/library ok; ./internal/proc/... ./internal/testenv/... and the root package ok; TestNpx*/TestReadNpx under -race ok. - xiaomi-gpu (win-run): TestNpx*/TestReadNpx ok. - Real, on xiaomi-gpu, Node 22 + real npm registry, sandbox HOME: the library synced server-memory into a Codex config.toml; the install took 12.8s and the second sync wrote command = "node", args = [the install's …\server-memory\dist\index.js]. Started from that entry, the server answered initialize and tools/list, and its process tree was 1 process at 56.2 MB, against 4 processes and 143 MB through npx. - Broken by hand: without the npxDirect call in syncMCP, TestNpxServerRunsByNode is red ("the package was never installed"). Not tried: a real Codex or Claude Code session starting the node entry (the entry has the same command/args shape they already start), and macOS's process tree (npx's node and sh there too). Not done (#3885 stays open): Codex starting the same MCP once a thread. |
||
|
|
1ff54f079f |
grok: each model is asked on its native API (responses, messages), not Chat for all (uk.jent)
uk.jent on Discord: magpie wrote api_backend = "chat_completions" on every
[model."magpie/…"] table of Grok Build's config.toml, so a Responses-only
GPT or a Claude on an Anthropic endpoint was translated through Chat by
the gateway. Grok Build 1.0.67's own docs (the "Supported API Backends"
page bundled in its binary) take api_backend per [model.*] table:
"chat_completions" (default), "responses" and "messages" (Anthropic
Messages), sent to base_url + /chat/completions, /responses or /messages.
grokBackend now writes the model's native API from catalog.Model.APIs, as
Pi, droid and dsh pick theirs; Chat stays for a Chat-native or unknown
model and for a group whose members differ. All three go to the same /v1.
Grok App (grokapp.go) is unchanged: it has one channel, [model.magpie],
whose model the App's composer switches, so a backend written for the
picked model would be wrong for the next one picked there.
Run:
- TestGrokAsksEachModelNatively (new): red with the old "chat_completions"
put back by hand ("resp/gpt-6-sol: api_backend "chat_completions" ...
want "responses""; same for anth/claude-sonnet-5 / "messages"), green
with the change.
- At this head (rebased on origin/main
|
||
|
|
2cdbe92ded |
pii: a value the model found sure once in a text is sure wherever it found it there
wangwu25685333 on X (10-29): of one sentence with an address repeated
400 times, the address was left unmasked "a few times", thought to be
where the text was cut into chunks.
Reproduced with the real model (AstrLink Guard, pure Go, Linux box,
GOMAXPROCS=4) through masking's strict path and redact.MaskJSON, 400
copies of a sentence in one message:
"Please ship it to 1600 Amphitheatre Parkway, Mountain View, CA 94043
by Friday." joined by "\n": 346 of 400 left as written; by " " or
nothing: 0. Two Chinese addresses, any joiner: 0.
It isn't where the text is cut. Guard found the address on every line,
but less surely the more often it had read it in the text: 0.99 alone,
0.59-0.70 at 20 copies, and on 400 the whole address 325 times at 0.50
to 0.90 and split ("1600" at 0.85, the rest at 0.50-0.59) 65 times.
Masking takes 0.8 and over, so it masked only the sure ones, about one
a piece. Joined by "\n" the pieces are alike, so every piece got the
same few sure finds.
Now spread puts each value of 8 bytes or more the model found in a text
(minSpread, as redact's minKnown) wherever else it is in that text,
with its label and the score of its surest find there, then merges. A
value never found sure stays as unsure as it was, and a house number
alone isn't looked for. It runs on each text and piece the model reads
and on a long text's merged pieces, before they are cached. Spans from
the disk cache written before keep their scores until read again.
After, the same probe: 0 of 400 left for every sentence and joiner.
Test: TestValueFoundSureOnceIsSureThroughoutItsText has a stand-in model
that finds an address sure only first in its first read and unsure
after, on 3 and 400 lines, and fails when an address is left unsure,
another value never found sure is raised, or a short one is spread.
Broken by hand: without spread in find.go it fails ("1600 Amphitheatre
Parkway" at 110 scored 0.50).
docs/subsystems/gateway-routing.md says this, the pieces' ends
(landmark) and the turn's order (takeTurn, queue) of the two commits
before.
At
|
||
|
|
53913be7aa |
providers: a key or account with no limit on requests at once shows how many run (chentuoyan on Discord)
The account and key rows' lane pill said only "No limit at once" when no
concurrency limit was set, never how many requests were out. Now, with no
limit and requests out, it says "{n} running" (zh: "{n} 运行中") and is
shown without a hover, in the same pill style (no full-lane or queue
colour). Idle with no limit it says "No limit at once" again and goes back
to hover-only. Rows with a limit are unchanged.
Backend: /api/lanes (Server.Lanes, /v1/magpie/concurrency's data) only
listed lanes with a limit, because lanes.take took nothing for limit 0.
take now counts a request with no limit in its lane (Limit 0, never
waits; grant still lets any waiter go at once when a limit is lifted) and
gives it back through the same once-only releaser, so Lanes says Busy for
it. Cost: the same one mutex take every request already paid, plus one
small lane and closure; /api/lanes, read every 2s, copies a map of only
the lanes with requests out. A limit set while unlimited requests are out
now counts them (the vendor does see them). The only caller of take
(serve) always calls release (deferred after attempt, or on an RPM
failure). Strings in zh, zh-TW, ja and de. gateway-routing.md says it.
Tests:
- TestLanesCountWithNoLimit (new, internal/gateway): three held streams on
a provider with no MaxConcurrency read Lane{Busy:3}; all gone after.
Red on origin/main's concurrency.go: "lane = {Busy:0 Waiting:0 Limit:0},
want 3 out, none waiting, no limit".
- TestLanesLimitLifted now releases its limit-0 acquire (it was a no-op
before).
- lane-limit.test.cjs "with no limit, what runs is shown, and none running
says no limit again" (Chromium and WebKit, en and zh), red on
origin/main's app.js: expected '3 running', actual 'No limit at once'
(zh: '3 运行中' vs '并发不限'). lane-limit.test.cjs whole: 16/16 ok on mote.
Run on mote at the tree rebased on
|
||
|
|
72ca3d593b |
codex: magpie as Codex's provider keeps the Codex app's ChatGPT account while it has room, so its Work chats and projects stay
Qyburn3 on X: with magpie taking Codex over, the Codex app's "Work"
sessions don't load while the model still answers; turned off, they
come back.
Cause: [model_providers.magpie] had no requires_openai_auth, so Codex's
app-server answers account/read and getAuthStatus with no account and no
token whenever magpie is Codex's provider (magpie API, or the codex.out
takeover). ChatGPT.app 26.1021 then switches to an identity of no
account: onboarding again with no name, ChatGPT mode's projects and
chats ("Work") empty, no avatar, no Chrome control (#1824).
Now putProvider writes requires_openai_auth = true while Codex has a
ChatGPT sign-in with room (openaiAuth: codexChatGPTKnown and not
codexUsedUp), and takes it out otherwise:
- API key alone: left out. With it Codex drops image_gen (captured: 11
tools without, 10 with), and there is no account to keep.
- No sign-in: left out (the app would ask for a sign-in).
- A sign-in the Codex app holds (codex.out, or magpie API while used
up): left out, since the app's composer gate (authMethod chatgpt +
allowed false, #540) would grey Send for magpie's models again. The
takeover's note now names "its ChatGPT chats and projects" among what
is off till the reset, beside Keep on ChatGPT.
- An unknown sign-in read leaves the table as it is.
Sync rewrites the key on any table that disagrees (authStale), an older
magpie's included, and the key joins codexAppRoute, so the Codex app's
app-server is restarted onto its account with nothing for the user to
do. The magpie API note no longer says Chrome control needs ChatGPT (en,
zh, zh-TW, ja, de); agent-wiring.md says why.
Real app (mote, ChatGPT.app 26.1021 with its codex 0.164.0-alpha.11,
sandbox CODEX_HOME, copied real ChatGPT auth, auth.json unchanged after):
- native config: the account's projects and recent chats listed.
- magpie table without the key: onboarding, "ChatGPT Work" with no
projects, no chats. app-server: account null, authMethod null.
- magpie table with requires_openai_auth = true (the keys this commit
writes): every project and chat back; account/read chatgpt pro,
getAuthStatus authMethod chatgpt with a token.
- Model requests to a capturing server, with and without the key:
Bearer is magpie's experimental_bearer_token, no ChatGPT-Account-ID,
15 tools both ways with a ChatGPT sign-in (image_gen kept).
Tests: TestCodexMagpieProviderKeepsChatGPTAccount (ChatGPT + magpie API,
used up and back; taken over and the reset; an older magpie's table from
live config bytes; API key and no sign-in, fresh and after ChatGPT) and
TestCodexAppRouteFollowsOpenAIAuth. Broken by hand: on the old codex.go
5 of 7 subtests red; without the Sync re-derive 3 red; with the key kept
while used up 2 red; agents.go without the route key, the route test red.
Run (mote-run, at this tree on origin/main 157d575c3; the build and the
agent run again after the rebase onto
|
||
|
|
e5e2aa58e5 |
routes: each provider's wallets go by what they have left in a group too (#4095)
mycf_711 (#4095, comment): SuperMagic's accounts asked directly went by their points (6,636, 282, 119), but in group/deepseek-v4.1-flash1017 they went 282, 119, 6,635, the provider's listed order. A Smart group weighs its members' accounts as one pool (planLevel → weigh over the heads), and the pool held WorkBuddy's credits beside SuperMagic's points: byLeft returned nil as soon as it saw two kinds of LeftIn, so no balance ordered anyone. Each 400 「积分已不足」 was then met on the small balances first. byLeft now orders each kind (provider + unit) in the places its own seats take: the told seats' places in the pool's order (Smart) or by what magpie sent each lately (Pace, Least used, as their tie-break after the balance), each kind's seats put into its places by what they have left, and seats of two kinds keep that order between them. A seat that told none still goes after those that did. It is one rank per seat, so the comparators stay a consistent order; comparing two kinds as a tie would not be. One kind alone orders exactly as before (TestWalletsGoByWhatTheyHaveLeft unchanged). Tests: TestWalletsOfSeveralProvidersEachGoByWhatTheyHaveLeft (routes: Smart, Pace, Least used, the reporter's three behind a WorkBuddy seat, two kinds interleaved, and Least used's token order between kinds) and TestGroupWalletsGoByWhatTheyHaveLeft (gateway: weigh over a group's pool with the reporter's balances, smart/pace/usage). docs/subsystems/provider-plugins.md and gateway-routing.md say it. Broken by hand: with the old strategies.go both tests are red (the group keeps 632, 710, 051 under every routing). Run on mote, at |
||
|
|
3627742104 |
gateway: an error read as out of credit moves on at any 4xx (#4095)
mycf_711 (#4095): SuperMagic answered an account with no points left 400 "非常抱歉,当前对话需要调用大模型 / 付费工具,您的可用积分已不足。 您可以点击右上角「用户头像」,通过「充值」通道补充积分…". failure() read it as failCredit (creditWords: 充值), but retryable()'s 400/422 branch asked quotaWords only, which has neither 积分, 不足 nor 充值. So hw.failed() was false: the 400 went to the agent while another account in the order had 6,467 points, and the empty account was never rested. retryable() now takes any 4xx failure() reads as failCredit, after the overflow check, so the two deciders agree on credit at every status (400, 422, and the 4xx outside the always-retried list, 409 say). Sibling: shapeRefused() kept out quotaWords but not creditWords, so a shape refusal saying 请充值 would rest nobody; it now keeps out both. Quota: usedUpWords (failQuota) is a subset of quotaWords, so 400/422 already agreed; a quota word at another 4xx (413's "exceeded the limit" is the request's size) is left alone on purpose. Tests (credit_400_test.go), with the reporter's literal body: TestCreditRefusalIsRetryableAtAnyStatus (400/409/422, raw and as magpie tells it on, plus shapeRefused) and TestCredit400MovesToTheNextAccount (two keys: the empty one 400s, the next answers 200, the empty one rests as credit 400, the next request goes straight past it). docs/subsystems/gateway-routing.md says it. Broken by hand: with the new case disabled and creditWords taken out of shapeRefused, both tests are red (every status not retryable, the shape case rests nobody, the request ends 400 after k-empty alone). Run on mote, at |
||
|
|
1319a44bbc |
docs: plugin guide says what four rules do when a plugin gets them wrong (plugins#468)
Guide (en, zh, ja) and provider-plugins.md: - usage: leave used out rather than send 0; with amount/limit it is their share, with no count the window is text and routing doesn't read it; aside keeps a window out of routing whatever its count. - sign-in: a model refused is 403/404, not 401; a 401 that says only that the model isn't served is read as kept. - free comes only from the vendor's word; rate 0 is none given, never free (magpie infers nothing from rate). - GitHub listing licence: from LICENSE as GitHub reads it, else package.json's license. Docs only. Checked each claim against the source at this tree (plugin_usage.go quotaOfPlugin, plugins.go modelOnly401, fallback.go modelRefused, plugin/providers.go Model.Rate, models.go FreeModel, github.go readTagged). Site deployed with wrangler and the pages read back with curl. |
||
|
|
7a79318337 |
redact: a package's name goes as written, an import's module first (dniray on Discord)
dniray (v0.1.1917): "脱敏会把包名给替换了", with the case
import { and, eq } from ' drizzle-orm ' going out as
from ' {{SECRET_…}} '. The SECRET came from the local model; the rules
left it. AstrLink Guard reproduces the class on mote with
require( ' jsonwebtoken ' ) -> {{SECRET_…}} and a requirements.txt
django-rest-passwordreset==1.4.0 -> {{SECRET_…}}==1.4.0; Privacy Filter
took a pnpm-lock integrity hash (sha512-…==}) for one, eating the }.
A probe of ~60 package shapes (npm scoped and pinned, Java/Android ids,
Go module paths, Python modules, purls, Debian, Cargo, Gradle, Maven,
CocoaPods, lock files) through Preview, rules alone and with both real
models, default kinds and all kinds, found these and fixed each class:
- model, any kind: the module a line of code loads is never PII
(moduleAt): a quoted specifier after from on an import/export line or
after } or *, import 'x', require('x'), import('x'), and unquoted
from x import / import x / use x:: / extern crate x at a line's start.
A from in prose ("the token from 'Zq8v…'", "copy it from Zq8v…") is
judged as before.
- model SECRET: a name a version is pinned after (==, >=, ~=, !=, <=,
===; pinnedAfter); @ is left out so s3cretPass@10.0.0.5 still masks.
- model SECRET: an SRI hash (sriRe in namesThing).
- secret-named field rule (fieldAt, keyAt, modelTakes): a version or a
range is no secret value: "js-tokens": "^4.0.0-beta.1",
jsonwebtoken = "9.2.0-beta1", secretVersion = '2.1.0-alpha03'
(versionValue).
- user@host (off by default): js-tokens@4.0.0: in pnpm-lock.yaml went
as a user and a host (notPackagePin); alice@10.0.0.5 still masks.
Left as is: SECRET_PACKAGE=@acme/secret-store-v2 and
PASSWORD_LIB=passlib-1.7.4 (a value under a secret's name, not told
apart from a password), and Privacy Filter's "Dagger Hilt" as a person.
Tests: package_names_test.go. TestPackageNamesGoAsWritten (rules,
default and all kinds), TestPackagePinIsNoLogin,
TestModelPackageNamesNotMasked (dniray's literal bytes first, through
fakeModel), TestPackageNameChecksKeepRealValues (emails, an ssh host,
password=, API_KEY=, a secret-named field with a real value, alice@ip,
a model secret in prose after from, before ==, before @ip).
Run, at
|
||
|
|
87a983423e |
codexcat: Codex's own GPT models stay in the Codex app's first 100 whatever the user's order (maiya on Discord)
maiya (Discord): after updating, the Codex app lists magpie's models and none of Codex's own GPT ones. Cause: the Codex app and its VS Code extension read the first 100 of the list by priority (codexcat.AppList). codexMerged ranks the list by the user's order from the Agents page (codexcat.Order, #855), where a model the order doesn't name goes after every one it does, and codexcat.Fit only brought the models Codex used back into the 100. The GUI saves the whole shown list as the order, so an order saved while Codex's list had no Codex section (the codex provider kept for routing groups before |
||
|
|
40f206dff1 |
vertex: partner models (DeepSeek V4.1 Flash, GLM, gpt-oss) go to Google's OpenAI-compatible chat completions
Dani Ariyanto (Discord) asked for Vertex AI's partner/open models, such as
DeepSeek V4.1 Flash, beside Gemini. Google serves them (Model as a Service)
on an OpenAI-compatible chat completions endpoint in the same project,
https://<host>/v1/projects/<p>/locations/<loc>/endpoints/openapi/chat/completions,
with the same OAuth token. The model goes in the body as publisher/model
(deepseek-ai/deepseek-v4.1-flash-maas). Source: Google's
maas/call-open-model-apis page.
An existing Vertex provider needs no change. A model id with a slash
(VertexPartner) is a partner model, as is every publisher/model id that
models.dev lists for google-vertex as @ai-sdk/openai-compatible. It is
asked on Base(Chat) = <project base>/endpoints/openapi (ListedAPIs, so
ModelAPI can't move it). Gemini ids have no slash and stay on
streamGenerateContent. Speaks is now [chat, gemini].
- vertexEffort (Gemini's levels) no longer applies to a partner model.
Before, a Codex xhigh was clamped to high.
- The provider's own test probes Gemini only. A partner model answers
only after the project enables it in Model Garden, so an unenabled
partner model would turn every Gemini user's test red. A partner model
is tested by its own model test.
- tinyBody's chat probe uses Base(Chat), so the probe goes to the openapi
address. That address is the only one Sign lets the token go to.
- A test as Codex is refused for Vertex, as it already is for Claude Code
("only of a relay").
The global list adds the three partner models that Google's docs list as
live at global on 2026-10-28:
- deepseek-ai/deepseek-v4.1-flash-maas (Preview, global only)
- zai-org/glm-5.2-maas
- openai/gpt-oss-120b-maas
Left out of the list: Gemma 4 (Experimental) and the models retired on
10-21 (v3.x, glm-4.7/5, qwen3, llama-3.3...). Gemma 4 still routes when
typed in by its full id. us/eu/regions are unchanged.
Docs: providers-accounts.md and gateway-routing.md Vertex rows;
reference.md (the global row, how a partner id routes, Model Garden
enablement, typing one in).
Run (on mote via mote-run):
- go test -tags nogui -run TestVertex ./internal/provider ./internal/gateway: ok.
- New: TestVertexPartnerModel (gateway). It covers Chat, Anthropic and
Responses clients, streamed and whole, against a fake openapi endpoint
answering in the shape of Google's docs. It checks the path, the Bearer
token, the body model and the client's text, that Gemini stays on
streamGenerateContent, and that xhigh is kept.
- New: TestVertexPartnerModels (provider). It covers Speaks/Base,
APIs per model, the global list, no partner model at us/us-central1,
that Test() probes Gemini alone, and TestModels on openapi with the
minted token.
- TestVertexProviderListed now pins Speaks [chat gemini].
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./..., go build ./...: all ok; gofmt -l clean.
- Full suite: go test -tags nogui -count=1 -timeout 45m ./... at
80f2bda50 (this change on
|
||
|
|
602ad84adc |
plugin: the host is told the gateway's address (MAGPIE_ADDR), so a page's own service reaches it on any port
yuesh1_ on X (reply to 2115451149633626237) opened the community chat page (Magiczerowxy/magpie-chat, @magpie-community/page-chat 0.1.16) and got "127.0.0.1 拒绝了连接". That is Chromium's frame error: the plugin's chat server on 127.0.0.1:3477 wasn't listening. Before v0.1.1905 ( |
||
|
|
6ecc65b6db |
agent: the CodeBuddy IDE is CodeBuddy too, found with no CLI
bjzhangwn on X: magpie supported CodeBuddy only as its CLI, not the IDE. The CodeBuddy IDE (4.12.2, codebuddy.ai's CodeBuddy.app, com.tencent.codebuddy, and codebuddy.cn's CodeBuddy CN.app, com.tencent.codebuddycn) reads the file magpie already writes for the CLI: its genie extension's CustomModelsProductProvider loads ~/.codebuddy/models.json's "models" (a string id and url each) and "availableModels", and lists them in its own picker. So one row, renamed CodeBuddy, stands for both. desktopApps gets a "codebuddy" entry, with a "more" list for the second build's bundle id. A `sign` lists the row with only the IDE installed. That row shows the IDE's version, is never "CLI not found", and the CLI isn't offered for install. Tests: TestCodeBuddyIDEIsCodeBuddy uses the real Info.plist bytes of both builds, cut to their first keys. TestCodeBuddyIDEReadsMagpieModels reads the written models.json the way the IDE's loader does. Run (mote, macOS 27): - gofmt -l: clean. - GOOS=linux and GOOS=windows go vet of ./internal/agent/... and ./internal/sessions/..., plus GOOS=windows -tags nogui ./internal/gui: ok. - go test -timeout 45m -count=1 ./... at |
||
|
|
d4f1d6480c |
plugin: a program a plugin starts with no folder runs in plugin-work, not beside magpie's settings
jiakun_zhao on X asked whose page_<hash>.html, magpie_home.html,
magpie_install.sh and magpie_*.md files they had found after using the
chat page plugin (Magiczerowxy/magpie-chat). That plugin starts the
user's MCP servers from the plugin host with node:child_process spawn
and no cwd, and runs their tools for a model. The host runs in magpie's
config folder (~/.config/magpie), so every file such a tool saved by a
relative name went beside settings.json and providers.json, and a tool
told to write "providers.json" would have written over magpie's.
host.js's spawn wrapper (which already hands on the proxy and keeps
programs off the host's stdio) now starts a program that names no
folder of its own in <config>/plugin-work, created on first use, with
PWD to match outside Windows. A folder the plugin gives is kept.
Not the cause of files in the user's home folder: magpie's host never
runs in ~, and no magpie code names a file page_<hash>.html or calls a
user's MCP tool itself. Files in ~ come from a process whose folder was
~: the chat's server started by hand (node serve.mjs) from ~, or
another agent run there. Filed on magpie-chat for the plugin to give
its MCP servers a workspace of its own and tell the model where it is.
Run (mote, macOS):
- TestPluginProgramsRunInTheirOwnFolder (new; testdata/clicwd checks
child_process spawn, spawn with env, execSync and Bun.spawn, plus an
own cwd kept): ok. Red with origin/main's host.js put back by hand
(plugin-work not made; programs ran in the config folder).
- go test ./internal/plugin ./internal/agentplug ./internal/pluginrt
-count=1: ok (plugin 261s).
- go test ./internal/gateway -run Plugin -count=1 at
|
||
|
|
ca499953e7 |
gui: a plugin page with a host part starts the host when it opens
guesssssssswhat on X: the Magiczerowxy/magpie-chat page ("对话") sits
on its loading text and never opens. The page says hello and then
navigates its frame to http://127.0.0.1:3477, a server the plugin's
index.mjs starts inside the Bun host. The host was started only by a
call: at launch while providers are first read, and after a Restart
(a plugin installed, updated or set, a Bun update) or a crash only once
something asked a plugin again. With the host down, WebKit (the macOS
window's WKWebView, WebKitGTK) leaves a frame whose navigation is
refused on its old document with no error, and the hello had already
cleared the 10s broken timer, so the page waits forever. Chromium shows
chrome-error instead.
Now serving the entry HTML of a page or panel whose plugin is not
page-only starts the host if none is up (plugin.Warm), waiting at most
7s, then serves the page. Page-only plugins, and the page's other files
and the bridge, don't touch the host.
Reproduced on mote (sandbox HOME, magpie web on a free port, plugin
0.1.16 from GitHub): with its 3477 listener killed, old main's page
stays on "正在连接到本地对话服务…" in Playwright WebKit (chrome-error
in Chromium); the fixed build restarts the host on open and the chat UI
loads in both engines. In the real macOS app (wails://) the frame
reaches 127.0.0.1 (seen by a logging server). TestPluginPageStartsItsHost
is red with the pageHost call removed by hand.
Run at this head (
|
||
|
|
012c584cc1 |
usage: clear a model's usage, or all of it, from the Usage page
CrazyMouse_TT on X asked for a way to clear usage, all of it or one model's, to measure a local model fresh after deploying it. The Usage page's Models list has a "…" on each row (and a right-click menu) with "Clear usage…", and "Clear all usage…" sits under the lists below the "Counted from…" note. Each asks first, in a confirmation that says what is deleted, that it can't be undone, and that key spending limits and allowances still count the calls. A clear is a mark in settings (usageCleared: provider, model, unix ms), read at read time; usage.jsonl is never rewritten. The Overview hides calls up to the mark in summarizeFrom; the Requests page, heatmap and ledger/CSV hide them in Filter.keepsRow, their one choke point, and the request index's meta carries the marks so its cache is dropped. Key budgets, window holds and Codex reads go through usage.Visit and the raw log, so a clear never resets a key's spending limit or a quota. A later clear of the same model or of everything takes the place of an earlier one. The marks ride the settings part of a sync (sync-backup.md) and a save of the Settings page keeps them (api.go's keep list; the guard test TestSettingsSaveKeepsWhatItDoesNotSend caught it missing). gateway-sessions.md and sync-backup.md say so. Run on mote (mote-run) at this tree, rebased on origin/main |
||
|
|
4cc331bab4 |
gateway: a Chat relay's text-part contents go as a string (Atria on Discord)
tim072844 on Discord: a custom provider on OpenAI compatible (Atria,
Shanghai AI Lab's Intern discovery API, model Atria-Dawn) answered
DeepSeek Harness with 238 validation errors saying `input` must be a
string. That "input" is pydantic's wording for the value it rejected,
not a Responses field: DeepSeek Harness (pi-ai's openai-completions)
sends every user message's content as a list of text parts, the gateway
relays a Chat client's body as it came, and that server's Chat schema
takes content as a string alone.
passthrough's Chat case now runs textPartsAsString: a content list made
only of {"type":"text","text":...} parts goes as their text joined by a
newline (as vLLM renders such a list). A list with an image, a file, a
thinking part, cache_control or any other key stays as it is. Every
other byte of the body stays as sent, and a body with no such list
comes back byte for byte. This covers every Chat-protocol upstream, not
Atria alone; buildChat's translated requests already sent strings.
TestChatRelayLeavesOutEmptyAssistant's "blank parts" case now expects
the joined user text as a string, since the parts are flattened before
silentAssistantsOut joins the two user turns.
Run (on mote, worktree at this commit's tree):
- go test -run 'TestChatRelayTextPartsAsString|TestTextPartsAsStringOnlyPlainText|TestChatRelayLeavesOutEmptyAssistant' ./internal/gateway: ok
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway: ok (553.6s); again after rebasing on
|
||
|
|
c2aad3db02 |
redact: a wallet address goes as written, and an IP as a documentation address the agent can use
0x0_air on X (10-28): with masking on, the agent stopped and asked again.
Their EVM address (0x89dfBD9b…, public) went as a secret placeholder and
the vendor's model told them to rotate it in case it was a private key;
the server IP they typed went as {{IP_…}} and the model refused to ssh
to it and asked for the real host.
- model.go: the local model's SECRET/ACCOUNT span on 0x and 40 hex
digits (evmRe) is left as written; no rule matched it, the model's
label did (the 0x prefix and mixed case got past hexRe). A 64-hex
private key is masked still, and so is a 40-hex value called a key
(secretCued).
- shape.go: an IP the IP rule masks goes as an address from the
documentation ranges (192.0.2/198.51.100/203.0.113 .101-.254, IPv6
2001:db8::/32), stable for the value, never shared by two values
(falls back to {{IP_…}} past 462 IPv4 ones), and put back only as a
whole address in replies and streamed tool calls (restoreAddr).
Preview shows the same stand-in.
- docs: gateway-routing.md, and masking.html in en/zh/ja.
Run:
- Real models through the local gateway, the screenshot's ssh prompt
with the placeholder vs a documentation address: with
{{IP_k3v9x2mq}}, deepseek-v4-pro, glm-5.3, kimi-k3 and
claude-sonnet-5-5 mostly searched ~/.ssh or asked for the real IP;
with 203.0.113.147 or 192.0.2.183 all 20 runs over 5 models ran ssh
at once.
- New tests (internal/redact/standin_ip_test.go): the screenshot's
message, the tool call restored whole and streamed cut at every byte,
boundary cases, IPv6, 472 addresses never sharing, the screenshot's
address under labels secret and account_number with every category
on, and a 64-hex key still masked. gateway TestRedactedKinds now
wants a documentation address upstream.
- Broken by hand: without the evmRe check TestEVMAddressGoesAsWritten
is red for every text and label; without restoreAddr the boundary
cases are red; without the IP stand-in all three IP tests and
gateway TestRedactedKinds are red.
- On mote at this head (rebased on
|
||
|
|
6a074fc132 |
pii: the default's local model reads what a request adds first, a backlog 4 KB a request, on 4 cores at most
shensmart and xinvxueyuan on Discord (10-28): with the local model on by
default, a long history kept the CPU high; the model off, 5-15%.
What was heavy (measured, TestLiveHistoryCost below): not re-reading.
A text read once is kept by hash (cache, on disk too), and a warm turn
costs what the rules alone do. The heavy case is a history the model
hasn't read (a resumed session, or one from before the model was on),
on the CPU path (Linux, Windows, Docker). Each request's 2 s wait was
spent reading that history oldest first on every core (threads =
GOMAXPROCS-1, windows at once = GOMAXPROCS), the newest turn last, and
the 12 KB chunk in flight was finished past the wait. A 32-core Linux
box spent 33-60 CPU seconds a request, 13 cores busy for as long as
requests came, and the backlog was still unread after 30 requests.
Nothing ran on after the last request (1 ms CPU in the 20 s after).
Now:
- guard.Cores: AstrLink Guard reads on half of GOMAXPROCS, 4 at most.
- backend.missing reads a request's unread texts newest first (the last
text, a long one's last piece, first).
- AstrLink Guard's chunk is 4 KB (backend.chunk), not 12 KB, so what a
request leaves the model finishing past its wait is about a second.
- pii.Bounded (masking's default, not a model the user turned on):
what a request went without reading is remembered by hash
(backend.sent); a request after it reads what it adds first, and that
backlog backlogCap (4 KB) at most, nothing found for the rest (the
rules mask it, as past the 2 s wait). The answer past the wait with
what was read is 874b86653's (pii.Partial), unchanged.
- A model the user turned on (strict) still reads everything, within
874b86653's strictWait.
- Not done: OS priority (nice) for the model's threads; the core cap
is the bound.
Measured, TestLiveHistoryCost (internal/masking, gated on
MAGPIE_GUARD_FILES, no network): a 2,041,658-byte Codex Responses
body (2,032,267 bytes at the rebased tree), 200 turns (repo files as tool output, doc paragraphs as answers,
Chinese names and an email every 10 turns), 30 requests 3 s apart, a
turn more each, model never having read it, then 20 s idle.
WSL2 Ubuntu 24.04 on xiaomi-gpu (32 cores, CPU path):
before: 33-60 CPU-s a request (44.0, 38.3, 50.4, 42.8, 54.3 ...),
session 23m16.8s CPU over 1m48s (1293% of a core),
wall median 2.759s, max 3.07s; 20 s after: 1 ms
after: 6.3-9.2 CPU-s a request, session 4m1.5s over 1m30s (268%),
wall median 2.389s, max 2.438s; 20 s after: 1 ms
warm turn after a full read: 876ms wall / 5.284s CPU before; after
the rebase the "full read" is strict and stops at 874b86653's
15 s, so that line is not a warm turn (2.41s / 7.9s); before
the rebase, at a full read, 1.28s / 3.04s (4 cores, not 31)
rules alone: 394 / 384 ms CPU
mote (M5 Pro, CoreML):
before: requests 1-3 2.2 CPU-s each, then ~0.45; session 18.7s CPU
over 1m30s (21%); warm 396ms / 380ms
after: request 1 2.12 CPU-s, then 0.44-0.62; session 17.2s CPU
(19%); wall median 562ms; warm 476ms / 465ms
On the CPU path a turn adds about 15 KB here, more than 4 cores read
in 2 s, so each request still spends its wait (now on 4 cores, newest
text first) and the backlog isn't reached until turns get shorter;
on CoreML the backlog is gone after the first request.
Tests, each red with its part of the change undone by hand:
- TestNewestTextReadFirst (pii): red on the old code as it stands
("read first: a a a ..."); red again with the last piece not first.
- TestBoundedReadsTheBacklogALittleARequest: backlog cap removed, the
second request read 75169 bytes.
- TestGuardReadsShortChunks: red with guard's chunk unset (12288).
- TestReadsOnFewCores (guard): Cores at 32 and 1 procs.
- TestDefaultModelIsBounded (masking): red with the default's ctx not
Bounded ("on by default, the model wasn't asked Bounded").
- TestJoinSplitsAtChunkSize now expects the newest-first order.
Rebased onto
|
||
|
|
874b86653d |
masking: the model the user turned on is waited 15s at most, and what it read is kept (xRayySummers on X)
xRayySummers on X (0.1.1877, Linux, AstrLink Guard turned on in
Settings -> Privacy): in one minute masking took 1.2s to 290s, and each
request whose wait ended was "gateway: masking failed, so nothing was
sent".
Cause: the model reads on the CPU one chunk at a time on one turn,
about 6 KB a second on 8 Linux cores. A burst of requests with text it
hadn't read (new tool results, subagents at once) queued behind each
other, and the turn goes round between chunks, so all of them finished
near the end of the burst. Turned on by the user, the wait had no
bound, and when anything ended it (the client, a deadline) masking.model
panicked: the request was held back whole, and even the finds already
cached for its history were thrown away (backend.find returned nil).
Not a reload (60-90ms) and not a lock in redact.
Now:
- pii.FindContext, when the wait ends, answers with what was known of
the texts (its cache: earlier turns' history, chunks read meanwhile)
and a *pii.Partial saying how many it hadn't read.
- masking.model waits at most strictWait (15s) for the user's model,
defaultWait (2s) for the default's as before. Past it, the model's
finds mask what it read and the rules mask the rest alone; the request
goes. Nothing the rules mask goes as written. Logged once a minute.
- A model that fails (not on disk, didn't load, held back after a
failure) still holds the user's requests back, as before: broken, not
busy.
- masking.find gives a model that doesn't stop for ctx 100ms (handBack)
to hand back what it knew, so a partial answer racing ctx.Done isn't
dropped.
- docs/subsystems/gateway-routing.md says so, with the numbers below.
Run:
- Reproduced with the real AstrLink Guard (guard-7216b6a3) on Linux
(wsl-run, magpie-desktop, GOMAXPROCS=8), a throwaway test not
committed: load 63-87ms, reload on a request 57ms, a 125 KB history
20.8s first read and 66us cached; six requests at once with 67-145 KB
of new text each took 62, 91, 92, 108, 108 and 110s on the old code.
With this change each went at 15.0s with the history's 14 finds and
the model's finds for 1 to 4 of its 9 texts.
- mote-run at
|
||
|
|
7c900f468f |
antigravity: a tier Google refuses in fetchAvailableModels is asked once a day and is no "Model list" row (ferock4669)
ferock4669 on Discord: with an Antigravity subscription, the Requests page filled with "Model list" (模型列表) rows for /v1internal:fetchAvailableModels, each answered 400. Cause. For an account loadCodeAssist gives a paid or non-free tier, magpie asks fetchAvailableModels first with entitlement.userTier named ( |
||
|
|
df9376592d |
routing: a group's member may offer several reasoning levels for the agent to pick among
Garydesu on X: "能不能让路由组里的模型设置多个可选推理强度,现在只能选一个或者整个 路由组的". A member was one fixed `:effort` or followed the group's levels. A member's suffix may now join several levels with "+", `provider/model:low+xhigh`, kept lowest first, each once. provider.MemberLevels splits it into Member.Levels and leaves Effort empty, so the member isn't fixed; one level is a fixed effort as before. The whole stays the member's id, so rules, fast, off, weights, share and the CLI key it as any member. The gateway fits the agent's ask to the member's own levels (groupLevels returns the candidate's levels first; ofMember, the quiet check and the trace see them), and the group lists them to agents (buildGroupEntries), intersected with the other members' as usual. In the Routing page's group editor the member's reasoning menu has "Several levels…", a menu that stays open with each level ticked or not; a fixed level picked from the first menu replaces the old one as before. i18n in zh, zh-TW, ja, de; CLI help and docs/subsystems/gateway-routing.md say it. Run on mote (mote-run). Rebased on |
||
|
|
25df3187bf |
gateway: a model whose upstream says thinking.type must be "enabled" is asked again thinking
cybercaius on Discord (#help), v0.1.1862: Claude Desktop's connection
check failed with 'Gateway rejected model
"magpie-0958175816.anthropic.claude-haiku-5-5[1m]" (HTTP 400)', the body
'天翼云: {"error":{"message":"{\"code\":\"400\",\"message\":\"thinking.type
must be \\\"enabled\\\" …","type":"upstream_error",…}}'. 天翼云 is his own
provider, a relay whose message is its own upstream's whole body.
What was sent: Desktop's check ({"max_tokens":1,"messages":[{"role":
"user","content":"."}]}, raised to 16) asks for no thinking. Relayed to
a Messages provider, a vendor's model gets thinking {"type":"disabled"}
(thinkingOffUnlessAsked) and a Claude-named one none; translated to Chat
it gets no reasoning_effort. Nothing today changed that: no gateway
commit since yesterday touches what thinking is sent. What changed is
where the check goes:
|
||
|
|
e296211b8b |
masking: the default's local model is waited for 2s at most, then the rules mask alone
shensmart on Discord (10-28, magpie in Docker on Linux, web UI remote): Codex's requests sat "masking…" on the Requests page from about ten minutes into use. |
||
|
|
51247a55b2 |
docs: one commit, one goal moves into the code standards (seen a third day)
LESSONS.md's "One commit, one goal" was seen on 10-05 and 10-06. On 10-28 |
||
|
|
a5315c70d5 |
redact: the local model doesn't read an agent's tool definitions (niuniu_8964 on X)
码妞 on X: the official container on a 4-core, 8 GB server, AstrLink Guard on, Claude Code's requests sat at 脱敏中 for minutes and timed out, load 1.78, a short conversation. |
||
|
|
25fc92d59a |
fallback: a model unchecked in its provider's list is not a fallback to go to (#3911)
The sibling of the group fix before this: a provider's Fallback list
resolved each entry with Resolve, so a fallback the user unchecked in
its own provider's list was still sent to, while the fallback editor
says "No provider serves {id} now; it is skipped". plan's fallbacks,
and the places that read the same list (carefulOf, native compaction's
carrier check, unredactedRoute, codexFallsBack), now resolve through
provider.ResolveRoute, which skips it. ResolveRoute scans the entries
once for the one model rather than building a map per request.
Test: fallback_unpicked_test.go, plan/m answering 429 with fallbacks
a/x (unchecked) and b/x goes to b and never to a.
Run (mote): red on the previous commit's tree ("from ka", a tried
[ka]); green with this one. Full suite as recorded in the previous
commit, which ran at this tree: 76 packages ok, internal/plugin's
TestGatewayHookMixedPiPackage red at load ~134 (#2865), passing alone.
go vet darwin/linux/windows clean.
Not tried: a real provider with a fallback in the app.
Co-authored-by: timonwong <timon86.wang@gmail.com>
|
||
|
|
f561cc5d9b |
groups: a model unchecked in its provider's list is not a member to route to (#3911)
timonwong (#3911, also on Discord #feedback): with a group of a/x and
b/x, unchecking x in provider a's model list struck a/x on the Routing
page, but group/<id> still sent requests to a. membersOff resolved each
member through resolveIn, whose provider/model step takes any model of
a provider that is on, so that a request can name a model its list
lacks.
membersOff now skips a member whose provider has picks and whose served
models lack it (unpicked), as timonwong's fork did (38615ca9). A
provider with no picks still routes a model its list lacks (#2642), a
decision model (never in the catalog) is still a decision group's, and
a request naming a/x itself still reaches a. Every route mode goes
through membersOff (ordered, weighted, rotate, manual, nested groups,
found groups, count_tokens' group lookup), so all of them get it. The
entries map is built only when a member's provider has picks.
The Routing card's memberInfo (gui/groups.go) used Resolve too, so a
manual group's pick row showed an unchecked member as ready; it now
asks provider.ResolveRoute, the same check, and the group is not ready
when its picked member was unchecked.
Tests: group_model_pick_test.go (ordered, weight, rotate; nested; a/x
named directly still served; checked again comes back; a decision
group keeps a picked decider) and gui's
TestGroupMemberUncheckedInItsProvider.
Run (mote, at this tree plus the next commit):
- Red on
|
||
|
|
d6df72a2ba |
redact: a disassembly's symbols (system@plt, foo@@GLIBC_2.2.5, system@got) are no email
ch35tnut_ on X: reversing, symbols like system@plt were masked as
emails, so masking had to be turned off for reverse engineering.
The rule's regexp already needs a dot and a mail TLD (mailTLD), so
system@plt, puts@got.plt and memcpy@GLIBC_2.14 went as written by it at
origin/main. The local model's EMAIL spans pass realEmail too, which
never asked for a dot: .got is an ICANN top-level domain, so a model
span on system@got (IDA's "; system@got") was masked. And a
foo@plt.got ends in .got with a dot, so the rule masked that too.
realEmail now asks mailHost first, for the rule and the model alike: the
host has a dot, every label is letters, digits and hyphens (or non-ASCII,
an IDN's), no label empty, the local part does not end in @ (foo@@VER),
and the host is not made of linker table words alone (plt, got, sec,
iplt, igot: free@plt.got, memcpy@plt.sec). A version with an underscore
(@GLIBC_2_2_5) or no dot (@Base, @GLIBC_PRIVATE) is no host.
TestSymbolIsNoEmail has objdump, readelf, nm, gdb and IDA lines as they
print them, for the rule and for a fake model flagging each symbol as
private_email, and checks that rina.k@fastmail.com in code and
ops@build01.acme.io beside a symbol are still masked by both.
Run at this head (origin/main
|
||
|
|
6e080ca044 |
gateway: every model in /v1/models says it takes tools, a routing group too
psikent on Discord: an SSH client judges what a model can do from its
list entry, and a routing group, whose id is the user's own name, said
nothing of tools, so the client handed it none. /v1/models and
/v1/models/{id} now give every chat row models.dev's tool_call: true
(beside the reasoning it already had) and OpenRouter's
supported_parameters (tools, tool_choice, and reasoning when it thinks),
which Kilo's and Cline's list readers use (kilo.go reads the same field).
magpie has no model that takes no tools (a call written as text is read
back as one), so a group's members all take them and the group says so.
No `capabilities` key: Cursor Private Inference reads it as an object,
Ollama and LM Studio as arrays of their own words; magpie's Ollama
/api/show already says "tools". Desktop's, Science's and the decision
models' lists are unchanged.
windy on Discord: a 1M DeepSeek group with a 128K Trae member. A group's
window and output stay its largest member's, images any member's, as
#712, #756 and ARNO's truncation report decided: the gateway sends a
longer conversation only to members with room (roomy, withRoom), and
Context: Smallest model's tells agents the smallest. The editor's Context
hint now names the member a longer conversation skips when the windows
differ ("…longer than 128,000 skips Trae CN · DeepSeek-V4.1-Flash…"), in en, zh, zh-TW, ja, de.
Compaction written to agent configs follows the same window (CompactFor,
CompactSet takes the smallest threshold the user set); unchanged.
Run (mote unreachable all session, so on the other test boxes):
- TestGroupListedTakesTools on Linux (wsl-run): green; red on the old
gateway.go (a/m, b/m, group/g and /v1/models/group/g: tool_call false,
supported_parameters []).
- group-context.test.cjs on the Windows box, Playwright 1.62.0,
Chromium + WebKit, en and zh: 4/4 green; 4/4 red with the old
routing assets (the hint named neither 128,000 nor the member).
- Every GUI file that opens the group editor (56) plus i18n-keys, both
engines, on Windows: 816 tests, 792 pass, 24 red (793/23 on the run
before the hint named a member's provider). The red files with the old
assets: the same tests red (25). They are #3402, #3412, #3789, #3096 and name-suffix-saved's
WebKit provider editor, not this change.
- Full Go suite, -tags nogui -timeout 45m, on Linux: all ok but
internal/agent (7 install-detection tests), internal/proc TestTreeRSS
and internal/gateway TestUploadStillUnderwayIsNotCutByHealthPing; each
red at origin/main
|
||
|
|
aca0f0d8a1 |
guard: a long text's windows are read at once, one a core (niuniu_8964 on X)
码妞 on X: on a 4-core server in the Docker image, with AstrLink Guard,
Claude Code's requests sat at 脱敏中 for minutes, load 1.78. Guard read a
long text's 510-token windows one after another, and split only each
window's matmuls and attention over GOMAXPROCS-1 goroutines; the layer
norms, biases, GELU and quantizing between them ran on one core. A
2-CPU container got one thread for all of it.
Find now reads every window's logits first, min(GOMAXPROCS, windows) at
once, each with GOMAXPROCS/that many goroutines of its own, then merges
them in window order as before, so what it finds is the same. A window's
procs are passed down (logits, encode, matmul, attention, parallel) in
place of the package's threads. CoreML (a Mac) still reads one window at
a time.
Measured on magpie-desktop (WSL, Ryzen AI Max+ 395), 69,495 bytes of
docs, 22,488 tokens, ~59 windows:
GOMAXPROCS=4: 23.86s before, 17.90s now
GOMAXPROCS=2: 48.8s before, 30.50s now
GOMAXPROCS=1: 50.0s before, 57.0s now (the same code path; noise)
Run:
- wsl-run with MAGPIE_GUARD_DIR at the pinned model (rev 7216b6a3):
TestWindowsAtOnceReadAsOneByOne (new: 200 synthetic contact lines, over
4 windows, read at GOMAXPROCS 1 and 4, spans DeepEqual), TestModelFinds,
TestKernelsMatchGo, TestTokenizerMatchesHF, TestDecodeBIO: ok.
- mote-run: go vet ./internal/pii/..., GOOS=linux and GOOS=windows go vet
of it, go test -race ./internal/pii/..., go test ./internal/pii/...
./internal/redact/...: ok.
- win-run go test ./internal/pii/guard: ok.
Broken by hand: swapping the first two windows' logits after the wait
made the new test red ("windows at once found 800 spans, one by one
800": the same count, different spans).
Not tried: the reporter's own server, or a real Claude Code request
through the Docker image; TestCoreMLMatchesGo (needs the model on a
Mac) was only compiled. The full suite wasn't run: nothing outside
internal/pii/guard calls what changed but Find.
|
||
|
|
eb6d1d8d97 |
redact: a colour or an ordinary word is no personal name (黄绿色, 关键词)
hh05928822 on X after v0.1.1850: names were found in ordinary Chinese, "黄绿色" the worst, with 边••, 应••, 关••, 尚• in the screenshot. wangjunxiao128: "关键词" taken for a name. Both ways a Chinese name is found (the model's PERSON spans in modelSpans, and the cue rules in zhNameSpans) now go through one check, zhWordNotName: a span that is an ordinary word is no name, unless a role before it or a title after it says a person is meant (客户方圆, 江山老师). A word is (zhWordShaped): - a colour: Han colour characters alone, or anything ending in 色 (黄绿色, 红色, 金黄色, 浅蓝色); - a two-character word starting with a surname, from zhWords or the new zhDict (边界, 应该, 尚可, 关心); - such a word with a noun ending after it (关键词, 关键字, 应用层, 毛利率, 时间戳, 文件名). zhDict is zhdict.txt, embedded: ~1,550 two-character words from jieba v0.42.1's dict.txt (MIT, in THIRD_PARTY_NOTICES), the first character a surname, frequency >= 100, tag not nr/nrt/nrfg, and a list left out by hand (陆游, 关露, 欧阳, 司徒...) in its header. The surname list keeps 黄, 关, 边: they are real surnames, so 黄晓明, 关羽 and 毛利兰 are still masked. modelTakes' own zhWords check moved into the shared one. Run on mote at |