1ccacad63281094de8a3372d5a507d38f9969e5c
830
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
69453574d7 |
docs: a key's usage cap (@wanggenjidev on X)
gateway-routing.md and providers-accounts.md: a key whose usage windows magpie reads takes the same usage cap an account does. Record for the three commits (@wanggenjidev on X: Codex-style percent cap for OpenCode Go keys, generically for every key with windows magpie reads): - Run at the pushed head (rebased on |
||
|
|
9cdeb485bb |
gateway: a limit that names one model rests that model, not the whole key (WJaunita45604 on X)
A 429 or quota refusal whose body names the model asked (Groq's per-model TPD, OpenAI's per-model TPM, Gemini's QuotaFailure, any vendor's "limit for model X") used to rest the account's key, so every other model of the provider waited. modelNamed (routing.go) now sends such a refusal down the same path as modelCooledDown: it rests restID (key/model). Readers of rest state (restingOf, sink, GUI badges via Rest.Model) already understood those. Account-wide refusals (no model named, another model named, credit, auth) still rest the key. The id match is on whole ids (gpt-4o is not gpt-4o-mini). Cline's and ZCode's guard tests expected another vendor's words to rest the key even when they named the very model; they now expect the model alone. The "not a trial" ZCode row moved to the new test. Run (mote): the new TestModelNamedLimitRestsTheModelNotTheKey, TestLimitNamingNoModelRestsTheKey and TestModelNamedReads, red on the old code (mr-red.log); gateway tests matching Rest|Rate|Quota|Fallback|Limit| Cooled|Pool|Overload|Sink|Credit|ZCode|Cline; gofmt; darwin, linux and windows go vet of internal/gateway. Broken by hand: modelLimited back to modelCooledDown only, the new tests go red. Not tried: a real vendor account; the full suite (started after the tag). |
||
|
|
db4da33bc6 |
gateway: a LazyCat box's X-HC-* headers go on only to a provider whose PassHeaders names them (#5987)
On a LazyCat box (懒猫微服) every app sits behind the box's ingress, lzc-ingress, which puts on each request it passes the app who sent it: the box account (X-HC-User-ID), its role (X-HC-User-Role), what sent it (X-HC-Source), the device (X-HC-Device-ID, -PeerID and -Version) and when it signed in (X-HC-Login-Time); the box's docs name X-HC-User-Groups and X-HC-User-Ticket too. A request signed in to the box gets them on the app's public paths as well, where a package serves the gateway's client routes. The native route, the Codex passthrough and relay to the ChatGPT backend (copyHeaders) and /mcp/<server> passed them all on, so a vendor, the ChatGPT backend or a remote MCP server was told the box account's name and role and the device's ids. proxyIdentity takes any X-Hc-* as what a proxy says of the caller, as it takes Tailscale-*, so nativeHeaderDropped, copyHeaders and the MCP proxy's header loop skip them. lzc-ingress's X-Forwarded-By was dropped already (X-Forwarded-*). What |
||
|
|
ce5e5964db |
gateway keys: model search box, re: patterns and Model names in the key editor (tsingchao on X)
The model picker of a gateway key gets a search box (name or id) and takes "re:<regexp>" typed then Enter; the row menu gets Model names (aliases-key). Docs: gateway-routing.md "A key's model patterns and names". Run (mote): go vet darwin, windows, linux nogui on access/gateway/cli/gui; go test internal/access, gateway (937s), cli, gui all ok at the pre-rebase base; after rebasing on origin/main: go build ./..., the new Go tests, TestCoreScriptBudget, and GUI gateway-key-search-names + gateway-key-models + i18n-keys (28 ok, chromium and webkit, en/zh/zh-TW/ja/de, 1100 and 440). Broken by hand: pattern match off (gateway + access tests red), aliasRequest off (alias test red), search argument removed (all 20 chromium GUI red). Not tried: Windows/Linux GUI run, a real client against a real key; the full suite runs after the tag. |
||
|
|
3ebb1ba2cb |
gateway: Antigravity's refused lines get two zero-width spaces a word, not one after the first letter (shzutbi1 on X)
Claude Code's chats on Antigravity answered 429 "Resource has been
exhausted" again. Reproduced on the owner's real Antigravity account with
Claude Code 2.1.316's own system blocks (claude -p captured through a
local server): both x-anthropic-billing-header and "built on Anthropic's
Claude Agent SDK" are still turned away, and the first-letter break the
cloak made ("x", U+200B, "-anthropic...", "b", U+200B, "uilt on ...") is
turned away too, so the cloak did nothing. Bisected on the account:
a break after the second character, two breaks, or a break in each word
of the line go through (3 of 3 each); a break after the third character
of "x-a" does not. Codex's and Hermes' lines now go through as written.
antigravityCloak now puts a zero-width space after the first and the
second character of every run of three or more letters or digits in each
matched line. The full captured Claude Code prompt with that transform
was answered 3 of 3 on the real account. The refusal is still told
against the prompt as written (hint, 400, no rest), unchanged.
Run: go test -run Antigravity ./internal/gateway on mote (ok), gofmt,
go vet darwin, linux nogui, windows. New TestAntigravityCloakClaudeCode2316
pins the real prompt's output. antigravity_codex_test.go and the Codex
check in antigravity_cloak_test.go read the sent prompt past the breaks.
The old test expectation (first letter only) was changed, not broken by
hand: the old code can't compile against the new helper.
Not run: the full suite (started after the tag), a sandbox magpie binary
(the transform was sent through the live gateway's real account), Hermes
and Codex lines against the real account beyond "as written goes through".
The community plugins carry the same cloak and are fixed in
magpie-community/plugins (antigravity 0.1.1, antigravity-cloak 0.1.3).
|
||
|
|
6d78627693 |
gateway: an empty reply on two accounts of a model ends the request there (vhjjkkhg on X)
Alma on Responses to Antigravity's Gemini 3.8 Flash got "an empty reply" now and then in multi-turn tool turns, and each account's in-place re-asks plus the next account took 8 to 9 tries over 10+ minutes. A reply that said nothing on a second account of the same provider's model is about the request, not the account: the model's remaining accounts are not asked (emptyAccounts = 2, `emptied` in the candidate loop). Other providers and a group's other members still are, and nobody rests (the #1221 branch is unchanged). Cause of the empty reply itself: NOT found. Chat and Responses build byte-identical Code Assist contents for a tool conversation (compared), and about 50 real-account runs in a sandbox HOME (Antigravity login only) across efforts none to xhigh, multi-user-turn tool loops over both protocols, gave no empty reply. It looks like upstream's occasional behaviour (#667 / #1221), so this commit bounds the cost and does not claim a translation fix. Run (mote-run): TestEmptyReplyOnTwoAccountsEndsTheRequest (Responses and Chat; 5 accounts), TestGeminiEmpty*, TestLateRests*, full ./internal/gateway, gofmt, go vet darwin/linux/windows (nogui). Broken by hand: with gateway.go's change reverted the new test is red (12 asks, 5 accounts tried; 8 asks and 2 accounts with it). Not tried: a real Alma turn on an account that returns the empty reply. |
||
|
|
4623f54190 |
gateway: HTTPS for other computers, from magpie's CA or an imported certificate (zhangly1 on X)
zhangly1 on X: Claude on another computer on the LAN needed magpie at https://. Settings → Network and sharing → HTTPS (magpie https on) serves other computers TLS on the gateway's own port, with a certificate magpie's CA (the mTLS one, in ~/.config/magpie/mtls) signs for this computer's names and addresses; this computer keeps plain http://. The switch is read per connection, so no restart. - Certificate row: Import… takes the user's own PEM certificate (with chain) and unencrypted key, in any files and order; a pair that can't be served (no key, no cert, a stranger key, a passphrase, run out, nothing PEM) is refused with the reason in the page's language and leaves nothing behind. Remove goes back to magpie's CA. --tls-cert still comes first. - magpie's CA row: SHA-256 shown, Save puts magpie-ca.crt in Downloads; the gateway serves it without a key at /magpie-ca.crt to any address the share lets in. Rows under it give curl -kO, macOS, Windows, Linux and NODE_EXTRA_CA_CERTS steps with Copy. - A page open from another computer can't turn HTTPS on or off under itself (it would lose its own address). - magpie https status|on|off|import|remove|ca --out; the serve banner names magpie's CA or the imported file instead of "(mTLS)". - docs/reference.md and gateway-routing.md say all of it, and that Windows' curl.exe needs --ssl-no-revoke for any private CA. Run: - gofmt -l clean; go vet linux -tags nogui ./internal/..., GOOS=windows and GOOS=darwin -tags nogui vet of the touched packages (WSL, mote refused ssh all evening). - WSL: go test -tags nogui gateway -run HTTPS|MTLS|ClientCert|CAFile|TLS|LAN ok; gui -run HTTPS|MTLS|Keep ok; settings, settingsapi, mtls ok; cli -run Help|HTTPS|TLS|Serve|Banner|Flag|Unknown ok. The whole cli package hit its 40m timeout in TestEveryAgentFieldNameWritesNothing (#5234, #4247, not this change). - GUI (WSL Playwright, chromium + webkit): https-settings (en, zh, 390px, strings in all four languages) ok, plus mtls-settings, allow-ips, browser-access, cors-origins, gui-de/ja/zh-tw, i18n-keys, i18n-en-no-cjk, lan-*, public-url*, api-key-theme, connect-address-kept, gateway-connect-keys, gateway-caller-keys, side-gateway-lan, menu-scroll. Reds at load ~130: api-key-theme (#5044), connect-address-kept (#5972), gateway-caller-keys (#2572), gui-ja (#5943), lan-docker (#4692), all red the same at base |
||
|
|
6c3f113cee |
routing: a rule's hours over give the conversation back; looser times (MinglunZhu on X)
MinglunZhu asked twice for a provider by time of day and said the time setting in Routing rules is awkward. Three causes: - A conversation a night rule sent to its member stayed there after the hours: no rule matched the new turn, so Auto affinity kept it on the night's member by its cache (Smart and every routing but In order). ruleFor now sets RuleHit.Ended when the last turn's rule had hours that are over, and affine lets the conversation go (Affinity.Why "hours"); the trace says so in en, zh, zh-TW, ja, de. Tool rounds of a turn begun inside the hours stay put; Session, Strict and In turn keep their own way. - The time boxes took only ASCII "HH:MM", while their numeric keypad on a phone has no colon and a Chinese IME types ":". clockOf (GUI) and clockMinutes (CLI, saved files) now read "22", "2200", "930", "22:00", "22.00", "22点30" and full-width digits; "9:5" is still no time. time=22~08 takes ~ and ~ for the dash. - A new rule starts with an intent box; hours took an × and a +. Adding another condition now drops the intent box while it is empty. A time rule in a nested group doesn't give its conversation back yet: #5977. Run (mote): go test ./internal/provider (ok); go test -run 'TestRuleHoursOver|TestRuleTime|TestRule|Affinity|StandIn|Session|TestParse|Clock' ./internal/gateway (ok); go vet darwin, GOOS=linux -tags nogui, GOOS=windows for gateway and provider; gofmt. GUI, chromium and webkit: routing-time (8/8 after the new trace test's fix), and 28 rule/affinity/ i18n files (routing-rule-*, routing-time*, routing-intent-entry, routing-folder, routing-pause*, routing-smart-intent, routing-save*, routing-rules-line, routing-affinity-*, routing-behind-why, routing-kept-again, routing-session-folder, i18n-keys, i18n-en-no-cjk): 477/481, the 4 reds the new trace test's first wording, fixed and rerun. Broken by hand: affine's "hours" case off -> TestRuleHoursOverGiveThe ConversationBack red (Smart stays on kb by cache); origin's grouprule.go/ruleparse.go -> TestRuleTimeTypedLoosely red; client.js's "hours" case and the intent give-way off -> routing-time 0/4 in chromium; the old clockOf -> routing-time red on "9:00". Not tried: the real app with a real night/day pair of providers; the full gateway package and full GUI suite (the full Go suite runs after the tag); Windows run of the touched packages (vet only). |
||
|
|
72e804d2b5 |
gateway: a provider set Never a fallback takes no other model's request (sonnnnnnnnnnnna on X)
sonnnnnnnnnnnna asked that a request a local uncensored model was given
never falls back to an online provider (Anthropic, OpenAI) when the local
model is full (kv slots) or down, where it could get the account banned.
A provider now has Never a fallback (NoStandIn), off by default: the
Providers page's right-click, under Use first, ticks it; the CLI's
`magpie provider set <id> fallback-for-others=no` sets it. Its keys and
accounts are dropped from a request's plan once a candidate of an
unmarked provider was planned before them (standInsOut, run in planPaused
and in planGroup before restLast and sinkPlanned, so a local model that
failed and is resting still counts as first; a primary with nothing
planned counts too). A request that goes to a marked provider first still
moves on as before, and a weighed group (Smart, Cheapest) that picks a
marked member first sends it there. The dropped rows go to the trace's
left-out list as StandIn; the Routing page says why ("it is set never to
be a fallback for another model"), and the cap, held and barred refusal
checks ignore them so a refusal keeps its old status.
No classifier was built: the model that would judge the request is the
local one that is down, and any other would send the text somewhere the
user didn't choose.
Run on mote (macOS 27) at this tree on
|
||
|
|
e053c337aa |
gateway: join a shared magpie with a password (EV_John_Liu on X)
EV_John_Liu asked for quick setup on a LAN: the central magpie serves a
page behind a password where other PCs and Macs get their config and a
new key of their own.
Settings -> Network and sharing -> Join with a password sets the
password (at least 8 characters; only a salted PBKDF2-SHA256 hash is
kept, in join.json, 0600, written through temp-and-rename; a file that
can't be read or parsed means joining is closed). The row then shows the
address to give out, <shared address>/join, and Turn off joining.
/join is the key page (/me) opened to join: the visitor types a name for
the computer and the password. POST /v1/magpie/join makes a gateway key
named after that computer (or "Joined from <ip>"). The key is listed in
Gateway keys like any other, where it can be limited or removed. The
page shows the key once and then the setup for that key: Claude Code,
Codex, a new magpie tab (`magpie provider add remote-magpie '<key>'
url='<address>'`), OpenAI-compatible and curl.
Every route judged:
- lanGuard lets another machine reach GET /join and the join route
without a key, only while magpie is shared. The route checks the
password itself.
- A browser's POST must come from the page itself. Host must be one of
this computer's own names (IP, localhost, MAGPIE_PUBLIC_URL's, its
hostname), so a DNS-rebound name is refused. Origin must equal Host.
Missing Origin and Origin "null" are refused, and so is any
Sec-Fetch-Site but same-origin. corsGuard still refuses null, foreign
and *.localhost Origins before this. curl and scripts, which send no
browser marks, are judged on the password alone.
- Throttle: each try from another machine costs a token, a right
password too. The bucket holds 10 and refills one every 10s, so a
guesser gets about 360 tries an hour, and a flood of tries makes no
flood of keys. Over the limit the route answers 429 with Retry-After.
- The password and key never go in a URL or a log line. The key comes
back only in a no-store 201 body. Logs name the key's id and the
caller's address.
- The routes are classed in the key-slot and read-only route lists.
They carry no key.
Run on mote at this head (rebased on
|
||
|
|
c6bdce26fe |
agent: auto mode works on every model; its check is turned off unless each model gets Anthropic's results back (JoyYoung2Lucky on X)
Claude Code 2.1.322 in auto mode, routed through magpie, denied every action it would check with "Auto mode can't check actions in this session. Its safety check runs on the server, and your requests go through 127.0.0.1:3425, which doesn't pass it through" (auto_mode_no_check_in_session), on DeepSeek and on a Claude model alike. 2.1.316 fell back to its own classifier there; 2.1.322 doesn't when telemetry or feature flags are off (DISABLE_TELEMETRY, CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC, ...), unless CLAUDE_CODE_AUTO_MODE_SERVER is "0". magpie wrote that "0" only when no model Claude Code could reach was reviewed. Any reviewed one, a relay's Claude on its Anthropic endpoint included, left it unset, and /model (or a route that drops safeguard_results) then left the session with no check. That is why a Claude model failed too. Now claudeReviewed asks every reachable model (shown entries, group members, fallbacks, the models it is set to) for gateway.AutoModeAnswered: a reviewable model on the Claude subscription or on api.anthropic.com. Any other writes "0", and Claude Code runs its own classifier through the gateway, fitted to any model (classifierStandIn); its model is the Claude Code card's auto mode square (CLAUDE_CODE_AUTO_MODE_MODEL). An empty slot Sync passes (no small model, say) is skipped, not judged as a model. The gateway still passes safeguards to relays as before. Nothing mimics Claude Code and CLAUDE_CODE_ENTRYPOINT is not set. Real runs, Claude Code 2.1.322 in a sandbox HOME against the live gateway as a client, auto mode, `ls /`, DISABLE_TELEMETRY=1: - deepseek/deepseek-flash: the user's exact denial (before). - deepseek/deepseek-flash with CLAUDE_CODE_AUTO_MODE_SERVER=0 (what the fix writes), with and without a classifier model set: the local classifier ran (permission_check_status checking -> done), Bash ran. - openrouter/anthropic/claude-opus-5.5: ran (OpenRouter returned the results; the fix still writes "0" for it, which also works). - claude/claude-sonnet-5 (subscription bridge): ran. Fake upstreams with and without safeguard_results (in a stream's message_delta delta) showed the same split. Tests: TestClaudeAutoModeReview (DeepSeek beside a Claude model writes 0, the user's case), TestClaudeReviewedOnlyWhereResultsComeBack, TestClaudeReviewedJudgesTheSetModelWhereItGoes (empty slot), TestT3CodeAutoModeReview, TestAutoModeAnsweredOnlyWhereResultsComeBack. Broken by hand on WSL, each went red: AutoModeAnswered true for any reviewable model (relay cases red in agent and gateway); the old "any shown entry reviewed" rule (the user's case and T3 Code red); an empty slot judged as a model (three Claude-alone cases red). Runs, each at the tree named (the diff is the same in all three): - On |
||
|
|
b9a1b4aa1d |
copilot: each account's own models, listed together and routed only to the accounts that have them (applemacssma on X)
"支持多个ghcp账号轮换和平均负载均衡吗,每个ghcp账号有的模型不一样。"
Several Copilot accounts and the Routing strategies (In turn, by usage)
worked already. What didn't: the copilot provider's list was the first
account's /models alone, so a model only another account's plan has was
nowhere to pick, and the gateway took every account to have every model.
Now each Copilot account's /models is kept as its own (accountModels,
read by Account.Lists), and the provider's list is their union
(copilotPoolModels over poolModels, the body codexPoolModels had). A
fetch of the first account's list also asks the other accounts on: one
with no list at once, of the rest the stalest once its list is a day
old, one per fetch. Only a failed ask is remembered (retried after an
hour). A model Copilot refused one account (model_not_supported) stays
in the list while another account on lists it (copilotOthersList).
Run (WSL magpie-desktop at 425195bf3; mote refused SSH all session):
- go test ./internal/provider/ ./internal/gateway/ -timeout 45m: ok
- go vet linux, GOOS=windows, GOOS=darwin CGO_ENABLED=0 for both: ok
- gofmt -l: clean
- TestCopilotAccountsWithOtherModels: octocat lists gpt-4.1 and
claude-opus-9, hubot gpt-4.1 and gemini-9-pro; the list is the union,
each model goes only to its account under In turn, gpt-4.1 to both.
- TestCopilotRefusedModelGoesToTheAccountServedIt: octocat's list has
gemini-9-pro but Copilot refuses it; it then goes to hubot alone and
stays listed.
Broken by hand:
- copilotPoolModels call removed: the first test red ("lists [gpt-4.1
claude-opus-9 auto], without gemini-9-pro").
- models.go's union check dropped: the second test red (gemini-9-pro
left the list).
- A refusal check in Account.Lists made no difference (the gateway
already keeps a refused account off that model), so it isn't in.
Not tried: real Copilot accounts on two different plans; the full
suite (runs after the tag).
|
||
|
|
ca7a392919 |
gateway: MiniMax's image-01 draws on its own image_generation API (rocbomb123 on X)
minimax-cn/image-01 went to chat completions (catalog.ImagesAPI doesn't
know image-01), and MiniMax answered "invalid params, unknown model
'image-01' (2013)". MiniMax draws only on POST <host>/v1/image_generation
(platform.minimax.io and platform.minimax.cn API reference, t2i and i2i,
checked against the docs, not the report).
- draw_minimax.go: a MiniMax API key (filmsMiniMax: the minimax and
minimax-cn presets, or any provider at api.minimax.io, api.minimaxi.com
or api.minimax.cn) lists image-01 and image-01-live as drawers and
draws them at its own host: size -> aspect_ratio (a listed ratio or its
size; else image-01's width/height in 512..2048 by 8; else the nearest
ratio; 21:9 image-01 only), n, response_format base64, edit images as
subject_reference type character, the caller's seed, prompt_optimizer,
aigc_watermark and style passed on; mask and markup refused before
asking. data.image_base64 / image_urls are read; base_resp failures in
a 200 are told by code (1004/2049 key 401, 1008 balance 402, 1026
content 400, 1002 rate 429, 2013 400), and all images held back
(metadata.failed_count) says so.
- draw.go: viaFor sends them to the images path, drawImages to
drawMiniMax, DrawersOf adds them for a MiniMax key.
- A relay serving MiniMax models under another host is unchanged. The
minimax-code plugin sign-ins are not API keys and are untouched.
Run (mote, at
|
||
|
|
71075af726 |
codex: "subagents on any model" tells Codex V1 for a relay of the ChatGPT backend too (brethhbbm on X)
brethhbbm on X: lead on relay/gpt-6-astra, subagent model set to
relay/gpt-6.1-terra, "Codex subagents on any model" on. A new session's
subagents still ran on Astra, and Routing said the task was sealed and
only a ChatGPT account could read it. The model's catalog entry still
said multi_agent_version "v2".
Cause: the setting (settings.CodexAgentsV1) stamped V1 only on the
ChatGPT account's own models (codex/) and the groups one is in (Fast).
The relay lists Codex's own entry for gpt-6-astra (a sub2api asked with
Codex's client_version), "v2" included, and a relay offering Ultra is
given "v2" (AgentsV2) besides. In V2 Codex hands the lead the
collaboration namespace (spawn_agent etc.), whose arguments a relay of
the ChatGPT backend seals as the backend does (#1109), so
codexSubagentPick kept the subagent on the lead's model (sealedKept).
Fix: catalog.Model.Seals (provider.CodexSeals) marks a model whose
provider is of no sign-in on the Responses API, as the gateway's
canSeal, or a group with such a member. With the setting on, its entry
says V1 like the ChatGPT account's, listed by its relay or made by
magpie, so the task goes as text and the model set for subagents takes
it. Seals is in the list's tag, so Codex asks for the list again. A
model of an account that seals nothing (Copilot's Ultra, #656) keeps
V2, and with the setting off every entry is as before. No prompt text
or instructions change.
Real Codex (0.165.0, sandbox HOME/CODEX_HOME, fake Responses server,
model_catalog_json with the user's gpt-6-astra entry as
relay/gpt-6-astra): with "v2" the first request carries the
collaboration namespace (spawn_agent, send_message, followup_task,
wait_agent, ...); with "v1" it has none.
Run (Linux box via wsl-run; mote refused SSH for the whole session):
- go vet -tags nogui (linux), GOOS=windows go vet, GOOS=darwin
CGO_ENABLED=0 go vet -tags nogui on codexcat, provider, agent,
catalog, settings: ok; gofmt -l clean
- go test -tags nogui -count=1 ./internal/codexcat ./internal/catalog
./internal/settings ./internal/provider: ok
- ./internal/agent, and -run 'Codex|Ultra|Subagent|Sealed|Collab|AgentsV1'
./internal/gateway, were still running when this was pushed; their
results go on the release's issue thread if red
- at the pushed head (rebased on
|
||
|
|
e6f151507f |
sessions: each session's output speed, a curve of its last two minutes
The owner liked a tweet's token-speed curve and approved a mockup
(claude.ai/artifact/7mrkMKdVi6jA3HA1Z6pRr5). Each Sessions row now
shows its output speed with a small curve; clicking it opens a popover
with the current tok/s, two minutes of seconds, tool gaps, and the
round's average, fastest second and output so far. A row not live
shows "Avg {n} tok/s".
Gateway: a curveMeter (session_speed.go) on the Server counts every
reply's content bytes per agent and session, from liveRow.observe, the
same count the Live view uses, and turns them into tokens with the
learned per-model rate (tokenRates.rate). A model with no rate yet
shows the curve's shape and no number: a guess would be a wrong
number. counted() opens a session's in-flight span, so a second with
nothing in flight is a gap (a tool ran), not a zero. A pause past 2m
starts a new round; 10m of quiet forgets the session; at most 256
sessions. Codex's own sign-in (codex_backend.go) went past serve and
liveRow before; it now has a liveRow too, so its sessions are counted.
GUI: GET /api/speeds, kept out of /api/sessions* so a once-a-second
poll doesn't set off session reading. The page polls only while
Sessions is shown and visible. managedJSON gains keys, so a row
matches a session the gateway saw under another of its keys. The
curve hides below 620px.
Run (mote's sshd resets every connection today, so Linux and Windows):
- Linux (magpie-desktop, wsl-run): gofmt clean; go test -timeout 45m
./internal/gateway ./internal/sessions ok except
TestGroupFailoverTimesEachTry, red once under load, 5/5 green alone
here and on main (#5948); node --test over every sessions-*.test.cjs
and i18n-*.test.cjs: 546/549, the reds sessions-export en in both
engines, the same on origin/main
|
||
|
|
4a9142ccd4 |
agent: Obsidian, magpie's models in Copilot for Obsidian (shirotokiren on X)
shirotokiren asked for magpie to set up Obsidian's AI plugins, naming Copilot and Smart Connections. The new agent "obsidian" finds the vaults in Obsidian's obsidian.json: ~/Library/Application Support/obsidian on a Mac, %APPDATA%\obsidian on Windows, and on Linux $XDG_CONFIG_HOME/obsidian or the Flatpak or Snap folder. In each vault that has Copilot for Obsidian 4+ (.obsidian/plugins/copilot), magpie edits data.json in the shape Copilot 4.0.19 reads: - it adds providers.magpie, openai-compatible at /agent/obsidian/v1, with requiresApiKey false and no keychain id; - it adds one configuredModels entry per magpie model, with a deterministic uuid v5 id, plus limits, image input and reasoning efforts; - new models go into backends.chat.enabledModels; - on the first wire it sets defaultModelKey, and stashes the old value. A sync keeps the models the user turned off, their default, and the name they gave the provider. It writes only the keys that change (edit.PatchJSON, then temp and rename), and nothing when nothing changed. A provider named magpie counts as magpie's only when its baseUrl is magpie's Obsidian route. One the user added by hand under that name is theirs: it doesn't read as connected, Disconnect leaves it, and Connect says so and writes nothing. Disconnect takes magpie's entries out and puts the old default back. Copilot 3, a data.json it can't parse, and no vault with Copilot are each an error, and nothing is written. A notice asks the user to reload Copilot, since Obsidian holds the settings in memory. The gateway now answers CORS for app://obsidian.md keylessly (appOrigin). Copilot streams through the window's fetch, and without CORS headers it can read no reply. Only Obsidian's own window sends that origin, so it gets no more than its calls without an Origin get. From the network it still needs a key. Smart Connections is not wired. Its free plugin embeds with a local model only, and its API providers are in the closed Pro plugin, with keys in the keychain. Run (mote, at |
||
|
|
327fb57659 |
redact: Never mask holds from the next text on, earlier turns stay masked (NicoleS76448271 on X)
A value let go from the request view's menu (Never mask) went as written
in the conversation's earlier turns too, so the prompt the vendor had
cached no longer matched and the whole conversation was read again at
full price. Now a text sent masked on a route keeps that value masked,
with the same placeholder, while magpie remembers the text; new texts
(the next turn, another conversation) send it as written. It holds for
values added in Settings too.
allowkept.go remembers a maphash of (route, text) and of the value,
never the value, in two generations of 2^17 like sentSpans' memo. Only a
request with a route (Options.sent and Route) keeps it; a search's query
or an embedding's input has the value as written at once. Keeping a
value masked is the safe side: a collision masks a value the user let
go, and a text no longer remembered (after a restart) sends it as
written, as before. The menu's message now says earlier messages stay
masked so the cache holds (en, zh, zh-TW, ja, de). The request view's
inline Never mask was already there (yew_fence on Discord).
Run (mote refused SSH for ~30 min at load ~125, so on the Linux box):
- wsl-run go test ./internal/redact/ ./internal/masking/ ./plugins/redact/
ok, at the pushed head b9d1f00a5 too.
- wsl-run go test -run "Mask|Redact|Allow|Sent" ./internal/gateway/ and
-tags nogui ./internal/gui/: ok.
- go vet: GOOS=windows (redact, gui), GOOS=darwin (redact), linux -tags
nogui (redact, gui): ok. gofmt -l clean.
- node --test mask-value-menu, i18n-keys, i18n-en-no-cjk (chromium and
webkit, every language): ok. masking-records: the same reds as fresh
origin/main
|
||
|
|
82962db79a |
routing: a rule can match the system prompt or the last user message, by words or a regex, with no model asked (SucroseMoE on X)
SucroseMoE asked for routing on plain string and regex matches instead
of an intent model: `system[0] matches /^你是对话标题命名/` → model A,
`user[-1] matches /^正在上下文压缩/` → model B, so any harness's title
and compaction calls can be routed without a classifier.
Two new rule condition fields, beside message/effort/subagent/agent:
- system: any block of the system prompt as the agent sent it (Anthropic
system blocks, Chat system/developer messages, Responses instructions
and system/developer items, Gemini systemInstruction). Any block, not
only the first, because Claude Code's first block is its billing
header.
- last: any text of the request's last user message as sent, reminders
the agent adds included, so an anchored ^ still meets a compaction ask.
Ops for both: contains, doesn't contain, starts with, matches (regex,
case-insensitive; a value written /…/ has its slashes dropped). The
gateway reads system and last only when a rule asks (RulesRead), and
decodes raw system JSON lazily then. Like every rule, the decision is
made as a turn starts and its tool rounds keep it.
GUI: Routing → group → Rules, "+" on a rule row offers "System prompt text"
and "Last user message" pills (no modal), with tooltips, placeholders
and the bad-regex mark; zh, zh-TW, ja, de. CLI: `--when "system matches
^You are"`, with aliases system[0], user[-1], last-user. TUI hint, docs
(gateway-routing.md, site start pages) say the same.
Ran, on mote (macOS) until its sshd began refusing connections: gofmt
-l internal/ clean, go vet of provider/gateway/cli/tui, the rule tests;
the routing GUI files (routing-rule*, routing-rules-line,
routing-pause*, group-*, i18n-*, routing-compact, routing-intent-*,
routing-smart-intent) in chromium and webkit: 751 of 781, the 30 reds
being "System prompt" taken by a core word (now "System prompt text"),
routing-rules-line's + menu count (now with system and last), and
routing-intent-entry, red on main since
|
||
|
|
f1996e7e5d |
gateway: a provider named past its usage cap is not sent on to a group (Anotiaww on X)
Anotiaww on X: magpie on server B asked magpie on server A for claude/claude-opus-5-5. A's Claude account was past its usage cap (the trace: "a usage window at 98%, over the account's 98% cap"), and the Claude provider had no fallback set. The request was answered by a WorkBuddy member of the user's routing group claude-opus-5.5 (the trace row marked Fallback), with nothing said. They expect the cap's refusal. Cause: |
||
|
|
25c36e862a |
gateway: a relay's pooled refusal of one model rests that model, not the key (Jray05343207 on X)
Jray05343207 (Windows) connected Codex through magpie and got
"auth_unavailable: no auth available (providers=codex, model=gpt-6-sol;
last upstream error: model_not_found: The 'gpt-6-sol' model is not
supported when using Codex with a ChatGPT account." That text is not
magpie's: it is CLIProxyAPI's (sdk/api/handlers/handlers_errors.go,
enrichAuthSelectionError), a relay pooling ChatGPT accounts. It lists
gpt-6-sol whatever its accounts' plans serve, and once every account
refused it answers 503 with the last refusal in its words.
modelRefused read only 400/403/404/422, so the 503 was a plain outage:
the whole key rested on the backoff ladder, every model on the relay
with it, and the model stayed offered. Now a 5xx whose body is that pool
answer ("no auth available (providers=…; last upstream error: …)",
poolLastError) is judged by the last upstream error's own words, as a
404 would be: a model refusal rests only that model on that key
(restID), and the key's other models are asked straight. A last error of
quota, or none named, reads as before. plainUnavailable leaves such a
refusal to modelRefused too. docs/subsystems/gateway-routing.md says so.
Run (WSL magpie-desktop, Linux; mote's sshd reset every connection):
- TestPoolModelRefusalRestsTheModelNotTheKey (two keys on a relay
answering the reporter's exact body as 503) and TestPoolLastErrorRead:
pass.
- Broken by hand (the poolLastError branch removed): both red; each key
rested whole ("Why:other Status:503 By:backoff") and gpt-6-sol didn't
rest on its own.
- TestModelNotInPlan*, TestFallback*, TestEscapedWords*: pass.
- go vet ./internal/gateway for linux, windows and darwin; gofmt -l clean.
- go test -count=1 -timeout 45m ./internal/gateway: ok (1025s, Linux)
Not tried: a real CLIProxyAPI with a plan lacking gpt-6-sol (fixture is
the reporter's literal text in CLIProxyAPI's body shape); the user's
Codex still gets the 503 if gpt-6-sol is the model it asks for and no
other provider serves it, so the reply asks them to pick another model.
|
||
|
|
1ad9d157fe |
gateway: a compaction a ChatGPT-account relay refuses as system asks again with the roles as sent (#5067, acui145 on X)
Codex's summary ask to a provider that isn't OpenAI's carries its developer messages as system ones (forVendor, #2955). A plugin provider fronting a ChatGPT account (magpie-sub2api -> sub2api -> Codex backend) is such a provider, and the backend behind it takes developer alone: every compaction came back "System messages are not allowed", the sessions that got through fell to the conversation-as-text summary, and the ones whose refusal came as an error event after a 200 skipped every retry and were held after three (compactFails). Now a summary refused "System messages are not allowed" (as passed through, or as a current sub2api words it), or with a relay's bare "Upstream request failed" (the reporter's sub2api), as a 4xx or as an error event in the stream (roleRefused), is asked once more with the roles as Codex sent them (askAsSent turns off the compaction marker, whose only reader is forVendor's swap), then as text, then made by magpie. A summary with no developer message to give back is not asked the same twice. Every route a compaction reaches a Responses provider by (CodexPath, Codex's own models through magpie's accounts, the mask route, a CC Switch table) goes through codexCompact and serve's one forVendor call, so all of them are covered. #2955's chat-only vendors take system and are unchanged. Ported from ggbdpq's patch (fix/5067-compaction-system-messages, 79ec15d26), which matched only the passed-through wording on a 400. The review added the reporter's own "Upstream request failed", the error-event shape, the developer gate, lazyre for the words, and the subsystem page. Run on mote at this change on 6a253f8af; rebased onto |
||
|
|
ece12b370d |
search: TinyFish is a built-in search API (Niapyaya on X)
Niapyaya asked on X for TinyFish (tinyfish.ai) among the search APIs. TinyFish has a plain Search API beside its browser agents, so it is added as vendor "tinyfish", following Yuanbao Search ( |
||
|
|
f2b9ec354a |
gateway: Codex's auto-review goes on where its conversation does when the sign-in is out (riverleaf88 on X)
riverleaf88 on X: with Codex's ChatGPT allowance spent and magpie routing Codex on to another model, Codex's automatic review still failed. Codex's guardian (codex-rs guardian-v2 sync_reviewer) asks the same provider, so magpie's /backend-api/codex/responses, on codex-auto-review (approval_review_preferred_model) with x-openai-subagent: guardian. On a spent sign-in codexFallsBack and serve's groupsAfter looked for fallbacks and routing groups of codex/codex-auto-review, a model no group names, so the review was handed ChatGPT's 429 while the conversation's turns went on to the group. - codexReviewAfter: an auto-review on the codex sign-in takes the model its conversation's own turns go on (codexLeads). A codex model brings that model's fallbacks and groups (fallbacksOnly on the lead too); a magpie model the caller may use (servedSession) is tried itself. codexFallsBack and groupsAfter add them. - codexHolds: once a 429 naming a reset held the account, later turns (main turns too) were answered with the held refusal before any fallback. The held branch now hands a /responses turn with fallbacks to codexFallBack as the first spent turn was. - docs/subsystems/gateway-routing.md says both. Run (mote): go test -count=1 -run 'TestCodexReviewSpent|TestCodexHeld| TestCodexOneAccount|TestCodexSpent|Hold|Held' ./internal/gateway/ ok 71.2s; gofmt -l clean. New tests red on the old code: TestCodexReviewSpentFollowsTheGroup and ...FollowsMagpieModel (review got 429 usage_limit_reached); the held case in TestCodexHeldTurnFollowsTheGroup. Broken by hand: codexReviewAfter returning nil turns TestCodexReviewSpentFollowsTheGroup, ...FollowsMagpieModel and TestCodexHeldTurnFollowsTheGroup red; dropping the held-branch fallback turns TestCodexHeldTurnFollowsTheGroup and ...FollowsTheGroup red. Not tried: a real exhausted ChatGPT account; guardian-v2's async scorer; the multi-account pool path past serve's candidate loop is covered only through the one-account tests. Also run (mote, at this tree): go vet ./internal/gateway/ for darwin, GOOS=linux -tags nogui and GOOS=windows: clean. go test -count=1 -timeout 45m ./internal/gateway/: ok 1037.9s (base |
||
|
|
93a33d8174 |
agent: OpenBot's icon, its requests named its own, its skills in the Library (SSNQT on X)
SSNQT on X, magpie 0.1.3503 on macOS, OpenBot (
|
||
|
|
add0dadd4f |
codex: a service tier set in Codex's settings goes on every request of Codex's (JackyFill on X)
JackyFill asked for a choice in Codex's agent settings that rewrites
service_tier: follow the request, force Fast, force Ultra Fast. Codex's
settings on the Agents page now have "Codex service tier", picked from
the app menu: As Codex asks (the default, nothing changes), Standard,
Fast or Ultrafast.
The values are Codex's own request values (codex-rs protocol
config_types.rs ServiceTier, tui service_tier_resolution.rs): Fast is
"priority", Ultra Fast is "ultrafast", and Standard sends no
service_tier. Flex isn't offered: the ChatGPT backend's requests drop
it (codex_request.go).
settings.CodexServiceTier ("", "default", "priority", "ultrafast";
anything else refused) is set through POST
/api/settings/codex-service-tier. codexTiered rewrites the body where
Codex's requests come in, on both ways: codexBackend (Codex signed in,
/backend-api/codex) and the main handler's Codex-on-Responses block,
which a websocket turn goes through too. It applies only when the
request is Codex's (fromCodex or agentOf == codex). Everything after
treats it as Codex's own ask: an account whose list lacks Ultrafast is
put after a mate that has it or sent priority. A bare model (Codex's own
sign-in, whose plan magpie doesn't know) gets ultrafast only where one
of magpie's Codex accounts lists it on the model (UltraModels), else
priority. The body is edited with topMember/withoutTopMember, no full
decode. Fast picks still apply after, unchanged.
Run (mote):
- TestCodexServiceTierSet, TestWithServiceTier: ok. The test signs in a
Plus and a Pro ChatGPT account against a fake backend whose lists offer
gpt-6-luna's Ultrafast to Pro only, and checks the tier sent for each
setting x what Codex asked, through /v1/responses (account:tier tried)
and on /backend-api/codex for a model with Ultrafast and one without;
OpenCode's own priority is left alone; "flex" is refused.
- go test -count=1 -timeout 45m ./internal/settings ./internal/provider
./internal/gui ./internal/gateway: ok but internal/gui, which was red
twice: TestCoreScriptBudget (1,535,075 > 1,533,802) and
TestSettingsSaveKeepsWhatItDoesNotSend (a save of the Settings page
dropped the tier). Paid for by eight Codex-row comments cut in app.js
(now 1,533,416), no raise; settingsapi.Apply keeps CodexServiceTier
as it keeps the other Codex rows. At the pushed head: go test
./internal/settingsapi ./internal/settings ./internal/gui ok, the two
gateway tier tests ok.
- go vet darwin; GOOS=linux -tags nogui; GOOS=windows (gateway,
provider, settings, gui): clean. gofmt -l: clean.
- GUI, chromium + webkit: codex-service-tier (new, en/zh/zh-TW/ja/de at
900 and 400px: 20/20), agent-prefs (56/56, Codex's row list updated),
i18n-keys, i18n-en-no-cjk, settings-search, codex-titles,
codex-subagent-model, settings-general, codex-sheet-providers,
click-scroll: all pass; at the pushed head codex-service-tier,
agent-prefs, i18n-keys, settings-search, codex-titles,
codex-subagent-model, settings-general, click-scroll: 166/166.
Broken by hand:
- codexTiered returning the body as it came: TestCodexServiceTierSet red
(17 lines).
- the Ultrafast-to-Fast downgrade for a bare model removed: red on
gpt-6-sol (sent ultrafast, want priority).
- the GUI posting to the wrong path, and the row left out of Codex's
AGENT_PREFS: codex-service-tier red in chromium and webkit.
- settingsapi without the CodexServiceTier keep:
TestSettingsSaveKeepsWhatItDoesNotSend red.
Not tried: a real ChatGPT account's Ultrafast or Fast request with the
setting on (only the fake backend), a real Codex websocket session, and
Windows/Linux runs of the GUI.
|
||
|
|
efb75ad1f0 |
gateway: client certificates (mTLS), and Remote Magpie can show one (hhdaxia on X, #5596)
hhdaxia on X asked for mTLS so a shared magpie isn't open to the internet on a key alone; clxsh's #5596 asks Remote Magpie to send a client certificate and key (PEM) to an Nginx doing mTLS, the server still verified, the Gateway Key still sent, for models, the test and streaming. Server side (magpie's own CA, internal/mtls): - Settings -> Network and sharing -> Require a client certificate, or `magpie mtls on|off|issue <device>|list|revoke`. Issue saves client.pem, client-key.pem and ca.pem to ~/Downloads/magpie-<device>; the key is kept nowhere else. - With it on, a peer that isn't this computer or a WSL distro must finish the TLS handshake with a certificate the CA issued and hasn't revoked (RequireAndVerifyClientCert + VerifyConnection -> Admits). The TLS config is chosen per connection, so the switch needs no relisten; without --tls-cert the server certificate is made by the CA in memory. - lanGuard and ClientCertGuard (magpie web's page) refuse 403 what still arrives without a verified one: plain HTTP, a proxy or tunnel on loopback (unless MAGPIE_TRUST_PROXY=1), the page port, a connection from before the switch, a certificate revoked since its handshake. - Loopback, this computer's own address and a WSL agent with its key are answered as before. - A page open from another computer can't shut itself out: without a certificate it can't turn mTLS on, and it can't revoke or reissue the certificate it came with. Client side: a provider with a base URL of the user's own (Remote Magpie included) takes ClientCert, ClientKey and ServerCA paths (editor: Advanced -> Client certificate). netproxy.WithClientCert shows them to that provider's own hosts only, on a transport per identity keyed on the files' mtimes; through an https:// proxy such a request is refused. Save refuses half a pair, a pair that doesn't match and a CA that isn't one. Run (on mote, at 4024df0f9, this commit before its rebase): - gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows. - go test -count=1 ./internal/mtls ./internal/netproxy ./internal/provider ./internal/settings ./internal/settingsapi ./internal/cli ./internal/gui ./internal/gateway: ok (gateway 893s). The first run had three reds of this change, each green at base and fixed here: TestEveryRouteHasACommandOrIsNamed (the mtls routes now name `magpie mtls`), TestSettingsSaveKeepsWhatItDoesNotSend (MTLS kept), and TestGoroutineDumpAnswersWhileRequestsWait (mtlsRefuses asks whether the peer is remote before reading settings, so a local request never waits on the settings lock). TestHandedOffGatewayAnswersAConnectionNotedLate was reset because ServeTLS now always wraps the listener: tlsListener hands a connection it took as Close came to the server instead of dropping it. -count=3 of these and every TLS/MTLS/Handover/Relisten test ok. - Every route without a certificate, with a foreign one, a revoked one and a good one: TestMTLSOtherComputerHandshake, TestMTLSGuardEveryRoute, TestMTLSThisComputerAndProxies, TestMTLSToggleWithoutRelisten, TestMTLSRevokeMidConnection, TestClientCertGuardPage. Remote Magpie against an httptest server asking RequireAndVerifyClientCert: models and the connection test fail without the certificate and pass with it (TestRemoteMagpieClientCert). - GUI: the 92 files near the change (settings-*, provider-*, editor-*, lan-*, i18n*, allow-ips, remote-*, mtls-settings new) in Chromium and WebKit: 2904 pass, 74 fail, all in nine files red the same way at base |
||
|
|
5426c43cca |
gateway: DSH's compaction leaves a provider out of its limit for the same model elsewhere (qtwaiter on X)
qtwaiter's DSH chat ran on WorkBuddy's deepseek-v4.1-flash until
WorkBuddy rate-limited it. A switch to Trae CN's deepseek-v4.1-flash
failed with the same 429 ("WorkBuddy: 您的使用量已超出频率限制 ...
(out of its allowance: not asked again before ...)"), while DSH's own
DeepSeek route switched fine. compaction-basic (0.2.2-rc.1, agent/request
hook) compacts on the model it switches away from before a turn on
another, whenever the history is over the new model's threshold (Trae CN
lists the model at 200000/64000, so ~84K; DSH's own routes are 1M and
never compact), and fails the switch with MODEL_SWITCH_COMPACTION_FAILED
when that compaction is refused. The compaction went to WorkBuddy, which
magpie held as out of its allowance, so every switch failed.
Now a dsh compaction whose provider has every key or account resting
(quotaHeld or timedHeld over its candidates) goes on the same model from
another provider (provider.AutoGroupOf), the widest window that is
served, allowed to the key and not resting itself
(dshCompactElsewhere in dsh_compact.go). The route records it as
Moved{Why: "dsh-compact-rested"}, which the Routing page explains in
five languages. With no such provider it stays as asked with a log
line. A compaction model set on dsh's row (#5395) is still read first.
Run (mote):
- go test -run TestDshCompact ./internal/gateway/: ok.
TestDshCompactLeavesRestedProvider replays the screenshot's case:
turn on workbuddy 429 (Retry-After 3600), compaction then served by
trae-cn/deepseek-v4.1-flash with WorkBuddy not asked again, the next
ordinary turn still held. Red on the old code with the reporter's
exact 429 text. TestDshCompactStaysUnlessRested: not resting, no other
provider, another agent all stay.
- go vet ./internal/gateway/ on darwin, linux (nogui) and windows; gofmt.
- go test -count=1 -timeout 45m ./internal/gateway/: ok (908.8s)
- GUI (chromium + webkit, 5 languages, 2 widths): dsh-compact-model
20/20, routing-moved-why 20/20, i18n-keys 4/4, i18n-en-no-cjk 4/4.
At the pushed head (rebased): go vet and the TestDshCompact tests ok.
Broken by hand: skipping the stand-in (`false && m != ""`) turns
TestDshCompactLeavesRestedProvider red; removing the client.js case turns
dsh-compact-model red. Both restored.
Not tried: the real DSH app with a rate-limited WorkBuddy account. A
switch away from a model no other provider serves still fails while its
provider is out of its limit; the compaction model square covers it.
|
||
|
|
a79d16c684 |
routing: a rule can match on conditions: effort, subagent, message content, agent (aipha2025 on X)
A routing rule takes field/op/value conditions (Rule.Where) beside its
existing match. Fields: reasoning effort, whether the request comes from
a subagent, the user's own message that opened the turn (content), and
the agent. Ops: is, is not, contains, starts with, regex, greater/less
than. Only Claude Code and Codex say when a request is a subagent's.
- provider: rulecond.go parses and evaluates conditions; grouprule.go
and ruleparse.go carry them in a rule.
- gateway: the request's effort, subagent flag and opening user text
reach the rule check (ir.go, rules.go); the trace names a rule's where.
- CLI: `when="..."` on a rule; TUI shows it.
- GUI: the conditions are edited inside the existing rule row (no
dialog), in every language (routing i18n).
- Docs: gateway-routing.md, site start pages (en, zh, ja).
Run:
- GUI: 124/124 on the touched files (routing-rule-ops, routing-rules-line,
i18n-keys and the routing files), chromium and webkit.
- A wider 236-file GUI run is red only where the old code is red too:
menu-input-scroll (#3402), webkit context-fold, intent-entry, row-swap.
- gofmt; go vet darwin, linux (nogui) and windows.
- go test ./internal/provider ./internal/cli ./internal/tui
./internal/gateway pass.
- After the rebase on origin/main
|
||
|
|
0791c91c5a |
gateway: text that isn't UTF-8 in a request body reaches the vendor as U+FFFD (laincatx on X)
A JSON body holding bytes that aren't UTF-8 (GBK, a surrogate written as
UTF-8, \xed\xa0\x80) or a lone surrogate's escape ("\ud800") was sent on
with those bytes as they came. DeepSeek and OpenAI answered 400, MiniMax
200 with nothing, so in a routing group one request worked or failed by
which member got it.
readBoundedRequestBody, which every route reading an agent's body goes
through (each API, Gemini's, count_tokens, the Codex backend path and
relay, a Codex socket's turn, served as a POST through the handler), now
makes them U+FFFD (textBody): one per bad byte, as Go's encoding/json
does. A surrogate pair's escapes, an escaped backslash before "ud800",
and multipart, audio, image or octet-stream bodies are left alone.
Why replace, not refuse (the report's option A): a tool result carries a
file's bytes as they are, and an agent resends the whole history every
turn. Anthropic answers a lone surrogate 400 ("no low surrogate in
string"), which fails every later turn of a Claude Code session; a 400
from magpie would do the same. Replacing is what Go's decoder and WHATWG
decoders do, keeps the session going, and changes only bytes that were
not text. Since nothing bad reaches the vendor, its 400 can't rest an
account or count against a key (the test checks nothing rests).
Cost: utf8.Valid plus a scan of backslashes, no copy when valid; 24 MB of
escape-dense JSON in 24.5 ms on mote (~1 GB/s).
Run (mote):
- new tests: TestBadTextReachesVendorsAsReplacement (inbound Chat,
Responses, Messages x upstream Chat, Responses, Anthropic x six bad
texts x stream on/off, in a user message and a tool result),
TestBadTextOnSocketAndGemini, TestGoodTextGoesAsSent, TestTextBody:
ok; also ok on Windows (win-run).
- broken by hand: with the textBody call removed from
readBoundedRequestBody, TestBadTextReachesVendorsAsReplacement,
TestGoodTextGoesAsSent and TestBadTextOnSocketAndGemini go red with the
fake vendor's 400 (the reporter's case).
- the whole internal/gateway package: queued behind other sessions on
mote's suite lock (2h+); the full suite runs after the tag and its
reds are filed. Rerun at the rebased head (cdff4b726 parent
|
||
|
|
60f0433d1b |
dsh: a model of its own for DeepSeek Harness's compaction (Musikrv77852 on X, #5395)
DSH compacts on the session's latest model (compaction-basic with no summarizationModel). A session on magpie/workbuddy/deepseek-v4.1-flash switched to another model compacted on WorkBuddy first, got 429, and the switch failed. DeepSeek Harness's opened row on the Agents page now has a "compaction model" square (compact_model), offered once dsh is on magpie's route. It is magpie's own Live setting (settings.DshCompactModel), so nothing is written into dsh's profiles and no restart is needed. The gateway moves a dsh compaction to it (dshCompactTo, Route.Moved why "dsh-compact") when the model is enabled, served by its exact id and allowed to the key; else the compaction stays as asked with a log line. The Routing page says why. On magpie's llm-pi-ai routes DSH sends no x-deepseek-harness-compact mark, so its compaction is now known by compaction-basic's own ask (@deepseek-ai/dsh-compaction-basic 0.0.1-rc.3, the latest) in compactAsks. As a result DSH compactions show as Compaction in Usage and Routing, and a group's Compact rule reaches them too. The options are spelt magpie/<id> like the model field's, so `magpie dsh deepseek/flash` still sets the model (fieldForValue gives a bare value to the first field offering it). CLI: `magpie dsh compact_model magpie/deepseek/flash`; API: /api/set. zh, zh-TW, ja and de strings added. Run (mote): go test -count=1 -timeout 45m on internal/gateway, provider: ok at the base before the rebase on 0842bc517; agent, gui, settings, settingsapi, and the gateway's TestDsh/TestCompacting/ TestRuleCompact: ok at this head. The first agent run caught the square reading dsh's profiles at a stopped WSL distro (TestWSLColdPlaceOpensNothing, #3896); its options now look at nothing at a cold place. go vet on darwin, GOOS=linux -tags nogui and GOOS=windows: clean. gofmt clean. GUI in chromium and webkit: dsh-compact-model (new, 5 languages x 2 widths), desktop-subagent-model, codex-subagent-model, routing-moved-why, i18n-keys, i18n-en-no-cjk, claude-subagent-effort-row, codex-start-model-field, model-test-why and agent-connect-no-models: 140 of 140 pass; after the rebase (i18n.js changed upstream) i18n-keys, i18n-en-no-cjk, dsh-compact-model and routing-moved-why 48 of 48. Broken by hand, each red: dropping the compactAsks line (TestCompacting, TestDshCompactMoved on all three protocols), skipping the move in serve (TestDshCompactMoved), dropping the agent check (TestDshCompactLeft's other agent), taking the square out of extra() and dropping the routing story's case (dsh-compact-model.test.cjs). Not tried: a real DeepSeek Harness desktop app (none on this Mac or on mote); the compaction text was checked against the npm package's source. DS Bot's requests can't be told from dsh's, so its compactions follow the same setting, though it has no square of its own. |
||
|
|
0549e5301a |
masking: Send requests unmasked is found from Settings › Privacy and holds on every route (CrazyMouse_TT on X)
CrazyMouse_TT runs a model of their own and wanted masking off for it.
The switch already existed (the provider editor's Advanced › Send requests
unmasked, provider.Unredacted), but nothing near masking pointed to it,
and it held only on chat-shaped routes.
- Settings › Privacy has a "Sent unmasked" row: each provider set so is a
button that opens its editor with Advanced open; with none, the row says
where the switch is (settingsJSON.UnmaskedProviders, redact plugin's
unmaskedRow).
- Images (draw.go), videos (video.go) and Ark's own API (native.go) go as
written when every model they may go to is such a provider
(unmaskedMembers); a group with one member left on stays masked, as a
chat's route does (unredactedRoute).
- A Remote magpie may be set so too (SkipsRedaction no longer refuses
it): it is sent the request as written with no X-Magpie-Masked-As, so
it masks by its own Settings and switches, once, before any vendor
(1d6d263ee's hop). Left off, it is masked here, as before. The editor
says so for a remote magpie.
- Default stays off for every provider: nothing changes for anyone who
hasn't ticked it.
app.js stays under TestCoreScriptBudget by a shorter unmaskRow call and
three trimmed comments (app.js -51 bytes vs base).
Run (mote, at this tree): gofmt -l clean; go vet darwin, GOOS=linux
-tags nogui, GOOS=windows clean; go test -count=1 ./internal/gateway
./internal/provider ./internal/cli ./internal/masking ./internal/gui ok.
GUI (chromium + webkit, 5 languages, 1100/440px):
provider-unmasked, unmasked-providers, i18n-keys, i18n-en-no-cjk,
redact-route: 126 pass, 0 fail. masking-records.test.cjs is red the same
on origin/main
|
||
|
|
1d6d263ee0 |
gateway: a hop to a Remote magpie masks once and isn't retried over the remote's own retries (YeYaka88 on X)
YeYaka88 on X: with magpie desktop using another computer's `magpie
serve` as a Remote magpie, the gateway, routing and masking all ran
twice. Reproduced with two sandboxed magpies on mote (old binary, a fake
OpenAI vendor behind the remote, the same masking settings on both):
- masking: the request reached the vendor masked once, but the remote
ran its masker again over the already-masked body (masking_ms on the
remote's usage row; with the local model on, a second model pass).
- routing: with the vendor answering 503, ONE agent request asked the
vendor 35 times over 174s. The remote ran its 7 tries (~33s) and
answered 503; the local magpie's same-one retries and patience then
asked the remote again, 5 times, each running all 7 again. The remote's
ledger got 6 calls for one request.
What changed:
- Retries: a failure the remote answered after its own routing (its
reply names its provider, X-Magpie-Provider, kept by keepRetry as
answeredThereHeader) is not retried on the same remote by passing()
(same-one retries, keptAgain) nor put in patience's next round
(routedThere). This magpie's other members are still asked; a remote
that can't be reached, or refuses before routing (its key, the key's
limit), is retried as before.
- Masking stays on the sending computer, on purpose: the values never
leave it (not on the wire, not in the remote's session records), and an
older remote still gets a masked request. After masking, serve and
countTokens note what they masked by (ownMaskedAs: this build's version
plus masking.Fingerprint, a hash of every setting that changes what is
masked, the local model and its threshold included, never the words),
and passOnCaller sends it as X-Magpie-Masked-As. The remote skips its
own pass only when the value equals its own, and passes it on to a
further magpie. Different settings or build, no header, a request not
a magpie's (magpieAsks) or a remote with a masked-request route
(RedactRouteTo) mask again: two sets of rules are both applied, on
purpose. The header is stripped on arrival (withCaller) and from every
vendor request. A client holding a key can send it only for its own
request, so it can only leave its own text unmasked.
- Usage is still recorded on both sides (each computer's ledger), by
design.
Run:
- mote-run go test -timeout 45m ./internal/gateway ./internal/masking:
ok (gateway 982s, masking 1.7s)
- new tests TestRemoteMagpieMasksOnce,
TestRemoteMagpieMasksWhatItIsNotToldWasMasked,
TestRemoteMagpieRoutedFailureNotAskedAgain, TestFingerprint
- broken by hand (maskedBefore always false, routedThere always false):
the three gateway tests went red ("masked 2 times", "masked again 1
times", "asked 15 times"), green restored
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
on ./internal/gateway ./internal/masking
- the two-instance run on mote, new binary: busy vendor asked 7 times in
33s (was 35 in 174s), remote ledger 1 failed call with tries 7 (was 6),
remote usage rows carry no masking_ms (was masked again), vendor still
got {{TERM_…}}/{{API_KEY_…}} placeholders and the agent its values back
Not tried: a remote on an older magpie (it masks again, as before, and
its 503 carries X-Magpie-Provider since remoteModelRest); the local model
masker on both sides with a real model; images/embeddings/video hops,
which still mask on both sides; GUI untouched.
|
||
|
|
65f93ac27d |
routing: a group's member may be pinned to one account, tried in the group's order (EastonXvii on X)
EastonXvii asked for a group like Codex/Astra on account A, then Astra on B, then Sol on C, tried strictly in that order, with the same model on two accounts as two members. Before this, Group.Accounts held the whole group to a set of accounts with no order among one provider's accounts, so the only way was one group per account. A member id may now end with the account: provider/model[:effort][:fast]#<account> (provider.MemberAccount, groupaccount.go). - Every list keyed by a member's spelling (rules, Fast, Off, Weights, Placed, EffortMaps, Pick) and membersFound's dedup key include it, so the same model on two accounts is two members. The vendor is still asked for the model's own id. A group saved before has no "#" and reads as it did. - SaveGroup stores the account's stable id (a typed name is resolved by ResolveAccount). It refuses an account on group/ and auto/ members, and a new account magpie doesn't have. One the stored group had already that is gone since stays, matching nothing. - Gateway: planLevel's keys() leaves the provider's other accounts out for such a member (memberHeld; Held rows with HeldOwn in the trace). Fallback goes to the next member, never to another account under the same member. count_tokens counts on the resolved member's account (heldByGroupAt). Images and videos: drawingTries keeps one try per member account, and each try runs on a request held to that account (memberOn). - Sharing and importing a group drop members' accounts. - GUI: Routing → edit a group → each model row has an account chip (openPicker menu): "Any account", each account, and "Also on another account…", which adds the model on a free account as a member of its own after the row. Strings in en, zh, zh-TW, ja, de. - CLI: models=relay/m#B,relay/m#A,other/m (by name or id); show prints "on <name> alone". TUI effort cycling keeps the account. Run (mote, at the pushed head after rebasing on |
||
|
|
ab084fdf25 |
gateway: a model's own system prompt, added after the agent's on every route (liucl on X)
liucl asked for a system prompt per model rather than per agent. A provider's editor now has a System prompt box in each model's Model settings row (Providers > a provider > Model settings). The gateway adds the text after the agent's own system prompt on every request for that model, whatever agent sends it. Empty, the default, sends the body byte for byte as before. It is only ever appended. Codex's base_instructions, Claude Code's identity block and any agent's prompt stay first and unchanged (withModelSystem in internal/gateway/model_system.go), in the agent's protocol, in serve's candidate loop after triedOn, so before translation and before a plugin's fetch: - Anthropic: string system + "\n\n" + text; a block array gets one more text block; none gets system. - Chat: the last leading system/developer message gets it after a blank line (or one more text part); none gets a system message first. - Responses: a developer message after the leading system/developer items, instructions untouched; a string input becomes that message plus the user's; none when previous_response_id is set (the turn it follows had it). - Gemini: systemInstruction / system_instruction gets one more part. count_tokens counts it (countOn). magpie's own asks (search and vision side calls, Codex titles, the router's classifier) get none. A fallback to another model gets that model's own, or none. Stored as settings.modelSystemPrompts["pid/model"] (SetModelSystemPrompt: trimmed, at most 64KB, no NUL, a model the provider serves), saved through modelPrefs[id].system; renames carry it (perModelFields). The Restore default title now says it takes the system prompt away too; the four tests that pin that title follow it. app.js stays in its budget with one comment cut, no raise. Run, on mote at this head: - TestModelSystem* (every wire format with exact bytes, empty unchanged, own asks skipped, messages/chat/responses/gemini/count_tokens routes, another model sent byte for byte as before, a plugin's model), TestProviderSaveModelPrefs, settings keep test. - Broken by hand, each red then restored: no call in serve, no call in countOn, prepend in Anthropic, empty not guarded, own asks included, any model of the provider; SetModelPrefs ignoring system; the GUI not staging it. - GUI: model-system-prompt.test.cjs (Chromium and WebKit, en zh zh-TW ja de, 1200 and 420px), model-limits, model-headers, provider-same-as, provider-detect, provider-listed-as, i18n-keys. - Real run: Claude Code 2.1.321 -p in a sandbox HOME and CLAUDE_CONFIG_DIR, through a sandbox `magpie serve` built from this tree, to a fake Anthropic upstream recording bodies. Its /v1/messages system had 3 blocks, Claude Code's own first, the prompt once, at the end of the last block; count_tokens sent "Be terse.\n\nAlways answer in Chinese." - gofmt; go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...: clean. - The full go test -timeout 45m ./... and the whole GUI suite were queued on mote at this head and run after the tag (the owner's ship-now rule); what they find goes in follow-up commits. Not tried: Codex or any agent other than Claude Code for real; a real vendor upstream; the Responses, chat and Gemini shapes only through the gateway tests' fake upstreams. |
||
|
|
91fb441843 |
antigravity: effort stays selectable in the app's own picker
YujunT46308 on X: "antigravity 接入 magpie 会导致模型的 effort 不可选".
Antigravity's picker (main.js served by its 2.29.0 language server)
offers effort only by grouping catalog entries named "<name> (Low)",
"(Medium)", "(High)", "(XHigh)", "(Max)" under one row with an effort
submenu, two levels or more. magpie's listSource catalog listed each
model once, so no model of magpie's had an effort control.
Now /v1/models?format=antigravity lists a model with two or more of
those levels once a level, "<id>:<level>" named "<name> (<Level>)".
The app sends the chosen entry's id, and the gateway's existing
":level" suffix handling sends that level upstream, ahead of the row's
pick and of the app's own reasoning_effort (low whatever was chosen,
in a 2.29.0 run). models.defaultModelId names one of those entries
(gateway.AntigravityModel: the row's effort fitted, else medium, else
the lowest), since an id the catalog doesn't list starts the app on
its first model; Sync moves a file written before onto a level. The
row's effort sets the start level and still applies to models with
fewer than two levels. The model field shows the id without the level.
Run:
- Real Antigravity 2.29.0 language server + its UI in Playwright
Chromium on mote, sandbox HOME, magpie built from this tree serving
a fake upstream listing g3 with low/medium/high: `magpie provider
add`, `magpie antigravity magpie/up/g3` wrote defaultModelId
"up/g3:medium"; the picker shows one "g3 · up" row with Low, Medium,
High (starts on Medium); picking High and sending "ping" reached the
upstream as model g3 with reasoning_effort "high" (the app's title
call went at medium, the start level). `magpie antigravity default`
left {} as before.
- go test -tags nogui ./internal/agent ./internal/gateway -run
Antigravity on mote; gofmt -l; go vet of both packages;
GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...
- Full suite on mote, go test -tags nogui -timeout 45m ./... at this
commit on origin/main
|
||
|
|
6fe754cb20 |
claude: Fable 5.2 on Vertex, Bedrock, Desktop's fable tier and Anthropic's fast mode
Anthropic launched Claude Fable 5.2 (claude-fable-5-2) on 11-09 (thelegendof2414 on X: not in magpie's list). Checked against Anthropic's "What's new in Fable 5.2" page, AWS's model card, models.dev and Claude Code 2.1.321's own bundle: - Claude subscription and Anthropic API: the list follows models.dev, which already has claude-fable-5-2 (8/40, cache read 0.2, write 10, 1M context, 128k out), so it shows once the catalog syncs (at most 24h). TestClaudeAccountListsFable52 holds that with the literal models.dev row: listed first, priced, 1M window, low to max efforts. - Vertex global and Bedrock presets list it (global.anthropic.claude-fable-5-2 is on AWS's card). - Claude Desktop's fable tier now behaves as claude-fable-5-2 (2.1.321's latest_per_family); Desktop's own catalog v4371 still ends at 5.1. - Fast mode on Anthropic's API key: Fable 5.2 has it ($16/$80; 2.1.321's fast-mode opt-in set is fable-5-2 and mythos-5-2). Fable 5.1 never had it and stays off. A Claude subscription account still gets no fast mode in magpie, as before. - Claude Code's effort: 2.1.321 reads the top-level effortLevel only for models up to Fable 5.1 and Mythos 5.1, so 5.2 goes in modelSettings, as Opus 5.5 does (claudeReadsTop unchanged, test added). - Gateway: adaptive-only thinking, no sampling, thinking off never sent, xhigh kept: the version rules already cover 5.2; tests now name it. Run at this tree (mote): gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok; go test -count=1 ./internal/agent ./internal/gateway ./internal/provider -run 'Fable|Claude|Fast|Vertex|Bedrock|Effort|Thinking|Xhigh|XHigh|Desktop|Sampling|Adaptive' ok (84s, 178s, 36s). Not run before the push: the full go test ./... (mote had six suites queued on suite.lock at load 420); it runs after, and a red is filed. Not tried: a real Fable 5.2 request through magpie; fast mode on a real API key. |
||
|
|
803d7747e7 |
gateway: an account rate limited till a time its vendor named is not asked again before it (hsjzg58958 on X)
hsjzg58958 on X: a vendor limited an account for 300 seconds, and magpie asked it again about every half a second as the agent retried, until the vendor flagged two accounts. Cause: a candidate resting on a 429 was still "tried all the same" when it was the last one left (restLast/probeOne), and the last one left was never rested at all, so every client retry went upstream. Codex on its own sign-in is relayed by codexUpstreamOn outside the candidate loop and had no hold at all. Fix: - timedHeld/vendorTimed (fallback.go): when every candidate left rests on a 429 whose time the vendor named (Retry-After, anthropic-ratelimit-*- reset, x-ratelimit-reset-*, resets_in_seconds/resets_at), none is asked; the agent gets 429 with Retry-After = when the first is back. A ChatGPT account out of its allowance is answered as the backend's usage_limit_reached with its x-codex-* windows (Rest.out/outHeader). - The last one left now rests too on such a 429 (vendorSaidWhen); a 429 naming no time rests nobody, as before. - codexHolds (codex_held.go): Codex's own relayed sign-in is held till the vendor's time; its retries are answered locally with the stored body, x-codex-* headers and Retry-After. Lifted by restarted() for quota holds. - Not held: LimitRestOff accounts (the user's setting), auto-reset weeks, rests "there" (answered by the vendor's own hold), Codex's API key. Run: - New TestRateLimitedKeysHeldUntilTheirReset (4 signals x 1 and 2 keys) and TestRateLimitedCodexAccountsHeldUntilTheirReset (3 refusals x 1 and 2 accounts): red at |
||
|
|
c6331b427c |
routing: a group bound to gateway keys is theirs alone (Xerxes754)
Xerxes754 on X asked to bind a routing group to one or two gateway
keys, so other keys neither see nor use it. Before this a key could only
be held to models from its own side (naming group/<id> in its Models);
a key with no limits reached every group, and nothing on a group could
keep it from one.
A group now has Keys (key ids). Set, only those keys, and keys issued
under one of them, may use it:
- groupBarred/groupGiven in key_models.go answer it for every route that
reaches a group: chat, responses, messages, count_tokens, embeddings,
images, video, the decider and the subagent and image MCP paths. Any
other key gets 403 "bound to other gateway keys", naming the group and
the Routing page, and nothing goes upstream.
- /v1/models and /v1/models/{id} leave it out for any other key, a key
held to models that names it included. provider.GroupsBound keeps an
unbound magpie's list as before.
- A keyless request from this computer uses it, as key limits never
hold one; callerGuard now names a loopback request's key when it
sends one, so a key used locally is held too.
- SaveGroup keeps the stored keys when a save doesn't name them (the
CLI, the TUI, the card toggles); an empty list clears them. Ids are
trimmed, deduped and capped. Sharing a group leaves its keys out;
importing over one keeps them.
- GUI: Routing, a group's Edit, row "Gateway keys" (网关密钥) with a
button "Any gateway key" (任意网关密钥) that opens the app menu of the
user's keys (multi-pick); a bound key since deleted shows "key
deleted" (密钥已删除). The row shows once there is a key to bind.
/api/groups lists gatewayKeys (no browser, read-only or issued keys).
zh, zh-TW, ja, de strings.
- Not covered: a bound group nested in another group is reached through
the outer one (documented in gateway-routing.md).
Run (mote unless said), at this head rebased on
|
||
|
|
fdd38154b8 |
docs: the Usage, Video generation and sign-in links to their settings
gui-shell.md, gateway-routing.md and providers-accounts.md name the links 22c665d6f, |
||
|
|
88b541a25c |
images: every pointer names Settings › Models › Images, where the page is
The image models moved under Settings › Models, but the Library's Magpie
Image sheet, the MCP server's instructions to agents, the gateway's
"no image model" errors, the video tool's text and the docs still sent
users to "Settings › Images", a tab that no longer exists (the scattered
settings audit after netube99 on X). Every user-facing string now names
Settings › Models › Images in en, zh, zh-TW, ja and de, as do the site's
Qwen docs (en, zh, ja), llms-full.txt, the subsystem pages and comments.
Run in the tree with this change and the rest of the audit's fixes
(mote, base
|
||
|
|
40cbdaa7e8 |
provider: an account's window can be capped at a fixed amount of its unit
A window magpie reads with a total and a unit (a day's 1000 credits, a
plan's requests) can now be capped at an amount of that unit, not only
a share: 9won_25273 asked to stop an account at 300 of its day's credits.
- AccountWindowAmounts keeps it per account and window (capId). An
amount and a window's own share replace each other.
- WindowCaps.limitShare turns it into a share of the total for the mark
and NearCap. CapHeld and capReached hold the account once the window's
count reaches the amount (past), and rest it as the percentage cap
does: the next account takes the request. cappedError and the trace
say "has used 300 credits ... past its cap of 300".
- A reading with no total ignores the amount; the account's share
applies.
- GUI: the window meter's menu has one more item, Amount..., typed in
place (provider/windowcap with amount). It shows only on a window
with a unit and total. Strings in zh, zh-TW, ja, de.
- CLI: magpie provider account-cap <id> <account> --window <name>
--amount <n|off>.
Usage outside magpie counts: every cap reads the vendor's own count, so
what the account spent in the vendor's app or on another machine counts
from the next reading on. magpie can only hold back its own requests.
Run, at this head on Linux (wsl-run, magpie-desktop):
- gofmt -l: clean; go vet ./... for linux (-tags nogui) and windows: ok (darwin
vet needs cgo, so it runs with the full suite on mote afterwards)
- go test -run 'Lang|ToolLoop|LoopGuard|Cap|Amount' ./internal/gateway
./internal/provider ./internal/cli: ok (TestWindowAmountCapHeld,
TestSetWindowAmount, TestWindowAmountHoldsTheAccount, the CLI cases)
- GUI window-cap, window-cap-pool, account-cap in chromium and webkit,
420 and 1100 wide, en zh zh-TW ja de: 78 of 78 in each engine. An
earlier webkit run lost the amount test's page once ("Target page,
context or browser has been closed"); it passed in 2 more full-file
runs and 60 of 60 alone
- i18n-keys: only "a plugin's words are its own" red, words that aren't
this change's (#5332, #5426, #5482)
Broken by hand: limitShare ignoring amounts (of < 0): TestWindowAmountCapHeld
and TestWindowAmountHoldsTheAccount go red.
Not tried: the full go test ./... at this head (queued on mote, runs
after); a real account at an amount cap.
iFlytek: 9won's 讯飞 overshoot isn't covered. Loomy's daily window sends
used as a count and amount as what is left (plugins#889); AStudio's
wallets tell a balance only, which no cap can hold (#5770).
Reported-by: 9won_25273 (Discord)
|
||
|
|
3245b730d2 |
gateway: the tool-loop notice is written in the conversation's language
When magpie stops a conversation going round one tool call, the notice the agent shows was English only and began "magpie stopped this turn". A conversation in Chinese got an English notice. The notice goes upstream with the next turn, so it now names neither magpie nor a vendor's limits. conversationLang (reply_lang.go) reads the user's own words in the whole body. It skips tool results, system prompts and whole <tag> blocks, and decides by script: kana -> ja, Hangul -> ko, Han -> zh or zh-TW (by simplified/traditional-only characters), Latin with German marks -> de, otherwise en. toolLoop.notice(lang) picks the matching text; the setting is named as the GUI names it in that language (Korean, which the GUI lacks, names it in English). Run, at this head on Linux (wsl-run, magpie-desktop): - gofmt -l: clean; go vet ./... for linux (-tags nogui) and windows: ok (darwin vet needs cgo, so it runs with the full suite on mote afterwards) - go test -run 'Lang|ToolLoop|LoopGuard|Cap|Amount' ./internal/gateway ./internal/provider ./internal/cli: ok (TestLangOfEachLanguage, TestConversationLangReadsTheUsersWords: each language, mixed, empty; TestToolLoopNoticeInTheConversationsLanguage) Broken by hand: counting kana as Han in langOf; all three tests go red. Not tried: the full go test ./... at this head (queued on mote, runs after), a real agent looping in Chinese. The reply loop guard's notice (loop_guard.go) is still English and names magpie: #5764. Reported-by: tenacious_eagle_96548 (Discord) |
||
|
|
0024660445 |
gateway: a key's slot is taken before an account's turn near its cap
ox0pine on X: a gateway key held to one provider sometimes hung "in
routing". With the key's MaxConcurrency set and its account within 5
points of a usage cap, two turns could each wait for what the other
held:
- Turn B took the account's near-cap turn, then the key's slot (kept for
the whole request, key_slots.go), and got a passing failure (503).
- B slept and went back to the same account (i--). At the top of the
loop it gave the near-cap turn back.
- Turn A, waiting for that turn, took it and waited in keySlot for the
key's slot, which B held.
- B found the turn taken, was the last candidate and waited in
nearCap.take, which A held. Neither could move until its agent hung up.
Neither had a try that could start, so the GUI showed "routing…".
serve now takes the key's slot before the near-cap turn, so locks are
always taken key, near-cap turn, lane. The wait still counts in the try's
Queued (nearInKey). Eager routes already took the slot before serve.
forward and codexUpstreamOn take it in their handlers and never take a
near-cap turn.
TestKeySlotAndNearCapTurnNeverWaitOnEachOther: one Codex account at 89%
with a 90% cap, a key held to codex/* at MaxConcurrency 1. The first
try gets a 503, and a second turn is sent while the first is paused.
Run on mote (mote-run):
- the new test on the old serve: red 5 of 5 (both clients time out at
8s). Green after, and green without the key's cap on the old code.
- -run 'NearCap|Key|Cap' -count=2: ok.
- go vet ./internal/gateway for darwin, GOOS=linux and GOOS=windows;
gofmt -l clean.
- rebased on origin/main
|
||
|
|
2b22425b45 |
agent: Claude Science in a WSL distro is found and run on magpie from Windows
shuitunlulu_ (Discord) has Claude Science in WSL2, and Windows magpie didn't find it. It is now a WSL twin (claude-science@wsl:<distro>), found by the probe's claude-science (~/.local/bin or PATH). Its daemon is restarted there through wsl.exe with ANTHROPIC_BASE_URL set, the same steps as this machine's (claudescience.go is now one scienceHost for here and for each distro), and v0.1.3334's keeper puts it back on magpie in each running distro that has a note (claude-science-wsl-<distro>.json). With no note, nothing runs in WSL. The daemon takes http only to a loopback address and sends its Claude sign-in as the key. In mirrored networking it gets the gateway's address. Under NAT magpie starts a relay in the distro: socat on 127.0.0.1:<gateway port> to Windows' WSL address. The daemon gets http://127.0.0.1:<port>/<WSL key>; the gateway's lanGuard takes the key off the path (takeWSLPathKey) before fromWSL judges it. Connect says so when the distro has no socat. Disconnect stops the relay with the connections it forked, as one process group. When Windows' firewall keeps WSL out, the row shows the same firewall drift and rule as other WSL agents. Run: - gofmt -l clean - go vet: darwin, GOOS=linux -tags nogui, GOOS=windows (mote) - go test ./internal/agent ./internal/gateway on mote (macOS) - go test ./internal/agent on xiaomi-gpu (Windows 11): 26 FAIL; 25 fail the same at origin/main |
||
|
|
a6a99717e0 |
gateway: thinking with no signature never goes to Claude
citricdu (Discord, 0.1.3356): Claude Code auto-compacted a session on a
Smart group that had moved to Cursor's Grok 4.7, then the group went
back to Kiro's Claude Opus 5.5. The compacted history kept a thinking
block Grok made, which magpie hands a Messages client signed "", and
Kiro answered 13 times in a row with a bare invalid_request_error. The
same request without the block was answered.
withoutForeignThinking dropped only DeepSeek's UUID-signed blocks and
kept an empty signature on purpose ("a block with no signature Claude
takes"), and Kiro's refusal names nothing boundRefusal reads, so
refuseBoundThinking never mended it. Now every thinking block whose
signature is empty, blank or missing is left out for an upstream
serving Claude (api.anthropic.com, or a claude- model: relays, Bedrock
and Vertex ids, a plugin's fetch such as Kiro's), on every route
forwardOnce takes (relayed, translated, plugin, count_tokens), and
refuseBoundThinking runs it too. Text, tool_use and tool_result stay;
Claude's own signed thinking and redacted_thinking are untouched. A
model that learned thinkingBackNeeded (DeepSeek under another name)
keeps its unsigned blocks. Chat and Responses translated into Messages
already dropped unsigned thinking in anthropicBody.
Tests: TestUnsignedThinkingNotSentToClaude builds the reporter's shape
(the compaction summary, then two tool turns opening with Grok's
thinking signed "") against a fake Kiro that gives the same bare 400,
relayed and through the fake plugin's fetch (FAKE_KIRO model added).
TestGrokThinkingThenClaude runs the switch itself: a group answered by
a Chat Grok, then moved to Claude mid tool loop.
TestWithoutForeignThinking adds an unsigned block, Bedrock and Vertex
ids, a missing and a blank signature.
Run (mote, at this head rebased on
|
||
|
|
93bbcc8bfb |
gateway: a Responses conversation another resource made goes whole, without its item ids
hykql (Discord) uses Azure OpenAI behind a relay that spreads one key over several resources. A turn after the first was answered by another resource, which turned it away: "The requested item was created under a different Azure OpenAI resource. Use the same resource that created the item to access it." prevRefused only knew "previous_response", so the 400 reached the client, and sending the conversation whole would not have helped: the items magpie brings back still carry the first resource's ids. - prevForeign knows that refusal. A request whose conversation magpie holds is asked once more, whole, with the ids of the items magpie brought back taken out (prevElsewhere): an item that may go without its id (idOptional) loses it, reasoning stays only with its encrypted_content, the client's own new input is as sent. Nothing is asked again when magpie doesn't hold the conversation, or when the body would be the same, so an unknown previous_response_id is still relayed as sent and its refusal passed on. - A kept turn remembers the provider and key whose reply it is (made). Going on with another one, those ids are left out at once: it never made them. The same provider and key gets them as before. - No setting and no GUI. This is the part of hykql's branches (feat/responses-state-client-profile, feat/provider-editor-responses- state) the review kept; their retry stripped previous_response_id from a delta magpie doesn't hold (a 200 with the history gone), and their client profiles included Claude Code's User-Agent. Neither is taken. Run on mote (lockf ~/suite.lock mote-run), at |
||
|
|
608c1543e8 |
gateway: a bare model name goes to the asking agent's own subscription first
freefcw on X: Codex, started by Mirasim, asked for gpt-6-astra by its bare
name. Its own ChatGPT subscription serves it, but magpie sent it to Devin
through the group it found (auto-gpt-6-astra, soonest renewal first).
With found groups off it still went to another vendor: Resolve takes the
first provider in the Providers order, AutoStandIn and agent.Reseat did
the same.
Now:
- A bare model id the asking agent's own subscription in magpie serves (a
provider whose Account.Agent is the agent: Codex's ChatGPT accounts,
Claude's for Claude Code, Copilot's) goes there, found groups on or off
(gateway ownFirst, provider.OwnRoute). count_tokens counts it there too.
- Kept as they were: a group the user made or changed by that name; a found
group magpie set one of the agent's fields to (agent.SetToGroup over the
applied record, #750's bare spelling included, wired as
gateway.SetToGroup); a gateway key held to some models; ids with a
provider in them and group refs; clients magpie doesn't know as an agent.
- Found groups off: a bare id several providers serve, none of them the
agent's own, is refused for an agent that has a subscription of its own
in magpie, with a 400 naming the provider/model ids and
"magpie group auto on" (provider.OffSpread). Off, magpie picks no vendor.
- AutoStandInFor and Reseat's sameModel prefer the agent's own
subscription for a found group that is gone.
Docs: gateway-routing.md's Model resolution row and the bare-ids section.
Run (mote, at this tree on
|
||
|
|
c7ebb6f8d9 |
settings: Video generation picks the model Magpie Image makes videos with
The same Discord (#feedback) user: a custom provider's video model still couldn't be chosen. A custom provider's video model was already found (seedance, kling, veo, wan, hailuo ids by name, or marked by hand with right-click › Makes › Video model, #1399), but generate_video always used AutoVideomaker's pick, the first video model of the first provider, with nowhere to choose another, as Settings › Images does for images. settings.VideoGen (provider/model or a routing group) is now the model a request that names none makes its video with, while it resolves; else AutoVideomaker's, as before. Image generation turned off turns video off with it, as before. Settings › Models › Images gets a Video generation row under Image generation: Automatic (naming the automatic pick) and every model Magpie Image can make videos with. A pick that no longer makes videos (provider gone or off, model unmarked) says so and the automatic one is used in its place; the settings API refuses a model that makes none, and keeps the pick when a save doesn't send it. The row is drawn by videogen.js, imported when Settings draws Image generation, with one call in app.js: drawn in app.js it put the core scripts 616 bytes over TestCoreScriptBudget (1,534,418 > 1,533,802, found by the first full run), and the budget is not raised. Run on mote: - At this change on |
||
|
|
c630d9a29c |
gateway: the key page's Claude Code setup keeps each tier on its own family
The /me page's Claude Code tab wrote the picked model into
ANTHROPIC_MODEL and into ANTHROPIC_DEFAULT_OPUS_MODEL, _SONNET_ and
_HAIKU_ alike, so picking Opus sent every Haiku background call to Opus
too (and picking a GPT model made "haiku" a GPT model).
The pick now sets only ANTHROPIC_MODEL. /v1/magpie/me returns `tiers`,
built by keyPageTiers from the models this key may use: for opus,
sonnet and haiku, the newest model of that family (claudeTier and
claudeVersionOf; routing groups and fable are skipped). A tier the key
has no model for is left out of the snippet, so Claude Code keeps its
own default for it.
Siblings: the agent writer (internal/agent/claude.go) has its own tier
design (tiers follow the main model, haiku to the provider's Haiku, the
user's own tiers kept) and writes the user's real config; it is a
different situation and is left as is. OpenMausBot's snippet writes
only ANTHROPIC_MODEL.
Run (mote, via suite.lock):
- go test -count=1 -run KeyPage ./internal/gateway/: ok
- GUI key-page.test.cjs: chromium 13/13, webkit 13/13
- gofmt -l: clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./..., and go build for darwin, linux (nogui) and
windows: ok
Broken by hand:
- old keypage.html: the new GUI test is red in both engines
(ANTHROPIC_DEFAULT_HAIKU_MODEL 'claude/claude-opus-5', want
'claude/claude-haiku-4-5')
- keyInfo without keyPageTiers: TestKeyPageTiersAreTheirFamilys red
("tiers map[]")
Full suite (go test -tags nogui -timeout 45m ./...): queued behind
other sessions on suite.lock at push time; its result goes on the
follow-up, with an issue for any red.
Not tried: a real Claude Code against the page's snippet, and the
gateway binary in a sandbox HOME.
Reported-by: strinah (Discord)
|
||
|
|
c81065ca72 |
providers: System One for a custom provider and Ark's pay as you go
A user on Discord (#feedback) found no System One endpoint under a custom provider's More endpoints (OpenAI Responses), no System One choice in its Model settings, and on the Volcengine Ark page neither an endpoint nor any model a routing group could ask as its classifier. System One is asked at POST …/systemone under a provider's Decide base; a model is offered as a group's classifier only when its provider has one. Two causes: - A custom provider kept a Decide URL only when its API was "System One base URL". With a Responses or chat URL there was no field for it, and Save sent "" for one the provider didn't have yet. More endpoints now has "System One URL" for any API, saved as typed. - Ark's pay as you go answers System One on the same key at ark.<region>.volces.com/api/v1, but a provider asked at …/api/v3 (the preset's or a custom one, chat completions or Responses) had no Decide unless the user knew to type it. normalize now sets it (arkSystemOne); a URL the user gave is kept. The Coding and Agent Plans answer System One 404, so they get none, and decideKeys leaves out a key whose plan has none (a Coding Plan key beside a pay-as-you-go one). Ark's one decision model is offered whatever chat models are picked, as Bailian's is (OfferedDeciders). Run on mote at this head's tree (65aacb8f8, on |