ac4af582301a4e8a29245dbba767eba31334ddf9
2027
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
34116ec012 |
gateway: Codex signed in to one account lists another account's models
bigfisheatsmall on X: Codex was kept signed in to ChatGPT account A, on the Free plan. Account B (Team) was the only account on in magpie. dsh listed B's models and Codex didn't. codexMerged added CodexListed(), which leaves out every ChatGPT account's own models because it assumes the backend lists them. But the backend list is fetched with Codex's own sign-in (A, Free), so B's plan-only models were listed nowhere. Routing already sent codex/<model> to B (codexAccounts). - provider.CodexListedBeside(backend) lists an account's own model by magpie's id (codex/<slug>) when the sign-in's backend list lacks it. codexMerged uses it, and FitOwn keeps those entries. - spawnChoices (spawn_agent's models) had the same gap. It now uses the same rule with the slugs in Codex's models cache. - buildCodexListTag covers the accounts' own models, so another account gaining or losing one has Codex ask for the list again. Every Codex asks once after the update. - TestSyncCatalogAgesCodexCache built its "current" tag by hand from CodexListed(). It now uses provider.CodexListTag(), the tag SyncCatalog compares against. Tests (sandbox HOME, fake backend with per-plan lists): TestCodexListHasAnotherAccountsModels covers the list, routing of codex/gpt-6.1-sol to the Pro account, and spawn_agent's choices. TestCodexListOneAccountNoneTwice checks that a single account gets no codex/ duplicates. Run on mote at this tree: go vet (darwin, windows, linux) on gateway, provider and agent: ok. go test -count=1 on provider, agent and codexcat: ok. go test -run 'Codex|Spawn' on gateway and gui: ok. Run at the tree before the sync_test change and the buildCodexListTag tidy: the full gateway package was ok (1224s). Agent was red only in TestSyncCatalogAgesCodexCache, fixed above. Broken by hand: on the old codexMerged, the new test fails with "Codex's list lacks codex/gpt-6.1-sol: [gpt-6-luna gpt-5.6-terra gpt-5.6-luna]". With only codex_spawn_models.go reverted, it fails with "spawn_agent's models lack codex/gpt-6.1-sol". Not tried: real accounts or a real Codex. Not a full go test ./... run. Not tried: models the backend marks hidden. A Codex here for failover alone (codexOwnOnly) is unchanged. |
||
|
|
1b579ca4f8 |
router: Droid and omp get the hub's tools whole; find_tools' description names each server and its tools
tao5010 on Discord (11-04): with the MCP router on, omp, pi and droid
rarely called the servers behind it. Asked for a picture of a cat, the
model searched three times and stopped, and found magpie-image only when
told "我的mcp有啊".
Since v0.1.2950 an agent not in hubSearchesItself with more than 10 tools
is given only find_tools and call_tool. Droid (0.231) defers every MCP
tool to its own ToolSearch, showing the model names only, and omp (18.9)
mounts MCP tools in a catalog by each description's first line. Both were
handed two opaque tools whose description said only how to search, while
the servers were named in initialize's instructions, which Droid doesn't
show and omp shows apart from the tool. Read from droid's binary and
omp's dist/cli.js.
- hubSearchesItself gets droid and omp: they search their tools
themselves, so they get every tool whole as Claude Code, Codex and Pi do.
- find_tools' description, for every agent still given tools on demand,
starts with HubLine (each server and what it is for, <= 250 chars), then
how to search, then hubDetails (each server's tools) within
hubFindSayMax = 1200 characters.
Ran on mote at this head:
- gofmt -l internal/gateway (clean); go vet -tags nogui ./internal/gateway
on darwin, GOOS=linux -tags nogui, GOOS=windows
- go test -tags nogui -count=1 -run 'Hub|MCP|FindTools' ./internal/gateway: ok
- repro (sandbox HOME, magpie serve on 127.0.0.1:3563/3564, a fake stdio
server with generate_image/generate_video/generation_result and one with
12 tools, router on): the old build (
|
||
|
|
a1f1810e93 |
gateway: a 400 that only says the request is too long counts as an overflow once it is past half the model's window (#4420, MYCF711)
A group member answered 400 "内容太长了,请精简输入或开启新对话" at ~730K on a model it declares at 1M. |
||
|
|
7818dc316a |
gateway: a relay's Cloudflare 520 to 524 is asked again before the agent sees it, as a 502 or 503 is (vdaoren)
vdaoren on Discord: an API-key provider's 4xx/5xx now and then went
straight to the agent; they asked for retries on chosen status codes.
What a single API-key provider already did: the last one left is asked
again after a failure that passes (passing, fallback.go): 408, 500, 502,
503, 504 and 529 twice (lastRetries), a 429 that is a short rate limit
three times (rateRetries), pauses 1s, 2s, 4s or a Retry-After up to 8s,
then within the provider's patience (singlePatience, 60s by default,
`magpie provider set <id> patience=`) in rounds (busy, patience.go), all
while the reply is held and nothing has gone to the agent. A plan used
up, no balance, a 401, a request the vendor refuses for its content and a
conversation too long are the agent's at once.
What was missing: Cloudflare's own 520 (unknown error), 521 (origin
down), 522 (connection timed out), 523 (origin unreachable) and 524
(timeout), which a relay behind Cloudflare gives now and then, were in
neither list. Such a 5xx moved on to another member in a group, but on a
lone provider it reached the agent after one try. busyStatus now holds
the one list passing and busy read, with 520 to 524 added. No setting:
the default serves it, and patience= already exists for the length.
TestCloudflareErrorIsTriedAgain (retry_test.go): each of 520 to 524, as
Cloudflare words it to an API client ("error code: 520") and as its HTML
page, twice and then 200, is answered 200 after 3 tries; a stream's 524
then an SSE reply reaches the agent with nothing of the 524 in it; a 401
invalid key and a 400 content_policy_violation are tried once.
Broken by hand (busyStatus's list back to 408..529): red, every 52x case
"520 after 1 tries" and the stream "524 after 1 tries"; the 401/400 cases
pass either way.
Run on mote at this tree (base origin/main
|
||
|
|
b61c71448c |
keys: a custom provider's key can be made for its Gemini API (corddis_114)
corddis_114 on Discord has a relay that gives out a key per protocol,
one of them for Gemini ("gemini sk-d…SarG"), and the key row's protocol
menu offered Any, Anthropic, Chat Completions and Responses only. A
custom provider already serves Gemini upstream (its Gemini URL, the
"Gemini compatible" tab, x-goog-api-key, the model list through
FetchGemini, probes), so only the per-key layer lacked it:
- keyProtocolOK takes "gemini"; WithKey leaves a Gemini key the Gemini
URL only and takes the Gemini URL from a key made for another
protocol (it had kept it, so an Anthropic key could be sent to
generateContent).
- keyFit: a gemini* model (modelFamily Gemini) goes to the key made for
Gemini first, the other keys in their order behind it; a GPT model is
never put on the Gemini key (it ranked 0 there before). Claude's rule
is unchanged.
- app.js: Gemini in PROTO_OPTS ("Gemini API (generateContent) · Gemini
CLI, Gemini models"), offered when the provider has a Gemini URL;
keyLacksURL says "No Gemini URL" for a Gemini key without one. The
note in zh, zh-TW, ja and de. The provider-level tabs and Routing's
"keys for Gemini" already had it.
Run on mote (go1.26.8):
- go test -timeout 45m ./internal/provider ./internal/gateway: both ok (provider 229s, gateway 938s).
- TestKeyMadeForGemini, TestKeyProtocolGemini, TestKeysMadeForOneProtocol,
TestKeyForAProtocolWithNoURLIsSaid, TestKeyPoolsByProtocol,
TestCustomGeminiUpstream ok; internal/gui's budget tests ok.
- GUI (node --test, Chromium and WebKit, en/zh/zh-TW/ja/de, 420 and
1000px): key-gemini (new, 40/40), key-nourl, proto-menu-overflow,
key-row-chips-fit, key-plan, key-import, key-weight-fit,
provider-many-keys, provider-gemini, provider-add-gemini,
provider-url-each-api, model-api-gemini, provider-base-api,
routing-keys-fold and i18n-keys ok; the only red in the 360 was
tencent-cloud's region-strip test (#4321, open).
- gofmt -l clean; go vet, GOOS=linux go vet -tags nogui, GOOS=windows
go vet on provider, gateway, gui ok.
Broken by hand: the old fallback.go turns TestKeyMadeForGemini red
(Gemini models went to the Chat or Anthropic key, GPT to the Gemini
one); the old keys.go turns TestKeyProtocolGemini red (unknown
protocol "gemini"), and WithKey keeping p.Gemini turns it red too (the
Anthropic key speaks [anthropic gemini]); the old app.js turns
key-gemini red in all 40.
Not tried: the reporter's relay or any real Gemini-compatible relay;
the real app's editor.
|
||
|
|
4062cda781 |
provider: a custom provider at a Token Plan's or Ark's address is asked for no access key (ysm119)
ysm119 on Discord saved a custom provider (no preset) at https://tokenhub.tencentmaas.com/plan/v3 with a plain sk- key on the OpenAI-compatible tab, and its editor asked for a SecretId and SecretKey. AccessKeyVendor decides by host alone, so any provider at a Token Plan's /plan address (or an Ark plan's) got the access-key fields, and a Singapore Token Plan or Ark one also got a Usage card asking for them. Now AsksAccessKey(p) gates the two places a user is asked: the editor's listing (gui/providers.go) and the keyless Usage cards (tencentPlanQuotas, volcPlanQuotas). A preset's provider is asked as before; a custom one only once it has an access key saved (so a key the user did give is still shown and still used for its usage). The host rules themselves are unchanged, since presetAccessKey and the presets read them on providers with no preset of their own. The key itself was already sent as typed: no Tencent signing exists on chat, Responses, the model list or a probe; the access key only reads plan usage. TestCustomTokenHubIsSentAsTyped holds that (Authorization: Bearer <key>, on Chat and Responses). Run on mote (go1.26.8): - go test ./internal/provider ./internal/gui: provider ok; gui red only in TestMainWindowCorners (AppKit, #3949, macOS 27 on mote). - TestPlanCardWithoutAccessKey, TestCustomTokenHubIsSentAsTyped, TestProviderListTellsTencentAccessKey ok. - GUI (node --test, Chromium and WebKit, 5 languages): tencent-access-key, tencent-cloud, volc-access-key, usage-access-key-card, i18n-keys and the provider editor's key files ok, except tencent-cloud's "a region clicked right after the strip scrolled" (#4321, open, same on main). - gofmt -l clean; go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet on provider, gateway, gui ok. Broken by hand: AsksAccessKey returning AccessKeyVendor(p) always turns TestPlanCardWithoutAccessKey (my-ark gets a card), TestCustomTokenHubIsSentAsTyped and TestProviderListTellsTencentAccessKey (my-tokenhub, my-intl, my-ark asked) red. Not tried: the reporter's real tokenhub key; the real app's editor. |
||
|
|
7564e46690 |
library: a subagent names its model, written into Codex's role as model (#4421)
luckymanjc (Discord) set Codex's subagent model to Default on the Agents
page and gave a Library subagent a prompt that named a routing group.
Codex knew the group's name, but the subagent ran on Codex's own model.
A Library subagent had no model field, and Codex's role file
($CODEX_HOME/agents/<name>.toml) got only name, description and
developer_instructions. So Codex started the subagent on the model the
lead passed in spawn_agent, or on the lead's own model. The group was
only text in the prompt.
codex-rs reads a role file's model (AgentRoleOverrides). In
child_config.rs, prepare_agent_spawn_config applies the lead's
spawn_agent model, or [agents] default_subagent_model, first, and then
the role. So the role's model wins. A subagent now has a Model field: an
app menu with "Picked by the agent", the models and routing groups Codex
lists (groups noted as a routing group), and a saved id Codex no longer
lists. The Model is written as model = "..." to Codex's role only. A
subagent without a Model is written as before, byte for byte. Other
agents' files don't change; the hint names the agents that don't take
it. When the Agents page's Codex subagent model is set, the gateway still
puts that in place of the role's model (codexSubagentPick), and the hint
says so.
Run:
- Real codex 0.165.0 on mote, sandbox CODEX_HOME, fake Responses
server. With no role model, the collab_spawn request carried the
lead's model. With model = "group/review" in the role, it carried
group/review, also when the lead named gpt-6-sol in spawn_agent.
- mote-run go test ./internal/library: ok. TestSubagentModelGoesToCodex
went red with codexRole given "" for the model by hand.
- GUI library-subagents.test.cjs: 12/12 in Chromium and WebKit, in en,
zh, zh-TW, ja and de. Red with origin/main's client.js (timed out
waiting for the model picker).
- i18n-keys 4/4: it was red at first, because the plugin defined
"Routing group" and "Find a model". The change now uses core's
"routing group" and "Find a model…".
- gui-zh-tw, gui-ja, gui-de, library-all, library-gone-agents,
library-wsl-asleep: ok.
- gofmt -l is clean. go vet, GOOS=windows go vet, and GOOS=linux go vet
-tags nogui on internal/library and internal/gui: ok.
- go test ./internal/gui: only TestMainWindowCorners/macOS_26_SDK is
red. It is red alone on origin/main
|
||
|
|
532d054bee |
sessions: every Cursor row has a delete, and the right-hand column lines up
ysm119 (Discord), Sessions page, Cursor tab: some rows had a delete and
some had none, and the time / "N sessions" column stood at a different x
from row to row.
Causes:
- Delete: listAgentWith set Deletable = Deletable(agent) && !ReadOnly, so
every editor-transcript row (read only) came back deletable:false, and
client.js drew .sm-del only for deletable rows.
- Alignment: a folder adds its ⋯ only when it has actions, and a session
row's Resume / terminal / Continue in / delete come and go per row, so
.sm-when, .cost and .num moved with them. "Copied" is wider than
"Resume", and at <=600px the cost line wrapped at different places.
Change:
- rowDeletable decides per row. An editor transcript the editor no longer
keeps (no state.vscdb, or it was read and has no composer for that id)
is "loose" and deletable: Delete trashes only its <id>/ folder or
<id>.jsonl/.txt, never state.vscdb. A chat the editor keeps, or a store
that can't be read, stays undeletable with undeletable:"cursor-editor".
- In an agent magpie deletes from, every row has its delete. One it can't
delete is aria-disabled, says why in its title, and a click shows the
reason in the status line and sends nothing (en, zh, zh-TW, ja, de).
- A row without Resume, Continue in or a terminal, and a folder without
its ⋯, keep that room with an inert, aria-hidden slot. Resume reserves
the wider of Resume and Copied; at <=600px the cost keeps a min width.
- docs/subsystems/gui-shell.md says so.
Run (on mote via mote-run, base f44fa2ef6; origin/main 93d5c76c0's 3
commits since touch none of these files):
- go test ./internal/sessions: ok. go test ./internal/gui: ok except
TestMainWindowCorners/macOS_26_SDK, an AppKit titlebar red on macOS 27
already filed as #3949.
- gofmt -l clean; go vet native, GOOS=linux -tags nogui, GOOS=windows ok.
- New sessions-cursor-align.test.cjs: 10/10 (chromium + webkit x en, zh,
zh-TW, ja, de; widths 1100/660/420, hover, Copied).
- Sessions GUI set (sessions-*, session-*, gateway-conversations,
gateway-mode-sessions, account-mask-sessions, header-session-hint,
routing-session*, routing-ctx-sessions, usage-session*, i18n-keys,
gui-de, gui-ja, gui-zh-tw): 728/728, and 728/728 again after the
rebase onto
|
||
|
|
93d5c76c0d |
router: an agent with many tools is given them on demand
ArvinCharl on X: the MCP router's tools fill the context. An agent that
doesn't search its MCP tools itself (all but Claude Code, Claude
Desktop, Codex and Pi) sends every tool's whole schema on every
request. Given more than 10 router tools, such an agent now lists two in
their place: find_tools (matches by name and description, the first 5
with their inputSchema, 15 more by name) and call_tool (runs one by
<server>__<tool>, its bare name, or arguments sent as a string; an
unknown name is told the close ones). The instructions still name every
server and its tools, and a tool called by its own name still runs. The
request log names the tool call_tool ran. The address for any other app
lists every tool, since which app connects isn't known.
Library → MCP gains a "Tools on demand" toggle (settings
routerAllTools, kept by KeepOwn and the settings API); turned off,
every agent gets every tool whole as before.
Run on mote (after the rebase onto
|
||
|
|
083821dc96 |
plugins: a search entry can use the plugin's own sign-in, with its own rests
Asked for by axelburks on Discord. A plugin's search hook entry can name
a provider its own auth hook signs in to, `auth: "<provider id>"`. It then
takes no key. The host picks an account, renews it under `fresh` (the wait
counts within the search's time), runs the hook in `inScope`, and gives it
`ctx.getAuth()`, which returns that account's sign-in. A token the hook saves
with client.auth.set goes to the same account.
The gateway (askSearchSignedIn) asks one account at a time. It takes the
accounts that are on, in the order the provider's model requests take them
(accountsOn, now shared with fallback.go), and puts an account resting from
a search refusal last. A refusal rests only that account's search
(restSearchKey "account <key>"), never its models' rest (restingUntil). Every
attempt gets its own request-log row. An entry without `auth`, or naming a
provider the plugin doesn't sign in to, is a keyed entry as before, with no
getAuth. In Settings → Search, a bound entry shows "Signs in with {name}" in
place of the key field, and the row says whether it is signed in and how
many accounts are on (every language).
Docs: reference.md (with an example), plugin-runtime, plugin-tools and
provider-plugins.
Run on mote at
|
||
|
|
f44fa2ef6a |
sessions: gateway mode lists only the gateway's sessions, never this computer's agents' files
paultian on Discord: magpie web in gateway mode, on a machine with Claude
Code and Codex installed, listed that machine's own sessions beside the
ones other computers sent through it. Owner's call (via the lead): keep
Sessions in gateway mode, scope it.
- sessions.OwnOff (set by the gui to ownSessionsOff): while it holds,
currentReads answers "none", Found and Dirs are empty, the trash lists
and restores/purges only what the gateway kept, and moving Claude
Code's folder is refused. Every route built on Reads follows: the list,
one, transcript, markdown, export, stats, overview, search, manage,
delete, carry, Usage's agent-file calls. Gateway-recorded sessions
(ledger projection, recorded conversations) are not behind the gate.
- ownSessionsOff: magpie web's page, and Settings' gateway mode On, or
Automatic with --gateway or no agents found (looked at once per 30s,
and again on another HOME/PATH). A turn of the answer resets the
sessions' caches and stats; the gateway-mode route does it at once.
- /api/sessions/reads says gateway:true: the page asks nothing, its empty
state names the gateway's sessions (en/zh/zh-TW/ja/de), and Settings ›
Privacy leaves out Agents' session history.
- The gateway-mode subtitle (5 languages), docs/reference.md and
site docs/docker.html (en/zh/ja) say Sessions stays and what it lists
(they said there was no Sessions tab, which was already wrong);
docs/subsystems/gateway-sessions.md has the design.
- Tests: Handler marks the process as magpie web for good, and 13 tests
served magpie web's page, so a later test's sandbox could be in gateway
mode by itself. webPageHandler ends the mark with the test, and
TestWebPageHandlerEveryWhere fails on a direct Handler(webHost{...}).
Ran (mote, at this tree rebased on origin/main):
- TestGatewayModeListsNoOwnSessions: red on the old code, green now.
- gateway-mode-sessions.test.cjs: chromium + webkit, en 900/390, zh,
zh-TW, ja 420, de 390: 36/36; red on the old client.js (every case).
- GUI files the change reaches (gateway-mode*, sessions-*, session-*,
privacy-*, usage-sessions-*, i18n-keys), both engines: 657/657.
- TestCoreScriptBudget ok.
- go test -shuffle=on ./internal/gui ./internal/sessions: sessions ok;
gui ok but TestMainWindowCorners/macOS_26_SDK, red the same on
origin/main
|
||
|
|
2f726b1f95 |
gateway: a request its vendor's risk control refused isn't sent on to the provider's other accounts (_teamtaylor_)
_teamtaylor_ on Discord: WorkBuddy's risk control spreads across accounts that send the same request, and magpie sent one request on from account to account until its tries ran out, so each account was restricted in turn. The gateway already read the refusal (WorkBuddy's 403 11140 as the plugin words it, provider.WBRestrictedHint; ZCode's 3012, ZCodeRestrictedHint) as failRestricted and rested the account 2h, but the candidate loop then went on to the next candidate, which is usually a sibling account. Now such a refusal (riskRefused: failRestricted and not a remote magpie's) walls the provider off for the rest of the request: its other accounts are dropped from the candidates (elsewhere), from busyNow's replan rounds and from roomy's left-out list (elsewhereWeighed). A group's other provider is still asked; with none left the agent gets the refusal. The last candidate's restricted refusal now rests the account too (before, only a non-last one did). Generic: any plugin ending its error in either hint gets it. The workbuddy plugin needs no change (it does no cross-account retry of its own). Run (on mote, through mote-run): - go test -count=1 -timeout 45m ./internal/gateway: ok (727s), before the rebase onto origin/main |
||
|
|
43849d51c3 |
routing: By session heads a session by its title, its folder quieter beside it (flandern1211_58540 on Discord)
Routing's By session headed each session "Claude Code · folder · title",
and with no title only the folder and id ("路由这里的会话名只能看到目录名和
会话ID吗"). Now the head is the agent and the session's title on one
line (whitespace folded), with its folder after it in a quieter .dir; with
no title the folder stands in, and with neither the id. The tooltip keeps
the title, the folder and the id.
The title comes from what magpie already reads, no second reader:
sessions.Titles (the agent's own title, else its first prompt) and Codex's
name index, and where both find nothing, the first prompt the gateway
recorded for that session (sessions.GatewayTitler, the title the Sessions
page shows for it), looked up under the agent the page names and the one
the gateway records it under (usage.AgentOf). A Codex thread Codex never
named now goes to sessions.Titles as a codex: key, so its rollout's first
prompt names it. withGatewayTitles and codexReadableTitles in trace.go.
Nothing is read that the Sessions page doesn't show already, and nothing
leaves the local GUI.
Tests: TestSessionTitlesFallBackToFirstPrompt (new): an unnamed Codex
thread gets its first prompt, a named one keeps its name, an unknown id
stays out, a pi session known only to the gateway gets its first words.
routing-session-folder.test.cjs follows the new head: title then .dir,
the first prompt on one line, the folder said once, the id with neither,
nothing clipped (chromium and webkit, en zh zh-TW ja de, 1100 and 420px).
Run on mote via mote-run, at origin/main
|
||
|
|
0f1b40bbc4 |
gateway: a reply in flight shows on Routing how much has arrived and roughly its tokens (#4951, Canda15)
A long or reasoning reply looked stuck on the Routing page. A request still out now shows, on its row and beside the account answering it, the bytes the agent has had, "≈ n tokens" once a rate is learned, and how long ago content last came; after 15s with no content the account's dot stops pulsing. Nothing stays once the request is done. Ported from Canda15's 7f7bdb189 (github.com/Canda15/magpie), the idea and the per-protocol content extractors kept, the hot path and storage reworked: - every write to the agent passes captureResponseWriter.Write, which calls liveRow.observe; the row hangs on the request's inflight (an atomic pointer), not a context value made per request - rates are in memory only (256 pairs); the fork wrote a JSON file under the estimate lock on every finished request - a whole JSON reply is counted in bytes only: the fork held and decoded up to 8 MiB of it at the end; a stream is cut into lines in place, only a line cut by a write's end is copied, a line over 1 MiB passed over, and each event decoded once (the fork ran json.Valid then Unmarshal) - the reply's kind comes from its first byte, not a header read on every write; the keepalive check allocates nothing (the fork split each write) - everything a row counts is under its own lock, and inflight.tr is read under f.mu; the estimate is in float64 (the int64 product overflowed) - the route's Seq is bumped on every write and traceGather batches the wake-ups; the fork's global throttle could drop the last update before a pause - learned only from a streamed reply that did not fail and had the vendor's output tokens - left out: the finished row's "Received" metric and the ended caption (layout restraint; an ended row has its own metrics), a duplicate "Received" i18n key, the receive-monitor doc (the design is in gateway-routing.md now), the fork's xmod and Windows CI commits The Routing plugin and i18n.js are outside TestCoreScriptBudget. Run on mote at this head unless named: gofmt -l; go vet (darwin), GOOS=linux -tags nogui and GOOS=windows go vet ./...; go build ./...; go test -race on the live tests; go test ./internal/gateway ./internal/gui (gateway ok; gui red only on TestCoreScriptBudget, #5139, 1533907 > 1533802 before this change and untouched by it, and TestMainWindowCorners/macOS_26_SDK, #3949); routing-live-bytes.test.cjs and i18n-keys in Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and 420px (24/24); every routing-* and panel-routing* GUI file with i18n-keys in WSL Linux (Chromium all green; WebKit reds in 12 files, the same class at origin/main |
||
|
|
9095fd82d8 |
gateway: a conversation kept for its cache is asked again once on a passing 5xx before it moves (jiabubu)
jiabubu on Discord: a channel that errs once and answers a moment later had the conversation moved off it at the first error, under every rule, and the next one was sent it all uncached. Only the last candidate left (or Strict's lone one) was ever asked again. Now when the conversation is kept where it is (Affinity.Kept: Auto with a warm cache, Session, or within a turn) and that key or account fails in a way that passes (busy: overloaded 503/529, another 5xx that says nothing of quota, 408), and not as a 429, quota, refusal or sign-in, it is asked once more after retryPause (or a Retry-After up to longestPause) without resting. Once per request; failing again it rests and the next is asked as before. A conversation nobody answered yet, or under Stays Off, moves at once (keptAgain in affinity.go). The trace marks the try (Try.Kept) and the Routing page says it was asked again for what its vendor cached, not "nobody else is left to ask", in en, zh, zh-TW, ja and de. TestFixedMemberEffort and TestHeldRuleFailsOverWithinItsMember had a kept member fail with a lasting 500; they now expect it asked once more (kq1 kq1 kq2) before it moves, the outcome unchanged. Run on mote (mote-run): - TestKeptConversationAskedAgainBeforeItMoves (7 cases: Auto, Use before expiry, Session, failing twice, 429, new conversation, Off), TestFixedMemberEffort, TestHeldRuleFailsOverWithinItsMember: ok. - go test -count=1 -timeout 45m ./internal/gateway/: all ok but TestGroupBackupStandingInWhileTheFirstIsBackAndBehind and TestGroupMemberPutFirstOnItsMeritsKeepsItsCache, red with keptAgain switched off too: #5209. - routing-kept-again.test.cjs: 20 of 20 (chromium + webkit, en zh zh-TW ja de, 1100 and 420 wide). - GUI routing-*, group-*, i18n*, gui-* (2967 tests, concurrency 4): 42 red, all in files this doesn't touch; 14 of those files alone: 28 red, and the same files at origin/main |
||
|
|
7dd2434d31 |
remote quotas: a key with Quotas on but told no card shows why too (yi_time)
|
||
|
|
c03dee7e3e |
agent: LiveAgent, magpie's models in its model picker (xiaoxiaofei. on Discord)
xiaoxiaofei. asked for LiveAgent (Stack-Cairn/LiveAgent, v2). LiveAgent 2 is a Tauri app that runs its models through K-brain, a Go backend it starts as `k-brain backend -data-dir <root>`; every provider lives in <root>/config.json (JSONC, Pi's provider shape). Root: $LIVEAGENT_HOME, else $K_BRAIN_HOME, else the folder ~/.liveagent/data-dir.json points to, else ~/.liveagent, on every OS (LiveAgent's data_home.rs and kbrain_backend.rs, K-brain's internal/config and internal/storage). Connect adds providers.magpie: type claude_code + api anthropic-messages (what LiveAgent's own settings write for an Anthropic-compatible provider), baseUrl the gateway root (K-brain appends /v1 and posts /messages with X-Api-Key), the key naming LiveAgent, activeModels null, modelOrder in magpie's order, models sorted by id with display name, window, output limit and input [text, image]. K-brain decodes with unknown fields refused, so only its fields are written. A default or compact model still K-brain's endpoint-less demo model1 becomes magpie's first; the user's own pick stays. Through a sync the user's name, the models they turned off, their order, K-brain's metadata and a model's own displayName stay; a new model is on and last; nothing to change writes nothing. A file K-brain wouldn't read as providers (not an object, providers not an object, top-level models, a bare provider) is left alone. Disconnect takes the entry out, puts picks back to K-brain's default, gives a file left with no provider K-brain's demo back (its CLI restores config.json.bak, which could hold magpie's, from a file with none), and removes a file holding only what magpie made. LiveAgent's backend holds the settings and writes them whole on any change, so a change is refused while liveagent or k-brain runs (macOS/Linux; the notice says to quit it first, in every language). Logo: the app's own 64px icon (src-tauri/icons/64x64.png, MIT) in an SVG. Run on mote at this tree: - gofmt -l clean; go vet ./internal/agent ./internal/agentenv for darwin, linux (nogui) and windows - go test -tags nogui ./internal/agent -run 'LiveAgent|GatewayKey|ListsModels' ok; ./internal/agentenv ok; ./internal/gui: only TestCoreScriptBudget red, which is red on its base too (app.js untouched here; #5139) - GUI icon-tile, i18n-keys, agent-notice-lang, gui-zh-tw, gui-ja, gui-de: Chromium 27/27, WebKit 27/27 Broken by hand on mote, each red: the user's activeModels not kept (TestLiveAgentProvider "activeModels after sync [], want [...]"); the demo provider not put back (TestLiveAgentMakesItsFile "emptied file"); the demo default not replaced (TestLiveAgentProvider, TestLiveAgentMakesItsFile). Real use on mote (sandbox HOME and LIVEAGENT_HOME, this magpie on 127.0.0.1:3562, a fake Anthropic upstream on 3561, LiveAgent 2.0.5's bundled k-brain from the release dmg): - k-brain backend's first start wrote config.json as {}; magpie liveagent magpie then wrote providers.magpie and the default pick - `k-brain run "Reply with exactly: pong"` (K-brain's CLI, same config and routing code) answered "pong"; the upstream saw POST /v1/messages from magpie - the backend LiveAgent starts listed magpie's model in /v1/models with it as the default, and its /v1/text/generate answered "pong" through magpie - with k-brain running, connect/disconnect were refused with the notice; after it quit, disconnect removed the file magpie made Not tried: LiveAgent's window itself (its model picker was not opened; the backend's API it reads was); LiveAgent on Linux or Windows; a real vendor reply (fake upstream). |
||
|
|
0a5dc40abc |
gateway: a group's trusted Claude, GPT and Gemini thinking streams as it comes, a refusal or error after it going to the next member (#4166)
A try whose model's vendor may refuse after its reasoning (#248) had its reasoning held while another candidate could answer, whatever the member had answered lately. Through a routing group Claude Code saw a Claude member's thinking only with its text, all at once, and never its "thinking with <effort> effort". waynesguan measured it on one WorkBuddy account: `workbuddy claude-opus-5.5` alone, first thinking at 3.66s; through the group, all 67 thinking deltas with the text at 17.25s. Ported from waynesguan's 71aacaa (on |
||
|
|
e7b0c398ee |
sessions: find a ZCode title by its gateway id (#5195)
ZCode sends its session id to the gateway without the sess_ prefix stored in its database. Routing asks Titles with that bare id, gets no title, and falls back to the folder name even though the Sessions page can show the real title. Titles treats zcode:<id> as an alias for zcode:sess_<id> when it reads local session files, and returns the title under the key Routing asked for (the sess_ key too, which callers ignore). A regression test uses the database id shape ZCode writes and the bare request id it sends. Ported from Flandern's b1a952b73 (fix/zcode-routing-session-titles on flandern12111/magpie), code and test unchanged, reviewed line by line; the body is rewritten (the original had literal \n's), and gateway-sessions.md says it. Run on mote via mote-run, at origin/main |
||
|
|
70a98dd85c |
routing: a long Accounts and keys shows its first rows, the rest behind Show N more (ferock4669, iyou00 on Discord)
With many keys the Routing page's Accounts and keys ran on and on: each card held every window, the models it answered and a meter. Now a card keeps its name, one line of what is left (or its rest) and how it fares, with Try now or Sign in again when it needs one. The models it answered are in its tooltip under its id, and a subscription's other windows are on hover over its figure. A list longer than 8 rows shows the first 8 and puts the rest behind "Show N more" at its foot (kept across a reload in magpie.routingActsAll). Never behind it: a row to sign in again, a resting account or model, failures with no answer, a remote whose allowance can't be read, rows under a fold the reader opened, and the heading of a provider with a row shown. Two more alone aren't folded. The button clicked stays where it is on the screen. "View usage" beside it opens Usage's Overview, where each account's card says it all, without making that tab the reader's own (window.openUsageOverview). The foot writes only what changed, so an idle page writes nothing (routing-live-calm). Tests: routing-acts-compact.test.cjs (new; chromium and webkit, en zh zh-TW ja de, 1300px and 420px). routing-account-windows, routing-read-allowances, routing-wallet-lapse, routing-accounts-narrow and routing-columns follow the card's new shape and the foot. Run on mote via mote-run, worktree based on origin/main |
||
|
|
c4245c4c20 |
gateway: a Messages body's tools with a root union go folded to every upstream
ziko on X (11-04): ZCode on Zed's subscription, Claude Sonnet refused every request. Six of the GoAnyAPI MCP server's tools (goanyapi_adsense, the 36th, among them) have a oneOf at their input_schema's root, ZCode sends every tool with every request, and Anthropic's API turns such a request away: "input_schema does not support oneOf, allOf, or anyOf at the top level". Cause: a request translated to Messages always had its tools folded to an object root (objectSchema, #1271), but a Messages body relayed as it came (ZCode or Claude Code to an Anthropic-protocol provider, the Zed plugin's models among them, whose plugin provider has an Anthropic URL) never was: foldsRoots and objectRootsBody handled Chat and Responses only, so neither the first ask nor the retry after the refusal folded it. Change (object_root.go): - foldsRoots is true for every Anthropic-protocol relay, from the first ask, as a translated request already was. - objectRootsBody takes a Messages body: a client tool's input_schema goes through provider.ObjectRoot; a server tool (no input_schema) and a schema with no root union go as they came. The translated path (to != Anthropic guard at gateway.go's objectRootsReq) is unchanged, so nothing is folded twice. - docs/subsystems/gateway-routing.md gains the root-union bullet. Test: TestMessagesRootUnionFolded, POST /v1/messages (stream) to a relay with an Anthropic URL whose fake refuses a root union with Anthropic's own wording: the union tool goes as an object root on the first ask, its branches' properties merged; a plain tool's schema goes unchanged, and so does a body with no union. Run on mote at |
||
|
|
14f6d10de0 |
routing: a remote's Claude card whose read failed says so on its row, not nothing (yi_time on Discord)
remoteWinsOf ( |
||
|
|
ef6bd155ff |
provider: a remote magpie that holds this key says so, where its Claude card went missing with no word (yi_time on Discord)
yi_time on Discord: "没变化 还是不显示通过局域网添加的Claude额度". |
||
|
|
00d8aac596 |
routing: Free quota by expiry spends the soonest-lapsing free quota first (wowbbs)
wowbbs (and shamen_xiaohong) keep check-in free accounts in one group:
WorkBuddy CN x2, MiniMax Code, TraeCode CN and Qoder CN. They asked that
the group spend the free quota that lapses soonest first, go on to the next
when one is used up or has lapsed, and use a paid account only when no free
quota is left.
This adds `expiring` (provider.FreeExpiring, routes.FreeExpiring). It is a
group's only, picked in the Routing page's group menu, with
`magpie group set <g> routing=expiring` or in the TUI. Nothing changes for a
group or provider that doesn't pick it. A provider keeps refusing it, as it
refuses `cheap`.
- routes: Seat.FreePlan and Strategy.ByPlan. FreeExpiring has three tiers:
- free seats (Free, a model at no cost, or FreePlan) by Expires, the
earliest of the window renewals and Lapse, to the hour; an unknown
expiry goes last and ties keep their listed order;
- then the paid seats, as Smart orders them;
- then the spent and resting seats, by when they come back.
- provider.FreePlan reads an account's plan word: free, trial, 免费, 试用,
体验, 體驗.
- gateway: weighRouted fills FreePlan when the strategy asks. The trace's
Weighed rows gain `expires`, so the Routing page's story can say "its free
quota is lost soonest, in 1d 2h". There are also lines for "a free one with
no expiry told" and "no free quota left, so the paid one".
- GUI: an option in the group menu, the mode line, the story lines, and
i18n in zh, zh-TW, ja and de. app.js only adds `expiring` to ROTATION,
paid for by a shorter comment beside it, so the core is 11 bytes smaller
than at its base.
- docs: gateway-routing.md (order of keys and accounts) and
plugin-runtime.md (Seat and Strategies).
Plugins whose usage doesn't say when their free quota lapses got issues
rather than edits:
- magpie-community/plugins#718: Trae sums its packs; the soonest end comes
from any pack, spent or past, and there is no runsOutAt.
- magpie-community/plugins#719: Qoder's plan is the raw userType
personal_standard, which doesn't read as free, and its add-on, shared and
dedicated pools have no expiry.
WorkBuddy (Free plan, resetsAt and runsOutAt) and MiniMax (Free, runsOutAt
on credits) already report what this needs.
Run, all on mote via mote-run at this tree (base
|
||
|
|
0e804be29b |
provider: requests missing together list logins once, and a plan asks OwnPaused of the held list
Every request's routing plan lists the agent's accounts (perKeyEvery asks AlsoOn, and OwnPaused of the signed-in one), and each list took logins.json's lock. A write in a request (a token refresh) dropped what was held, and every request then in flight listed again, one after another on the lock: 20 requests queued on it in #5104's dump. And OwnPaused was never held: each ask was its own read under the lock. heldOf now builds a missed key once a request: the first caller builds, the others wait for it and take its value. OwnPaused goes through heldOf under its own key, so a write lists it anew as it does Logins. Ported from ggbdpq's ecb829370 (#5104). Changed from that patch: - A waiter takes the build only if nothing changed while it ran: held's generation, filememo's generation (settings.Save tells only filememo) and the environment. The patch skipped heldFreshLocked on wake and kept a build made across a filememo write, so a later caller could get settings from before the save. - A caller outside a request (no Hold) never joins a build; it builds fresh, as on main. - The wait is bounded (heldWait, 5s). A stuck or panicking builder, or one waiting on a lock its waiter holds, can't hang the request; the waiter builds on its own. - When a write came during the build, waiters go round again (up to heldRounds) so one of them builds and the rest wait, instead of all rebuilding at once. - With heldFor 0 a waiter takes the builder's own result (it is not kept, so the patch's waiters found nothing and built again). - New tests: TestHeldWaiterBuildsAgainAfterAWrite (Changed and filememo.Forget), TestHeldWaiterTakesTheBuild, TestHeldWaiterNeverStuck (stuck builder, panicking builder). providers-accounts.md says it. Run (mote, at the pushed tree): - The patch's two tests on main's product code: red 3 of 3 ("20 listed before the first was built", "OwnPaused was not listed once a request"). - go test -race -count=20 -cpu 1,2,8 -run 'TestHeldWaiter| TestLoginsMissedTogetherListedOnce|TestOwnPausedListedOnceARequest| TestLoginsListedOnceARequest|TestHold' ./internal/provider: ok. - go test ./internal/provider: ok. go vet for darwin, linux, windows; gofmt -l clean. - Nesting: an instrumented run of provider, gui, agent, gateway and profile recorded every heldOf inside another build and every heldOf made under a file lock. No heldOf key reaches itself (only heldFrom, untouched). Under logins.json.lock only "migrations" is asked, and its build takes no lock and asks no key; under caller-keys.json.lock the keys asked take logins.json.lock only. No build takes caller-keys.json .lock. So a waiter never holds a lock its builder needs. - Half-written files: unchanged readers. logins.json is written through temp+rename, sharedLogins keeps the last good list on a bad parse, another process's write is seen when loginsMu is taken (Look). Broken by hand, each red: - No filememo check on the build: TestHeldWaiterBuildsAgainAfterAWrite got "before", built 0 times. - Unbounded wait: TestHeldWaiterNeverStuck timed out at 60s. - No take of the builder's result: TestHeldWaiterTakesTheBuild built again. Not tried: a live load of parallel Claude Code requests; two magpie processes contending for logins.json; Windows and Linux test runs (vet only). #5104 Co-authored-by: ggbdpq <67929842+ggbdpq@users.noreply.github.com> |
||
|
|
129baeca01 |
gateway: the same 5xx from two accounts in one request rests neither (mycf_711)
mycf_711 on Discord: 127 of one provider's 128 503s in a day were
"AIError AI服务异常" word for word, all one agent's request with an empty
tool schema the upstream always refused. forbiddenAlike/unforbid
(plugins#243) only took plain 403s, so each such request walked every
account of the provider into backoff, and other agents' normal requests
then found every account resting.
A 500/502/503 that says nothing of why (plainUnavailable: failOther, not
overloaded, no proxy down, not codexReset, not the protection refusal, not
"did not stream", some words) now joins forbiddenAlike when:
- a second account of the same provider, model and reasoning gives it in
the same status and words, request/trace ids left out (refusalWords);
- and the provider answered another request within answeringLately (5m,
noted in servedCandidate as routed.answered).
Then neither rests, the first one's rest and failure count are taken back,
the other mates go last (matesLast, so a group's other members are asked
first), and the last one left isn't asked again after a moment
(sameRefusal; before, the two-account case re-sent the request 13 times).
Kept as before: one account's 503 alone rests it; 503s in other words are
each account's own; a provider that answered nothing in the last 5 minutes
may be down, and its alike 503s rest as before, so an outage is backed off
once 5 minutes have passed since its last answer. A 403 is still alike only
to a 403. Overloads keep their own short model rest.
Ran (mote, via mote-run, at this tree on 6b47bce67; after the rebase onto
|
||
|
|
f8987ce617 |
gateway: Qoder 1.1.82's requests find their session in Qoder's own files
qodercli/qoderclicn 1.1.82 (11-03) stopped sending session-id to a
provider of the user's own, and nothing else in a request names the
session (coderlee233 on Discord). Its requests were recorded with no
session: the Sessions page lost the conversation's title and showed each
title and suggestion side call as a row of its own.
A request from Qoder or Qoder CN (by its agent token) on this computer
that names no session is now matched against Qoder's session files
(sessions.QoderDir/projects/<project>/<id>.jsonl and its subagents'
files): the session whose typed prompts (user lines with humanInput /
origin.kind human) appear most in the request's user text wins, the file
written last on a tie. Qoder's <system-reminder> blocks are left out. A
side call (no tools) no file matches yet is held up to 600ms, since the
first title is asked ~0.1s before Qoder writes the file. The id found
goes on the request as session-id, the header 1.1.81 sent, so it is
grouped and titled as before. A request that names a session (older
Qoder's session-id, X-Magpie-Session) is left as it came. Files are read
incrementally; a half-written last line waits for the next read.
Run (on mote, rebased on origin/main
|
||
|
|
6b47bce670 |
cli: magpie model compact <agent> sets an agent's own Long conversations
|
||
|
|
75e30625f5 |
plugin: a command that serves no pages moves a page's service off the app's port (#5187)
MYCF711 (#5187, Windows, 0.1.2901): magpie plugin update run while the
app runs hung with no output. Its host loads every plugin, and
page-chat's service waits for port 3477, which the app's host holds:
each CLI command that starts a host waited ~6s on it, then kept trying
the port every second in the background, so it could take 3477 from
the app's host when that restarted after the update.
Now magpie run with a command that serves no pages (anything but the
app, tray, tui, web, serve, a bare magpie or a magpie: link opened in
the app; servesPages) sets plugin.ServePages(false), and its host hands
a plugin whose magpie.page.service names an option a free port of its
own in that option (hostOptions). The plugin's other parts load at once
and the app's port is left alone. plugins.json is not changed, and a
service no option moves is started as before. The class, not
page-chat: any plugin page service declared with an option.
Run, at base
|
||
|
|
3eb2bda4f2 |
settings: Codex, Claude Code and Grok Build each take a Long conversations of their own (molianyin4227 on Discord)
molianyin4227 (Discord #help): models differ, so one compaction size
for every agent fits none; they asked for Codex, Claude Code and Grok
Build to each have their own, falling back to the shared one.
- settings.AgentCompacts[agent] {At, Full} for the agents that write a
compaction window (CompactAgents: codex, claude, grok); Settings.
ForAgent(agent) lays it over CompactAt/FullContext for that agent's
readers only: codexcat.entriesAt, provider codexListed, Claude Code's
writeCompact and desktopPlan, grokModelTables, the route list's
buildModels, Codex's window line (api.go) and Tuned for you
(gui/tune.go, agent/tune.go). A model's or provider's own Compact at
still comes first. An agent with none follows the shared value, so
nothing new is written for it, and an agent outside the three has no
such key and is refused (provider.SetAgentCompact).
- POST /api/settings/agent-compact {agent, own, full, at}; own false
takes the agent's value away. settingsapi.Merge keeps the map.
- GUI: a row "Long conversations in <agent>" under Long conversations,
in the agent's opened row and its sheet: Every agent / Compact at N /
Full window (segs, no select), a size box when Compact at. It lives in
agentcompact.js, imported when the agent's settings hold Long
conversations, then put in synchronously (an async put-in after a
redraw moved the page in chromium: codex-memories-settings' scroll
check). It draws again only when its own values change. i18n in
zh, zh-TW, ja, de.
- Tuned for you's Use on an agent with its own value changes that one,
stashed under tune.long.compact.<agent>; Undo puts it back.
- codex-memories-settings' "no Codex" check counts Long conversations
alone again (:not(.agent-compact)) and waits for the new row.
- docs/subsystems/agent-wiring.md: a row for it.
Core size: app.js 1,311,919 bytes, 109 under origin/main
|
||
|
|
0ee424e3ee |
codex: a thread Codex 0.166 won't resume for its provider moves with Codex (毅, AcMilan on Discord)
Codex 0.166 (openai/codex#57840) refuses to resume a thread whose saved
provider isn't the configured one: "This chat uses openai, but your
current provider is magpie. Switch to openai to continue." (毅), and
"This chat uses cc-switch-official, but your current provider is
openai" (AcMilan). The rollout's session_meta provider wins over the
state DB row, and no -c override gets past it (openai/codex#58865).
Cause on magpie's side: bringOver relabelled only plain rollouts in
place. A thread Codex had packed to .jsonl.zst (a week after its last
turn) stayed on openai, so with magpie as provider it can't resume.
cc-switch-official is the id CC Switch 3.17-3.20 gave the official
account; CC Switch 4 moves those threads back to openai itself (#7948
there), but a user who left CC Switch keeps them stranded.
- sessions.MovePackedCodexThreads: packed threads on `from` updated in
the last 30 days, newest first, up to 128 MB per sync, each moved by
the existing packed rewrite with its copy kept in the trash. Rows
are checked against the file (plain absent, .zst present, meta on
`from`, same home). A state DB without updated_at moves nothing.
- bringOver calls it after RelabelCodexThreads; bringBack already
moves packed threads back.
- bringOfficial: while magpie wires Codex and Codex is on openai or
magpie, cc-switch-official threads move there, unless the user's
top-level model_provider or a profile names cc-switch-official.
- Other providers and packed threads older than 30 days are left; the
Sessions page's Move or Resume takes them.
Run (mote, at the pushed base
|
||
|
|
c7bbd3faf6 |
routing: a Claude joined over the network shows its windows in Accounts and keys (yi_time on Discord)
A remote magpie's provider row on the Routing page showed no usage, while the subscriptions above it did. The remote's cards already reach the window as /api/usage/quotas entries with `from` set (provider = <remote id>/<card provider>), but the page's cardOf/winsOf match only kind "account" with no `from`. remoteWinsOf (plugins/routing/client.js) now draws those windows on a remote-magpie row: a claude-* model row gets the remote's claude cards, gpt/codex/o\d rows its codex cards, each window prefixed by the user when several cards match. When the remote's read failed it says "Allowance unavailable — hover for why" with the error as the title (existing string, all languages), never 0. The usage comes from the machine that owns the account; no gateway change. Run (mote, no Go change): - routing-remote-windows.test.cjs (new; 5 languages, widths 1100 and 420, chromium and webkit) and routing-account-windows.test.cjs at ec697e692 on origin/main 07f02d0d9..: 44 pass, 0 fail. - Broken by hand: render call removed, and the model-family filter removed; each took the new test to 0 pass, 11 fail. - Full go test -timeout 45m ./... at ea1aab179 (same client.js, rebased on |
||
|
|
f0b99745ed |
provider: a Codex account is held on allowed false alone, as the 26.1029 app's Send gate reads it (xiaoq6285)
xiaoq6285 (Discord, Codex App 26.1029 on Windows, Plus, model_provider = "magpie", requires_openai_auth = true) answered |
||
|
|
f177c36a9b |
provider: routed Until used up, Codex's sign-in stays on the account the requests went on to
WalterAIBuilder on X (11-04): two Codex accounts, A (Team, first) and B
(Plus), routed Until used up, affinity auto, stop at cap on. A used up
its 5h window (98% cap). Codex was signed in to B, then signed back in
to A once A had room, while B's week kept being spent until it was at
100%.
Cause: returnsToFirst (internal/provider/codex_switch.go) sent Codex's
sign-in back to the first account for every routing but Claude's and a
switch-only Codex's. Routed Until used up, the gateway keeps requests on
the account it moved to (routes.Drain, internal/routes/strategies.go),
and auto affinity keeps a conversation on whoever answered last while
the cache is warm (chatGPTCold, internal/gateway/affinity.go). So Codex
and the accounts list showed A in use, with B marked to go back from,
while requests through magpie stayed on B. The GUI note under Routing
also promised "back to the first" for drain. This is the hxy920830 rule
("not use one up, then the next") missing its Drain sibling.
Now, routed Until used up, Codex's sign-in stays on the account it moved
to till that one is used up too, the same as the requests. In order and
Smart still go back to the first. The Routing note has its own drain
text in en, zh, zh-TW, ja and de. The subsystem page says so.
Old data: a user signed back in to the first stays there. A user with a
return still pending stays on the next account until it is used up, and
the "First again" mark goes away.
Not changed (filing is the reviewer's call): a provider's own accounts
have no back-to-first under auto affinity (backToFirst and
backFromStandIn apply to groups only, inOrder := isGroup && ... in
internal/gateway/gateway.go). Routed In order, a conversation that moved
to the second account stays there after the first renews, for as long as
its cache is warm.
Run on mote (mote-run), at base
|
||
|
|
d3c544ddf4 |
claude: a replayed transcript marks no earlier turn as the one to answer
The interactive mode gives a conversation no run has to a new Claude Code as its own transcript (replaySession): a user line with the messages before the last reply, the reply as the assistant line, and the turn after it typed. The user line was rendered with renderClaudePrompt, which ran historyEnd again on the cut messages, so for U0 A0 U1 A1 U2 it was history(U0, A0) + <current_turn>U1, "the turn to answer now", followed by A1, then U2 typed. U1 was answered already; the reporter saw the model answer an old question again, and say earlier tool calls had no results (愛睏柴犬阿茶 on Discord #feedback, with the analysis and the fix suggested). renderClaudePrompt is now renderClaudePromptAt(req, historyEnd(...)); replaySession calls it with the split at the end, which tells every message before the reply inside <conversation_history> and closes it there, with no <current_turn>. Every other render is unchanged. Siblings: historyEnd has two callers, replaySession (whose own split, on the whole request, is right: the reply and the turn typed after it) and renderClaudePrompt. replaySession is the only place that renders a cut slice of the messages (grep 'Messages = .*Messages\[:'). renderClaudeTurn (the typed turn) has no history marks. Run (on mote, mote-run): - go test ./internal/gateway -run TestClaudeTUIReplayMarksNoEarlierTurnCurrent: red on the old code (all 5 subtests: two turns, three turns, tool results in both turns, tool results only before the reply, the client's calls after the reply), green with the fix. - Broken by hand: put renderClaudePrompt(&before) back in replaySession, the new test went red; restored. - go vet ./internal/gateway, GOOS=linux and GOOS=windows go vet: ok. - go test ./internal/gateway -run 'Claude|Replay|Prompt|Turn': ok 124.6s. - go test ./internal/gateway -run 'Loop|Guard|Doc': ok. - gofmt -l internal/: clean. Not tried: a real Claude Code resumed on such a transcript with a real account (the change to what the model sees was checked in the transcript file only); the full suite runs after the tag. |
||
|
|
1987fe220c |
agent restart: a script run on the app's own executable is not the app (WorkBuddy's sidecar)
Northes (Discord #feedback, 11-04): WorkBuddy's Agents row kept "重启 WorkBuddy 后生效" after they quit and reopened it, and its Restart quit WorkBuddy and never opened it again. #3700 (Raters0) is the second half on WorkBuddy AI. Cause, from WorkBuddy 5.5.6's app.asar (read only) and its processes on the Windows box: WorkBuddy starts a sidecar as `<its own executable> .../app.asar/main/sidecar-entry.js --token ...` (ELECTRON_RUN_AS_NODE, detached). The sidecar outlives the app's quit and the next start reuses it, and its prewarm and `--serve` CLIs run as `<executable> .../cli/bin/codebuddy ...`. The daemon is `WorkBuddy.exe ... daemon-app-server-entry.js --stdio`. All of them match the running check's `Contents/MacOS/<exe>` pattern (and WorkBuddy.exe's image on Windows), so: - (a) findRestartable took the oldest match, the sidecar, as the app's start, so magpie's change was always "after" it and the row never cleared, however often the app restarted. On Windows the earliest start was used too. - (b) reopenBundle waited for every process under Contents/ to end; the sidecar never does, so after 30s it said "still open" and never ran `open`. Fix: runsScript(cmd, exe) tells a script run on the app's executable (a .js/.cjs/.mjs argument, or a first non-flag argument that is an absolute path) from the app itself and its helpers (--type=..., /prefetch:, -psn_, a deep link). The macOS running check and the reopen's wait skip such processes (appProcs), and the Windows check reads each process's command line (proc.CommandLine, new) and skips them too. The reopen still waits for real helpers (renderer, GPU). This is shared by every restartable app: Claude desktop, WorkBuddy, WorkBuddy AI and the Codex app. Tests (red on the old code: a copy of the base with runsScript returning false failed all three, since = the sidecar's 2h, the Windows since the sidecar's, and 6 RunsScript rows): - TestWorkBuddySidecarOutlivesQuitOnMac (WorkBuddy and WorkBuddy AI, a space in the bundle): a 2h-old sidecar and prewarm beside the app; the row is behind by the app's start, a manual reopen clears it, the sidecar alone is not "running", Restart quits then opens. - TestWorkBuddySidecarOutlivesQuitOnWindows: same, and Restart closes and ends only the app's tree, then opens it. - TestRunsScript: real Windows command lines from WorkBuddy on the box, macOS ones, and #3700's `codebuddy --serve` line. Run at this head (rebased on |
||
|
|
5957223d89 |
library: a project's skills can be given to DeepSeek Harness, in the project's .agents/skills
xingchen_c on Discord (#general, 11-04): "资源库按照项目配置能否支持一下dsh".
projectSkillsDirs left dsh out, its comment saying it reads no project
folder magpie can rely on. It does, and always has: the skill provider
every dsh profile mounts (dsh-base's cordis.patch.yml, id skill-filesystem)
scans <projectRoot>/.dsh/skills (rank 100) and <projectRoot>/.agents/skills
(rank 200), the project root being the nearest folder up from the
session's cwd with a .git, else the cwd (roots and findProjectRoot in
@deepseek-ai/dsh-skill-filesystem 0.2.1-rc.5; the same two joins in
0.0.1-rc.3, 0.1.0-rc.6, 0.1.5-rc.3, 0.1.7-rc.2, 0.2.0-rc.2, 0.2.1-rc.1
and 0.2.2-alpha.3). dsh now gets the shared .agents/skills, so the
project row lists it and one link serves it with Codex and the rest.
MCP stays as it was: dsh's servers are dsh-mcp-client rows in a
profile's patch layers (bundles, the profile's and $DSH_HOME's
cordis.patch.yml, --patch overlays; composeProfile in @deepseek-ai/dsh
0.2.1-rc.5), none of them the project's. Said in project_mcp.go and
docs/subsystems/library.md.
Run:
- mote: go test -count=1 ./internal/library/ ok (102.9s); gofmt -l
clean; GOOS=windows and GOOS=linux go vet ./internal/library/ ok.
- Broken by hand: TestProjectSkillsDsh with projects.go at origin/main
fails ("magpie knows of no folder dsh reads a project's skills from").
- Real dsh: @deepseek-ai/dsh 0.2.1-rc.5 from npm on mote, sandbox HOME
and DSH_HOME, headless profile against a fake OpenAI-compatible server.
Run in a folder with .git, a skill linked into its .agents/skills is in
the request's <available_skills>; run in a folder with no .git, its own
.agents/skills is read; run in a subfolder of the repository, only the
root's is read, not the subfolder's (filed as #5172).
- GUI: /api/library's view from library.Read with a sandbox ~/.dsh,
served to the real assets in Chromium and WebKit, en and zh: the
project card's skill rows have a dsh chip (lit where given), and the
"reads no project skills folder" line no longer names it.
Not tried: the dsh Desktop app (its own profile; the same base bundle
is assumed, not checked); the full GUI suite (no GUI file changed);
Windows copy mode with a real dsh.
|
||
|
|
83bdfe70d2 |
otlp: OTEL_RESOURCE_ATTRIBUTES and OTEL_SERVICE_NAME name the server a trace or metric came from (#5167)
Several magpie servers exporting to one collector or to Langfuse all sent
the same resource, service.name=magpie alone, so nothing said which server
an event came from. Both signals' resource now merges the standard
OTEL_RESOURCE_ATTRIBUTES over that default, and OTEL_SERVICE_NAME over
that (otelResourceAttributes in internal/otlp/otel_resource.go). Nothing
about the machine is looked up; only what the user set is sent. Neither
variable turns export on.
Ported from reyoung's 7ed03b819 (feat/otel-resource-attributes, base
|
||
|
|
cd83c3147f |
plugin: a hook's auth.set doesn't sign in again an account signed out while it ran (#5126, #5119)
Cause: a plugin hook that saves a sign-in through client.auth.set (a models list spending a rotating refresh token) wrote it into plugin-auth.json unconditionally. A listing that began before a sign-out, or before a failed move's putBack took the accounts back out of the plugin (plugin.Take), landed after it and wrote the account in again. TestMoveToPlugin's reset signs fakeco out, but a background listing set off by the step before spent a@fake's "rot-a" token again (rot-a+++++ seen in the file right after the sign-out), so the next Move saw a@fake as the plugin's own (movedAccount.Was), restored it on failure, and "the plugin kept an account of a failed move". TestMoveCutShort (#5119) fails the same way: the account Take removed came back through the same write. Not a leak between runs: the race is inside one run, and more runs only gave it more chances. It is a real bug for users too: signing out of a rotating-token account while its models are listed brought it back. Fix: inScope in host.js notes whether the account was signed in when the call began (had); auth.set skips the write under the file's lock when it was and is gone now, as renewLocked already does for renewals. Sign-in steps (signingIn) are not held to it, their account is new. Test: TestSignOutOutlastsRunningHook holds the fake plugin's models hook (new FAKE_MODELS_HOLD: marker file in, release file out) across a SignOut in a real host and checks the account stays gone, and that a hook not raced still keeps the token it saved. Run (all at this tree): - mote-run go test -count=30 -run 'TestMoveToPlugin$|TestMoveCutShort$' ./internal/provider: ok. Before the fix the same run on mote failed 3 TestMoveToPlugin + 9 TestMoveCutShort of 30 each; -count=15 of TestMoveToPlugin alone failed 2 to 4 of 15. - wsl-run go test -count=20 of the two plus the new test: ok. Before the fix: 4 + 17 of 20 failed on Linux. - mote-run go test -count=5 -run TestMoveToPlugin$: ok. - mote-run go test -count=5 TestSignOutOutlastsRunningHook: ok. - mote-run go test -timeout 45m ./internal/provider ./internal/plugin: ok (provider 171.6s, plugin 160.4s). - gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet of both packages: ok. Broken by hand: host.js reverted with the test kept: TestSignOutOutlastsRunningHook red 3 of 3 ("the hook signed the account in again"), and the provider tests red as above. Not tried: a real vendor's rotating-token plugin signed out mid-listing (the fake plugin's rot- sign-ins stand in for it); the full ./... suite runs after the push. |
||
|
|
40cfd32b0b |
provider: a Codex account with no credits and every window at 100% counts held though allowed isn't false (xiaoq6285)
xiaoq6285 (Discord, magpie 0.1.2891, Codex App 26.1029, Windows): a used-up
Plus account, no credits, 用量 showing it used up, config.toml with
model_provider = "magpie" and requires_openai_auth = true, Send grey until
Codex was switched off in magpie. Banked resets and paid credits were ruled
out (codexHeld reads neither resets nor, here, any credits). What is left is
a reading that doesn't say allowed false: codexHeld needed exactly that, so
CodexUsedUp stayed false and Sync kept requires_openai_auth, which makes the
app read the account's rate limit and grey Send.
codexAtLimit now holds: allowed false (as before); allowed not said with
limit_reached or a window at 100%; allowed true with every reported window
at 100%. Credits and the workspace-overage exemptions are unchanged and
still run after it.
Why the two cases that were false stay narrow:
|
||
|
|
d1fa254b1d |
gui: masked words and Never mask are a list, a row per word (noahhrreion on Discord)
noahhrreion: "希望脱敏词选项可以做成真正的列表,在一个小输入框里面不方便管理多个脱敏词". Settings → Privacy's Masked words was one comma-separated box. It is now a list (wordList in plugins/redact/settings.js): each word is its own row, edited in place (Enter or leaving the row saves, Escape puts it back, emptied is removed), × removes it, and the last row adds. Its sibling, Never mask under the mask actions, had the same box and gets the same list. Stored values are unchanged: redactWords and the allow list are still string arrays, saved through the same savePrefs / settings/redact-allow calls, and nothing is rewritten on open (the new test checks that opening the page saves nothing). Typed or pasted text splits as the old box did (, , and newlines, trimmed, empties dropped), so a pasted "a, b" is two rows. The Hide eye still shows every row as dots. New strings are in the redact plugin's i18n for zh, zh-TW, ja and de; the two old "separated by commas" hints are gone from the core i18n. The site's masking docs (en, zh, ja) say a row each. Run (on mote via mote-run, Chromium and WebKit): - new redact-words-list.test.cjs: 5 languages × 1100/400px × both engines, draw, add with Enter, paste-split, edit, Escape, ×, empty-and-Tab, reload; with i18n-keys 24/24 ok - redact-words-hidden, any-case, whole, mask-actions, redact-route, redact-kinds, redact-shape, settings-search, settings-sections, settings-lines-wrap, settings-hints, settings-groups, readable-focus, masking-records, mask-alert: 378/378 ok - go test ./internal/gui/ -run 'TestCoreScriptBudget|TestSettings': ok (app.js shrank; no budget raised) - screenshots light/dark, 1100/400px, both engines, looked at Broken by hand: without wordFocusBack (focus kept across a redraw) the new test goes red (waitForFunction timeout after the first add). Dropping the blur guard during a redraw (wordsRedrawing / isConnected) stays green in both Playwright engines, which fire no blur on removal; it is kept as a guard for engines that do, with no test that fails without it. Not tried: the real app on WebKitGTK / Windows WebView2; no Go files changed. |
||
|
|
43345c0ca8 | docs: gateway-routing names the GPT ids sent output_config.effort | ||
|
|
247794c613 |
codex: an account that is out takes over for other models too (reverses f37742e14)
With one ChatGPT account out and nothing to serve Codex's own model on (provider.CodexServesWhileOut false), |
||
|
|
2741b749f9 |
sessions: a codex fork's rollout-<n> turn does not end the copied head (#5090)
ownTurn ended a Codex fork's copied head at the first turn id the parent's
file didn't hold (
|
||
|
|
90bf96a23d |
search: a plugin can give a web search API (its search hook)
treeman on Discord #help asked for web search to be pluggable so users can
add search vendors. A plugin's `search` hook, {search: {<id>: {name, keysURL?,
keyOptional?, url?, execute({query, count, key, url}, ctx)}}}, adds an API to
Settings > Models > Web search as `<plugin>:<id>`. It is added, keyed, ordered,
switched off and removed like Tavily or Brave. The built-in APIs stay built in.
How: host.js collects the hook's entries (id [a-z0-9-], an execute) into
Loaded.Searches and runs one with the `search` op (timeout from ctx, an error
with a numeric status comes back as a refusal). The host notes them in
plugin-searches.json (internal/plugin/search.go); provider.AllSearchVendors
adds the noted ones of plugins that are on to SearchVendors, so Ready, check,
the CLI and the GUI list see them. askSearchAPI hands a plugin vendor to
askPluginSearch below askSearchAPIKeys, so keys, rest on 401/402/403/429,
order, the masked query and the request-log row are the built-ins' own.
Run (mote, on this tree, whose base
|
||
|
|
df7c94bdf5 |
gateway: inline image descriptions survive a restart (#5121)
The vision description cache (Server.sights) was in memory only, so a restart, update or handover described every image of a long conversation again (62 calls in 2.5 minutes in the report). Completed descriptions of inline images are now appended to vision-cache.jsonl (0600) in the config dir before their waiters are released, and New restores them under the same 2048-entry LRU. URL images stay in memory (their bytes can change); failures are never written. Appends and compaction go through a file lock, a corrupt or truncated line is skipped (and backed up before compaction), and shutdown waits for pending saves within the drain window. Patch by MYCF711, applied clean on main. One change: the Unix permission test now makes the config folder before it pre-creates the file (it failed on a fresh sandbox, where the folder doesn't exist yet). Run (mote, at this tree): go test ./internal/gateway filtered to the vision/sight/cache tests, ok; gofmt -l clean; go vet ./internal/gateway for linux and windows, clean. Broken by hand: saveSight call removed from see(), TestDescriptionSurvivesGatewayRestart red (2 descriptions, want 1), green again with it back. Windows: the same filtered tests on xiaomi-gpu via win-run. Not tried: full go test ./..., go vet ./... for linux (wails cgo doesn't build off-platform on mote), a real process kill or a real handover, a real gateway with a real vision model. Co-authored-by: MYCF711 <323101370+MYCF711@users.noreply.github.com> |
||
|
|
6673171595 |
update: the app and magpie web follow each other's update (visamzh on X)
visamzh on X: with the desktop app and magpie web both open, an update
from either side left the other still offering it ("↑ 更新") until it was
quit by hand.
Cause: the app and magpie web are two processes over one program, each
with its own updater (state, download, latest) in memory. One restarting
to update puts the new binary in; the other is told nothing. Its
replaced() (the binary on disk is no longer the one it started from) was
read only on a click of its own Update or on magpie update's gateway ask
(restartBeside), which reaches only the process serving the gateway. And
a browser's page reloaded (backAsNew) only after a restart it asked for
itself, so magpie web's tab kept the old page and its pill even once
the process under it was new.
Fix:
- followReplaced (update_beside.go): every updater stats its binary each
5 s and, once another magpie replaced it, restarts into it through
restartBeside, once: at once when idle, else after the gateway's
requests (waitIdle), as for magpie update's ask. Not for what this
process put in itself (installed, set by install, cleared by
wontStart), not twice (followed), not for a build that isn't a release
(make dev, go build rebuild in place). It stops with backendCtx, so a
copy left draining after a handover doesn't look.
- waitFor (update_wait.go): a wait for the gateway restarts into what
another magpie put in whatever the feed says now; before, a feed out
of reach or a "latest" answer ended the wait with nothing restarted.
- boot.js names the version that served the page (bootPrefs.version);
app.js's servedAnew reloads a browser's page (web) when /api/update's
current names another, on the reads it already made (load, focus, back
into view) and once a minute while shown. The app's own windows come
back with their new process and are left alone.
- docs/subsystems/gui-shell.md describes it.
Run (mote, through mote-run, at
|
||
|
|
0e1054ce19 |
statusline: the gateway serves Claude Code's status line to another computer (steven_4422)
steven_4422 (Discord) runs magpie in Docker and Claude Code on the host.
The status line square writes the host's settings.json, which the
container can't reach, with a command naming a binary inside the container.
GET or POST /v1/magpie/statusline answers the line `magpie statusline`
prints, as text/plain, so the host needs only curl:
curl -fsS -m 1 -H 'Authorization: Bearer <key>' --data-binary @- http://<host>:3425/v1/magpie/statusline || true
Claude Code's stdin JSON (session_id) adds the model, as /v1/magpie/route
does; ?session= and ?only= work too. The renderer moved to
provider.StatuslineText, shared by the CLI and the endpoint. A caller that
isn't this computer needs a gateway key (lanGuard, unchanged; the handler
also refuses a non-local caller without one). A read-only key is allowed
(GET and POST in readOnlyRoutes) and gets the windows without the model; a
key held to budget, models or accounts sees only its own (scopeQuotas).
corsGuard and origin checks are untouched.
magpie web shows the command in Settings -> About (en, zh, zh-TW, ja, de).
Docs: reference.md, agent-wiring.md, gateway-routing.md, docker pages en/zh/ja.
Run at this head (rebased on
|
||
|
|
59c1306035 |
claude: an auto-mode client's tool loop keeps its interactive run (#4804)
Auto mode's safeguards change with every tool batch: prior_turn_context grows by the turn before. An interactive Claude Code run read them once, from CLAUDE_CODE_EXTRA_BODY in its environment as it started. So a tool loop either started the run again (the whole conversation written to the cache again), or kept it and sent the classifier the context it started with, which is not what real Claude Code sends. Each turn's safeguards now reach the running run: - The bridge writes the extra body to <run tmp>/guard.json and hands its path to the helper as MAGPIE_CLAUDE_GUARD (mapped for WSL in newTap). - tap.js, on each /v1/messages request whose string body has a safeguards key, reads the file and puts its safeguards in the body. It also sets CLAUDE_CODE_EXTRA_BODY to the file's text, so Claude Code's own later reads agree. The first time, it writes guard.json.live. - setSafeguards rewrites the file (temp and rename, retried for Windows) instead of restarting, once .live exists. Without .live (a Claude Code that doesn't load the tap), it falls back to the old rule: keep the run when only the varying parts changed, otherwise restart. A beta change, or safeguards appearing or going, still restarts. The tap changes only the safeguards value; any other byte of the body is Claude Code's own. Bodies without safeguards, count_tokens and non-string bodies are passed through untouched. The tool-results path logged "process expired" alone while the run's end read "magpie ended it". It now aborts the run with the reason and logs "tool results process expired: <reason>". continueWith's "not waiting for tool results" does the same. Tests: - TestClaudeTUIToolLoopCarriesEachBatchsSafeguards: three tool batches with growing prior_turn_context, then the answer. Checks one run and that each request carried its own batch's safeguards. - TestClaudeTUIToolResultsLogWhyTheRunEnded: no tap and the rules change. Checks that the log has the reason. - TestTapPutsTheGuardFilesSafeguards (bun and node): the rewrite, the bodies left alone, the env, and .live. - TestTapEnv: MAGPIE_CLAUDE_GUARD is passed through, WSL-mapped. Run (worktree at |
||
|
|
d8b3749ef7 |
agents: Copilot CLI reaches magpie's models through its providers.json (BYOK)
tony9759 on Discord asked for Copilot CLI to be wired to magpie, since its
docs say it takes a custom model provider URL.
What Copilot does (1.0.105, @github/copilot-darwin-arm64's cli-main.js,
`copilot help providers` / `help environment`; GitHub docs
docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/use-byok-models):
env BYOK (COPILOT_PROVIDER_BASE_URL, _TYPE openai|azure|anthropic, _API_KEY,
_WIRE_API completions|responses) and a providers.json at
$COPILOT_PROVIDERS_CONFIG, else <COPILOT_HOME or ~/.copilot>/providers.json:
{providers:[{name,type,baseUrl,apiKey}], models:[{id,provider,name,
maxPromptTokens,maxOutputTokens,...}]}, picked as <provider>/<id> in
settings.json "model". Neither needs a GitHub sign-in. The multi-provider
file is marked experimental in the SDK types. The version BYOK started in is
not verified (github/gh-aw#25014 says 1.0.19; GitHub's changelog of
2026-04-07 announces it).
magpie writes the persistent file, not the environment: provider "magpie"
(openai chat completions, the gateway's /v1, the agent-named key) and one
models entry per catalog model, then model = magpie/<ref>. Only entries
naming magpie are magpie's; the user's providers, models and other keys stay
through connect, Sync and Disconnect (which also restores the model they were
on); a file that does not parse is never written over. COPILOT_HOME and
COPILOT_PROVIDERS_CONFIG are honoured (the latter added to agentenv.Vars).
Copilot's own models stay in the field's list.
Run at this head (a4fb75bfd's tree on
|