ac4af582301a4e8a29245dbba767eba31334ddf9
792
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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 |
||
|
|
e0f6eda641 |
gateway: a probe's reply that thinks its 16 tokens and ends unsaid is answered (plugins#827)
Through a Remote magpie, the plain model test of Open Design's
glm-5.3-flash was red. The model always thinks. It spent the test's 16
tokens on that and ended after content_block_stop, with no message_delta
or message_stop. So:
- translate made it a 502 "ended before it was complete";
- the 502 is busy, so the remote retried it and waited out its 60s
patience;
- the asking magpie had given the remote only 20s (testWait), and said
no answer came.
Each step is now fixed for the class, not for this model:
- A reply whose request was capped at a short probe's worth
(cutVoidTokens, 1024) and that spent some of it, then ended cleanly
with nothing saying it ended, ended at its length (endsAtProbeCap).
- This holds in translate, in streamTranslated and in gathered (a
Responses plugin's stream asked whole becomes response.incomplete at
max_output_tokens).
- It covers Anthropic and Responses upstreams only. Gemini always
ends with a finishReason, so a Gemini stream without one stays a cut
(TestGeminiUpstreamEndedShort, asked for 256, caught a wider first
draft).
- A reply asked for more than 1024, or one that spent nothing, is
still the 502.
- A client may say how long it waits (provider.WaitHeader,
X-Magpie-Wait, in seconds). The gateway then takes no same-one retry
pause and no patience round that would end within clientRoom (10s) of
that wait (keptAlive.outlives), so the client gets the error while it
still waits. Like every X-Magpie- header, it is not sent upstream.
- A model test through a remote magpie waits pluginTestWait (60s), as a
plugin's test does here, and sends that wait as X-Magpie-Wait.
Not changed: a stream relayed as it came (passthrough to an agent of the
same protocol) still gets no end added. That is filed as #5736 and named
in gateway-routing.md.
Run, through mote-run:
- At the pushed tree, rebased on origin/main
|
||
|
|
b68218f43e |
gateway: a Responses reply to a client that isn't Codex carries only the Responses enum's events (#4482)
Grok Build, reading /v1/responses through async-openai's typed ResponseStreamEvent, lost whole turns on a ChatGPT account: the backend speaks part of the Codex protocol (codex.rate_limits, codex.response.metadata, response.metadata, a keepalive event), and the client read each as `unknown variant` and ended the turn. passthrough now runs responsesEnumTidy (responses_enum.go) last in its chain for a Responses stream to a client that isn't Codex (the fromCodex / agentOf pair codex_own_v1.go uses): every event whose `event:` name, or data `type` where it names none, is outside the OpenAI Responses enum is dropped; a keepalive goes on as an SSE comment so a quiet upstream still keeps the client's idle timer alive. sniff and codexLimitsTap read the upstream bytes before it, so failover and the account's windows are unchanged. Codex itself gets every event as it came. A plugin's Responses reply goes through the same passthrough, so it is covered too. The WebSocket route's synthesized header frames (socketTurnWriter.headerFrames) go to Codex alone too. The response.failed shape from the report (missing created_at / sequence_number) was already fixed on main by |
||
|
|
44d6dd75d1 |
gateway: a subscription's capped or spent turn goes on to the user's group with it in
adorable_piglet on Discord (v0.1.3354): a Codex subscription with a usage
cap set in magpie, first in a routing group with two APIs after it. Past
the cap the Codex app's turns were answered 429 "usage cap reached" and
never reached the APIs; only switching the subscription off in Providers
moved them.
Cause: the Codex app signed in to ChatGPT asks Codex's own model
("gpt-5.5"), never "group/<id>". With a cap on the account,
codexAccounts routes the turn as codex/gpt-5.5, and serve plans the
codex provider and its own Fallback list only. A group that merely has
codex/gpt-5.5 in it was never planned, so with every account held the
answer was cappedError's 429. A request for the group itself was already
routed on past the cap (TestCappedSubscriptionGivesWayInGroup, green on
the old code too). The same gap was on Codex's own sign-in out of its
allowance at OpenAI: codexFallsBack counted the subscription's Fallback
only, so the backend's usage_limit_reached reached Codex.
Fix:
- provider.GroupsAfter(id): the routing groups the user built that have
the model in them and another member to go on to, in the user's order;
auto groups, hidden or switched-off ones are none.
- serve: when every account is held at its cap (pl.capped, no candidate
left, CapStop off), or for a turn codexFallBack handed on, the provider
is planned again with those groups after its own fallbacks
(groupsAfter), each group routed as a request to it is. One place, so
it holds on every protocol (chat, responses, messages, Codex's backend
path), streaming or not, and for plugin-served subscriptions.
- codexFallsBack counts those groups as fallbacks too.
- Stop at the caps (CapStop) still answers 429 (planPaused returns
before any fallback, the groups included).
Tests:
- TestCappedCodexOwnModelGoesToItsGroup: backend path with "gpt-5.5" and
/v1/responses with "codex/gpt-5.5", stream and not; red on origin/main
|
||
|
|
82ca554be9 |
routing: a provider's accounts routed In order give a conversation back to the first
CryptoSarom on X: with a provider's accounts set to In order, a
conversation that had moved to the second account (the first was
resting) stayed on the second once the first was ready again. Only a
group's members went back to the first; a provider's own accounts never
did, because inOrder was read from the group's routing alone.
- gateway.go: inOrder comes from the provider's routing, or the group's
when the request is to a group.
- affinity.go: backToFirst compares accounts (who()) for a provider's
own accounts. For a provider it overrides only a cache that would have
kept the conversation (cacheHolds: worth keeping and still warm), so a
cold or empty cache keeps its own "cold"/"new" label.
- plugin_factory_cap_test.go: "auto, cached on B" pinned the old
stay-on-B behaviour; it now expects A, the first account, on purpose.
- GUI: the Routing affinity line for "order" without a group says the
provider goes in order and the first is ready again (all languages).
- docs/subsystems/gateway-routing.md: the In order bullet covers a
provider's own accounts.
Run on mote at this tree on aa3d11d5b; rebased onto
|
||
|
|
c6bdc172a0 |
netguard: a fake-IP resolver's own AAAA beside its fake A is left out, not refused
jiezhengj (Discord, 11-08): under Clash Verge Rev's TUN (mihomo
1.19.33, enhanced-mode fake-ip, fake-ip-range 198.18.0.1/16) every
web_fetch of `magpie mcp search` answered "it is at a private address".
#2593 already lets a name whose every answer is in 198.18.0.0/15 through,
so that wasn't it. Clash Verge Rev writes dns.ipv6: true and
fake-ip-range6: fdfe:dcba:9876::1/64 into its default config (and fills
in 2001:2::/64 when IPv6 is on without one), and mihomo then answers
AAAA from that pool too (dns/middleware.go withFakeIP, read at
v1.19.33). The resolver's answer was 198.18.x.y beside fdfe:dcba:9876::z,
the ULA is private, a fake answer beside a private one is refused, so
every name failed.
netguard.FakePaired names that AAAA: an IPv6 address in fc00::/7 or
2001:2::/48 while the same answer holds an IPv4 one in 198.18.0.0/15.
It is dropped where Loon's paired AAAA is dropped (dropLoon in the
gateway's publicTransport, iconIPs for a provider's icon, the two
places that share netguard), and the fake A is judged and pinned in its
place. 2001:2::/48 (RFC 5180 benchmarking) joins Public's special ranges;
it wasn't covered by 2001::/32 and passed as public.
Why this opens nothing new: the AAAA is never dialled. What is dialled
is the fake A, exactly as when the resolver answered the A alone, which
#2593 already allows: an address in 198.18.0.0/15, which no host on a
normal network uses, so without a TUN it goes to the default route and
reaches the internet or nothing. A hostile DNS that pairs 198.18.0.9
with fd00::<a LAN host> gets the 198.18 address dialled, never the LAN
one. Through a proxy on this computer the proxy gets the name, as for a
pure fake answer; a hostile resolver could already give a proxy another
answer for that name than it gave magpie, so the pairing adds no route.
What stays refused (tests below): a ULA or 2001:2:: alone or beside a
real A, a fake pair beside 10.0.0.1 or ::1, a fake A beside a public
address, and ULA / 2001:2:: / 198.18 address literals.
Ran (on mote; whole packages at base
|
||
|
|
7a56c83e72 |
gateway: a compaction Copilot sealed stays out of Codex's auto-review
echo_ts (Discord #feedback) runs Codex Desktop's turns on GitHub Copilot
through magpie, with Copilot's native compaction on, and Codex's
auto-review on its built-in codex-auto-review through the ChatGPT
sign-in. The guardian's review carries the conversation's history, so
after the first compaction it carried Copilot's sealed compaction item
too. A request for one of Codex's own models with no magpie Codex
account to route it is relayed to the sign-in as it came, and
codexInputAs keeps any non-magpie1: compaction ("OpenAI's own, for
OpenAI"), so OpenAI was sent Copilot's ciphertext and refused every
review: 400 invalid_encrypted_content "The encrypted content P4ih...bDU
could not be verified". After the next compaction, the new ciphertext.
The siblings: a side call routed through magpie (the auto-review set to
a magpie model, a subagent or a title on another provider's model)
met checkpointReaders, found no writer among its candidates and was
refused with checkpointError, so the review failed there too. A turn or
a /responses/compact on one of Codex's own models relayed to the sign-in
sent the seal to OpenAI to be refused (sealedCompact took a Copilot
writer for the sign-in's own and relayed it).
Now:
- compactionAside names the calls Codex makes beside the conversation
with its history in them: the guardian (or anything asked on
codex-auto-review), memory, subagent, title, description, thread
summary, prediction and suggestion. In serve, when the writer of the
sealed compaction isn't among such a call's candidates, it goes on
without the compaction item (withoutCompaction, body and plain);
instructions, developer/user messages, the turns since and their tool
calls and outputs stay. The conversation's own turns are still held
to the writer or refused saying why (#1099), unchanged.
- foreignToSignin: on the relay to Codex's own sign-in (codexBackend), a
compaction magpie recorded as sealed by a provider other than the
Codex subscription is never relayed. A side call goes without it; a
turn or a /responses/compact is answered checkpointError, magpie's
own explanation, with nothing sent to OpenAI. A seal with no record
(OpenAI's own, compacted on the sign-in), one the codex provider
sealed, and one whose provider can't be read are left as before.
No portable plaintext summary exists for a native compaction (only the
writer can read it), so the side call goes without it rather than with
a summary.
Run (on mote, through mote-run, at
|
||
|
|
9bef67d420 |
gateway: Claude Code's and Codex's requests reach a Remote magpie as magpie's, so it takes X-Magpie-*
linkaww (Discord #feedback, Mac v0.1.3315 to a Docker remote v0.1.3288): a capture showed X-Magpie-Claude-Cache-TTL reaching the remote on a request whose User-Agent was claude-cli/2.1.319, not magpie/. The remote takes X-Magpie-* only from a magpie's request (magpieAsks), so it dropped the cache lifetime (Opus still 5m, Haiku 1h), the agent, the computer (X-Magpie-Via), X-Magpie-User-Agent, and X-Magpie-Hops, the guard that answers 508 when two magpies are each other's remote. Cause: forwardOnce sets magpie's User-Agent for a Remote magpie (userAgentFor, OwnClient), then #179's copy of Claude Code's headers (p.Account == nil) put claude-cli/... back over it. Codex had the same hole: its copy (codexClientHeader) puts codex_cli_rs/... on too, which keepTurnAsks had already worked around. Fix, on the sending side: after every copy, a request to a Remote magpie goes with magpie/<Version> (forwardOnce). Decision, retrieval, image and video requests already set it at their call sites and copy no client header. On the receiving side, so a relay behind the remote that serves only Claude Code or Codex still gets their headers: the remote knows Claude Code by the User-Agent the near magpie named (claudeCodeAsks, agentUA) for #179's copy, ?beta=true, the test-as record and Desktop's move, and both copies put on the agent's User-Agent (agentUA), not the magpie/ one that came in. Codex is known there by its originator, as before. A key+URL provider that is not a magpie still gets Claude Code's and Codex's own User-Agent (TestClaudeCodeHeadersReachAnthropicRelay, TestRemoteMagpieClientHeaders). The reporter's guess that this empties the remote's Usage > Sessions is not borne out: with the bug the remote still recorded each call's session id (x-claude-code-session-id was copied), only under agent "claude-cli" with no via. Filed separately. Run (on mote, mote-run, at this tree): - TestRemoteMagpieTakesClientsHeaders (new): Claude Code and Codex through two in-process gateways to a relay. The remote is asked as magpie/, with X-Magpie-User-Agent; callerFrom on what it got reads agent, via, hops 1, the relayed UA and the TTL 5m picked in settings.json; the relay gets the agent's UA, originator, x-app and ?beta=true and no X-Magpie-*; the remote's record names the agent and a via. Red on the old gateway.go: UA claude-cli/codex_cli_rs at the remote, agent "claude-cli", via "", hops 0, ttl "". - go test -tags nogui ./internal/gateway -run 'Remote|ClaudeCode|Codex.*Header|UserAgent|ClaudeCacheTTL|Desktop|SawClient|TestAs|Hops|Loop': ok. - gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway: clean. Broken by hand: - the magpie UA reset taken out: the new test red in both subtests (remote sent claude-cli/codex UA, nothing taken). - the remote-side detection put back to fromClaudeCode(in) and the copies' UA left as it came: the new test red (x-app and ?beta=true lost, relay sent magpie/dev) and TestRemoteMagpieClientHeaders' three Codex cases red 403. Not tried: a real Docker remote or a real Claude Code; the full suite was not run at push (run after). The remote must update too for its relays to send them as the agent: an older remote, asked as magpie/, copies no Claude Code x-app, X-Stainless-* or ?beta=true to its relay, and puts magpie/ over Codex's User-Agent there (it is known by its originator), so a relay behind it that serves only Claude Code or Codex refuses until it updates. The TTL, agent, via and hops need only this (sending) side. Reported-by: linkaww |
||
|
|
e215d335a6 |
gateway: a gateway key can cap its requests at once; the rest wait their turn
young02036 on Discord: a provider can be given a concurrency, so why
can't a gateway key? A key now has an optional MaxConcurrency, from 1
to 1000. Left unset (every key today), nothing changes.
- access: Key and Change get MaxConcurrency, and Identity carries it, the
issuer's cap included. The concurrency-key action refuses a value
below 0 or above 1000.
- gateway (key_slots.go): every route that asks a model is held to the
key's cap, however the request came (loopback, LAN, a Remote magpie, a
Responses socket's turn). One request too many waits in the key's
queue in arrival order. It shows as "slot" in Active, and its wait goes
into the try's Queued. A request whose agent goes away while it waits
leaves the queue and sends nothing. A stream holds its slot until it
ends. serve's routes (chat, responses, messages, ollama, gemini, the
Codex backend) wait inside the try, after keepQueued, so a streaming
agent gets keepalives while it waits. The other model routes (images,
embeddings, rerank, audio, videos, search, decisions, native) wait
before their handler runs. forward and codexUpstreamOn take the slot
too, so nothing reaches a vendor without one. A key issued under
another waits for its own slot, then for its issuer's.
/v1/magpie/concurrency lists each capped key under "keys", and counts
its waiters in "waiting". A key's limit (key_limit) reports the cap.
Not held, as a provider's MaxConcurrency doesn't hold them: GET,
HEAD, OPTIONS, count_tokens, :countTokens and MCP.
TestKeySlotEveryRoute fails when a route is judged neither held nor
free.
- cli: magpie gateway-key concurrency <id> [<n>|off]. It refuses 0, a
negative, over 1000, a fraction, a word, --help or an extra argument
with its usage.
- gui: the key row gets a badge in the provider concurrency badge's
style. It opens the app's menu with No limit, 1/2/3/5/10 and Other…,
and Other… takes a number typed in place. A value that isn't a whole
number up to 1000 is refused and nothing is sent. Browser and
read-only keys have no badge. Strings are in en, zh, zh-TW, ja and
de. An unset badge, which a hover shows, gives way before the masked
key (flex-shrink 8). Without that, at 420px in en and de, the extra
badge squeezed the key until its copy button slid under the pointer
that came to drag the row, and gateway-key-arrange went red.
- docs/subsystems/gateway-routing.md describes it.
Run (on mote, at this tree on origin/main 0f8c3d867; rebased onto
|
||
|
|
1aabc66fd1 |
gateway: /v1/models answers its ETag, and 304 to a client that has the list already
clyzhicore (Discord) runs a server magpie as the gateway and a local magpie that takes its /v1/models and writes the models into dsh. They asked for an ETag or a list you can wait on, so the local side knows a change at once and a dead connection costs little. The wait is there since |
||
|
|
eef99e4bbe |
redact: a value on both Masked words and Never mask is masked; Never mask still beats the user's rules
TakaNaShi_ShiKi on X asked for a way to keep a value from being masked.
That exists already: Settings › Privacy › When a value is found ›
Never mask (RedactAllow, Options.Allow, since
|
||
|
|
2d90c7c565 |
redact: a hex number (0x and up to 16 hex digits) goes as written, whatever the local model takes it for
TakaNaShi_ShiKi on X: in reverse-engineering notes, an address written
as inline code, `0x004EA5E0`, went to the vendor as {{SECRET_6kkmmxxd}},
and the vendor's model lost the data it was asked about.
Which finder took it: no rule. With Secrets and Personal on and every
kind on, the rules alone mask none of the values in the new test (the
"by the rules" checks in TestHexNumberGoesAsWritten). The local model
did. Asked for real (Privacy Filter and AstrLink Guard from this Mac's
cache, copied to mote, MAGPIE_EVAL_CACHE), on a notes table:
Privacy Filter: secret 0.679 on 0x0058C210 (beside "密钥表")
AstrLink Guard: secret 0.625 on the same
Privacy Filter, "The license check is at `0x004EA5E0`; the key table
at `0x0058C210`.": account_number 1.000 and 0.995 on both
Privacy Filter, "key: 0x004EA5E0": secret 0.992
modelFits let them through: hexRe, which holds back a bare hex run
unless a key's name is right before it, asks lower case and no 0x, and
numberLike reads 0x004EA5E0 as a number, so ACCOUNT took it too. That
is the sibling, with the real model's evidence; PHONE did not take one
in the fake-model test, and decimal numbers already have their own
checks (numberNamedSecret), so nothing wider is changed.
Now modelTakes takes no value of any kind that is 0x or 0X and 1 to
16 hex digits (hexLiteral, a 64-bit value: an address, a constant, a
flag). No cue is asked, unlike a bare hex run: the function at an
address is often named for a key (DecryptKey: 0x004EA5E0), and
secretCued would read that as "key:". A longer 0x value (a 64-digit
private key, a 128-bit 0x+32) is masked as before.
Tests:
- TestHexNumberGoesAsWritten (new): the reporter-shaped table row, a
cued address, 0X upper case, 0xFFFFFFFFFFFFFFFF, a 64-bit x64dbg
base; none masked by the rules, nor as secret, account_number or
private_phone from the model; 0x+64 and 0x+32 still masked.
- TestMaskEval: cases hex-addresses and hex-addresses-en, with the real
models' recordings added (only these two entries; the rest of the
recordings were left as committed, since re-recording on mote moved
other cases' scores slightly).
- Broken by hand: the hexLiteral check taken out of modelTakes.
TestHexNumberGoesAsWritten FAILs with eight masks
("0x004EA5E0" as secret: masked "...`{{SECRET_7bm7qoxm}}`...", as
account_number "{{ACCOUNT_rcgox2br}}", 0xFFFFFFFFFFFFFFFF and
0x00007ff6a1b20000 as secret), and TestMaskEval/privacy-filter FAILs
with 'hex-addresses: "0x0058C210" was masked, and should go as
written' and both hex-addresses-en values. Restored: both pass.
Run (mote-run, at base
|
||
|
|
7a6211d047 |
providers: a model's own headers, in Model settings
axelburks on Discord: a vendor routes one model by a header of its own. A key's provider (built-in or custom) can give each model headers (settings.ModelHeaders["pid/model"]). They go on that provider's requests for that model alone, after the provider's headers and after auth: a name both have is sent once, as the model's, so a user's value is never overridden by the provider's or magpie's key header. The gateway names the model (provider.WithModel) on every route that asks one: chat on each API, translated and streamed, count_tokens, System One's decision, embeddings, images, videos and the model test. A fallback provider serving the same model id gets its own headers only. Accounts and plugins carry their sign-in's headers and take none. The editor's "Name, price and reasoning level" panel is now "Model settings" (every language), with + Add header per model, staged and made with the Save; Restore default takes them away. The rows being typed are kept out of the draft's compare, so an untouched editor still closes without asking. Broken by hand: dropping WithModel from gateway.go turns TestModelHeadersReachTheirModelOnEveryRoute red; dropping the provider id check in modelOf turns TestModelHeadersStayWithTheirProvider red. Run, on this stack over origin/main |
||
|
|
06324e99e8 |
automode: say that Claude Code may have no local check behind a gateway
chenxiang0010 saw "Auto mode can't check actions in this session ... your requests go through 127.0.0.1:3425, which doesn't pass it through". magpie's comments and the gateway-routing and agent-wiring pages said that Claude Code, finding no safeguard_results, classifies locally. Claude Code 2.1.312 to 2.1.316 (read from their bundles) turn that local classifier off behind a non-Anthropic base URL when Anthropic's per-account flag tengu_bright_dragonfly is "all" (PA(), bbt(): auto_mode_side_calls_retired, localClassifierSwitchedOff). A call with no server verdict then gets "No classifier runs for this session", and each action the check would judge asks for approval. 2.1.314 adds the text for CLAUDE_CODE_AUTO_MODE_SERVER=0: "Claude Code no longer has a check of its own to use instead". So on a route only Anthropic doesn't answer (another vendor's model, another subscription's Claude, a translated route, a relay that drops the fields), auto mode has no check at all for such an account. magpie can't answer one on Anthropic's behalf. The reviewed routes (Anthropic's API, a relay passing the fields, the Claude subscription bridge) still carry the beta, safeguards and safeguard_results as before. Comments and docs only, no change in behaviour. Not changed: answering 400 naming safeguards on an unreviewed route, as Claude Code's gateway spec allows. It sets a refused latch for the session, so a later /model to a reviewed Claude stays unchecked, while the strip loses nothing. Run: gofmt -l internal (clean); go vet -tags nogui ./internal/gateway ./internal/agent on mote (ok). Not tried: a real Claude Code run, since the flag is Anthropic's per account and the reporter's route is unknown. Reported-by: chenxiang0010 (Discord) |
||
|
|
00198b26e0 |
gateway: a session's side call goes on the account its main conversation is on (#5655)
With two Claude accounts, Claude Desktop's own Sonnet calls beside an
Opus chat (desktop-beside), and Claude Code's auto mode classifier, ran
on account B while the chat was on A. Each model's conversation is kept
under its own scope (p.ID/model), so the side call was routed as a
session of its own: leastHeld, or Smart's order once its cache was cold,
put it on the account the fewest others held, and B's 5 hours drained on
calls the user never made there.
Decided (product call delegated): one session goes on one account. The
user picked one, the vendor sees one client, and the cost is one cache
write of the side call where the session goes on reading it.
withSession (affinity.go) puts first, for a request whose session a
header names, the key or account of that session's largest conversation
under another model's scope (answered within heldFor, at least
cacheWorth kept, larger than this one's own). It acts for Why first,
gone, cold, no-cache, cache and session; never mid-turn, under Strict,
for a subagent (withLead), past a rest, reserve, credits or a fallback
routing put first, nor to an account that isn't readyForNew. The trace
says Why "lead" with LeadModel, and the Routing page says "Put on
{first}, where this session's {model} is: one session goes on one
account." in en, zh, zh-TW, ja and de. docs/subsystems/gateway-routing.md
says the same.
Not fixed here: the classifier's ~110-130K cache write per call. That one
is ours too: in Claude Code's interactive mode the bridge pastes the
classifier's transcript as one block without the client's marks
(claudetui userPieces, clientCache.pasted), so only the fixed prefix
(Claude Code's system plus the appended rules, the 68,925) is read and
the rest is written again on every call. The cause and a candidate fix
are on #5585. It changes what a real Claude Code sends and can't be
checked without a real account.
Run (mote, through mote-run), at this head (aeeeed54a's tree, origin/main
|
||
|
|
350599a0f1 |
gateway: a held request's route is done before its 504 goes (#4200)
TestUnroutedRequestShownThenAnswered went red on ubuntu CI under -race at |
||
|
|
2b08ccc838 |
routing: the story says why by the keys Smart sorted by (#5646)
The Routing page explained Smart's order from each window's raw reset (Weighed.Renews), while the gateway sorts by Allowance.Renewal (a credit pack's end when it runs out before the reset) and breaks hour ties by Allowance.Lapse. So a WorkBuddy account whose pack ends in 3 days was said to "renew within the same hour, so the order given stays". The trace now carries both keys (Weighed.Soon, Weighed.Lapse); renewsBy, cmpRenews, firstWhy and behindWhy compare them, with two new story lines (credits expire before the other renews; same hour but its credits expire sooner) and a row note, in en, zh, zh-TW, ja and de. "Kept in order" is said only when every key ties. A route from before soon falls back to renews and restarts. The other keys Smart reads (tier, unreached, learns, balance, use first) were already in the trace. Two accounts with one name: logoed() gave only the first its icon. Each later occurrence of the name now gets the next same-named member's own icon, so "louis and louis" shows WorkBuddy's and Zhipu's. Run (mote, via mote-run): - go test ./internal/gateway -count=1 -timeout 45m: ok (1010s), before the rebase onto |
||
|
|
d32a7a70cb |
remote magpie: once magpie updates, the Remote magpies it uses update too
nnlrl_75403 on Discord: a magpie used as another's Remote magpie stayed on
its old version after the local one updated, and had to be updated by
hand on the other computer. Now nothing needs setting up:
- provider.KeepRemotesUpdated (started by the app's updater and by
magpie serve) runs UpdateRemotes 30 s after start and hourly. A
released build with automatic updates on reads each Remote magpie's
version (GET /v1) and, when it is older, asks it through
POST /v1/magpie/update?version=<v> with the provider's key, at most
once in six hours per version. Off here, or a dev build: nothing asked.
- The remote updates as its own automatic update would: the app
downloads and restarts once idle (updater.updateAsked → download,
waitIdle); magpie serve puts the latest in where it runs from, one at
a time, never elevated, and serveFollow restarts into it. Automatic
updates or downloads off there: it answers "off" and stays.
- A copy that can't replace itself says why: a container (docker pull
ghcr.io/yetone/magpie:latest), a package manager's (its command), a
folder it can't write, a build from source. A magpie from before the
route answers 404 ("too old"), a read-only or held key is "refused".
The provider's row on the Providers page adds a short status to its
line ("updating to v…" for 30 min, or "can't update itself" etc.),
with the reason and the command in its tooltip. en/zh/zh-TW/ja/de.
- The route replaces the program, so it takes the Codex reset's
admission: another machine only while shared, never a browser page,
an enabled key with full access from loopback too (401 without one),
read-only 403 gateway_key_read_only, held 403 gateway_key_held. It is
in readOnlyRefused and the CORS route list.
App.js stays under TestCoreScriptBudget by cutting two comments; the
budget is not raised.
Run (on mote, at the tree committed here):
- gofmt -l internal/: clean. go vet of gateway, gui, cli, provider for
darwin, GOOS=linux and GOOS=windows: ok.
- go test -count=1 ./internal/gui ./internal/cli ./internal/provider
./internal/gateway: gui and cli ok but for #5644's two settings tests
(red on main since
|
||
|
|
2b3f76d880 |
gateway: a held request's report is taken before its 504, so a client that closes on it can't let its wait go first (#4300)
TestUnroutedHeldReportSaved was red in full gateway runs and on CI with the report's image description wait no longer "(under way)". Cause: giveUp answered the 504 first and took the report after. The answer says Connection: close, so the client reads it and closes; the server's background read then ends the request's context, the description wait (describeKeyed's select on ctx.Done) returns, and the noteWait ends. When that happened before heldReport ran, the report said the wait had ended and its stacks showed the request let go. Not a test-only race: a real held request's report could name no wait under way in the same way. giveUp now checks under f.mu, lets go of it, takes the report (waits, body, stacks), takes f.mu again and checks again that nothing routed, answered or let the request go meanwhile, and only then answers. The log line uses the same snapshot of the waits. The dump stays out of f.mu. heldAnswered (nil outside tests) is called once the 504 is out; the test holds giveUp there until the request's context has ended and the description wait has let go, so the ordering is forced, not timed. The subsystem page says the report is taken before the answer. Run (mote, Go 1.26.8): - Old giveUp plus only the heldAnswered call, with the new test: go test -tags nogui -race -count=5 -run 'TestUnroutedHeldReportSaved$' ./internal/gateway: 5 of 5 red, "the report doesn't say "(under way)"" (the same text as the issue). - This change, same command: ok (5 of 5). - go test -tags nogui -count=1 -timeout 45m ./internal/gateway: ok (875s), at base |
||
|
|
7a2946caf4 |
gateway: a Codex side call to magpie's own API goes on the conversation's model
With magpie as Codex's provider, the Codex app asks a new conversation's title on a model it chooses itself, not the one picked for the conversation: ephemeralGenerationModel, and when the provider's model list lacks it (magpie's always does), the list's default model, else the first visible one that takes low effort (app.asar's oX). magpie wrote the title on that model as asked, so with the conversation on A/dsf4.1 the title went to B/qwen3.7, another provider (tenacious_eagle_96548). Now a title, description, summary or prediction that reaches /v1/responses goes on the session's model (codexSideSession, as the ChatGPT route already did; it waits for the conversation's turn like it does there), and on the model asked only when no session's model is known. settings.CodexTitles, when set, still writes every title. TestCodexOwnTitleFollowsThePickNotTheAppsChoice: the title on third/ (the app's choice) before the turn on fourth/, then a description and a summary on third/ in that conversation. Red on the old gateway.go (the app's choice got the requests), green on the new. Run (mote, at this commit's tree): go build ./..., go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: clean. gofmt -l: clean. go test -count=1 -run Codex ./internal/gateway/: ok (172s). Full suite (go test -tags nogui -timeout 45m ./..., through the suite lock) was still queued/running at push; any red it shows gets an issue. After a rebase onto |
||
|
|
6c7cedece8 |
gateway: the first Codex title after magpie starts waits for the turn, not the config's model
Codex signed in to ChatGPT, its config's model one provider's (B/qwen3.7),
the conversation put on another provider's (A/dsf4.1) in the Codex app:
the first new conversation's title was written by B. The app asks for a
title on a temporary thread with no link to the conversation, sent as
the first message is, so it can reach magpie before that conversation's
first turn. codexLeads.sideOf waits for that turn when the key's last
turn is old, but when the key had no turn at all (nothing through magpie
since it started) it returned at once with nothing, and servedSession
fell back to CodexSideModel, the config's model. Now such a call waits
the same way (codexSideWait, 5s, or its cancellation) and takes the
turn's model; the config's model only when no turn comes. A memory call
before any turn (Codex consolidating as it starts, no turn on the way)
still takes the config's model at once. A model set for titles in
magpie's settings (settings.CodexTitles) still wins, as before.
TestCodexFirstTitleFollowsThePickNotTheConfig: fresh server, config on
third/, the title sent, then the conversation's turn on fourth/. Red on
the old codex_follow.go ("the config's model got 1 requests, the title
among them"), green on the new. TestCodexSideTurnsOnThePickedModel sends
side turns with no turn ever: it sets codexSideWait to 0 so it doesn't
wait 5s on each.
Run (mote, at this commit's tree):
go build ./..., go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: clean. gofmt -l: clean.
go test -count=1 -run Codex ./internal/gateway/: ok (172s).
Full suite (go test -tags nogui -timeout 45m ./..., through the suite
lock) was still queued/running at push; any red it shows gets an issue.
After a rebase onto
|
||
|
|
6b7ee4a984 |
routing: every group follows a default for rate limits, slow starts and busy members unless it sets its own
jiezhengj on Discord asked to set the per-group policies once instead of
in each group. The Routing groups page's Settings card, under the list,
now has three rows: Rate limited (keeps its place / goes to the back),
Slow to start (wait / 30 s ... 4 min) and Every member busy (off / 1 min
... 4 min). They are saved in settings.json as groupSink, groupFirstToken
and groupPatience (settings.SetGroupDefaults, POST /api/groups/defaults).
A group follows the default for each value it leaves unset, and its own
value always wins:
- Sinks() is the group's Sink, or else the default unless NoSink, a new
field for an explicit "Keeps its place".
- FirstTokenOr() is the group's own FirstToken (-1, FirstTokenWait, is an
explicit Wait), or else the default. The gateway reads it where it
reads a group's first-token time.
- Waits() reads the default when Patience is 0. 60 is an explicit 1 min.
Groups saved before have 0 and no NoSink, so they follow the default,
which starts at magpie's own (keep its place, wait, 60s). Nothing a user
set changes. The group editor's three rows gain a Default option, on for
a group that sets none, and its hint names the value it follows. Segments
only, with no native select.
Run on mote, at 06b2daeff rebased on origin/main
|
||
|
|
3b541a7f36 |
routing: Smart ranks an account by its week once its month can't be used up before it renews (#5639)
Smart ranked a Volcengine Agent Plan (5 hours 2,000, week 7,000, month
20,000) by its month, the biggest window, so it always stood behind
accounts renewing weekly, and its month could reach a point where it
could no longer be used up before it renewed.
The rule keeps #1778's reasoning: a month holding less than its weeks add
up to is the real cap while the weeks can still carry it. Once what the
biggest window has left is more than the next window (a day or longer,
same unit, counts known) can let through between its own reset and the
biggest one's (Of x time between / Span), what the week leaves at its
reset is lost, and the week ranks the account.
- provider: Allowance.Unreached counts the biggest windows to pass over.
Renewal and Seat.Soon are unchanged for other strategies and plugins.
- routes: Seat.Unreached; Smart compares Soon past it.
- gateway: weighRouted fills it; the trace's Weighed carries `unreached`.
- GUI Routing: renewsBy skips those windows, and a new story line says the
shorter window decides. The Smart header and the group hint say so in
en, zh, zh-TW, ja and de.
- docs: reference.md (How magpie picks an account) and
subsystems/gateway-routing.md.
With the issue's numbers as reported (month 696 h away, 18,372 left),
four weeks carry 28,017, so the order is unchanged. Two weeks before the
month renews, 14,017 < 18,372, and the plan goes first, ahead of the
point where a week's leftover is lost.
Run on mote at this tree (base 2dac9b84e; origin/main
|
||
|
|
7f2706e7fb |
gateway: a System One request is masked, at /v1/systemone and from /v1/decisions
With Settings' masking on, a /v1/systemone request went to the decision model's vendor as the agent wrote it: serveSystemOneBody and serveDecideTries never called the masker, so a secret or a name in the state or a question's instructions left unmasked. |
||
|
|
c7810ea5cc |
gateway: /v1/decisions asks a System One decision model, and /v1/systemone a Decisions-only one (wudi_boy)
wudi_boy on Discord: a Decisions request (Python-urllib) to the Qwen
decision model, decision-model-preview, was refused, while the same
model answered on /v1/systemone. canDecide sent Decisions only to an
OpenAI key, Azure or another magpie, and nothing translated between the
two APIs.
Now a Decisions request whose model answers System One (Qwen's, Ark's,
a Jev, a Clef, a plugin's, or a decision group whose members do, none
of them a provider that serves Decisions itself) is asked there
(decisions_systemone.go): predicate -> noul, choice -> criteria map
(boolean values as "true"/"false", typed back on the answer), score ->
criteria list "label: description" least first, an unnamed question ->
question_N answered with a null name, input -> state (a string as it
is, items as {"messages":[{role, content, refusal}]}, input_json as its
JSON text). The answer comes back in the Decisions shape in the
questions' order, a missing answer as refusal, with input and output
tokens. prompt_cache_key/options and safety_identifier change no answer
and are left out. Everything with no counterpart is a 400 naming it,
before the vendor is asked: an image unless every target is a Clef or
another magpie, an http image, function/custom tool calls and outputs,
an image or refusal in a question, any other field or question type.
The reverse: /v1/systemone whose model no System One provider has but
the Decisions API serves (openai/gpt-6-luna) goes through
serveRetrieval as /v1/decisions does, and is answered as System One.
A vendor's error passes through as it was said.
Tests, against fakes with the real shapes (Ark's 2026-11-01 System One
answer, Cloudflare's result envelope, openai-python's Decision):
TestDecisionsAskSystemOne, TestDecisionsMessagesAsSystemOneState,
TestDecisionsUntranslatableRefused, TestDecisionsImagesToClef,
TestSystemOneAsksDecisions.
Run on mote (mote-run) at this change on
|
||
|
|
970a86ff30 |
gateway: a vendor thinking for minutes is not pinged into GOAWAY too_many_pings
zdevoz (Discord, Windows, 0.1.3249): gemini-4-argon at effort high
through Antigravity waited ~235s for its first byte and then failed with
"http2: server sent GOAWAY and closed the connection; LastStreamID=3,
ErrCode=ENHANCE_YOUR_CALM, debug=\"too_many_pings\"". magpie logged a 502
and sent the whole turn again, so one turn took 421s.
Cause: the gateway's transports used Go's HTTP/2 health check
(netproxy.HTTP2Health, SendPingTimeout 10s). Go's client resets its
read-idle timer on every frame it reads, the ping's own ACK included
(h2_bundle.go readLoop / healthCheck), so a silent connection is pinged
every 10s for as long as the silence lasts, about 24 pings in four
minutes. Google's front end holds clients to gRPC's ping policy
(keepalive.md: a ping within MIN_RECV_PING_INTERVAL_WITHOUT_DATA, 5
minutes, of the last with no HEADERS or DATA sent between is a strike;
past MAX_PING_STRIKES, 2, the server sends GOAWAY ENHANCE_YOUR_CALM
"too_many_pings").
Fix: netproxy.CalmHTTP2 gives the gateway's vendor transports
(vendorTransport, so upstreamTransport and each Dispatch clone) an
HTTP/2 health check of magpie's own, on x/net/http2 with a ConnPool that
never dials (net/http dials through the proxy and hands the connection
over in TLSNextProto). The first ping of a silence still goes at
PingAfter (10s) and a lost one still drops the connection after
PingWait, in Go's words ("http2: client connection lost", which lostPing
reads), so #2843 and #4936 are found as fast as before. A silence starts
at the vendor's last HEADERS/DATA/CONTINUATION frame (read from the
frame headers as they come) or at the request handed to the connection.
After an answered ping the next waits PingAgain, 5 minutes, so a 4-minute
silence has one ping. A Dispatch clone gets its own pool (Clone copies
TLSNextProto, not RegisterProtocol), and t.CloseIdleConnections reaches
the calm pool through net/http's altProto lookup, so the proxy-move and
region drops (#4523, #5182) still close the connections.
uploadTransport stays on Go's HTTP/2 with no ping (#3909), and
http.DefaultTransport keeps HTTP2Health: its requests are short, and it
is cloned at 8 sites that would share one calm pool across proxies.
Retry after a GOAWAY: the retry the reporter saw is still made. With the
pings gone it should not be needed. When a GOAWAY does come, the
connection can't take a new request and the pool drops it, so the next
try dials anew (TestTryAfterGoawayDialsAnew).
Tests (no network):
- TestLongSilenceIsNotPingedIntoGoaway: a raw x/net Framer HTTP/2 vendor
that enforces gRPC's ping policy (minimum gap scaled to 600ms, GOAWAY
ENHANCE_YOUR_CALM too_many_pings past 2 strikes) and answers after a
2.5s silence, reached through upstreamTransport with pings scaled to
100ms/1s/1s.
- TestTryAfterGoawayDialsAnew.
- TestRequestOnAHoledConnectionFailsAtThePing now runs for HTTP2Health
and CalmHTTP2, and the calm run must fail with "client connection lost".
- TestCalmFindsAPathDeadLaterInTheSilence: a path that dies after the
first ping was answered is found at the PingAgain ping.
- TestCalmIdleConnectionsCloseAndClonesKeepTheirOwn.
Run (mote, Go 1.26.8):
- go vet -tags nogui ./internal/netproxy ./internal/gateway, plus
GOOS=windows and GOOS=linux vet; gofmt -l clean.
- go test -race -count=1 ./internal/netproxy: ok.
- go test -count=1 -run
"H2|HTTP2|Silent|Upload|Uplink|Region|Proxy|Goaway|LongSilence|Unsent|Replay|Fresh|LargeBody|Codex|Antigravity|CodeAssist"
./internal/gateway: ok (131s).
- win-run (xiaomi-gpu, Windows 11): go test ./internal/netproxy ok, and
the gateway's Goaway/LongSilence/SilentHTTP2/Unsent/Upload/LargeBody
tests ok.
- Again at the pushed head, rebased on
|
||
|
|
c8eb7b3877 |
search: a search API's keys are a list, each switched off, moved and removed on its own
Web search took one key per API in one field (辰林鸭~ on Discord: only one
Tavily key). Settings › Models › Web search now lists an API's keys under
it as a provider's accounts are: each masked on its own row with a tick
(off / on), Show, Copy and Remove; several pasted at once (commas,
semicolons, lines), the reply saying how many were new and how many it
had; the order changed by dragging or Alt+↑/↓. A resting key says why and
until when on its row ("asked last until 14:05: rate limited"), from the
gateway's rest (SearchKeyRest, SearchQuota.Ref); rotation on 401/403,
402/432/433 and 429 (#1477) is unchanged.
provider.SearchAPI keeps Key as the keys on, comma-joined, so the gateway
and an older magpie never ask one switched off; keyList is written only
while a key is off. A Key that differs from the list (an older magpie, a
sync) wins, its keys on in its order, the list's off keys after. The last
key on can't be switched off or removed. The GUI names a key by
SearchKeyRef (a hash): POST /api/settings/search-keys (add, ref+on,
ref+remove, arrange) and /api/settings/search-key with ref. Saving an API
with no key keeps its keys, off ones too. Backup and WebDAV sync carry
the off keys, or leave them out with the rest. `magpie search` says
"+N off". docs/subsystems/gateway-routing.md has "The keys as a list".
Run (mote, at this tree, base
|
||
|
|
dbc74414bb |
claude: a relayed run keeps its prompt cache as long as the user picked, not always an hour
linkaww (Discord #feedback, server v0.1.3237 in Docker, Claude Code 2.1.319) set the Agents page's prompt cache for the main conversation and subagents to 5 minutes, and settings.json had "5m", but 237 of 241 relayed requests since 11-01 wrote an hour's cache. cleanClaudeEnv took CLAUDE_CODE_PROMPT_CACHE_TTL out of the run's environment and put back "1h" every time ( |
||
|
|
3441035a2e |
routing: a group's member maps the reasoning level asked to the one sent
A Routing group that relays one long task across vendors sent every
member the same effort word, but one vendor's high is another's xhigh
(LuckymanJC on Discord). A member that follows the group may now carry
a map from the level asked to the level sent: Group.EffortMaps, json
effortMaps, keyed by the member's id as Members spells it.
- Default: no map, or a level the map doesn't name, goes as asked, so
every group saved before is unchanged and nothing of the user's is
overridden. A member fixed at an effort (or with several levels) and
a rule's UseEffort still win over the map.
- SaveGroup keeps a map only for a plain member of the group (not
:effort, not :a+b, not group/), drops pairs that send what was
asked, lowercases, and refuses a word that isn't a reasoning level.
- Carried by member rename (groupfast RenameMember and the all-groups
rename), provider rename, fold (and its fingerprint), share/import
and CanonicalRef; on a collision the map already spelled so wins.
- Gateway: the level asked is the suffix's/agent pick, then the turn's
pick, then the request's own (askedLevel: agentEffort, plus none for
an Anthropic request with thinking disabled); the target is sent with
withFixedEffort, fitted to the model's catalog levels unless none, and
the trace's try records mappedFrom. Per candidate, so fallback and
retries send each member its own; count_tokens sends no member effort.
- The group lists a mapped member's own levels plus the map's keys to
agents (mappedLevels in buildGroupEntries).
- GUI: the member's reasoning menu has "Map levels…" (app menus only):
a level asked, then As asked or one of the model's levels. The chip
reads "Mapped reasoning", its title the pairs. Follow the group or a
fixed level drops the map. zh, zh-TW, ja and de.
- docs/subsystems/gateway-routing.md says all of it.
Run (mote, at this tree):
- gofmt -l: clean. go vet (provider, gateway, gui), GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test ./internal/provider/: ok. go test -run
'Effort|Level|Group|Fallback|Rule|Auto|Fixed' ./internal/gateway/: ok.
- node --test group-member-effort-map (30: chromium + webkit, en zh
zh-TW ja de, 1100 and 420px) and group-member-levels: pass;
i18n-en-no-cjk: pass. i18n-keys' "a plugin's words are its own" is
red only for the three words it is red for on origin/main
|
||
|
|
dec791f849 |
gateway: a Codex conversation's next turn goes on its kept socket as a delta
rem_thank on X: Codex sends a turn on its kept WebSocket as only its new input after previous_response_id, while magpie opened a socket per turn to chatgpt.com and sent the whole conversation, which a long one meets as 1009 (message too big). A conversation's socket is now kept between turns (codex_socket_keep.go), as codex-rs's WebsocketSession and get_incremental_items do it: - kept for a turn that names its conversation (session-id/thread-id, else prompt_cache_key) and ended response.completed with an id, under a key of host, path, a digest of Authorization and chatgpt-account-id, the conversation ids and the subagent headers, so another account's turn never finds the socket nor names its response; - taken out of the pool by the next turn, so two turns at once each have a socket and the last to end is kept; - let go after 10 min idle, at 55 min from the handshake (the backend ends at 60), and the oldest past 32; the closes run outside the pool's lock, and no lock is held across a read; - the turn goes as a delta when every field but input, client_metadata and stream_options is as the last turn sent it and its input starts with the last input and then that turn's output_item.done items (compared without id, status, nulls, empty lists, annotations, logprobs); anything else goes whole on the kept socket. It is compared on the body as it goes, after masking, so a turn masked otherwise goes whole; - a kept socket that fails before the reply is handed on (closed while kept, the write fails, an error frame first such as previous_response_not_found or the connection limit) is closed and the turn goes whole on a new socket, and from there over HTTP as before. The socket's dial context is detached from the request (the handshake alone ends with it) and cancelled when the socket closes. The gateway's tests drain the pool in socketOn's cleanup. Tests (codex_socket_keep_test.go): the delta on one socket and an edited history or another model whole on it; previous_response_not_found asked again whole on a new socket; a socket closed meanwhile; another account gets its own socket; idle let-go and no keep without a conversation; two turns at once take the kept socket once; a turn after another reply goes whole. Run (first at origin/main |
||
|
|
abe7b00631 |
gateway: a key+URL provider is sent the agent's own User-Agent by default, through a remote magpie too
nb5p runs a gateway of their own behind magpie and saw nearly every request arrive as "magpie/<version>". The agent's User-Agent now goes on as the agent sent it, wherever magpie isn't itself the client. What each path sends now: - Key+URL providers (official vendor keys and custom OpenAI/Anthropic compatible ones), on chat, Anthropic, Responses, Gemini, count_tokens, embeddings, images and videos: the agent's User-Agent, as sent. Before, this was the opt-in passUserAgent (#1851) and the default was magpie's. The opt-out is magpieUserAgent: `magpie provider set <id> user-agent=magpie`, or untick "Send the agent's own User-Agent" in the editor. passUserAgent is no longer a field, so a file that set it true reads the same as the new default. A provider someone turned back off after opting in can't be told apart from one never touched, and now sends the agent's too. - When the agent sent no User-Agent, and on magpie's own requests (classifier magpie-router/1, vision, search, the image tool, model lists): magpie's, unchanged. - A header.User-Agent the user set: still wins over both. - Subscription accounts (Claude, Codex, Copilot, Google, ZCode…), plugins, and OpenCode/Cline/Kilo: unchanged. Their signing sets the official client's UA (provider.PassesUserAgent still refuses an Account or OwnClient). - Claude Code and Codex header copies: unchanged. - Remote magpie: the near magpie still asks as magpie/<v>, because the far end trusts X-Magpie-Agent/Via only from that. It now adds X-Magpie-User-Agent (passOnUA, on forwardOnce, embeddings, draw and video; the classifier's decision request names none). The far end takes it only from a magpie/ request (callerFrom) and strips it on arrival (withCaller). agentUA/callerUA then hand it to userAgentFor, so the far vendor sees the agent's. A client that writes the header itself, straight to a magpie, is ignored. magpie's own UAs are never relayed (magpiesOwn). Vendor check: invalid-key requests with magpie/, claude-cli, a Chrome UA and pi's went to Anthropic, OpenAI, Gemini, DeepSeek, Moonshot, Kimi For Coding, Zhipu, OpenRouter, xAI, DashScope, MiniMax, Volcengine Ark, Groq and Mistral. Every vendor gave the same auth error for every UA, so no edge-level UA gating was seen. Kimi For Coding's agent allow-list sits behind a valid key, which wasn't tried. Run (mote): - go test -run 'UserAgent|RemoteMagpie|ZCode|Blocked' ./internal/gateway: ok - go test ./internal/provider ./internal/cli ./internal/gui: ok - node --test provider-user-agent, provider-native-compaction and i18n-keys (chromium and webkit; en/zh/zh-TW/ja/de; 900 and 440 wide): 123 of 124 pass. The red is i18n-keys "a plugin's words are its own" (plugins' words said in files this change doesn't touch), already filed as #5327/#5332, #5426 and #5482. - gofmt -l clean; go vet; GOOS=linux -tags nogui and GOOS=windows vet: ok at the rebased head (on |
||
|
|
f13d5f16f4 |
history: today's plain file takes no room from the days before it
pruneHistory held every file in routing/ to historyBytes (200 MB),
today's plain .jsonl included. Today is never dropped, and its file is
written plain, about ten times what it is once gzipped (this Mac's
2026-11-06: 5,785 routes, 1.1 MB gzipped). On a busy gateway, today's
file took the room of the days before it, and every prune (the first
save after a start, then hourly) dropped the oldest days until it fit;
past 200 MB plain, it dropped every day but today. The Context tab then
listed only today's sessions, while Usage's Requests, read from the
ledger, kept them. The budget now holds the days that are over; today's
file is counted from the next day on, gzipped.
From linkaww's report: on their Docker magpie, after each nightly
update, Context lists only today's sessions while Requests keeps the
older ones. NOT confirmed as their cause. A real Docker run on
xiaomi-gpu (the image built from this tree, a named volume on /config,
a fake upstream in a second container) kept every session across
`docker restart` and across rm + run on the same volume, as the
documented update does; so did a sandbox chain (desktop magpie ->
remote magpie with a gateway key, the remote restarted). A plain
restart loses nothing; this budget is the one path found that drops
past days while the ledger keeps them. Their routing/ listing would
tell.
History already dropped is gone: the routing days are their only copy,
and the ledger keeps no prompt tokens or sessions to rebuild them from.
Run (mote, at
|
||
|
|
191f3c0af1 |
gateway: POST /v1/decisions goes to OpenAI, Azure OpenAI or another magpie
A Discord user's POST /v1/decisions was answered 404 ("magpie serves
/v1/chat/completions, ..."). It is OpenAI's Decisions API (gpt-6-luna):
one input, up to 400 questions, typed answers, input tokens billed only.
The shape was taken from openai-python (resources/decisions.py,
types/decision_create_params.py, types/decision.py, added in #4033 on
10-06) and the Decisions guide, not guessed: POST /v1/decisions, a JSON
body of model, input (a string or messages/items with input_text,
input_image as a data or http(s) URL, JSON parts; function and custom
tool calls and their outputs), questions (predicate / choice / score),
and optional prompt_cache_key, prompt_cache_options, safety_identifier.
The answer is {answers, model, usage}, not streamed; usage.input_tokens
includes input_tokens_details.cached_tokens and cache_write_tokens. The
Azure client sends it on the v1 API (/openai/v1/decisions), the model in
the body.
- decide (decisions.go) goes through serveRetrieval as embeddings and
rerank do, body as sent with only model changed. So a disabled model,
a key's models, accounts and spent limits, pause rules, keys/accounts
of the provider, masking and the Routing page hold here as on every
route.
- Only a provider canDecide takes is sent it: an OpenAI API key on
api.openai.com, Azure OpenAI (IsAzure, at its OpenAIBase, so
/openai/v1/decisions with api-key), or another magpie. Anyone else (a
relay, a plugin, a ChatGPT sign-in) gets a 400 that says who serves
it, checked in serveRetrieval's try loop beside the no-OpenAI-API
check (refusingRetrieval), never the vendor's 404; a group moves on.
- A bare gpt-6-luna is a kind group "decision" (servesDecision), so a
relay that lists the same id is never its member.
- Usage is recorded as "decisions" (countedRetrieval): input less the
cached and cache-written tokens, those as CacheRead/CacheWrite, and
no output, so gpt-6-luna's own models.dev rates price it as OpenAI
bills ($0.10/1M input, cache read/write at their rates).
- /decisions joins the one-port client prefixes, another magpie's URL
suffixes, the 404's route list and info's apis. The readonly, LAN
and CORS guard tests list the route.
- native_endpoints is left alone: it names the chat APIs a model is
relayed on (Cursor's names, a remote's API choice).
- docs: gateway-routing.md has a Decisions row; reference.md a section.
Run on mote at this tree (mote-run): gofmt -l clean; go vet of gateway
and provider; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet
./...; go build ./..., linux nogui and windows builds ok;
go test -count=1 -timeout 45m ./internal/gateway ./internal/provider
./internal/usage: ok (gateway 413s, provider 88s, usage 18s).
Red on the old code (
|
||
|
|
0978a68681 |
gateway: a ZCode trial entry's 3012 rests that entry, not the account
young02036 (Discord, 11-07): on an account with a GLM Coding Plan, GLM-5.3-Flash-Trial answered 405 code 3012 (ZCode's risk control) while the account's paid models worked. The plugin's 3012 words read as failRestricted, which rested the whole account for two hours (restrictedRest), so magpie stopped sending the paid models the account still served. A -Trial entry goes to zcode.z.ai's Start Plan, and a dual account's plain models to its GLM Coding Plan on api.z.ai, so the 3012 is zcode.z.ai's: zcodeTrialRestricted rests the entry alone (restID), as zcodeTrialBlocked already does for the edge block page. On a gift-only account the plain model goes to zcode.z.ai too, gets its own 3012 and rests the account, at the cost of that one more refused request per rest. riskRefused still walls the provider's other accounts off for the rest of the request. TestZCodeTrialRefusalRestsTheTrialAlone: "trial risk control" now wants the entry's rest and the account's GLM-5.3 served after it; new cases "plain risk control" and "another vendor's risk control" want the account's rest. docs/subsystems/gateway-routing.md says so. Run (mote): go test -count=1 -run 'TestZCode|TestRisk|TestRestricted|TestMovedZCode' ./internal/gateway/ ok; gofmt -l clean; GOOS=linux and GOOS=windows go vet ./internal/gateway/ ok. Broken by hand: the routing.go check removed, trial_risk_control red (rested "zcode@api key", want ".../GLM-5.3-Flash-Trial"), then restored. Not tried: a real 3012 account (the reporter's); the full suite runs after this push. Reported-by: young02036 |
||
|
|
fd0cac2505 |
gateway: a full window of some models only rests that model (plugins#817)
A subscription account that fails with a window full rests until that
window renews (restAfter's "window" branch). The rest was always on the
account (restKey), whatever the window counted. Now, when every full
window that counts the model counts some models only (Allowance.Pooled,
the same reading a quota refusal already narrows by), the model rests
(restID), and its siblings in their own windows still answer. A full
window of the whole account rests the account as before.
zane668's ZCode Start Plan gift account: GLM-5.3's daily bucket was
spent, and the plugin passed its 200 "exceed quota limit" on as it came.
The gateway read that as a 502 that did not stream (failOther), the
window branch took GLM-5.3's full bucket, and the account rested ~22h.
GLM-5.3-Flash, with its own bucket 71% left and a weekend bucket unused,
was skipped by every group. zcode 0.1.53 now says that answer as a 429
(failQuota, which pooled already narrowed). This change is for any
plugin or built-in whose failure isn't worded as quota while a
per-model window is full.
Checked the reporter's reading before changing anything: spentUp runs
only on the forcedGift and freeGift paths, and the plain path returns
done(kept(res)). failure(502, "... did not stream: exceed quota limit")
is failOther. pooled is computed for failQuota only, and the window
branch set modelBackoff false and kept restKey.
TestScopedWindowFullRestsTheModelOnly builds the allowance through
PluginAllowanceForTest from the plugin's startUsage windows as the
report read them (GLM-5.3 100%, Flash 29%, the weekend bucket 0%):
- the 502 that did not stream rests GLM-5.3 alone till its reset, and
Flash not;
- the plugin's new 429 1005 does too;
- with a whole-account plan window full as well, or alone, the account
rests and Flash with it.
Not changed: the Codex out-of-credit branch's window. Its credits are
the account's.
Run at
|
||
|
|
8e350155b6 |
routing: a provider set to Use first goes ahead of the others Smart weighs it with
hzh_1119 on Discord: ChatGPT Pro and Business now come with monthly API credit, and they want an OpenAI API key spent before the ChatGPT subscription where both serve a model, the subscription taking over after. Smart had no way to say so: an API key tells no allowance, so it went after every account with room, in every model's found group (auto/<model>). The only way round was a group set to In order with its members dragged, one group at a time, which nothing pointed to. A provider row's right-click has Use first (provider/usefirst, provider.SetUseFirst, Provider.UseFirst, copied onto its accounts by accountSettings, kept by the editor's Save). Its keys and accounts are routes.Seat.Lead, and Smart (leadFirst) puts those not all but used up ahead of every other seat, each side in Smart's own order. A resting one is passed over as before, so a 429 insufficient_quota (out of credit) or a failure moves the request on to the subscription. Off by default; within one provider nothing changes. The Routing page says why the first went first (Weighed.UseFirst, firstWhy) and doesn't call the one behind it "renewing later" (behindWhy). The menu shows a tick when it is on. Free quota by expiry orders its paid seats with Smart and so follows it; other strategies don't read it. The core's script budget is met by cutting three Providers-page comments in app.js, no raise. Run (on mote via mote-run, at |
||
|
|
30a0bfe889 |
gateway, provider, cli: search APIs marked mix are asked together, their pages merged (#2845)
A search asked the search APIs in order and gave the model the first one's pages. On #2845's 80-query benchmark no single API was best on both sets. The deduplicated union of two or three APIs' pages scored higher than the best single API and lost no query (60-query set: 108 to 114-117 of 120, sign test p <= 0.03). Off by default. When two or more search APIs are marked mix (SearchAPI.Mix), they are asked first, at once (askSearchAPIsTogether). Each uses its own keys and timeouts, as when it is asked alone (askSearchAPIKeys). Their pages go to the model in turn: each API's first page in the saved order, then each one's second. A page an earlier API already gave is left out by its address (pageKey). One that fails or finds nothing leaves the others' pages. When none finds anything, the APIs not mixed are asked in order. With fewer than two mixed APIs on and ready, a search runs in order as before. No text says which API found a page, so what a vendor sees reads as before. MixSearchAPIs marks the vendors named (two or more, set up, each once) and clears the rest; none clears all. SetSearchAPI keeps the mark, as it keeps off, since Settings sends an edit without it. Backup copies the whole entry, so the mark carries over. CLI: magpie search mix <api>,<api>, magpie search mix off, and magpie search lists a mixed one as mix. docs/subsystems/gateway-routing.md has a section on it. Ported from mdwsk88's 2966cce77 and reviewed line by line. What changed from it: - The cap follows the search's count (#5545, the commit before this): searchMixMost is 2 x the count a search asks for, at most 20 (searchHitsMost). The default stays 12 pages, as in the patch. TestSearchAPIsMixedCapped is a table over count settings and named counts. - The CLI keeps both search count and search mix. - No Settings toggle. The mode stays CLI-only, by the UI-restraint rule; the docs say so. Run (mote-run): - go test -count=1 -run "Search|Mix" ./internal/gateway/: ok; -race -run "TestSearchAPIsMixed|TestMixSearchAPIs": ok. - go test ./internal/provider/ ./internal/backup/: ok; ./internal/cli/ -run "TestSearchCLI|TestEveryRoute": ok. Broken by hand: with apiSearch's mixed branch turned off, TestSearchAPIsMixedAskedTogether fails (only the first API's pages) and TestSearchAPIsMixedCapped fails ("count set 0, named 0: 6 pages, want 12"). Restored, both pass. Not tried: a real search with two vendors' live keys. The tests use fake search APIs. Co-authored-by: mdwsk88 <11055210+mdwsk88@users.noreply.github.com> Reported-by: mdwsk88 (dawei on Discord) |
||
|
|
4e0e8e7933 |
gateway, settings, gui, cli: the results a search is answered with can be set, 1 to 20 (#5545)
Claude Code's WebSearch and Codex's web_search never name a count, so magpie answered every such search with searchHits, 6 pages (#5545, mdwsk88: more pages for research-heavy work, fewer to save context). settings.SearchCount holds the count. 0 means the default, 6 (SearchCountDefault), and the most is 20 (SearchCountMost), the most Brave and Tavily return. Save refuses a value out of range, so nothing is written. Settings.SearchPages reads it. The gateway's searchCount falls back to it when a search names no count. The web_search MCP tool still answers a named count with that count, and its schema's default says the count set. It reaches every search API (Brave, Tavily, Exa, You, the plugins' searchers), as a named count already did. - Settings › Models › Web search: "Results per search", segments 3, 6, 10, 15 and 20, plus a count set by hand in settings.json. POST /api/settings/search-count sets it alone. settingsapi.Apply keeps it as it keeps search-all, so a save of the Settings form doesn't put it back. - CLI: magpie search count says the count; magpie search count <n> sets it; magpie search count default puts 6 back. A bad value is refused and nothing is written. - docs/subsystems/gateway-routing.md says it. - New strings are in zh, zh-TW, ja and de. Run at this tree (mote-run, macOS): - go test -count=1: internal/settings, settingsapi, cli, gateway (TestSearchMCPCount, TestSearchCountReachesEveryAPI, TestSearchCountSetting), and gui (TestSettingsSearchCountSetOnItsOwn, and TestSettingsSaveKeepsWhatItDoesNotSend with SearchCount set): ok. internal/gateway whole: ok with -timeout 45m (847s). internal/gui whole: ok but TestMainWindowCorners/macOS_26_SDK (#3949, mote is on macOS 27). The first cli run was red on TestEveryRouteHasACommandOrIsNamed: the new route had no CLI entry. cliForRoute maps it to search count now. - Broken by hand: searchCount returning searchHits again makes TestSearchCountSetting fail ("set 11: a search naming no count asks for 6, want 11"). Restored, it passes. - GUI: node --test --test-concurrency=4 over routing-*, usage-*, ledger-*, panel-*, call-*, search-*, searcher-*, settings-*, i18n-* and gui-* (Chromium and WebKit; the files cover en, zh, zh-TW, ja and de), with #2398 and #5545 in one tree: 4961 of 5016 ok. The 55 reds are in 12 files. i18n-keys' "a plugin's words are its own" names other files' strings (#5327, #5426, #5482). The other 11 files were run alone at dc49feca9 (this tree without either change) and at this tree: 52 and 51 reds, the same tests. The one apart is usage-focus-steady, which flakes (#3501). Each is filed: #5392, #3414, #5048, #3799, #3415, #3954, #4627, #4628, #5223, #1529. routing-canceled-row.test.cjs: 10 of 10. With the .rt-req.gone rule taken out, its dot is the answered green rgb(24, 154, 88) and it fails. Restored, it passes. - Not tried: a real Claude Code WebSearch through this tree with a live search API key. The tests use fake search APIs. Co-authored-by: mdwsk88 <11055210+mdwsk88@users.noreply.github.com> Reported-by: mdwsk88 (dawei on Discord) |
||
|
|
8de63c8b5a |
gateway, usage, gui, otlp: a request its agent canceled is no failure (#2398)
An agent that cancels its request before it is answered is logged 499 "the agent canceled the request": a person stops the reply, or sends the next message while it is coming and Claude Desktop cancels it and asks again, or Codex takes a subagent's report (#2398). The gateway already says nobody failed (no rest, no reroute: TestCanceledRequestRestsNobody), but Record.Failed is a status >= 400 or an error, so every page counted it as a failure: the Requests card's "N failed" and success share, its Failed filter, the CSV's error column, the Routing page's "errors your agent saw", the Context page's error rate, the failed colour in the Requests list, Routing and Recent calls, and the OTLP export's error status. A Claude Desktop session on 2026-10-27 had four, each a message sent mid-reply; #2398 had 91 of a day's 92 failures. usage.CanceledBy tells the agent's cancel (499 with AgentCanceled) from magpie's own limit on a request it asked of itself, logged 499 too and still a failure (#2318). The cancel is logged with an error type of its own, agent_canceled (usage.CanceledErrType, set in failedWith), so the record says what it was and nothing guesses it from a 499, as #2398 asked. Record.Canceled reads the type, and a record logged before it by its status and message, so the old log reads the same with nothing migrated. A middleware's usage rows carry the type, so a module can tell the cancel from magpie's own limit, which its rows (no error text) couldn't. Record.Failed leaves the cancel out; Totals counts it apart (Canceled, in count and plus); RetriedRequest and the first-token and speed sums ask Answered, so a canceled request is timed nowhere, as before; Codex's memory of the last model still skips it. Routes and Recent calls say canceled (set as a route is done and as a day's history is read, so old days read the same); the Routing totals and the Context page's errors leave it out. Ledger rows say canceled, and the pages show it muted, in neither the failed nor the answered colour: the Requests list and its detail ("499 · canceled"), the Requests card ("N canceled", the success share of the requests not canceled), the overview tile, the Routing page (a "gone" outcome, no speed) and Recent calls (muted). New strings are in zh, zh-TW, ja and de. The OTLP export: the records the gateway gives its observers for a request and its try carry the type too (canceledAs), and a root span's error.type follows Record.Failed, so a canceled request's span and its try's go with status code 499, no error and no error.type. TestOTelWaterfallFailureAndCancellation's canceled case held two failed spans (the try the vendor refused as the agent left is recorded canceled, as the request is); it now holds neither failed, both 499 and no error.type. That change to the test is the point of this one. mdwsk88's patch (aea0027fd) ran its tests at |