75e78a5a040d0f0ca9fedb97cdc367dde2decdd4
886
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
75e78a5a04 |
tui: quitting hands the gateway to magpie's service on Linux
zaidu259434 on X: "启动codex这些cli连接会失败,AI分析没自动启动magpie的网关".
With magpie installed inside WSL (or on a server over SSH), nothing
opens magpie at login, and XDG autostart doesn't run there. So once
`magpie tui` quit, the agents it had connected asked a gateway that was
gone.
When the terminal quits having served the gateway with an agent
connected, on Linux and where magpie doesn't open at login, keepGateway:
- starts magpie's service (magpie daemon) when it is installed;
- installs it when the user never removed it (daemon.Removed: Uninstall
now leaves a daemon-removed mark, and Install clears it), so it starts
with the system or the login from then on, and says how to remove it;
- otherwise (no systemd, which is WSL's default, or the user removed it)
starts `magpie serve` in its own session, logging to magpie's cache,
and says so. In WSL it also says how to turn systemd on.
macOS, Windows, nothing connected, or magpie opening at login: the same
"gateway stopped" note as before. Docs: gui-shell.
Run:
- TestKeepGatewayAsTheTerminalQuits covers each of those cases, and
TestUninstallRecordsTheUsersNo checks the mark.
- go test -timeout 45m on the four packages, the same run as the
previous commit's: all four ok (gateway 428s, agent 255s, tui 23s, daemon 16s), at
|
||
|
|
a1c1b7053b |
gateway: WSL under NAT reaches the Windows gateway with sharing off
zaidu259434 on X (tweet 2114203077989527990): on Win11, Codex and the
other CLIs in WSL failed to connect to magpie. A distro in NAT
networking (WSL's default) reaches Windows at the address Windows has
on the WSL network (vEthernet (WSL), 172.17.32.1 on the test box), and
magpie wrote that address into the distro's agents. But the gateway
listened on 127.0.0.1 alone unless LAN sharing was on, so every request
from WSL timed out. Turning sharing on wasn't enough either: the WSL
adapter is in Windows' Public profile, and a Private-only allow rule
still keeps WSL out (reproduced on the box).
- gateway: while it listens on loopback alone, on Windows it also
serves at each address on a vEthernet (WSL...) adapter (serveWSL,
looked for again every 10s, since the VM brings its adapter up and
down). A request there counts as this computer's only when it comes
from that network to that address with the WSL key (fromWSL). The key
is `wsl-` plus 48 hex in magpie's folder (wsl-key, 0600), with
`-<agent>` after it optional. The request is then served as a
loopback one with the token (asFromLoopback). Anything else there is
judged as another machine's, so a Docker Desktop container on the
same network gets 403.
- agent: WSL twins at that address get the WSL key (keyAt, agentKeyAt,
ourKey and gatewayKey know it). Whether it answers is asked from
inside the running distro (reachFrom, wslReach: curl, wget or bash's
/dev/tcp), never from Windows, where the listener answers whatever the
firewall keeps out. A distro that can't connect is shown the firewall
rule that lets it in (Profile Any, vEthernet (WSL*), magpie.exe).
- The NAT notices no longer say it answers only while sharing is on (en,
zh, zh-TW, ja, de).
- Docs: gateway-routing (WSL under NAT) and agent-wiring.
Run:
- TestWSLCallerServedWithSharingOff and TestServeWSLListensBesideLoopback
(gateway), and TestWSLAgentsGetTheWSLKey and
TestWSLReachAskedInsideTheDistro (agent). All four were red with the
fix taken out: "403 magpie isn't shared on the local network",
"answers = false", the token given at the WSL address, and no drift.
- go test -timeout 45m ./internal/gateway ./internal/agent ./internal/tui
./internal/daemon: all four ok (gateway 428s, agent 255s, tui 23s, daemon 16s), at
|
||
|
|
15f0d4cdeb |
sessions: a Claude Code session goes on in Codex, and a Codex one in Claude Code
0xPlato on X asked for conversations to carry across agents, at least on
one machine. A session row's Continue in (换 Agent 继续) now offers Codex
for a Claude Code session and Claude Code for a Codex one, when the other
is installed. Picking it converts the session then: a new session in the
target's own store, which its own resume opens. Listing converts nothing.
- Claude Code to Codex: a rollout in CODEX_HOME/sessions/YYYY/MM/DD with
session_meta (model_provider from config.toml now, no
base_instructions, so Codex uses its own), response_items and the
event_msg user/agent messages the TUI shows. Codex indexes it on
resume itself.
- Codex to Claude Code: CLAUDE_CONFIG_DIR/projects/<cwd>/<uuid>.jsonl,
lines chained by parentUuid, assistant model "<synthetic>" so usage
counts no call for them.
- Carried: user and agent text, pasted images, shell calls natively
(Bash and exec_command) with their output, other tools as the agent's
text (name, input, result in fences, cut at 64 KiB). Dropped: thinking,
reasoning, signatures, encrypted content, Claude Code's own and Codex's
context messages. After a compaction only what replaced the history.
- The source is only read. The new file goes through temp, sync, rename
and never over an existing path. Asking again for an unchanged file
gives the same session (memo by path, target, size, mtime).
- POST /api/sessions/carry {agent, id, to, open}: copies the resume line,
or with open (Mac app) opens it in the session terminal. The details
pane's Continue in line converts from its copy button too.
- Read-only and WSL sessions get no offer. Pi, omp, OpenCode, Kimi,
Cursor and the rest are not converted.
Run (worktree at
|
||
|
|
46c4188327 |
gateway: Codex's access_programs goes to OpenAI alone, so OpenCode Go's DeepSeek and GLM answer (#3172)
csic21, HONGs23 and TimWongUp (#3172): a Codex subagent inherits
access_programs {"cyber":"standard"}, magpie relayed it to OpenCode Go,
and Go answered DeepSeek and GLM with 503 "Upstream request failed:
Endpoint is unavailable."; without the field, or with null, 200. Go's
Haiku took it.
Scope: Codex itself sends the field only with a ChatGPT sign-in, or an
API key on its provider named "openai" (codex-rs core/src/
cyber_access_program.rs, for_auth and for_provider; read at openai/codex
970111f6c). It comes to magpie because Codex thinks magpie is OpenAI,
the same reason forVendor takes OpenAI-only parts out (#292). So the
class is "only the upstreams Codex would send it to", not an OpenCode Go
rule: no other vendor has a Cyber program to read, and Go is the one
seen to refuse it. keepsAccessPrograms keeps it for a ChatGPT (Codex)
account, a host ending in openai.com, another magpie (IsRemoteMagpie,
whose own upstream decides) and a codexAsSent relay when Codex sent the
request. Every other Responses upstream, relayed or built (from Chat
too), plugins included, goes without it. A relay that fronts ChatGPT
loses it unless set codex=as-sent, as Codex with a custom provider
would send it none.
- forwardOnce takes it out before the user's extraBody is merged, so an
access_programs the user wrote there still goes (Edward4226's branch
did it after, which would override the user's own value).
- withoutTopMember (from Edward4226's branch, using longBody's spans on
a long body) removes the member, every one of that name, the rest byte
for byte; a body that isn't a valid object goes as it came. A
bytes.Contains check first, so a body without it costs nothing.
- Chat and Messages builds never carried it (now tested).
- Docs: gateway-routing.md, providers-accounts.md, ir.go comment.
Run:
- TestAccessProgramsGoToOpenAIAlone (new; fakes by the gateway client's
RoundTrip, no network): Go DeepSeek/GLM from Codex and from curl, null,
Chat built as Responses, Zen, a relay, codexAsSent with and without
Codex's headers, the user's extraBody, OpenAI (daybreak_blue, null,
from Chat), another magpie, a Chat and a Messages upstream.
TestWithoutTopMember (new). TestCodexAccessProgramsReachBackend,
TestAccessProgramsNullKept, TestCodexAccountTakesExtraBody pass.
- Broken by hand, each red: no strip (9 cases: Go, Zen, relay, extraBody);
IsRemoteMagpie out; openai.com out (3 OpenAI cases); codexAsSent out;
codexAsSent without fromCodex; Codex account out
(TestCodexAccessProgramsReachBackend red); strip moved after extraBody
(the user's value lost).
- gofmt -l clean; go vet -tags nogui ./... for darwin, linux, windows.
- HOME=<scratch> go test -tags nogui -timeout 45m ./internal/gateway/:
ok (414s), at
|
||
|
|
a2ff7e6cab |
plugin: add takes a community plugin's name (WorkBuddy, think-tags, qoder-cn)
Atlas on Discord (#help, 10-25, Linux): `magpie plugin add WorkBuddy`
said "isn't an npm package name". Worse, a bare `workbuddy` passed the
npm-name check and installed npm's unscoped workbuddy@latest, not
@magpie-community/opencode-workbuddy-auth.
plugin.Add, which the CLI, the Plugins page's field (/api/plugins/add)
and the movers all go through, now resolves a bare name first
(internal/plugin/resolve.go). Case aside, a name one community listing
goes by is its package, at the version given: the package or its bare
name, the short name (workbuddy, think-tags), the shown name (WorkBuddy,
Command Code), a provider id it serves or the subscription it replaces,
and a retired subscription's id through its mover (qoder-cn; provider
sets plugin.SubscriptionPlugin = MovePackage). The CLI says which
package it picked. A name two listings go by, or none that isn't an npm
name, is refused with the community plugins listed. A name no listing
goes by is npm's own package (opencode-gemini-auth keeps working), but
only when the list was fetched within the six hours: when the fetch
fails, the copy kept or built in may not name a newer plugin, so the
name is refused with why, and npm:<name> installs npm's package as
written. market() now says whether its list is a fresh fetch (marketErr).
Scoped names, paths and git specs are unchanged. A backup's or a sync's
plugins go in by their own spec (plugin.AddExact via addPluginExact),
never resolved, so a restore isn't held by GitHub being unreachable.
Update, Upgrade and InstallMissing use add with stored specs, unchanged.
Tests (fake registry over httptest, fake bun; no network):
TestResolveCommunityNames, TestResolveRefusesWhatItCantName,
TestResolveListUnread, TestAddByCommunityName. TestUpdateAllUpdatesAPinnedPlugin
adds an unscoped third-party name, so it now serves a registry.
Broken by hand: Add without resolve -> TestAddByCommunityName red with
the reporter's own error ("WorkBuddy" isn't an npm package name) and
workbuddy -> workbuddy@latest. The unread-list rule turned off (valid
name goes to npm regardless) -> TestResolveListUnread red.
Real use, sandbox HOME, built binary, real npm and GitHub:
`plugin add WorkBuddy` -> installed @magpie-community/opencode-workbuddy-auth@latest,
listed workbuddy and workbuddy-ai; `think-tags` -> middleware-think-tags;
`opencode-gemini-auth` -> npm's, google-plugin listed; `qoder-cn` with
MAGPIE_PLUGIN_MARKET=off -> opencode-qoder-auth; "Work Buddy Pro" ->
refused with the 38 community plugins listed; `twinz` with the list off
or at a dead URL -> refused, saying why and npm:twinz.
Run at this head (rebased on origin/main
|
||
|
|
42976f9a08 |
usage: a renamed provider is shown once, by the id it has now
cybercaius on Discord (#help, 10-25): "已经更改供应商 id 的也没有变更过来反而
分开显示了". Reproduced in a sandbox HOME (magpie web on 3582, fake upstream
on 3583): after renaming myrelay to newrelay in the editor, the Requests
page's provider list had both myrelay and newrelay, each named "myrelay",
because the model-list probe row was still under myrelay. The summary was
already folded; the probe chunk, the Sessions tab's vias and the gateway's
loggedAnswers (lead-first routing) were not renamed at all.
What changed
- provider.Renames (UsageRenames): Of(id, time) is the id a call recorded
under id at that time belongs to now. Every usage reader goes through it:
summarizeFrom (and its historical-key set), ledgerMatched, NewPricer,
NewCoster, the Requests page's gateway blocks, probe rows and other
computers' days, window holds and their history, buildVias, and
gateway loggedAnswers. Visit stays as recorded so Of is taken once.
The summary, Requests and vias caches key on Renames.Key.
- An id reused by another provider no longer pulls the new one's calls
into the old one. Rename onto, or Save of a new provider under, an id in
another's Was moves it into that one's Gave with the time (giveID):
calls before then stay the old provider's. freeID treats Was ids as
taken, so adding the vendor again gets "-2". Renamed() (refs) skips ids
a provider or subscription holds now.
- A providers.json that can't be read keeps the last renames read instead
of none (a failed read is unknown), so usage doesn't split meanwhile.
- History: nothing in usage.jsonl is rewritten. Calls from before this
release under a renamed id show under the new id at once. An id that was
reused before this release has no hand-over time, so its calls show under
whoever holds the id now, as before.
Siblings checked: budget keys by caller key; per-key limits, RPM and
concurrency count live requests by the current id; tray totals go through
QueryPage; codex_memory reads Requested refs. None needed a change.
Run at the tree before the rebase; rebased onto
|
||
|
|
769355ab93 |
library: an MCP server's startup timeout reaches Codex as startup_timeout_sec, a hand-written one stays (#3168, miaomiaozi)
The Library's MCP server editor has a "Startup timeout" field (seconds), shown when an agent that reads one is installed (AgentView.Startup; Codex only). It is written to Codex's [mcp_servers.<name>] startup_timeout_sec, user-wide and in a project's .codex/config.toml. Empty writes nothing, so Codex keeps its own 30s, as before. The key and its unit are from Codex's own source: RawMcpServerConfig in codex-rs/config/src/mcp_types.rs (cb2581dae8de) has startup_timeout_sec: Option<f64> in seconds, and the older startup_timeout_ms, which is read only when _sec is absent. A value the user wrote in config.toml is never written over. magpie records the value it last wrote (Applied.Startup per agent, Project.Startup per project file). A value in the entry that differs from that record, one there before magpie wrote any, or any startup_timeout_ms, is the user's (startupTheirs), and magpie leaves the key alone. Once the user takes theirs out, magpie's goes in. The TUI's server editor keeps the GUI-set value, as it does for OAuth. Other agents with a startup timeout (Grok Build, Hermes, OpenCode) and a `magpie mcp add` flag are #3536. Run, in a sandbox HOME with pinned GOMODCACHE/GOCACHE: - go test -tags nogui ./internal/library ./internal/tui: ok (162s, 16s). - New tests: TestCodexStartupTimeout, TestCodexStartupTimeoutKeepsUsers, TestCodexProjectStartupTimeout. Broken by hand, each red: every existing value counted as the user's -> "startup_timeout_sec = 120, want 45"; magpie always winning -> "= 20, want 90"; no encode (the old code) -> "= <nil>, want 120". - GUI: new mcp-startup-timeout.test.cjs, Chromium and WebKit, en zh zh-TW ja de, 1100 and 390px: 22/22; red on the old client.js (no field). The 59 GUI files the change reaches (mcp-*, library-*, i18n-keys, gui-de/ja/zh-tw, every editServer/lib-editor file): 935 of 937 pass. The red, library-row-remove's hook-row trash in Chromium, fails the same way on origin/main |
||
|
|
208bd5c48b |
gui: Settings descriptions wrap instead of ending in … (arculongus on Discord)
arculongus (English UI, screenshot) couldn't read many Settings rows: the
line under a setting's name ended in "…". The generic `.row .sub` rule holds
a row's line to one line with an ellipsis; a few Settings rows opted out
(`.wraps`) and the rest were cut, among them Image generation's ChatGPT
note, Image recognition MCP server and Web search's Searches for other
models.
Fixed for the class, not the rows in the screenshot: every setting row's
line (`.row.pref .sub`) now wraps whole beside its control. That covers
every Settings part, Plugins › Built-in and an agent's own settings (the
same rows). The control keeps its size (`.prefs .val` is `flex: none`,
max 60%), and nothing else in the layout moves. The window is never
narrower than 560pt, so a row stays a few lines at most. Lines elsewhere (provider
and account cards, chips, URLs) stay one line; their full text is already
reachable through the hover title.
Tests:
- New settings-lines-wrap.test.cjs checks every visible Settings part plus
Plugins › Built-in, in chromium and webkit, en/zh/zh-TW/ja/de, at
1000px and 440px. No row's line is cut or nowrap, each control stays
inside its row, and the page never scrolls sideways (more than 30 rows
checked). It also checks the three reported rows by name.
- Tests that assumed one-line rows now follow the taller rows:
- searcher-pick: the help wraps rather than ellipsizing with a title.
- settings-general: one line only at 1000px, never cut at either width.
- reader.cjs reach(): goes up to 8,000px, not 2,400.
- member-model-setting, turn-done, connect-address-kept, tray-cost and
tray-totals: wheel to the control with reach() before
clicking, not scrollIntoViewIfNeeded or Playwright's own scroll, which
the app undoes.
- update-download, update-restart and tray-totals: a click whose row
grows a line may scroll, but only to keep the clicked control under
the pointer (the app's hold, #2134). tray-totals allows 2px, because
WebKit's whole-pixel scrolls drifted 1.3px over four holds.
- mobile-web: compares against an origin/main baseline without this
change.
- Docs: gui-shell.md and gateway-routing.md.
Run (worktree from origin/main
|
||
|
|
73d17f90ce |
codex: every CODEX_HOME folder's sessions count, its account renewed there
phantom3792 on X: with several ChatGPT accounts kept the way Codex supports, magpie counted only the default profile's usage, and the accounts added from the other profiles read no quota. Codex's mechanism, from openai/codex at 970111f6cb62: - One sign-in per folder. In codex-rs/login/src/auth/storage.rs the sign-in is $CODEX_HOME/auth.json, or the keychain item that compute_store_key(codex_home) names. - Sessions live in the same folder. rollout/src/lib.rs writes sessions/ and archived_sessions/ under codex_home. - `--profile <name>` only lays $CODEX_HOME/<name>.config.toml over config.toml (config/src/loader/mod.rs), and the sign-in stays shared. So a second account is Codex run with CODEX_HOME=~/.codex-work, and magpie read only the folder it runs with. There were two causes: - Sessions: codexFiles() walked CodexDir() alone. The sessions list, traces and the usage ledger (sessions.Calls) never saw other folders' rollouts. - Quota: an account added by importing another folder's auth.json is refreshed from magpie's copy. The import rotates the refresh token, which leaves two holders of one token, and whichever refreshes first signs the other out. The saved account goes "sign-in has expired" and its quota read fails. The fix: - appdir.CodexHomes finds the folders: CodexHome first, then folders named codex* or .codex* in the home folder or beside CodexHome, or one level down in one (~/.codex-profiles/work), that hold auth.json or sessions/. - sessions: codexFiles and Dirs read every folder. - provider: rememberLogins saves each folder's account with Home set to it (codexHomeLogins). The one ~/.codex is signed in to stays that folder's. - renewSaved renews such an account where that folder's Codex keeps it (codexHeldIn, as heldByCodex does for ~/.codex). This one funnel covers quota, gateway, warm-up, keep-alive and revoked sign-ins. codexLoginAuth reads its expiry from the same place. - switchSavedLogin, NextLogin's spares and forgetLogin leave such an account alone. Their errors name the folder and the CODEX_HOME=... codex command. - docs/subsystems/providers-accounts.md gains a row. Run (worktree at |
||
|
|
402577c15a |
gateway: image generation is an MCP server on the gateway, /mcp/magpie/image
JonahFu on X runs magpie in Docker in gateway mode, so he has no Library and
no stdio Magpie Image server, while image recognition is an HTTP MCP server
on the gateway (/mcp/magpie/vision). Now image generation is one too, with
the stdio server's tools: generate_image, generate_video and
generation_result, drawing with Settings › Images › Image generation.
- image_mcp.go: served by serveMCP, so it is guarded as the vision server
is (local or a shared magpie's caller, a refused Origin 403, POST only,
the key's limit reserved per call). A drawing is s.images run in-process
on a clone of the request (caller and key kept), so routing, key models,
usage and the timeout setting are draw.go's own. It runs as a job (15
min at most); the tool answers within 20s or gives an id that
generation_result waits on. Images come back as MCP image content (5 MB
each at most) and at /mcp/magpie/image/files/<name>, kept in memory an
hour, 256 MB at most, readable only by the key that made them. Videos
go through videosCreate/videosGet in-process and are given as
/v1/videos/<id>/content. Image generation Off is a tool error naming
where to turn it on, before the arguments are read.
- Input images go through the vision server's reader, now mcpImageSrc
(vision_mcp.go), so a file path is read only for a local caller.
- The tool schemas live in the gateway (ImageToolProps, VideoToolProps,
ResultToolProps); internal/imagemcp takes them and adds only its path
argument. Its tools/list JSON was compared byte for byte with the old one.
- Settings › Models: #imageMcpRow under #visionMcpRow with the address and
a copy button; the gateway-mode Image generation sub now points at it.
en, zh, zh-TW, ja, de.
The two rows are drawn by one helper (mcpRow), which took the vision
row's own code, so the row costs 462 bytes of app.js.
- core_budget_test: appScriptBudget 1,321,336 -> 1,321,424 and
coreScriptBudget 1,528,525 -> 1,528,972, the exact sizes with the row,
with no room added (10-25). Nothing moved out: the row is Settings'
own, which the core draws.
- search-api.test.cjs: the new row pushed the search row partly below the
1400px window at 420px, where scrollIntoViewIfNeeded leaves it, and
magpie puts back a scroll the reader didn't make, so the test's
coordinate clicks missed. It now brings the whole row on screen with
the wheel and checks it is still there a second later. Red with the new
row before this, green after; green on origin/main's GUI either way.
- oneport_test knows ImageMCPPath and ImageMCPFiles (ClientPath covers
them).
Run (worktree at this commit, on origin/main
|
||
|
|
5b32b7ea80 |
plugins: a Bun Windows can't load (0xc0000139, before 10 1809 / Server 2019) says so and what to do (zgcwkj on Discord)
zgcwkj runs magpie-cli-windows-amd64.exe as a Windows service (nssm) and every plugin install failed with "bun add …: exit status 0xc0000139: (and from the community repo's dist branch: bun add ./dist/….tgz: exit status 0xc0000139: )". Why: 0xc0000139 is STATUS_ENTRYPOINT_NOT_FOUND, the loader refusing the exe before it runs. Reading the PE imports (debug/pe) of Bun's windows-x64(-baseline) zips: 1.3.14 and later, so magpie's floor 1.4.2 and the latest 1.4.4, import kernel32's CreatePseudoConsole, ClosePseudoConsole and ResizePseudoConsole, which Windows has from 10 1809 (build 17763) / Server 2019 on. 1.3.13 doesn't. Bun's docs say "Windows 10 version 1809 or later" (bun.com/docs/installation). So Windows Server 2016 and Windows 10 1507 to 1803 (LTSB 2015/2016) can't run any Bun magpie uses. 1.4.2's pinned SHA-256 matches the asset. What changes: - wontLoad (internal/plugin/bun.go) reads an exit of 0xc0000139 as "this Windows" and 0xc000001d or SIGILL as "this processor" (Bun's x64 build targets SSE4.2), as a *BunUnstartableError whose message says which, the versions Bun needs, and MAGPIE_BUN. - bun add, bun update, cantStart and whyDied (the host's start) wrap it. - An install no longer tries the dist branch after it: that bun add can't start either, and its error read as the dist branch's. - The GUI's fail() answers it with code bun_unstartable, bunWhy and said, an i18n.js key (bunSaid in api.go), which api() in app.js puts through t(): en, zh, zh-TW, ja, de, in the window and in magpie web. The sentences live in Go so app.js grows one line: with both in app.js, TestCoreScriptBudget was 128 bytes over app.js's budget and 487 over the core's, and no budget is raised here. TestBunSaidIsTranslated fails when a language lacks one. The CLI prints the English message. - No fallback to an older Bun: 1.3.13 is below BunVersion and Bun doesn't support that Windows, and the -baseline assets are now the same binary. - docs/subsystems/provider-plugins.md says all this. Run: - New tests: TestWontLoadSaysWindowsOrCPU (injected NTSTATUS exits, a real kill -ILL), TestInstallOnUnstartableBunSaysWhyAndSkipsDist (0 dist requests), TestHostOnUnstartableBunSaysWhy, TestFailSaysBun Unstartable, TestBunSaidIsTranslated, plugin-bun-unstartable.test.cjs (chromium and webkit, every language, window and web). - Real Windows (10.0.26200 box, a sandbox dir of its own): a windows/amd64 nogui magpie-cli.exe with a fake magpie-bun.exe that exits 0xc0000139, `plugin add @magpie-community/opencode-raccoon-auth` printed the new message, and no dist folder was made. - gofmt -l; go vet darwin, linux -tags nogui, windows; builds of all three. - Full suite (go test -tags nogui -timeout 45m ./..., through suite-lock, at |
||
|
|
ff6090354e |
gateway: dsh's session and compaction marks are held on Messages and Responses too (#3298)
A user's own dsh llm-deepseek row pointed at magpie (e3491e2bb's docs) calls /v1/messages with x-deepseek-harness-session-id and x-deepseek-harness-compact. #2505 reads both in sessionOf/dshCompacts for every route already, but TestDshMarksSessionAndCompaction only covered /v1/chat/completions. TestDshMarksOnEveryRoute sends both marks (and llm-deepseek's x-deepseek-harness-user-id) to /v1/messages on an Anthropic provider and /v1/responses on a Responses provider, and checks the recorded session, kind "compact" or none, and that the vendor gets no x-deepseek-harness-* header. No behaviour changes: this guards what the docs now tell users, and so it passes on the old code too. docs/subsystems/gateway-sessions.md names it. Broken by hand: dropping x-deepseek-harness-session-id from sessionHeaders turns all four cases red (session ""); making dshCompacts always false turns both compact cases red (kind ""). Restored after each. Run before the rebase onto |
||
|
|
3387ea6156 |
gateway: an Antigravity drawing out of the image model's quota goes on to the next account and rests that model there (01huadalang)
01huadalang (Discord): with several Antigravity accounts, when one
account's image quota is spent, magpie doesn't move on to the next.
Model, entry point and error text were asked for and not answered yet.
What every image path does (generate_image MCP and /v1/images both go
through images() -> drawOnAccounts -> drawCodeAssist; a chat on the
image model goes through serve's candidate loop):
- A 429 (antigravityQuota, "You have exhausted your capacity on this
model. Your quota will reset after 3h19m30s.") already went on to the
next account, but rested nothing, so every drawing asked the spent
account first again.
- Antigravity also says a model's quota used up as a 200 whose stream is
the error event (the Code Assist decoder keeps its message; the chat
path's TestAntigravityTurnedAwaySaidInsideTheReply). drawCodeAssist
told every such error as 502, which accountRefusedDrawing doesn't move
on for, so the drawing ended on the spent account while the next had
its quota. The chat path already fails over on it.
Fix (internal/gateway/draw.go):
- saidStatus: an error said inside a drawing's 200 is 429 when its words
say quota or rate (usedUpWords, quotaCodes, rateWords), 402 for credit,
else the 502 it was. drawCodeAssist uses it, and so does the images
API's 200 with no image (its sibling).
- restDrawer: an account's drawing refused as failQuota (failure) rests
the image model on that account alone (restID, Rest.Model), until the
reset the refusal names (resetsAt) or quotaRest, held to longestQuota.
The account's text models aren't touched; keys and other failures rest
nothing, as before. candidates' restLast then asks the accounts that
still have the model first.
Tests (internal/gateway/antigravity_draw_test.go), Antigravity's real
QUOTA_EXHAUSTED 429 body (antigravityQuota) as a 429 and as the stream's
error event:
- TestAntigravityDrawingOutOfQuotaInsideTheReplyGoesOn
- TestAntigravityDrawingQuotaRestsTheImageModel (u1 then u2, then u2
alone; rest until ~3h19m30s; the account itself not resting)
- TestAntigravityDrawingOtherErrorInsideTheReplyStays (a 500 INTERNAL
inside the reply asks no other account, rests nothing)
Broken by hand: draw.go at origin/main with the new tests: the first two
red (502 on the spent account; "asked u1 u2 u1 u2"), the third green.
Run at this head:
- go test -tags nogui -timeout 45m ./internal/gateway: ok github.com/yetone/magpie/internal/gateway 432.7s (go test -tags nogui -timeout 45m ./internal/gateway at
|
||
|
|
ffe493773c |
usage: magpie's own Test, Detect APIs and model list requests are rows of the request log, counted nowhere
neiko and gys619 on Discord: a provider's Test or Detect APIs left no
trace in Usage > Requests, so a failing test couldn't be read back.
The provider package marks the context of the editor's Test, Detect APIs
(and per-model detection) and a model list's refresh with a kind
(internal/probelog). Each request sent under the mark is written once:
by the provider's Do, or by probelog.Transport under http.DefaultClient
(netproxy.Install), whichever sends it first; the Claude Code run and
the gateway's translated test write theirs from their result. A row
keeps time, provider, account, model, host, path (no query, no
user:password), method, status, ms and the first 500 bytes of the error.
The row is usage.SourceProbe, agent "magpie", Kind provider_test /
api_detect / model_list ("Test", "Detect APIs", "Model list" in Called
for; purposes.js regenerated). The log index keeps probes apart
(logSnapshot.probes), so Visit, Load, Summarize, budgets, Vias, heatmap,
shared days, LastSeen and observers never meet one. The request page
lists them (probeChunk) and counts none: Row.IsProbe, since a packed row
keeps the row's Source and not its record's. The page shows a muted
badge "magpie's own · not counted in any total" (en, zh, zh-TW, ja, de);
no new control, no layout change.
Tests, each red on the old code:
- usage TestProbeRowsListedNotCounted: listed, clipped, and absent from
Sum, Through, every By group, Summarize, Load, LastSeen, OwnDays and
the observer; a provider filter lists it and sums 0.
- provider TestTestWritesItsRequestsDown / TestDetectWritesItsRequestsDown:
every request the fake server saw is exactly one row, with the right
kind, model and 401 text; an unmarked Do writes nothing.
- probelog TestNoteKeepsNoSecret, TestTransportOnce.
- GUI usage-ledger-probe: badge per language, both engines, 1180/420,
light and dark, no left border, no sideways scroll.
- gui TestProviderDetectDraft now expects the log line (source probe,
kind api_detect, no key) and leaves usage.jsonl out of the unchanged
config comparison.
Broken by hand, each went red: request_page's uncounted check,
log_index's probe skip, Append's observer skip, Do's Taken (6 rows for
4 requests), Test's and Detect's marks, probelog's query strip,
page.js's badge (11 GUI fails).
Run at this head (on origin/main
|
||
|
|
1b32bdcfcb |
gui: magpie web's port answers the gateway's /v1 routes too, so one proxy location serves both (zgcwkj on Discord)
zgcwkj puts magpie behind nginx on one domain and wanted the browser UI (magpie web / serve --web, 127.0.0.1:3430) and the gateway (:3425) from one port, so one location works. Now the web port hands every gateway client route to the gateway: /v1/..., /v1beta/..., /models, /chat/completions, /responses, /messages, /images, /embeddings, /rerank, /audio, /videos, /muse-code/models, /backend-api/codex/..., the search path and /mcp/... (gateway.ClientPath). Everything else stays the page's, behind webGuard as before. /api/* stays split: on the web port it is the UI's API; Ollama's /api/* and Claude Desktop's /api/hello still need the gateway port, since the two can't share the path. Security: a handed-over request goes through the gateway's whole own stack, not a copy of it. gateway.Server.Front() is lanGuard(Handler()), built once; ListenAndServe serves the same handler. When this process serves the gateway, the web port calls Front() in process; when another magpie does, toGateway reverse-proxies to gateway.URL(), keeps the Host, copies Forwarded/X-Forwarded-* back (ReverseProxy strips them), and adds X-Forwarded-For for a non-loopback peer, so remote, proxied, rebound, Origin null, *.localhost and foreign-Origin requests are judged exactly as on the gateway port. The web cookie is never a gateway key. Paths that aren't clean (/v1/../api, /v1//x, /v1/./x) are not client paths, so they never reach the gateway as one. The allow list (AllowGuard) still wraps both. Tests: - TestClientPathCoversHandler reads every mux pattern Handler registers and fails when one is neither a ClientPath nor /, /api/* or /_magpie/*, so a new gateway route has to be placed. - TestClientPathOnlyClean. - TestWebOnePortServedHere / ServedElsewhere: with no web cookie, the UI API (/api/settings) is never reached for: no Origin (GET, POST), Origin null, a foreign Origin, a rebound Host (GET, POST), through a proxy (XFF), from another machine, /v1/../api, /v1/%2e%2e/api, /v1//api, and with a gateway key. The gateway routes on the web port: local agent 200; Origin null POST 403; foreign Origin 403; rebound Host 403 (with the page's cookie too); proxy or remote without a key 401 (with the page's cookie too); with a gateway key 200; not shared 403. - TestWebAssetsAreNoClientPath: no embedded asset shadows a client path. Run (full packages at the first rebase, on origin/main |
||
|
|
0b72ccbeff |
agentplug: connect's models carry /v1/models' native_endpoints and pricing
cleary5779 on Discord builds an agent as an agent plugin and wants, in
connect({ gateway, model, models }), the API each model passes straight
through on and what it costs. Each entry of models (and model) now also
has, by the names /v1/models uses:
"native_endpoints": ["/v1/chat/completions"],
"pricing": {"prompt": "0.0000003", "completion": "0.0000012",
"input_cache_read": "0.00000003"}
Each is left out when not known: a group or a model translated anyway
has no native_endpoints, an unpriced model no pricing, never [] or 0.
The fields connect had (id, name, context, output, images, efforts) are
as they were.
No second lookup: nativeEndpoints moved from the gateway to
provider.NativeEndpoints, and openRouterPricing/perToken to
catalog.OpenRouterPricing/PerToken (internal/catalog/openrouter.go); the
gateway calls them as before. magpieModels already priced each model with
provider.EntryPricer, the price /v1/models gives (m.Price); it now also
keeps NativeEndpoints in catalog.Model.Endpoints (json:"-"), which
plugged's wire turns into the two keys.
Docs: reference.md's agent plugins section (what connect gets, with an
example), agent-wiring and gateway-routing subsystem pages, and the
site's Plugins page in en, zh and ja.
Run at this tree (on origin/main
|
||
|
|
9949ad5eb0 |
gateway: a subagent a Responses Lite lead spawns elsewhere goes without Lite's reasoning context and header (TangForX on X)
TangForX: Codex with gpt-6.1-sol leading spawned a subagent on OpenCode Go's DeepSeek v4.1 flash, and every turn of it answered 503 "Endpoint is unavailable"; the same subagent under a DeepSeek lead, and on DeepSeek's own API, worked. Cause: gpt-6.1-sol is use_responses_lite, and Codex sends a subagent it spawns in the lead's Lite shape with only the model name swapped: reasoning.context "all_turns", tools in an additional_tools input item, and the X-OpenAI-Internal-Codex-Responses-Lite header. passthrough lifted additional_tools (#350) but sent the reasoning context on, and forwardOnce copied the Lite header (an x-openai-* header Codex sends) to every key+URL provider. OpenCode Go's DeepSeek route refuses that shape. Fix: fromLite takes the whole Lite shape off (additional_tools lifted, reasoning.context dropped, effort and summary kept) for every Responses upstream that isn't OpenAI, a Codex account, or a codexAsSent relay (liteKept); forwardOnce drops the Lite header on the same rule, for a translated Chat upstream too. A body with no Lite in it goes byte for byte as before. codexAsSent relays still get the request and header as Codex sent them (TestCodexAsSent). Run at the pushed head: - TestLiteSubagentLeavesLite: Codex's code-mode request with Lite's fields and the collab_spawn subagent headers, to opencode-go deepseek-v4.1-flash, deepseek and a custom Responses relay; the fake upstream answers 503 "Endpoint is unavailable" to any Lite remnant. TestFromLite: a non-Lite body is unchanged byte for byte. - gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...: clean. - go test -tags nogui -count=1 ./internal/gateway (Lite, Codex, CodexAsSent, DeepSeek, OpenCode tests): ok. - go test -tags nogui -timeout 45m ./... at ecfab308e (on |
||
|
|
3133f63434 |
gateway: /v1/models gives each priced model OpenRouter's pricing
cleary5779 on Discord builds an agent on magpie's gateway and wants the
list to say what a call costs. Each model magpie knows a price of now has
"pricing": {"prompt": "<USD/token>", "completion": "<USD/token>",
"input_cache_read": ..., "input_cache_write": ...}
as OpenRouter's /models writes it: decimal strings, the decimal point
moved rather than the float divided (perToken: $0.3/M is "0.0000003",
not 2.9999999999999997e-07). prompt and completion are always there for
a priced model (a price the user set at 0 included); the cache parts
only when they have a price. A model with no known price has no pricing
key at all, never a 0. Base price only: no tiers, no 1-hour write.
The price is the Usage page's (provider.EntryPricer, as EntryPriceIn):
the user's own, else the provider's list price or its maker's at the
price rate, a subscription's model at list price, a group only when
every member costs the same. It goes to the callers magpie_price goes to
(local or sharedWith), with or without X-Magpie-Prices; magpie_price
itself is still only for a list that asks. GET /v1/models/{id} carries
it too (pricedModelObject).
Siblings left without it: Claude Desktop's and Claude Science's lists
(Anthropic's shape, their apps read their own fields), Muse Code's
(models.dev metadata Muse reads), Codex's catalog, Ollama's tags, the
decision models (another magpie's System One), and the image and video
models, whose price isn't a token's.
Cost on the poll path (LESSONS: work added to a path every request or
poll takes): 755 models, 30 providers, the real models.dev catalog:
before the previous commit the pricing added ~30ms to a ~10ms list; with
it, the list is ~13-20ms against ~8-10ms without pricing, at load 65.
Run at 9afa86306 (both commits, on origin/main
|
||
|
|
7b1faf99f2 |
agent: a Codex auth.json caught mid-rewrite leaves Codex beside its ChatGPT sign-in (lucy)
lucy on Discord (v0.1.1394, Codex app, signed in in Codex, not in
magpie): on and off, Codex's account menu showed "magpie" instead of the
ChatGPT account, and the model picker listed magpie's catalog ("6.1 Sol
· Codex" ...) instead of Codex's own models.
Cause. codexChatGPT (internal/agent/codex.go:2022 on
|
||
|
|
0d2a101160 |
gateway: the Codex app's titles, descriptions and summaries go to the magpie model picked, not ChatGPT (atom_Ray on X)
atom_Ray on X: with a third-party model picked in the Codex app through
magpie, an hour of use still took 2% of the ChatGPT account's 5-hour
window, and at 0% left it could not be used at all.
The cause is the app's hidden side turns. ChatGPT.app 26.1013.40934 asks
for a thread's title, description and one-line summary
(ThreadMetadataGenerationService.generateTitle/generateDescription/
generateSummary in .vite/build/main-CLu1A25j.js; R0/z0/B0 via H0 and Jq
in src-DsLVGakC.js) on ephemeralGenerationModel, gpt-6-luna by default,
whatever model the conversation is on. A summary is asked after each
user and assistant message (bAu in app-initial). With magpie's model
beside the ChatGPT sign-in (openai_base_url), these reach
/backend-api/codex as gpt-6-luna. codexTitlesTo and codexDescriptionsTo
left an unset setting on the model Codex asked for, and thread_summary
had no route at all, so all three went to ChatGPT on the user's sign-in.
Now, with Codex's config model one of magpie's and magpie not Codex's
provider (agent.CodexSideModel, through gateway.CodexSideModel),
codexSideTo sends titles, descriptions and summaries on the Codex
backend path to that model. On Codex's own model nothing changes, and a
model the Titles or Descriptions setting names still wins. Summaries get
the same wrapper as descriptions (codexShaped): the plain answer is
handed back as the {"summary": ...} the schema asks for, with
compactSummary filled and cut to its maxLength (summaryJSON). This also
covers a summary on magpie's own API, where a Chat model's plain answer
was dropped by the app. No prompt, instructions or base_instructions are
changed: the request is sent to another model as Codex wrote it.
Run (this change on origin/main
|
||
|
|
3a47e377e0 |
usage: a call whose vendor counts no cache is left out of every hit rate (#3464)
#3464 (zeewell on X): Kiro caches on its side, but its replies give only credits and a context share, never cache tokens. Every hit rate outside the Routing page read those calls' CacheRead of 0 as a miss. A Kiro-heavy day showed "hit rate 6%" when the counted calls hit 90%. The plugin already says so (opencode-kiro-auth 0.1.16 sends usage.magpie_cache_unknown), and the gateway already kept it as RouteUsage.CacheUnknown for Routing. This carries it the rest of the way: - gateway: Usage.cacheNotCounted() (the vendor said so and no try reported a cache token) goes into usage.Record.CacheUnknown on every path that records a call: the gateway's own record, the OTel attempt path in observe.go, and trace's routeUsage. - usage: Record.CacheUnknown is kept as ledger row flag 8192 (rowCacheUnknown; grepped, no other flag uses that bit). Totals sums such calls' prompt into cache_unknown and counts them in cache_unknown_calls. Totals.HitRate leaves that prompt out of its denominator, and gives no rate when nothing is left. - Old records: calls kept before the plugin said so carry no flag. A Kiro call (provider kiro or kiro-plugin) with no cache counted is read as uncounted (usage.CountsNoCache): in the ledger's row read, in Totals, and for Routing's history in internal/gui/trace.go (cacheCounted). The rule is scoped to Kiro's two ids, so another vendor's 0 stays a miss (tested). - GUI: cacheHitOf in app.js drives the tray panel's card, the Usage page's agent rows and cache tile, the requests' Cache hit rate card and each ranking row. When only uncounted calls are left it shows "—" or nothing instead of 0%. Otherwise it says "{n} requests left out: their vendor doesn't count the cache". A request row's cache cells show "—", and its details say the vendor doesn't count the cache. The Context page (context.go, context.js) shows no cache for such a call and doesn't score it as a miss. - No budget raised. This adds 625 bytes to app.js (1,320,224 to 1,320,849, under its 1,321,336); |
||
|
|
d08b6118bd |
agents: Restart a desktop app that started before magpie's change, after asking
微雨南山 and stones on Discord: Claude Desktop, WorkBuddy and the Codex
app read magpie's settings only as they start, so a change made in
magpie did nothing until they quit and reopened the app themselves.
The agent's row now carries a Restart when the app is installed, running,
and started before its config last changed (agent.AppBehind):
Claude Desktop, WorkBuddy and WorkBuddy AI on macOS (bundle executable
via pgrep), Claude Desktop and WorkBuddy on Windows (process tree, main =
earliest process whose parent is outside it). A press opens magpie's own
dialog first (confirmAction); Cancel and Escape send nothing. On accept
POST /api/agents/restart/{id} quits the app gracefully (AppleScript quit
on macOS; taskkill without /F on Windows, then /F /T after appCloseWait
for a tray that holds on), waits, and opens it again. On macOS an app
that won't quit is reported (StillOpen) and never forced. The Codex
app's existing Restart now asks first too. CLI agents get none.
changedAt: a stash digest that changed with no file written since the
app started now counts the change as now, so a change magpie made while
the app ran is seen (it was dated to the old write and missed).
app.js budget, not raised: archivePanel moved into plugins/usage/page.js
(its own comment called it the Usage page's; Routing's trace calls it at
draw time, after page.js has loaded), maskWho, maskProv and stillMotion
into plugins/redact, and usageHidOpen into plugins/usage. app.js is
1,108 bytes smaller than on main, budget unchanged.
Run (the first five at the pre-rebase head, same code):
- GUI agent-app-restart + agent-stale-copies: 120/0, chromium and webkit,
en/zh/zh-TW/ja/de, window 980 and 440 and panel 440, no sideways scroll,
no placeholder in aria-label or title.
- Broken by hand: without the confirm the GUI test is red; without the
changedAt fix TestChangedAtWithoutAWrite is red; without the since gate
TestWorkBuddyRestartOnMac and TestWorkBuddyRestartOnWindows are red.
- macOS, real fake-app processes in a sandbox HOME with a stubbed
launcher: quit in 100ms and reopened; a held quit returns StillOpen
after 4s, not forced.
- Windows box, console session (schtasks /IT), fake app and stub
launcher: graceful close in 407ms; a tray that holds on is ended after
5.66s; reopened through the stub.
- gofmt -l clean; go vet darwin (agent, gui), GOOS=linux and
GOOS=windows; builds.
- At 2c5327925 (on origin/main
|
||
|
|
14b10f1166 |
library: an MCP server signed in to in Claude Code, in WSL too, says so instead of "needs sign-in" (CyberCaius on Discord)
CyberCaius signed in to a remote MCP server with Claude Code's /mcp in
WSL, and the Library still said 需要登录. The check connects as magpie,
without the agent's tokens, so an OAuth server answers it 401, and magpie
read no agent's own sign-in anywhere: not on Windows, not in a distro.
The check now reads each Claude Code target's .credentials.json, beside
the settings.json the target already has (readOwnSignIns,
mcp_agent_signin.go). A distro's Claude Code is a target under the
distro's home (wslTargetOf), so its file is read there through
\\wsl.localhost with no new setting. An mcpOAuth entry of the server's
name and URL with an access or refresh token, as Claude Code 2.1.310
counts one, names the agent in ServerHealth.AgentSignIn; the row says
"signed in in Claude Code (Ubuntu)" with the ok dot, and the tooltip says
magpie can't list its tools without signing in itself. An entry without
a token, another URL by the same name, and a file that can't be read or
parsed name nobody, so the row stays "needs sign-in". The tokens are
never sent or kept. A stopped distro has no target and isn't started.
On a Mac only the file is read, never the Keychain. The sign-ins are part
of the check's cache key, so a sign-in in the agent since isn't answered
from the session's earlier check. Strings in zh, zh-TW, ja and de.
Run:
- TestCheckNamesAgentsSignedInThemselves (internal/library): agent.FakeWSL
forces the Windows+WSL switch (Ubuntu running, its home a temp root),
sandbox HOME/USERPROFILE/XDG_CONFIG_HOME, CLAUDE_CONFIG_DIR cleared, a
real httptest server answering 401 with WWW-Authenticate.
- Broken by hand, each red with a FAIL naming the behavior:
- the old behavior (the reader names nobody): reading only this
computer's Claude folder (claudeDir()) instead of the target's:
"signed in in claude@wsl:Ubuntu, the check says {State:auth ...
AgentSignIn:[]}".
- counting an entry with no token: "a sign-in with no token counted".
- leaving the sign-ins out of healthKey: "signed in on both sides, the
check says ... AgentSignIn:[claude@wsl:Ubuntu]" (stale cache).
- library-mcp-health-wsl.test.cjs, chromium and webkit, en/zh/zh-TW/ja/de:
red on the old client.js (expected "signed in in Claude Code (Ubuntu)",
got "needs sign-in"), 12 of 12 after.
- gofmt -l (nothing); go vet on darwin, GOOS=linux -tags nogui and
GOOS=windows for ./internal/library ./internal/gui; go build darwin,
GOOS=windows and GOOS=linux -tags nogui ./...; go test -tags nogui
-count=1 -timeout 45m ./internal/library ./internal/gui: ok (187s, 63s).
- GUI: library-mcp-health, library-mcp-health-wsl, mcp-signin-health,
mcp-signin, mcp-oauth-app, library-mcp-tools, library-mcp-tool-switch,
library-mcp-unshown, library-items, i18n-keys, gui-zh-tw, gui-ja,
gui-de: 161 of 161 pass.
These ran first at a base before origin/main
|
||
|
|
3b5a2f612d |
dsh: Max reaches GLM-5.3 as max, asked adaptively with its level
01huadalang on Discord (10-24): DSH Desktop on magpie-anthropic, zcode
GLM-5.3 at Max; magpie's Routing log showed 77 of 78 requests at low,
one at high, never max.
What DSH sends, from the real app (DSH Desktop 0.2.1-rc.3's app.asar,
pi-ai 1.1.0 and dsh-llm-pi-ai, run read-only through node with
magpie's GLM-5.3 entry): at Max and at High alike, max_tokens 128000
and thinking enabled, budget_tokens 16384. pi-ai's clampReasoning turns
xhigh and max into high before thinkingBudgetForLevel, so no
thinkingBudgets setting can give Max a budget of its own. At Low it
sends 2048; with reasoning off, no thinking field.
What magpie did with it: 16384 is read as high (effortOfBudget) and
sent as output_config.effort high, so Max could never reach max. The
"low" rows were not reproduced: no request DSH builds at Max reads as
low here, and Z.ai refused none of the shapes (live, below), so no
refusal memory lowered it. A 2048 budget (a session or a subagent DSH
runs at Low; dsh-tool-subagent lets the model pick reasoning_effort)
reads as low, and that is the likeliest source. It is asked of the
reporter.
The fix, zero-config: Z.ai's GLM-5.2 and GLM-5.3 (the GLM half of
effortInOutputConfig) are written into dsh's magpie-anthropic route
with compat.forceAdaptiveThinking (gateway.AdaptiveWithEffort, beside
AdaptiveThinking). MiniMax-M3.1-Flash, the other half, is left on its
budget: adaptive wasn't tried on MiniMax (no key), so it is on #3496. pi-ai then sends thinking adaptive and
output_config.effort from magpie's thinkingLevelMap, max as max
(checked against the real asar: low/high/max each go as themselves).
The gateway already passes adaptive thinking with output_config.effort
through for these models (fitted to their levels, withOutputEffort;
TestGLMEffortInOutputConfig pins it), so the gateway only gains
AdaptiveWithEffort. No client name is keyed on, and a budget alone is
read as before. An adaptive-to-budget rewrite in withOutputEffort was
tried first and dropped: TestGLMEffortInOutputConfig pins adaptive
passing through, and Z.ai takes it.
Live, Z.ai GLM-5.3 with the zcode key (sandbox script, key never
printed): adaptive and enabled+effort both accepted; effort max
thought 1237-1427 chars against 426 at high, so max is a real tier.
Run, at this head rebased on origin/main
|
||
|
|
40b5c2daf0 |
agent: say why Claude Desktop's 3p mode can't keep a Chinese language (Dx25 on Discord)
Dx25 (Windows) set Chinese and found %LOCALAPPDATA%\Claude-3p\config.json
back at "locale": "en-US" after every Desktop start. magpie doesn't write
it: config.json is touched only by desktopCarryLocale, at switch-on, and
only when it has no "locale" (TestClaudeDesktopKeepsThe3pLanguage,
TestClaudeDesktopUserEditsThenReapply). Desktop writes it.
Read from Desktop 3.6556.2's bundle (current RELEASES.json, 10-22): in 3p
mode the window is the bundled UI, Resources/ion-dist, with 11 catalogs
(en-US de-DE fr-FR ko-KR ja-JP es-419 es-ES it-IT hi-IN pt-BR id-ID) and
no Chinese; its locale is its localStorage, else navigator.languages
mapped onto those 11, else en-US. On mount it calls
electronIntl.requestLocaleChange(its locale), and the main process's
handler writes that value with store.set("locale", ...). The main process
has zh-Hans and zh-Hant catalogs (for the signed-in window), but the 3p
window asks for en-US on every start, so a Chinese locale, carried or
set by hand, is replaced each time. 2.7032 (this Mac) and 2.9939.2 (the
Windows box) have the same 11 in ion-dist. Nothing magpie can write
keeps Chinese in 3p mode; it is Desktop's missing translation.
This commit changes no behaviour: desktopCarryLocale's comment and
docs/subsystems/agent-wiring.md now say the above, where they implied the
carry kept a Chinese language.
Run at
|
||
|
|
1184862583 |
agent: Codex background compaction writes the bare async_compaction = true where a Codex older than 0.163 reads the config (多喝热水)
多喝热水 (Discord #help, Windows, v0.1.1384, Codex desktop with ChatGPT
sign-in): Codex wouldn't open, "config.toml:154:1: invalid type: map,
expected a boolean". That line is the [features.async_compaction] table
|
||
|
|
93435f27dc |
docs: the partner list is fetched on a process's first ask and hourly, and by the gateway's magpie unasked (#3362)
providers-accounts.md still said the list is fetched every 6 hours. |
||
|
|
b18a6a080b |
gateway, cli: magpie goroutines writes the running magpie's goroutine stacks to a file (#3362)
#3362's second ask: an app stuck at something could only be read by killing it, which ends what was stuck. magpie heap and magpie cpu already ask the running gateway for a profile over loopback; magpie goroutines asks it for every goroutine's stack. That works on Windows too, where there is no SIGUSR1. GET /v1/magpie/goroutines (goroutines.go) answers the callers /v1/magpie/heap answers (profileRefused: a program on this computer over loopback, no browser mark, a loopback Host; a gateway key lets nothing else in) with runtime/pprof's goroutine profile at debug=2, the form a crash prints: each goroutine's state and wait ("[select, 4320 minutes]"), its frames with source lines, and who started it. It is text/plain and no-store, and X-Magpie-Goroutine-Stats names the process (pid, program, version, window, uptime, goroutine count). Arguments are words in hex, never what they point at, so the dump holds no keys, prompts or messages; it does name magpie's source files and the program's path, which the usage says. magpie goroutines [<file>] writes it to <file>, else magpie-goroutines-<date>-<time>.txt in this folder, 0600 and never over a file there, then prints the file and the process. --help, -h and help print the usage and ask nothing; a flag it doesn't take, "-", a blank name or a second file are refused before the gateway is asked. A magpie older than this one answers 404 and is told to update; with none answering, it says so. The refused callers TestHeapProfileOnlyToThisComputer listed move into profileCallersRefused, which the CPU test and the new one share. Run on |
||
|
|
a2cef8bf4f |
provider: partners.json keeps when the list was last tried and how it ended (#3362)
"partners":null} for three days, and nothing told a fetch that failed every time from one that never came back, or from none being asked. A failed fetch wrote nothing and logged nothing. refreshPartners now keeps two fields with the list: - tried: when the last fetch started, written before it is sent; - error: how it failed (whitespace folded, cut at 500 runes), cleared when the next one starts. Read together: error set, the last try failed; tried after at with no error, a try is still out; tried long ago, nothing has asked since. A failure is logged once until its error changes or a fetch gets the list again, and the fetch that gets it after a failure is logged too. The desktop app's log goes nowhere a user can read, so for the app the file is what tells. Checked for #3362 on the way: v0.1.1296's fetch, keep and save, given the bytes /api/partners serves now (Kimi Code, listed from 10-23 00:00 +08:00) over the 10-20 file, writes the file, with the icon fetched or not. So it isn't the save or the list. Run on |
||
|
|
f252b403d3 |
provider: the icon prune leaves a listed partner's logo, so the add sheet keeps drawing it (#3424)
partnerIcon keeps a partner's logo in the icons folder beside providers.json and, while its iconUrl stays the same, uses the file it kept as it is ( |
||
|
|
ba4b754b22 |
gateway: a relayed Chat stream's tool call with no index is given its call's (#3386)
xianfeng-zhu (#3386): Cursor's Private Inference on magpie's /v1/chat/completions, a Gemini model behind it, failed every turn that made a tool call with AI_TypeValidationError at choices[0].delta.tool_calls[0].index ("expected number, received undefined"), then a 499 loop; turns without tools went fine. Gemini's OpenAI-compatible API sends its calls with no index (Linka's frames in gemini_compat_cut_test.go have none either), where the OpenAI contract has one on every fragment, and a relayed stream went on without one. The AI SDK's OpenAI provider, which the report names as what Cursor reads Chat with, checks every chunk and turns that one away, so the call is never made. OpenAI's own node SDK, through its stream helper, keeps no call at all. chatTidy, which already mends a relayed Chat stream's empty ids, empty names and "stop" after calls, now gives a fragment with no index (none, or null) the index of its call (streamCallIndexes.give). A fragment with an id other than the open call's, or after the first in its delta, starts the next call, as chatDecoder reads a new id; any other goes on with the open one. So two calls in chunks of their own are 0 and 1. Given both 0, as their place in the delta would give them, OpenAI's node SDK merged them into one call with both arguments run together. A fragment with an index keeps it, and a stream whose calls have theirs goes as it came. It runs before the ids are mended, so a call with no id either (#3386's chunk) gets both. Not changed: the translations write an index already (chatEncoder, chatWholeEvents), and a whole reply's message needs none. Nor is a call given a type: Gemini's frames have "type": "function". The report's chunk has neither an id nor a type, and is taken as cut short: magpie gives a call with no id one (#2611, v0.1.1277), so the chunk it sent would have had one. What was run (tree e6023c66, on |
||
|
|
9a2106220c |
gateway: a background sub-agent's notification after tool results reaches the Claude run (stones_2026 on Discord)
Claude Code 2.1.310 runs Agent sub-agents in the background by default.
When one ends while the main agent is mid-turn, Claude Code tells its
model with a <task-notification> in a {role: "system"} message after the
tool results (several that end together share one text block), or as a
text block of the results' message. On the Claude subscription path
saidWithResults drops every system message that isn't the user's own
mid-turn words (#2060,
|
||
|
|
e219f699ca |
gateway: with no S3 bucket the request archive keeps calls on this computer, oldest removed past 1 GiB (CyberCaius)
CyberCaius on Discord: "请求存档只能存在 s3 存储桶里,不能保存在本地吗". The Usage page's Request archive switch refused without an s3:// sync. Now, with no bucket, the same switch keeps each call in <settings.Dir()>/request-archive/<date>/<id>.json: the same file the bucket gets, masked the same way (Archived, archiveRequest), written to a temporary file beside it, synced and renamed, 0600 in a 0700 folder. Past its size (RequestArchiveLocalMB, 1 GiB unless set) the oldest calls go first, down to a tenth under it; the call just written is never removed, empty day folders go, and a .part file an hour old is removed on the next scan. The running total is counted once and then added to, so a write walks the folder only once it is over. On by default or a switch: a switch, still off unless turned on. Bodies can hold secrets, so nothing is written to a disk where the user didn't ask. The local switch is its own field, RequestArchiveLocal, in KeepOwn with its size, so sync never turns it on at another computer, and RequestArchive synced from a computer with a bucket keeps nothing on one without (archiveDest). The GUI switch writes RequestArchive while sync has a bucket and RequestArchiveLocal while it has none; the tooltip names the folder and the size, and a failed write reads "Not saved" (en, zh, zh-TW, ja, de). GET /api/archive reads this computer's copy first, then the bucket. The Settings page's save keeps both fields (api.go). Docs: sync-backup.md and gui-shell.md say where the archive goes and why the switch is per computer; the privacy pages (en, zh, ja) say what the folder holds, that it is off by default, and how large it grows. The READMEs' Privacy is about what is sent and is unchanged. app.js stays under TestCoreScriptBudget (its comment was shortened, and one t() call folded); no budget raised. Run (worktree diff on |
||
|
|
b5d46acbed |
agent: Kiro Crew runs on a harness connected to magpie
Vincent on Discord asked for Kiro Crew (kirodotdev/KiroCrew v0.9.0: the KiroCrew.app desktop app, the kirocrew CLI, its dashboard and the Gateway on :5476). Crew has no model provider of its own. It runs each session on an ACP harness picked by agent.acp_backend (and dispatched members by agent.member_acp_backend) in $KIROCREW_HOME/config.json, default ~/.kiro/crew (src/kiro_crew/config/paths.py, loader.py, sections.py; ACP_BACKENDS_MEMBER_DISPATCH in agent_sdk/backends.py). Connecting sets those keys to an agent already connected to magpie, tried in this order: Codex, Claude Code, OpenCode, Pi, Goose. One whose ACP adapter is installed (codex-acp, claude-agent-acp, pi-acp) wins, so one click is enough. magpie looks for the adapter where Crew does and installs nothing; when it's missing, the notice gives the npm command. With no harness connected the connect is refused with a message naming which agents to connect. A harness set in config.local.json wins over config.json, so magpie doesn't write it and the row says so. The previous values are stashed. On Disconnect they are put back, but only for keys that still hold what magpie wrote, and a file magpie created is removed once it's empty. The row reads as connected only while its harness is still wired to magpie. deepseek is not offered: Crew runs it as dsh --profile acp, which magpie's dsh wiring doesn't reach. KIROCREW_HOME and the adapter path variables are read from the login shell (agentenv). Run (Go and the GUI files at base |
||
|
|
7765f27fcc |
gateway: a model an account refuses goes on to the accounts not listing it yet
01huadalang (Discord): Antigravity with several accounts, only some can
use Gemini 4. The model and its bar showed only after the right account
was made preferred and probed, and a request failed with the preferred
account's error instead of going on to the account that serves it.
st3lland (Discord): on ZCode (plugin) accounts serve different models.
Owner: no manual setting, magpie knows per account and routes.
Two causes:
- perKeyBarred puts an account whose own saved list lacks the model in
pl.unlisted / pl.left (Unlisted) and serve never asked it. So when
the listing accounts refused the model (Antigravity's real 404
NOT_FOUND "Requested entity was not found.", codeAssistModelMissing;
plugins through modelRefused's unservedWords), the agent got that
error even though an account whose list was simply stale serves it.
Now, once every listing account of that subscription/model has been
asked and one refused it as unserved (unservedTry), its unlisted
accounts are asked next, right after it and before any other member
or fallback (unlistedNext, askUnlisted for the trace). The refusing
try rests as before (restAfterMarked, for that model). Not for a
pinned account, a sealed conversation or strict affinity; a gateway
key's account list narrows unlisted too (allowedCandidates). Other
refusals (403 PERMISSION_DENIED, 429 RESOURCE_EXHAUSTED) don't open
the unlisted accounts.
- Antigravity's per-account lists were refreshed only on the first
listing, a probe, a sync or a Refetch, so a model granted later and
its bar (chosenWindows filters by exposed models) stayed hidden. Its
quota reading already fetches fetchAvailableModels per account; now
it saves that account's list (noteAntigravityList) and re-merges the
pooled list from every On account's list when it changed. An Off
account's reading changes nothing.
Other vendors: the unlisted route only opens on the existing unserved
classifiers (Antigravity's 404, plugins' unservedWords), unchanged here;
TestUnlistedAccountNotAskedForOtherRefusals holds that the other real
Antigravity bodies don't open it.
Run (at the rebased head on origin/main
|
||
|
|
31275d0734 |
gateway: a history call to a tool the request doesn't declare gets a stub where it is refused (pi, T3 Code tool_search)
Gearclickist on Discord: pi and T3 Code, on magpie's /v1 chat/completions,
load tools on demand. The tools a tool_search found are called in the
history but not declared in the next request's tools, and pi sends
"tools": [] with history calls when it has no tools left.
Cause, per upstream (magpie forwarded the calls unchanged on every path,
seen in a probe through fakes):
- Anthropic Messages (API, Bedrock/Vertex Claude, relays): a call to a
tool it isn't given is accepted, but calls with no tools at all get
400 "Requests which include tool_use or tool_result blocks must
define tools". anthropicBody dropped tools when the request had none,
so pi's tools: [] turn failed. Now each tool the history called is
declared as a stub (any object, "Called earlier in this conversation;
not available now.") with tool_choice none, as LiteLLM's dummy tool
and the Kiro plugin do.
- OpenAI Chat/Responses, ChatGPT backend, Gemini/Code Assist: take the
history as it is; left as sent (TestUndeclaredHistoryToolTakenAsSent).
- Stricter Chat/Responses/Messages upstreams (relays in front of Kiro or
Bedrock, vendors that check each call's name): a 400/422 that names an
undeclared history tool as not found/unknown/not defined, or says tools
must be defined beside the calls, is asked once more with a stub per
missing tool, relayed or translated, and remembered per provider and
API (historyToolsRefused). tool_choice none only where the client
offered no tools. Namespaced Responses calls are left to the namespace.
- Claude subscription: runs real Claude Code with the history as text,
not affected. Kiro plugin already stubs its history's tools.
Run, at 54874c9ee rebased on origin/main:
- the new tests and the gateway's ToolStrict/Anthropic tests: ok
- gofmt -l: clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: clean (before the rebase)
- go test -tags nogui ./... -timeout 45m was running at the pre-rebase
commit when this was pushed (ship-immediately); its result goes on the
tag's report.
Broken by hand, each red, then restored green:
- the refusal matcher off: RefusedThenStubbed (chat, responses,
anthropic) and ToollessHistoryRefusedOnChat red
- the remembered upfront stubs off: RefusedThenStubbed red (3 asks)
- anthropicBody's stubs off: ToollessHistoryToAnthropicDeclaresStubs red
- the stubs' tool_choice none off: same test red ("tool_choice \"\"")
Not tried: no real vendor was asked (fakes only); the refusal wordings
for stricter vendors are modelled, not captured from the reporter, who
named no upstream; the other community plugins' own translators
(Cursor, Devin, Qoder, ...) were not read for this; real pi/T3 Code not
run against this build.
|
||
|
|
436bcc946d |
routing: a request whose vendor counts no cache tokens shows no hit rate, not 0% (zeewell on X)
zeewell on X: every Kiro request in a routing group showed cache 0%, for
claude-sonnet-5.5 and claude-opus-5.5 from Claude Code, with 148k to
182k tokens and consecutive calls.
The cause, from real Kiro calls on the owner's account (read-only, from
a sandbox): Kiro does cache. A repeated 900-line prefix cost 0.0912
credits and then 0.0484, with or without cachePoints, and with a fixed
conversationId too. But Kiro's reply holds only assistantResponseEvent,
metadataEvent {stopReason}, contextUsageEvent (a percent) and
meteringEvent (credits). There are no token counts at all, and
kiro-cli 2.32's own trace shows the same. The plugin wrote
cache_read_input_tokens: 0, which magpie showed as 0%.
opencode-kiro-auth 0.1.16 (plugins 9f6c4e8) now leaves the cache fields
out and says `magpie_cache_unknown: true`. This commit reads that field:
- aUsage reads it into Usage.cacheUnknown, ORed in Usage.add.
- routeUsage sets RouteUsage.CacheUnknown (cache_unknown, omitempty) on
a try that counted no cache read or write.
- The Routing page's promptOf leaves such a try out of the hit rate. The
row and its session then show no Cache metric, as for older history.
Clients are never told the field. Usage.anthropic() leaves it out, and
a passthrough forwards the plugin's bytes as they came. The gateway
already relays cache_control to an Anthropic-protocol plugin as Claude
Code sent it, so nothing was lost on the way to Kiro.
Left alone: the usage ledger. usage.Record has no such flag, so the
Usage page's aggregate hit rate still counts a Kiro prompt as a miss.
Filed as #3464.
Run at this head (rebased on origin/main
|
||
|
|
ef37b6fb76 |
gateway: an exhausted ChatGPT account no longer greys Codex app's Send while magpie can serve the turn (MasterYi on Discord)
MasterYi (#help, 1563467829687222343): with magpie wired into the Codex
app, a used-up ChatGPT account greys the Send button, so the third-party
models joined in Codex's picker can't be used either.
Cause, as far as the app's bundled code (ChatGPT.app 26.1013.40934,
read-only) shows: Send is gated in the app itself. It needs
authMethod == "chatgpt", the /wham/usage reading (fetched by the app
straight from chatgpt.com, not through magpie) saying not allowed, and
no credits. authMethod is read as the app opens or on account/updated,
which the app-server sends only on login/logout, not on a config change.
So the gate lifts only when model_provider is magpie AND the app has been
opened again. #540 already made magpie the provider while out, but only
when a magpie model was the default; on one of Codex's own models
(joined), nothing changed.
What changed:
- A (agent/codex.go Sync): joined on one of Codex's own models and the
account out (not Always ChatGPT, not magpie API), magpie becomes the
provider on that model as magpie serves it (codex/<model>), the model
kept in codex.out_own. Once the account has room, Codex is put back
joined on that model. A model picked meanwhile stays the user's. With
no ChatGPT account in magpie to serve it, nothing changes. New
Agent.AppOut says magpie is the provider for a used-up sign-in.
- C (provider/codex_app_out.go): a usage_limit_reached rest on the
active Codex account (gateway routing) or an x-codex-* window heard at
100% (NoteCodexLimits) has the account read again at once
(CodexMayBeUsedUp: active account only, at most every 20s, only
while a KeepOnAnAccountWithRoom loop has made its first reading and
still runs), not only on the 5-minute look. A first cut turned this
on for good as the loop started; every gateway test's Serve starts
it, so later gateway tests had accounts read again behind them, and
TestCodexOwnModelMovesToNextAccount and
TestCodexSpentMovesToNextGroupMember went red in the package run
(green alone 3 of 3). Now a counter, up after the first minute's
reading, down as the loop ends; the package run is green with it.
- B (gui/codex_app_out.go): the app open when the account ran out is kept
by its app-server's pid (provider.CodexAppOut; a new pid means it
reopened and read the provider, standing in for "authMethod is still
chatgpt"). On macOS, every 10s, magpie reopens it through the Agents
row's ReopenCodexApp when: AppOut, the account still out, the app is a
copy from before the config change, no turn in flight through the
gateway and none ended in the last 30s. At most once per time the
account runs out, success or not.
Drafts: the app's code keeps composer drafts in a persisted store
(composer-prompt-drafts-v2, 250ms debounce, flushed on quit), and
threads are server-side, so an unsent draft and open threads should
survive the quit. Not watched in a real app.
- D (GUI): Codex's accounts say "The Codex app can't send on {user}'s
used-up account": on macOS that magpie reopens it once no turn runs;
off macOS (no reopen path) or once tried, to quit and reopen it.
en, zh, zh-TW, ja, de.
Tests (each red on the code without its part, broken by hand):
- TestCodexOwnModelGoesThroughMagpieWhileUsedUp: red at "used up" with
the out case off, at "allowance back" with the restore off.
TestCodexOwnModelKeptOnChatGPT: Always ChatGPT stays.
- TestCodexMayBeUsedUpReadsAtOnce: red at "a window full: not read"
with the NoteCodexLimits hook off. TestCodexAppOutEpisode.
- TestCodexUsedUpReplyAsksAtOnce (gateway): red, asked [], with the
routing hook off.
- TestCodexAppOutReopenedOnce (gui, reopen stubbed): red at "a turn in
flight" with the idle check off, and at "again" with the once checks
off.
- codex-app-out.test.cjs: 40 of 40 (chromium, webkit; 900/480; five
languages; both texts); 2 of 2 red with the notice's call site off.
What was run, at this tree:
- gofmt -l: none. go vet ./... (darwin), GOOS=linux go vet -tags nogui
./..., GOOS=windows go vet ./...: exit 0.
- go test -tags nogui -timeout 45m: internal/agent ok (414s, before a
comment-only reorder in Sync); internal/gateway ok (534s),
internal/gui ok (78s), internal/provider ok (137s), after the
live-check fix, at this tree before the previous commit's JS-only
move (then with a budget raise since taken back); internal/gui
again after the move.
- GUI (chromium, webkit), at this tree: codex-app-out, codex-app-stale,
i18n-keys, gui-de, gui-ja, gui-zh-tw and the files reaching the
previous commit's move: 164 of 164. Before the trim, every codex-*
and account-* file: 447 of 448; the red, codex-predictions chromium
ja 420 "picking a model scrolled the page", is #2624 and is red alone
on origin/main
|
||
|
|
6d707af083 |
routing: a member behind another by weight or order isn't told as kept for last (Creat.wu)
Creat.wu on Discord (#general, 10-24): in a group routed by weight, a
sub-group whose accounts are all near their limit "is skipped however
high its weight". The screenshot is the Routing page's line
"<account> 已用 91%,其他账号都无法响应时才用。"
Cause: the routing itself already gives such a member its share.
weightedUnits leaves a unit out of the round only when its head is
resting; Smart's 90% band orders accounts inside the sub-group and
nothing in the parent reads it. A sandbox probe with the reporter's
shape (parent weighted, group/sb:4 with two Codex accounts at 91% and
92%, a key at 1) sent 16 of 20 new conversations to the sub-group and 4
to the key. What was wrong is the explanation. On a request whose turn
went to the key, the sub-group's accounts are listed after it, and the
page's asides (client.js) said of each one "used 91%, kept for when the
others can't", which reads as the member being passed over.
Change:
- client.js: memberSplit finds where a later account parts from the
first one in the group tree. When that level is routed by weight (the
first has the round's turn) or by order (no affinity kept, no rule),
a low or not-yet-known account there gets one line per member instead:
"{member} isn't passed over for being near its limit: by weight this
request was {first}'s share, and {member} takes its own share of the
requests while it can answer." or "... it comes after {first} in
{group}'s order." Spent and resting lines are unchanged, and inside a
Smart sub-group the low line stays, since the band does order those
accounts.
- i18n.js: both strings in zh, zh-TW, ja and de.
- weighted_low_test.go: TestWeightedGroupGivesALowGroupItsShare holds
the share (16/4 over 20, only the account with most left inside, and
the sub-group's accounts behind the key not resting).
- routing-weight-member-low.test.cjs: weight, inner-Smart, order and
plain Smart scenes, chromium and webkit, every language.
- gateway-routing.md: the weighted sentence says a unit near its limit
keeps its share, and points at memberSplit.
Siblings: Smart, usage and pace parents weigh a nested group by its
head, so a low head goes later there by design and its line stays.
Manual picks a member and sorts the rest smartly (line stays). Rotate
is account-level.
Run (worktree at origin/main 7d9165d84; rebased on
|
||
|
|
c8901d4723 |
gateway: auto mode's classifier asks a model of unknown levels for no reasoning
CyberCaius on Discord (#help): in Claude Code's auto mode every
classifier request ended 499 in magpie, on a new-api relay's
gpt6.1-sol (an OpenAI-compatible provider the user added), v0.1.1364.
Cause (likely; not confirmed against the reporter's relay): Claude Code
2.1.310 sends the classifier as a non-stream sideQuery, thinking off or
left out, 64 (or 2112) tokens, and waits 60s an attempt for it (WWt in
the bundle; 120s cap on large prompts). fitAutoModeClassifier asked for
the least reasoning only when magpie knew the model's levels. For a
relay's own name it sent no reasoning_effort / reasoning.effort, so a
reasoning model reasoned at its vendor's default over the whole policy
and transcript. That ran past Claude Code's wait, and Claude Code
closed the request (499).
Change:
- automode.go: with the levels unknown, the classifier is asked for
effort none, marked as magpie's own ask (Request.OwnEffort).
- gateway.go forwardTranslated: a 400 to that own effort
(ownEffortRefused) is asked again. If it named the level, it is
asked at low (offRefused). If it named the field ("Unrecognized
request argument supplied: reasoning_effort", "Unsupported
parameter: 'reasoning.effort'"), it is asked without the effort, as
before. Either is remembered in unfit until restart. Only the
classifier gets OwnEffort, and no other request changes.
- docs/subsystems/gateway-routing.md: a bullet on the local
classifier.
Run:
- TestAutoModeClassifierReasonsLeastOnAnUnknownModel covers Chat and
Responses, non-stream, thinking off/64 and left out/2112. It is red
on the old code: no effort was sent in any of the four cases.
- TestAutoModeClassifierEffortRefusedGoesWithout covers a named level
going to low, and the Chat and Responses field refusals going
without. Each next ask takes one request.
- TestAutoModeClassifierOnlyTheClassifier now expects none for unknown
levels (the
|
||
|
|
3e9efe1d51 |
gateway: a Codex turn chatgpt.com's WebSocket refuses as too big goes over HTTP (Lamrfu)
Lamrfu on Discord, after updating: the Codex desktop app through magpie
kept showing "正在重新连接 2/5" with
unexpected status 502 Bad Gateway: Codex: Post ".../backend-api/codex/responses":
codex websocket: failed to get reader: received close frame:
status = StatusMessageTooBig and reason = ""
Cause.
|
||
|
|
ef1a203df9 |
gateway: an Antigravity account out of quota rests until the reset its 429 names, not 15 minutes (Dani Ariyanto)
Dani Ariyanto (Discord #feedback, 10-24): seven Antigravity accounts, several ticked, one First, OpenCode on Gemini 3.8 Flash. With the First account out, requests kept going to it instead of the next account, which had all its quota. Cause: Antigravity's 429 for a model's quota used up says when it is back as a Go duration: "You have exhausted your capacity on this model. Your quota will reset after 3h19m30s." (QUOTA_EXHAUSTED; the fixture antigravityQuota, already in the tests since |
||
|
|
1d6b72ada8 |
gateway: a search magpie runs for a model cites its pages in Anthropic text blocks (H20)
H20 on Discord (#general, 10-24): a client offering web_search_20250305
to auto/deepseek-v4.1-flash or deepseek/deepseek-flash got its text
blocks back with no citations, where Anthropic's API gives
web_search_result_location entries pointing at the
web_search_tool_result pages.
magpie's web_search tool asks the model to "Cite the URLs you use", so
the answer names pages by URL. After a KSearch event (or a Search part),
the Anthropic encoder and renderAnthropic now cut the following text
into lines (citer, search_cite.go). A line naming a found page's URL
whole (urlIn: not a longer path, a query or another host; Chinese
punctuation, markdown links and bold end a URL) is its own text block
with citations {type, url, title, encrypted_index, cited_text}; the
lines between run together in one uncited block, and whitespace-only
lines are held for the next, so no block is whitespace alone (Anthropic
refuses one sent back). Streamed, a cited block's citations_delta come
before its text_delta; text is buffered to the line end, only after a
search. The text is the model's, unchanged. A reply with no search is
said exactly as before.
encrypted_index is "", as the results' encrypted_content already is:
it is Anthropic's sealed pointer, which magpie can't make (Claude Code
2.1.310 knows "invalid encrypted_index in text block" and strips these
citations when that comes back). cited_text is Hit.Cited cut to 150
characters: a search API's page text, or the cited_text of an Anthropic
searcher's own citation (searchWith now reads it), else "". No prompt
text sent upstream changed; no Codex prompt touched.
Sibling filed: Responses and Chat replies still carry no url_citation
annotations (#3455). docs/subsystems/gateway-routing.md has a new
"Citations in translated Anthropic replies" section.
Run (at c579609d9 on
|
||
|
|
ccbbcbffcb |
gui: a restart to update leaves the Mac's menu bar icon for the next magpie (Mitsuha, audie)
From v0.1.1354 a restart to update hands the gateway over, and the old
magpie hides its own menu bar item with Wails' Hide, which is
[statusItem setVisible:NO]. AppKit keeps that in the app's defaults by
the item's autosave name ("NSStatusItem VisibleCC Item-0" = 0 on macOS
26), and the next item made under that name starts hidden. So after the
update the icon was gone, and quitting and reopening didn't bring it
back (Mitsuha on v0.1.1364; audie on two Macs, macOS 27.0.1).
Evidence: a 30-line Cocoa probe made a status item, setVisible:NO, and
every later launch of the same program started with visible=0 and the
key = 0; removeStatusItem kept nothing; removing the key brought it back
on the next launch. This machine's com.yetone.magpie.sbhandover.plist
(the handover commit's own sandbox run) holds
"NSStatusItem VisibleCC Item-0" => false.
Fix (internal/gui/trayshown_darwin.go, app.go):
- leaveMenuBar (was the onHandedOver closure) queues forgetTrayHidden
on the main thread after Wails' hide block, so the hide is made on
screen but not kept.
- bringTrayBack, once per computer (a flag in the Mac's defaults, never
in a WebDAV backup), forgets a kept hide before the tray is made: that
repairs everyone an older magpie already hit. A hide kept after that
is the user's and is left alone.
- A magpie handed over to by an older one (which still hides for good)
forgets the hide once that pid has quit and shows its item, unless a
hide was already kept when it started.
docs/subsystems/gui-shell.md says so under the handover.
Run (worktree at origin/main
|
||
|
|
ed91aa04ef |
checkin: an inactive or ineligible check-in shows the plugin's reason (plugins#304)
Qoder's plugin 0.2.32 (magpie-community/plugins 74be632) says why no check-in was offered: it asked with this machine's own device identity and Qoder offered no campaign, and Qoder desktop can claim one it shows. magpie dropped a hook's message for inactive and ineligible and showed only "No check-in event now". Now: - GUI: the Usage card's row reads "<label> · <message>", wrapped under the label rather than cut off with "…" (data-why, as a failed row's reason wraps, #821); Settings' check-in line under the plugin's switch carries it too. A result without a message reads as before. No new i18n keys: the message is the plugin's own text, as for failed rows. - TUI: the Usage cell is too narrow, so it adds "c says why"; c's flash carries the message (checkinWhy). - CLI: `magpie accounts checkin` prints it after the label. - The Qoder mover's min is 0.2.32 (npm view --prefer-online: 0.2.32). - docs/subsystems/provider-plugins.md says how the message is shown. Run at this tree (based on origin/main |
||
|
|
a3b45eb91e |
provider: a re: pattern matches in any case, as a glob does (usrname1833 on Discord)
A routing group's patterns (Group.Match) and a provider's auto-include rules both compile through compilePattern. A glob compiled with (?i) and a re: pattern without it, so re:gpt-.* missed GPT-5.5 while gpt-* took it. A re: pattern now compiles as (?i)^(?:…)$; (?-i) inside it makes case matter again from there on (re:(?-i)gpt-.*). The Routing page's editor works out a pattern's models in JS (patternRe in plugins/routing/client.js) and refused what JS can't read. It now reads re: with the i flag too, and takes Go's leading flag group ((?-i), (?s), ...) as JS flags, so re:(?-i)OR/B is taken and matches as the gateway will. A flag group further in is still refused there (JS has no bare (?-i)); the CLI takes it. Said in groupmatch.go's comments, magpie group's and magpie provider auto-include's help, and providers-accounts.md (Routing groups, List schedule and rules). No GUI hint said a pattern's case, so none changed and no string was added. Run: - TestRegexpPatternIgnoresCase (new): ok. With compilePattern's (?i) taken off by hand: FAIL, "re:GPT-.* ~ gpt-5.5: false, want true" and three more cases. - group-patterns.test.cjs, chromium and webkit, en and zh: 4 of 4 ok. With patternRe put back to the old re: line by hand: 4 of 4 red, "(?-i) keeps case 0 !== 1" (old JS refused re:(?-i)OR/B). - gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: clean. - go test -tags nogui -timeout 45m ./internal/provider ./internal/cli ./internal/gateway under a sandbox HOME at 1a956129c's tree: ok, ok, ok (380s). go build for darwin, linux (nogui) and windows: ok. - A full ./... run was started and stopped: the machine's disk was full (1GB free), and internal/agent's tests failed on "no space left on device" in TempDir, not on this change. No full suite ran. Not tried: the full suite (above); a real provider's auto-include fetch with mixed-case ids; the Linux app's WebKitGTK; a (?-i) further into a re: in the GUI. |
||
|
|
edff2f819a |
provider: levels kept of a model's own narrow only what is offered again (#92)
|
||
|
|
4a3e07f1cf |
model: magpie model spec sets a model's window, output, vision and levels at once
Dani Ariyanto on Discord (#feedback, 10-24): a custom provider's models (kenari/*:free) had no window, reply limit, vision or reasoning known, and there was no one place to say them. magpie model spec <provider/model> what it has, and whose each value is magpie model spec <provider/model> [--context <n>] [--output <n>] [--vision on|off|auto] [--reasoning <levels>|off|auto] magpie model spec '<provider>/*' --context <n> --output <n> magpie model spec <provider/model> --reset magpie model specs It writes the stores magpie model context/output/images/efforts write (providers.json contexts; settings.json modelOutputs, modelImages, modelEfforts, modelReasonless), so every reader that went by those goes by a spec: entryFor/EntryOf/Served, /v1/models, max_tokens, the GUI's /api/providers badges and chips, and the agents' model lists. Every part is checked before anything is written; a refused command writes nothing. Agents are told once. Readers that bypassed the stores and now honour them: - provider.Efforts returns the kept levels, so the gateway fits a request to them (fitEffort): xhigh asked of a model kept to low-high goes as high. This reverses #92 ( |
||
|
|
ea9454d2d8 |
usage: count two ids of one model as one, magpie model alias (SlouchyQuill507 on Discord)
A vendor names one model two ways (deepseek-v4.1-flash and deepseek-flash),
and Usage, Usage > Sessions and `magpie usage` showed two rows. Now:
magpie model alias deepseek-v4.1-flash deepseek-flash
magpie model alias deepseek-v4.1-flash (what it is counted as)
magpie model alias deepseek-v4.1-flash --reset
magpie model aliases
kept as settings.json "usageAliases" {from: to}. Off until one is written.
Ids match as routing groups match them (provider.sameModel: vendor/ prefix,
case, "_", snapshot date), at every provider; a chain is followed to its
end; an alias to itself, a loop, or a flag as an id is refused. A loop
written into the file by hand counts each model under its own id.
Display only: requests, agents' model lists, /v1/models, routing groups,
Same as and prices never read it. Each call is priced by the id it was
made under and only then counted under the alias; the alias's own price
is never put on the other id's calls, and a merged row is priced only
when every id in it is. Applied in usage summarize/direct (Models
groups), the gateway sessions projection (alias read before
gatewayCache's lock; the cache key hashes usageAliases), and
sessions.List/Get/Find/Stats (read before storeMu/mu, merged into new
slices so the memo is untouched; ModelEffort rows merged too). A failed
settings.json read keeps the last aliases read, and SetUsageAlias refuses
to write over an unreadable file (EditUsageAliases under fileMu). The GUI
settings save carries usageAliases. No GUI control.
Not aliased: the Requests ledger's per-request model and its model
filter, which show each call's own id.
Run (worktree at
|
||
|
|
f4640c0aee |
sessions: an agent's folders are one list, newest first, the temporary ones folded at the end
The Sessions page drew each folder as a boxed group with its checkbox,
path and buttons always showing. Now it is one list, the way Finder's
recents read: a row says the folder's name, where it is (home as ~, from
the manage reply's new `home`), its newest session's title, when, and how
many. Temporary folders, the disk's root and apps' hidden folders under
home wait folded under Other folders at the end; a search or a session
opened from elsewhere unfolds them. Checkboxes and the Delete bar come
only with Select, and Done lets the pick go. Relocate project and Delete
all sessions move into a folder's ⋯ menu (hover, always on touch, and
right-click); Delete all asks in magpie's own dialog.
Asked for by the owner ("这个会话页面其实特别丑"), who approved the design.
Tests: sessions-folder-list.test.cjs (new) checks the order, the ~ path,
the fold and its count, Select/Done, the ⋯ menu's Delete all and its ask,
and no horizontal scroll, in Chromium and WebKit, en/zh/zh-TW/ja/de, at
1000 and 420px. The other sessions tests follow the ⋯ menu and Select.
Run at this head (rebased on
|