d3db461bbb234cd1dfae034a17dd7dc1cbc707e3
900
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d3db461bbb |
redact: the local model's secrets leave UUIDs, digests and paths, and client_metadata goes as written
The owner's masking records showed Codex's turn metadata with every id as
{{SECRET_…}}: installation_id, session_id, turn_id, window_id,
context_window_id, root_turn_id, and a skill's file path in the
instructions. The local model (OpenAI's Privacy Filter) labels a UUID a
secret: run on Codex's x-codex-turn-metadata it took each id, and on a
log it took a request id and "sha256 9b74…". The vendor and magpie's own
sessions match a turn by those ids, so masking them can break what
depends on them, and hides nothing worth hiding.
- modelTakes: a secret the model finds is not taken when it names a
thing (namesThing): a UUID, with window_id's ":0" after it too; a
digest with its algorithm's name; a file's path. A password or a key
it finds is still masked, and the rules' secrets (sk-…, password=…,
API_KEY: …) are unchanged.
- client_metadata is in defKeys: the client's ids, which no model
reads, go as written, as tools and stream_options do.
docs/subsystems/gateway-routing.md says both.
TestModelSecretIsNoID uses what the real model labelled "secret" on these
texts (pf-serve with the q8 model, run here): the UUIDs, the request id,
the sha256 digest, plus the reporter's path; the password and the
32-hex key beside them are still masked. Broken by hand: without
namesThing 5 values are masked, without client_metadata in defKeys a
user word in it is.
Run:
- At 3fff6c011 (on origin/main
|
||
|
|
1bd99194ea |
provider: Claude Code stays listed, signed out, when every saved account's sign-in is gone
LeeHom on Discord: two Claude Pro accounts vanished from Providers, and
signing one in again showed the other as "needs sign in again". While
Claude Code is signed out, the claude provider is built on
claudeStandIn's account. claudeStandIn skips an account whose sign-in
Claude Code let go of (claudeLoggedOut's claudeLogoutLapse) or that is
still Held. With every saved account like that, it returned "", no claude
provider was made, and the subscription and both accounts left the GUI,
the TUI and `magpie providers` at once.
claudeStandInAccount and Logins now ask claudeListed: the stand-in, else
the signed-out account seen last. A Held account is never listed this way,
because the sign-in Claude Code left on disk would then be served
(TestClaudeSignedOut still holds). The listed account's token still fails
with the lapse reason (claudeSavedDir), so nothing is served on it.
claudeStandIn itself is unchanged, since addLogin and logins_on rely on
it.
The app's row already said "{user} is signed out" when every login in use
had lapsed. Provider.SignedOut is that rule in Go. With it, `magpie
providers` says "○ <user> is signed out · sign in again" and the TUI says
"○ <user> is signed out", instead of a green "signed in". The CLI's key
column moved into keyColumn so it can be tested. The providers-accounts
doc row says this.
Tests:
- TestClaudeAllSignedOutStaysListed: signed in, a second account
logout-lapsed, then Claude Code signed out. It fails on the old code
("Claude Code left the Providers list with every account signed out:
false") and with SignedOut returning false (both broken by hand).
- TestProvidersSaySignedOut, in cli and tui: a signed-out account reads
as signed out and a signed-in one still reads as signed in.
Run: gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags
nogui ./..., GOOS=windows go vet ./...; go build for all three.
Then go test -timeout 45m ./... under a sandbox HOME at base
|
||
|
|
3c38fe5c99 |
agent: Zoo Code (VS Code) through its autoImportSettingsPath (wani on Discord)
wani on Discord (#feedback) asked for Zoo Code (zoocode.dev), a fork of Roo Code for VS Code and JetBrains. Route: Zoo Code keeps its provider profiles in VS Code's SecretStorage, which magpie can't write. The one file it reads is the one its zoo-code.autoImportSettingsPath setting names. On every activation (src/utils/autoImportSettings.ts, Zoo Code 3.90.0) it imports that file as Settings → Import does (importSettingsFromPath). magpie writes <User>/globalStorage/zoocodeorganization.zoo-code/settings/magpie-import.json with one profile, "magpie": apiProvider openai on the gateway's /v1 Chat Completions, key magpie-zoo-code, the chosen model, and an openAiCustomModelInfo built from the catalog (contextWindow, else Zoo's own 128000 default; maxTokens only when an output limit is known). It points the setting at that file in the default settings.json and in each VS Code profile's. A value the user set themselves is stashed and restored by Disconnect. The file sits outside magpie's folder so that a sync keeps an address the user moved (kept.away skips magpie's own folder). Requests say "ZooCode/<version>", and usage names them zoo-code. Limits (also in docs/reference.md → Zoo Code): - Zoo reads the file only at start: the notice asks for Developer: Reload Window. - While connected, each start switches Zoo back to the magpie profile. - Disconnect stops the import but can't delete the imported profile from SecretStorage. The user switches away from it or deletes it in Zoo. - VS Code Stable only. JetBrains is not wired. Zoo Code for JetBrains runs the extension in its own extension host, which is handed an empty configuration on every start (RPCManager.startInitialize in Zoo-Code-JetBrains), so the setting never reaches it. Its secrets sit in ~/.zoo-code/secrets.json, an internal store with no lock and no documented format. Neither is a clean route. Tests (internal/agent/zoocode_test.go): - TestZooCode: connect, model switch, a stale key that Check reports and Sync fixes, and disconnect putting the user's own import path back byte for byte with the file removed. - TestZooCodeFresh and TestZooCodeProfiles: VS Code profiles, including one made after connecting. - TestZooCodeDetectAndUA: Roo alone is not detected; ZooCode/3.90.0 maps to zoo-code. Broken by hand (the restore disabled): TestZooCode and TestZooCodeProfiles went red. The generated file was checked with bun against Zoo's own zod schemas (providerSettingsWithIdSchema, isProviderName; zod 4.6.7 from its repo): valid, every field kept, current profile in apiConfigs. Run, set -o pipefail, GOMODCACHE pinned, sandbox HOME: - First full run, with this change on |
||
|
|
049040283e |
codex: a searched conversation under Codex's web.run isn't sent the hosted web_search beside it (Savin on Discord)
Savin (#help, magpie 0.1.1296, Codex 0.163.0-alpha.10.2, signed in with ChatGPT): the turn failed with the ChatGPT backend's "a single request can't contain both a client-declared function web.run and the hosted tool web_search". Who adds which: - web.run is Codex's own. codex-rs/ext/web-search (tool.rs) declares it as a function "run" in the "web" namespace, and spec_plan.rs's hosted_model_tool_specs leaves the hosted web_search out whenever web.run is registered: on a Responses Lite model (whose requests take no hosted tools at all), or with the standalone_web_search feature on. Codex never sends both itself. - The hosted web_search was magpie's. provider.DeclareSearch (#1270) adds the cached-only {"type":"web_search","external_web_access":false} to any ChatGPT-bound request whose input replays a web_search_call without declaring search. declaresSearch looked only for a web_search* type, so a conversation that had searched with the hosted tool and went on under web.run (a Lite model, a newer Codex, or magpie's own searcher's web_search_call items) got web_search added beside web.run, in the additional_tools item for Lite or in the tools. The backend then refused the turn. What changed: declaresSearch counts web.run as the conversation's search. It matches the namespace "web" holding a function "run", and a function named "web.run". DeclareSearch then leaves the body as Codex sent it. This covers both routes that call it: codexBody (a ChatGPT account in magpie) and codexUpstreamOn (Codex's own sign-in relayed). Nothing the client declared is dropped. web.run is the tool the backend serves this client (through /alpha/search), so magpie no longer adds the tool that conflicts with it. A namespace other than "web" with a "run" function still gets web_search declared. Not verified: whether the ChatGPT backend accepts a replayed web_search_call under web.run with no hosted tool. That is the request the official Codex client sends to it directly. It was not probed on a real account, and the test fake assumes it is accepted. Tests: - TestDeclareSearch: new cases cover web.run in Lite's additional_tools, web.run among the tools, the flat "web.run" function, and another namespace's run. - TestSearchedConversationUnderWebRun: protectedSearch now refuses a request that carries both tools, with Savin's error. The test covers Lite on Codex's sign-in (relayed byte for byte) and two turns on a ChatGPT account (Lite and tools). - On |
||
|
|
b855cfee9e |
redact: a file named like an address (…@2x.jpg) is not masked as an email (#3029)
vdxz on Pi with personal data masked: /Users/…/Pictures/261020_14-16-11@2x.jpg
went to the model as /Users/…/Pictures/{{EMAIL_…}}, and Pi could no longer
read the file. A Mac saves an image at twice its size with @2x before its
extension, which the EMAIL rule reads as user@2x.jpg.
realEmail leaves an address whose last label is a file extension no
top-level domain has (fileExt: jpg, png, gif, webp, svg, heic, pdf and
the like; py, md, sh, zip and mov are domains and stay out of it). The
local model's EMAIL spans pass the same check now (modelTakes), so it
can't mask the name the rule leaves. An address beside the file's name
is still masked.
TestFileNameIsNoEmail uses the reporter's path. Broken by hand: with
redact.go as on main the rule's half fails, with model.go as on main the
model's half fails.
Run at this head (on the #3143/#3144 commit, origin/main
|
||
|
|
88119d4f67 |
redact: Codex's tool server names, stream_options and snake_case words go as written (#3143, #3144)
Two reports from hibaliqya-yonma (v0.1.1306, Codex Desktop through
/backend-api/codex), each a 400 on every request until masking was
turned down:
- #3143: a user's word that is part of an MCP server's name went into a
Responses function_call's namespace as mcp__{{TERM_…}}. Codex checks a
namespace against ^[a-zA-Z0-9_-]+$, and the call is replayed every
turn. namespace is kept as name is, and so are the server's name in
its siblings: a Responses mcp_call's server_label, Anthropic's
mcp_tool_use server_name.
- #3144: the local model took stream_options.reasoning_summary_delivery,
"sequential_cutoff", for a name. stream_options is a request setting
now (defKeys, with reasoning and text), and the model's name is never
a snake_case word (snakeWord), wherever it is, so an enum or an
identifier in a tool's arguments or in code is not taken either.
The same word in the user's own message is still masked, and a name
beside it still is. docs/subsystems/gateway-routing.md says both.
Tests from the reporter's bodies: TestMaskJSONKeepsReasoningSummaryDelivery,
TestMaskJSONKeepsToolServerNames (namespace, server_label, server_name),
TestModelTakesNoSnakeWord. Broken by hand: with json.go and model.go as
on main, all three fail; with the change they pass.
Run at this head (origin/main
|
||
|
|
ba319a7587 |
gateway: the lone tool_choice none goes to the Grok plugin only (#3110)
|
||
|
|
19527ca8dd |
gateway: tools turned off with none declared reach a plugin as tool_choice none (#3110)
Cause: buildResponses wrote tool_choice only inside its tools block, so a
Chat "none", Anthropic {"type":"none"} or Gemini NONE with no tools was
dropped on the way to Responses. A provider plugin that adds a
server-side tool (Grok's x_search, plugins PR #263) couldn't tell
"tools off" from "no choice". The other builders (Chat, Anthropic,
Gemini, Code Assist) send no tool choice without tools, which is what
their vendors accept (OpenAI Chat refuses a lone tool_choice), so they
are unchanged.
Fix:
- buildResponses keeps a lone "none" (only "none"; "" and "auto"
still go unsaid).
- forwardTranslated strips it again for every non-plugin upstream, and
for a plugin on api.x.ai or Copilot (refusesLoneToolChoice, the #378
rule now shared with passthrough). A vendor never sees it.
- The grok plugin's body shaping (grokPluginBody) keeps a lone "none";
the built-in's grokBody still drops it. grok plugin 0.1.18
(magpie-community/plugins aee6b9d, on npm) drops any lone tool_choice
itself before Grok, so the mover's min goes 0.1.17 -> 0.1.18.
Run at this commit (worktree on
|
||
|
|
55b5eca055 |
gateway: a provider that searches for some of its models is offered as a searcher, with those models only (01huadalang on Discord)
Reported: 01huadalang has a Command Code plan, but web search offered no
searcher for it, although some of its models (gpt-6-luna) search on
their own. The picker counted a provider only when every model searched,
or when its host was a self-searching API.
Changed (internal/gateway/search.go, search_remote.go):
- partSearcher(p) holds for a provider with no Account and no
self-searching API host whose preset is in searchModels or whose base
host is in searchModelsHosts. modelSearchesAny(p, model) says whether
that model is one that searches.
- searchRank ranks such a provider 4 when one of its available models
searches. searcherReady keeps it. searchableModel offers only the
models that search, never e.g. claude-opus-5-5.
- docs/subsystems/gateway-routing.md says so.
Test: TestCommandCodeSearchesForOtherModels (search_models_test.go).
Broken by hand, each one red, then green when put back:
- search.go and search_remote.go reverted: "the picker offers [],
want Command Code's gpt-6-luna alone".
- partSearcher dropped from searcherReady's keep, and the
searchableModel case dropped: `Command Code searches with
"claude-opus-5-5"`.
Run, go1.26.8 darwin/arm64, sandbox HOME, private GOCACHE:
At this stack on origin/main
|
||
|
|
a8ecf4020e |
provider: a check-in file that can't be read or parsed stops the check-in
readCheckins, the reader every daily check-in shares (WorkBuddy, Trae CN,
MiniMax Code, Qoder and the plugins' own), took a file it couldn't read
or parse as empty. The next check-in then asked the vendor again for
every account and wrote its answers over the file: an account could be
checked in twice in one day, and the entries it couldn't read were lost.
readCheckins now returns an error for a file that is there but can't be
read, or doesn't parse into entries (cut short, zeroed, empty, `[]`,
`null`). A file not there is still empty. On the error:
- checkiner.checkinNow asks nothing and writes nothing. Each account it
would look at is `failed` with the reason (the path and why), so the
loop tries again after 30 minutes and a press (GUI, TUI, `magpie
accounts checkin`) says why. The error is logged once while it stays
the same.
- The readers that only show results (WithCheckins, *Checkins(),
PluginCheckins) go through shownCheckins, which gives what last read
from the file in this process, so a card keeps its last good data.
- adoptLegacyPluginCheckins' own strict copy of the read now uses
readCheckins too.
Docs: providers-accounts.md no longer lists check-in marks among the
caches written over; provider-plugins.md says the plugin file's case.
Test: TestCheckinUnreadableFileLeftAlone writes a cut-short, zeroed,
empty, `[]` and `null` workbuddy-checkin.json, runs the loop and a press
against a fake WorkBuddy, and checks no status or claim request went out,
the file is byte for byte unchanged, and the result says the path; a
folder in place of plugin-checkin.json does the same through a plugin
checkiner. TestCheckinMissingFileIsEmpty and
TestCheckinUnreadableKeepsLastGood cover the other two sides.
Broken by hand (checkinNow taking the error as an empty map again): the
test went red, every case claimed (Asked true), and green once restored.
Run in a worktree at origin/main
|
||
|
|
62a1df8010 |
provider: a plugin's daily check-in reaches every sign-in, also two that share a display name (plugins#254)
AutoClaw's plugin can hold several sign-ins under one default display name,
which AutoClaw doesn't let the user change. plugin_checkin.go keyed each
account's check-in on "<provider>|<AccountID>", the display name, so
checkinNow's per-key dedupe asked only the first sign-in of each name, by
the loop and by Check in now alike; the others stayed 今日未签 for good,
and Settings showed one row, and one Off switch, per name.
Each sign-in is now keyed on the key plugin-auth.json keeps it under
(pluginCheckinKey: "autoclaw|autoclaw", "autoclaw|autoclaw#x1y2z3").
Two sign-ins never share it; a refresh writes the same key, and signing
in to an account already signed in goes back to its key (host.js
settle). The display name is shown only. Cards, Settings rows,
CheckinOff and Check in now all read the same key, so app.js is
unchanged. An account without an AccountID already had this key.
Upgrade (adoptLegacyPluginCheckins, run when the plugin's accounts are
listed): an entry kept as "<provider>|<display name>" goes
- in plugin-checkin.json, to the first sign-in in use of that name (the
one the old key's check-in asked) and only to it, and the old entry
is dropped: it isn't asked again today, and its namesakes, never asked,
are;
- in settings.CheckinOff, to every sign-in of that name: the user turned
that name off and none of its sign-ins was checked in since, so the
upgrade switches none on (settings.EditCheckinOff edits that field
alone from what the file holds).
A plugin-checkin.json that can't be read or parsed is left as it is and
carried over once it reads; writes go through writePrivate
(temp-and-rename). Known gap: a sign-in made the same day after another
was signed out can take the freed key and that day's result.
The fake plugin's check-in now records a signed-in account as
name@fake/uid so two of one name tell apart in the presses.
Tests:
- TestPluginCheckinTellsSignInsOfOneNameApart: four sign-ins, A/u1, A/u2,
B/u3, B/u4 (the reporter's case). All four pressed once, none again
that day, four entries kept, four Settings rows, every card marked;
with A/u2 off, Check in now the next day presses the other three.
- TestPluginCheckinCarriesOverDisplayNameEntries: a plugin-checkin.json
with fakeco|A@fake and fakeco|B@fake claimed today plus another
plugin's entry, and CheckinOff ["workbuddy|123", "fakeco|B@fake"].
A's check-in goes to its first sign-in only, the old entries go, the
other plugin's stays, both B sign-ins are off and workbuddy|123 is
kept; the loop then presses only A's namesake, and a second look
presses nothing.
- TestPluginCheckinCarriesNothingOverAnUnreadableFile.
Broken by hand, each red:
1. key back on the display name: TellsApart pressed only A@fake/u1 and
B@fake/u3; CarriesOver kept the old entries.
2. adoption not called: CarriesOver ("A's check-in went to ... ok false").
3. record to every heir: CarriesOver ("carried to both") and Unreadable.
4. Off to the first heir only: CarriesOver (CheckinOff lacks one B).
5. old entry kept: CarriesOver and Unreadable.
6. parse error ignored: Unreadable.
Run at
|
||
|
|
f21dd99f5a |
privacy: every masking is recorded, and Settings › Privacy shows it
What was masked is now kept, so the user can see it. Settings › Privacy opens on a summary card: how many values were kept from vendors over 1, 7 or 30 days, by kind, by finder (rules, your words, the local model, known values) and by where they went, with a day strip. The page is grouped into What to mask, How it's found (rules and the local model are layers, not a toggle: the model adds names and addresses rules can't see) and Sharing. A records view lists each masked request: its kinds, finders, placeholders and, while magpie runs, the line around each value. Gateway › Recent calls and the Routing log carry a masked-N badge that opens the record. Originals never go to disk. internal/maskrec writes day files under ~/.config/magpie/masking (0600, 30 days, 100MB at most) holding kinds, finders, placeholders, a first character or key prefix and a length. The lines around values are kept in memory for the last 400 records only, and /api/masking/value answers only while the masker remembers a placeholder. Nothing is written under MAGPIE_TEST_SANDBOX. A masker says what it masked through gwmw.Teller (JSONHits, TextHits, Value); a plugin masker that doesn't is counted only, so older redact plugins keep working. Every route that masks notes it: chat, Responses, Codex backend and search, embeddings, images, video, transcription, decide and the search MCP query. Masking still fails closed: a masker that panics on any path refuses the request (TestMaskingOnAndOff's fake now panics on JSONHits and TextHits too, since the gateway asks a Teller through those). app.js grows to 1,314,432 bytes, so its budget rises to 1,335,000 and the core's to 1,528,800 (+1.5%): Settings is the core's own page. Run at this head (rebased on origin/main |
||
|
|
a3ebed202e |
gateway: Codex's compaction back on its own model goes without another vendor's reasoning text, so the turn after DeepSeek isn't refused over input[n].content (jue on Discord)
jue (Codex app, GPT-6.1 Sol) set a DeepSeek model for Codex on the Agents page, went back to GPT, and the next turn sometimes failed with "[ArrayParam] [input[8].content] [array_above_max_length] Invalid 'input[8].content': array too long. Expected an array with maximum length 0, but got an array with length 1 instead." Cause: when the model changes (or the thread passes its auto-compact limit) Codex compacts the thread before the turn, and shows a failed compaction as the turn's error. Codex's /responses/compact for one of its own models went to the ChatGPT backend (Codex's sign-in, its sk- key, or a magpie Codex account through compactOn) with its input as sent. A reasoning item from DeepSeek's Responses API carries its reasoning_text in content, which OpenAI accepts only empty, so the whole compaction was refused. A turn on the same routes already went through codexInput(body, false), which drops such items; the compaction didn't. "Sometimes" is when Codex compacts first. Fix: codexBackend's own-model branch runs codexInput(body, false) on /responses/compact too, before any of the three routes. OpenAI's own sealed reasoning (encrypted_content, no text) stays; a summary magpie made goes as its text, as from a turn. DeepSeek still gets its reasoning text (withReasoningText). Siblings read: the translated Responses path sends back only sealed reasoning (sealedReasoning); passthrough strips reasoning text for openai.com, Azure and Codex accounts and retries on the refusal elsewhere (#1411). Not covered: a full restore that drops openai_base_url leaves magpie off Codex's path. Codex's base_instructions and prompts are untouched. Test: TestForeignReasoningNeverReachesOpenAI sends the reported thread (input[8] a DeepSeek reasoning item with one reasoning_text, input[3] OpenAI's sealed reasoning) on seven routes: turn and compaction on Codex's sign-in, its API key and a magpie account, and /v1/responses with codex/gpt-6.1-sol. The fake OpenAI refuses a reasoning item with text with the reported 400 byte for byte. On the old code the three compaction routes are red with that 400 and the four turns green; with the fix all seven are green. Broken by hand a second way (codexInput(body, true) on the compact branch): the same three red. Run at |
||
|
|
592899467b |
gateway: Gemini's reasoning streams as it comes on the last candidate, so Codex isn't left with nothing for the whole of its thinking (LuckymanJC on Discord)
LuckymanJC and kkgg: through magpie the first turn of a Codex session on a Gemini model was very slow or seemed stalled. Measured with fake upstreams through the gateway (Codex Responses -> Chat DeepSeek, Gemini; OpenCode Chat; Anthropic passthrough), first content came within 1-50ms on every path but one: a Gemini model's reasoning was held even on the last candidate (`|| last && modelFamily(c.model) != ""` left Gemini out), so Codex got nothing at all, not even response.created, until the text began, while Claude's and GPT's has gone as it comes there since iTianbao's report. It was held there for #667, a reply that only reasoned being asked again. That re-ask happens in place in streamTranslated, keeping the reasoning the agent has, so it doesn't need the hold. But with the try passing, emptyRetries counted it as past the request's own re-asks and asked only streamRetries (2) times, and TestGeminiEmptyRepliesAskedAgain (three empty replies running) went red. A held try that went through on its reasoning alone (holdWriter.thoughtThrough) is now asked once more in place (streamRetries+1); a never-answering model still makes at most 4 calls (the test's bound is 6). Tests: TestThinkingStreamsWithNoOneElse gets "gemini" (Gemini upstream) and "chat gemini" cases, to Claude Code and Codex. With the old line restored they go red ("thinking held: first thought only 1.75us before the text"). With emptyRetries' new branch broken by hand (streamRetries+0), TestGeminiEmptyRepliesAskedAgain goes red with "an empty reply"; green with both. Run: go test -run 'TestGeminiEmpty|TestThinkingStreams|TestThinkingHeld|TestUncountedEmpty|TestReasoningLoop' ./internal/gateway: ok. Break check repeated at push: the old `|| last && modelFamily(c.model) != ""` turns TestThinkingStreamsWithNoOneElse/{gemini,chat_gemini}/v1/{messages,responses} red ("thinking held: first thought only 1.458µs before the text"). Full suite (go1.26.8 darwin-arm64, rebased on |
||
|
|
5206177704 |
agent: a 1M model Desktop lists by its [1m] id is told by its 1M, not a 272K GPT's beside it (dumplings on Discord)
dumplings (magpie 0.1.1295, Settings > 长对话 "完整窗口"): the provider
model showed 1M and its 1M variant was picked in Claude Desktop, but
Desktop's Code tab still showed 272K. With Desktop on magpie, claudePlan
tells Claude Code the largest window of every model it can run there
(CLAUDE_CODE_MAX_CONTEXT_TOKENS) and holds the smaller ones to their own
with modelSettings.<id>.autoCompactWindow. A model handed by a "[1m]" id
counted toward that largest only when it was Claude Code's main model,
so a 1M model Desktop lists by its 1M id (DesktopLongest) beside a 272K
GPT left 272K the value told, and with it alone nothing at all.
Now every [1m] model counts by its window (1M when unknown), and the GPT
beside it gets its own 272K entry. The `main` field it needed is gone.
Tests: TestClaudeDesktopContextWindow1M (rewritten: glm listed by its 1M
id alone tells 1M; beside a 272K GPT, 1M told and GPT held to 272000),
TestClaudePlan's [1m]-beside-272K case and its 500K->1M expectations.
Broken by hand (`case m.long && false:`): both go red
(TestClaudePlan "magpie's default: 500000", TestClaudeDesktopContextWindow1M
"glm listed by its 1M id alone: \"\""); green with the fix.
Run: go test -run 'TestClaudePlan|TestClaudeDesktop|TestClaudeContextWindow|TestBudget' ./internal/agent: ok.
Break check repeated at push: `case m.long && false:` turns
TestClaudePlan ("magpie's default: 500000") and
TestClaudeDesktopContextWindow1M ("glm listed by its 1M id alone:
\"\"") red.
Full suite (go1.26.8 darwin-arm64, rebased on
|
||
|
|
4ae6c06dc3 |
docs: gateway-routing says how magpie's Codex compaction is made portable
The magpie1: item, the message codexInputAs sends for it, and sessions.PortCodexRollouts: what it changes, the writer-lock protocol, when it runs, what was tried (Codex 0.162.1 resume against an upstream that refuses magpie1: as OpenAI does) and what wasn't (a Codex in WSL). |
||
|
|
f1e4516da2 |
gui: Codex's and Claude Code's own settings are in the agent's row on the Agents page, not in Settings
The owner, 10-20: Settings › General held Codex subagents, Long
conversations, Codex background compaction, thread titles, thread
descriptions, composer predictions, the auto-review model and the
memories model, apart from the agents they set; "很割裂、很分散,不直观".
They now sit with their agent (AGENT_PREFS): in its opened row on the
Agents page (a Settings list in connectPanel), in a sheet from the
tray panel's row ("Settings" line, openAgentPrefs) and from the agent's
menu ("{agent} settings"). Each row is the one element moved between
those places, so its handlers and state go with it. Settings' search
still finds them, with a row that opens the agent's sheet
(#agentPrefLinks). A gateway has no Agents page and none of them.
Strings for zh, zh-TW, ja and de; docs (reference, agent-wiring,
gui-shell) point at the new place. app.js 1,277,298 bytes and the core
scripts 1,469,058, so both budgets rise.
Run on 6416d639c (the dialog morph, on origin/main
|
||
|
|
0fe039f14d |
gateway: Ollama's /api/chat and /api/generate, for Zed's Ollama provider (super_lalalalala on Discord)
Zed's Ollama provider chats on POST /api/chat, which magpie answered 404:
it served only /api/version, /api/tags and /api/show. Both routes are now
served on the mux, so lanGuard, counted, corsGuard, callerGuard, withCaller
and keyLimited cover them as they cover /v1/chat/completions. The body is
turned into a /v1/chat/completions body and handed to the same
handle(provider.Chat) on a clone of the request, so routing, a key's models,
usage and errors are the /v1 path's own.
Request (ollamaChatBody, after Ollama v0.12.6's api/types.go and Zed's
crates/ollama):
- messages: images as data-URL parts (type sniffed); a tool message's
images in a user message after it; an assistant's thinking as
reasoning_content; tool_calls given ids when Ollama sent none, and
arguments sent as a JSON string;
- a tool result goes with its call by tool_call_id, else tool_name (what
Zed sends), else in order; one with no call is a 400;
- /api/generate: system, prompt and images as a two-message chat;
- tools, format ("json" or a schema), think (a level is
reasoning_effort, false hides thinking in the reply);
- options: temperature, top_p, seed, stop, presence/frequency penalty,
num_predict > 0 as max_tokens; num_ctx, top_k and Ollama's other own
options are dropped.
Reply (ollamaWriter): NDJSON lines unless stream:false, then one object;
message.content/thinking (or response) as they arrive, tool calls with
an id and their arguments as an object, and a done line with done_reason
(stop or length) and the token counts. An error is {"error":"..."} with
the status /v1 gives. A request with nothing to say is answered
done_reason "load", as Ollama warms a model.
/api/show took "plan/seer:latest" (what `ollama run plan/seer` asks for)
as unknown and the CLI then tried to pull it; ollamaName now gives the
bare id for show and both chat routes.
Broken by hand, each red: tool_name ignored, tool-call ids not kept,
arguments as a string, num_ctx passed upstream, status 200 on an error,
thinking kept with think:false, no route, and /api/show without
ollamaName (plan/plain:latest 404).
Real client: a sandbox gateway (magpie serve, sandbox HOME and
XDG dirs, MAGPIE_ADDR=127.0.0.1:3592) over a fake OpenAI upstream on
3591, with the ollama CLI 0.6.8: `ollama list` lists plan/seer,
`ollama show plan/seer` prints it, `ollama run plan/seer "hi"` and
`ollama run plan/seer:latest "hi"` print the upstream's streamed
"Hello from the sandbox gateway" (the :latest one failed with a pull
error before ollamaName). curl /api/chat and /api/generate, streamed and
stream:false, and a chat with tools, a nameless tool call and a
tool_name result: NDJSON/whole replies, upstream got ids paired and no
num_ctx. Zed itself not run (it would read the live Zed settings).
Run: gofmt -l (none); go vet ./... on darwin, GOOS=linux -tags nogui and
GOOS=windows: clean. `set -o pipefail; go test -timeout 45m ./...` at
1ebda9026 (this batch on
|
||
|
|
489d816213 |
agent: dsh's wiring round does nothing when nothing it reads changed
A user's live heap profile showed 35.7 GB allocated in 48 minutes with
~157 MB live. 12.1 GB of that was one path: KeepDshWired -> keepDshWired
-> dshWiredOnce. It runs every 30 s, and each time it rebuilt the whole
catalog and every route, only to write nothing. Within it:
magpieModels("dsh") 9.5 GB, dshRouteAgain 4.8 GB, dshPutRoute 3.8 GB, and
Exposed/Catalog/heldOf/entriesOf ~7.7 GB under them. heldOf caches only
during a Hold.
What changed:
- provider.StampNow (hold.go) records what the catalog is built from,
without building it:
- held.gen, which Changed and a plugin's change move
- filememo.Gen
- the environment
- the stat stamps of providers.json, settings.json and the catalog's
cache file, which another process's writes move
- keepDshWired keeps a dshRounds between rounds.
- It builds magpieModels again only when the stamp moved, or when its
models are dshModelsFor (5 min) old. The 5-minute rebuild covers what
no stamp sees: another app's account file, or a model retired by date.
- It skips the round when these are all the same as at the last round,
and that round wrote nothing and left the files as it found them:
- the bytes of dsh's files: every profile's cordis.patch.yml, the
home layer, settings.yaml, .env, .credentials.yaml, config.yaml
- the gateway URL
- the hash of the models
- A read error other than "missing" hashes as unknown, so the round
runs.
- dshWiredOnce (Sync, Connect, tests) still always does a full round.
- No singleflight and no new lock: the round already runs under dshWrites.
- docs/subsystems/agent-wiring.md says so.
Not done: caching Exposed/Catalog/entriesOf outside a Hold. Their output
depends on time (retiredNow, disabledNow) and on files other apps write,
and nothing signals a change in either, so nothing would bound how stale
the cache gets.
Measured with a throwaway test in a sandbox HOME, on top of 4f044c24c:
12 providers from a real models.json, 270 models, 3 dsh profiles.
- Before, per round: 132.61 MB, 900,624 allocations (~265 MB/min).
- After, nothing changed: 0.26 MB, 119 allocations.
- After, models older than dshModelsFor: 30.77 MB, 88,336 allocations.
The dsh parse and write are skipped because the models' hash is the
same.
- Averaged over time: ~6.7 MB/min, against ~265 MB/min before.
New tests:
- TestDshRoundWithNothingChangedBuildsNothing: AllocsPerRun must be at
most 300; it is 77 now.
- TestDshRoundAfterAChangeWritesAgain covers each change:
- a provider saved
- a setting saved
- the patch list written over
- providers.json written by another magpie
- a change no stamp sees, picked up after dshModelsFor
Broken by hand, each went red:
- skip always off: the allocation test, at 2099 allocations
- stamp check removed: the provider, setting and another-magpie cases
- roots left out of the stamp: the another-magpie case
- aging removed: the unseen-change case
- file bytes left out of the sum: the patch-list case and
TestKeepDshWiredWritesTheRouteAgain
Run at this tree. It is built on origin/main
|
||
|
|
42e6aee534 |
sessions: the stats and id lookups don't build every session's subagents
Why: in a 48-minute heap profile of the user's magpie,
gui.combinedSessionStats → statsFor → StatsAndNative → statsIn
allocated 3.9 GB, and gui.warmSessions → Warm 5.7 GB. Their scans went
through assemble → subagentsOf → ccTask: the stats built every
session's subagents (each one's task read from its file), only to
count tokens and tell which sessions are listed. Every statsFor call
in the profile came from the warm-up's steps.
What changed:
- assemble is split. assembleListed holds the part that decides
whether a session is listed and gives its agent, id, title, models
and usage. assemble adds resume, carry, transcript and subagents on
top.
- These callers now use assembleListed: the stats' native-key and
summary loops (stats.go), Titles, the Codex provider lookup
(codex_provider.go) and manage's id lookup.
- List, One and manage's listing still use assemble.
- The docs/subsystems/gateway-sessions.md subagent section says
which callers build subagents.
Tests:
- TestStatsReadNoSubagentFile writes a subagent with no meta and no
task in its first lines, then simulates a restart (Saved, Reset,
memos cleared). It then runs StatsAndNative(0), StatsAndNative(30)
and StatsFor(7) three times and expects 0 scans of that file. List
still shows the subagent.
- Broken by hand: the stats back on assemble make it go red with
"the stats read an unchanged subagent's file 1 times". Green again
once restored.
Measured on a read-only APFS clone of the user's ~/.claude/projects
and ~/.codex/sessions/2026/10, in a sandbox HOME, at load ~500 from
other sessions. The whole series against origin/main dee5c9d75; this
commit is the change to the stats rows.
| Pass | origin/main | This series |
| --- | --- | --- |
| warm StatsAndNative(0) | 596.7 MB, 157,195 allocs, 6.2–9.0 s | 28.9 MB, 73,976 allocs, 0.08–1.1 s |
| warm StatsAndNative(30) | 594.9 MB, 6.8 s | 28.7 MB, 0.8 s |
| restart StatsAndNative(0) | 3,106.7 MB, 509,239 allocs, 30.0 s | 48.2 MB, 241,721 allocs, 1.9 s |
| restart StatsAndNative(30) | 594.9 MB, 9.6 s | 28.7 MB, 0.5 s |
Run at the final tree of this series:
- gofmt -l internal: nothing.
- GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean.
- go test -count=1 -timeout 45m ./internal/sessions/ ./internal/gui/:
- sessions: ok, 366.7s.
- gui: only TestMainWindowCorners failed, "measuring the windows:
signal: killed". It also fails alone on an untouched origin/main
export, at load ~500. Filed as #1936 and #2645. Every other gui
test passed.
- go test -race -count=3 on the new tests: ok.
|
||
|
|
a23fbaeadf |
sessions: a subagent's file is read for its task only when its meta names none, once per change
Why: a 48-minute heap profile of the user's magpie allocated 6.3 GB
in sessions.scanAt, 3.5 GB of it from ccTask. The user has 3,174
Claude Code subagent files, 1,798 of them over 1 MB. Two things
caused it:
- subagentsOf titled each one `cmp.Or(m.Description,
ccTask(f.path))`. Go evaluates both arguments, so every subagent's
file was read for a first user line that was then thrown away
whenever the meta file had a description, which is nearly always.
- ccTask kept only a found task. A file whose first 16 lines name
none was read again on every ask.
What changed:
- Claude Code and Kimi subagent titles read the file only when the
meta (or the spawn record) gives no description.
- ccTask keeps what it read, a task or none, with the file's size and
mtime from before the read. An unchanged file isn't read again. A
grown, rewritten (even at the same size), or touched file is read
again from its first lines.
- A read that fails keeps the last good result, and a deleted file
gives "".
- A line appended while the file is being read changes the size, so
the next ask reads it.
- The docs/subsystems/gateway-sessions.md subagent section says so.
Tests:
- TestSubagentTaskReadOnlyWhenTheFileChanges counts scans through
scanHook for these cases:
- first ask: 1 scan;
- unchanged: 0;
- grown with a task: 1, then 0 once found;
- grown after the task: 1;
- rewritten shorter: 1;
- rewritten with no task: 1;
- same size with a new mtime: 1;
- a task appended past line 16: 1 scan, still "";
- appended during the read: found on the next ask;
- deleted: "", 0 scans.
- TestSubagentWithMetaTaskIsNotReadForIt lists a session after a
simulated restart (Saved, Reset, memos cleared) and expects 0 scans
of a subagent whose meta names its task.
- Broken by hand:
- ccTask back to keeping only a found task (`t.task != ""`) makes
the first test go red: "unchanged, no task yet: 1 scans, want 0".
- The title back to cmp.Or makes the second go red: "the list read
a subagent's file 1 times for a task its meta names".
- Both green again once restored.
Measured on a read-only APFS clone of the user's ~/.claude/projects
and ~/.codex/sessions/2026/10, in a sandbox HOME, at load ~500 from
other sessions. Times are noisy; allocations are not. Restart, then
List(All):
| Code | Allocated | Allocations |
| --- | --- | --- |
| ccTask keep, title still cmp.Or | 153.9 MB | 270,838 |
| this commit too | 25.8 MB | 109,854 |
| origin/main
|
||
|
|
20c0688316 |
gateway: Claude Code processes are held to what the machine's memory holds; a full room is a 503 the next provider takes (#2956)
Cause: nothing bounded how many Claude Code processes magpie runs for
Claude subscriptions. Busy runs had no limit, idle ones were capped at 6
and parked ones at 16 per bridge, and one-off tests, warm-ups and /usage
reads were counted nowhere. The reporter's 512 MiB systemd service had 2
busy runs and 14 starting at once when the memory cgroup's OOM killer
ended them.
Measured (Docker arm64, real Claude Code 2.1.303):
- one idle run holds about 205 MiB RSS, 86-112 MiB of it anonymous;
- six runs under a 512 MiB memcg gave oom_kill 2 and a peak of 512 MiB.
Fix: claudeRoom (claude_room.go). Every Claude Code takes a place before
it starts and frees it when its process exits. That covers startRun and
runClaudeTree (tests, warm-up, /usage).
How many may run:
- the user's claudeRunsMost (`magpie claude-code runs N|auto`). It is
machine-local (KeepOwn), and the Settings page's save keeps it.
- otherwise, on Linux, (limit - 256 MiB) / 128 MiB, at least 1. The limit
is the least of MemTotal, cgroup v2 memory.max and memory.high up the
tree, and cgroup v1 memory.limit_in_bytes. The reporter's 512 MiB
cgroup gives 2, and 1 GiB gives 6.
- otherwise no bound: macOS, Windows, or limits that can't be read.
A full room first lets go of the oldest idle run. Its session is
shelved, so the next turn resumes it. Next it lets go of a run parked
past parkLongest. Busy runs are never let go. Otherwise it waits up to
2 minutes, then answers 503 with the reason and the command.
Routing treats that 503 as protected. No Claude account is rested or
asked next, since each would wait for the same room, and another
provider in the group answers.
Tests (each run red by hand on the broken code):
- TestClaudeRunsHeldToTheRoom: 6 conversations at room 2. With take
forced to always admit: "6 Claude Code processes were alive at once,
2 may be". Fixed: at most 2, and all 6 answer 200.
- TestClaudeRoomLetsAnIdleRunGoAndItResumes, TestClaudeRoomFullIs503 and
TestClaudeOneOffsTakeRoom went red with take forced open.
- TestClaudeNoRoomPassesOnAndRestsNobody went red with the routing
exemption off: both Claude accounts were tried and rested.
- TestClaudeMemRunsFromTheCgroup uses the reporter's literal meminfo,
cgroup path and memory.max.
- TestClaudeCodeRunsSetsTheUsersOwn went red with validation loosened.
- TestClaudeRunsMostIsMachineLocal went red without the KeepOwn line.
- TestSettingsSaveKeepsWhatItDoesNotSend (internal/gui guard) caught a
Settings page save clearing the value. It is kept now.
Run at this tree (macOS, go1.26.8):
- go test -timeout 45m -count=1 ./... with pipefail, under a load
average of 650-800 from other sessions: 61 packages ok. Three were not:
- internal/agent and internal/gateway hit the 45m timeout mid-test.
The stacks show no hang. Re-run at -timeout 120m: agent ok (2779s).
- In gateway, TestClaudeAccountsSpentFallBackToCodex hit its 30s wall
bound. No room wait was logged before it, and it passed 5 of 5
alone.
- In the same run TestClaudeRoomLetsAnIdleRunGoAndItResumes was red
because of its own check: a random request id in the fake's log
spelled "a1". It now reads only the fake's "told" lines. Flipped to
"a2", it goes red.
- internal/gui: TestPanelJoinsFullScreenSpaces (a macOS window test)
passes alone. TestSetAnswersWhileDevinAndProvidersHang has a 10s
bound, and at the base commit under the same load it failed 2 of 3.
- The touched packages again, -count=1: settings, cli and gui ok.
gateway: the room tests and TestClaudeAccountsSpentFallBackToCodex
ok at -count=5.
- gofmt -l: clean.
- GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean.
Not tried:
- the Docker 512 MiB reproduction re-run with this build against real
Claude Code. The fix is shown with fake runs only.
- a real cgroup v1 host.
- the site's docker docs (en/zh/ja) don't mention `claude-code runs` yet.
|
||
|
|
75e769a9f9 |
routing: Free first spends the models that cost nothing before the ones that spend (#3054)
A provider or group can be routed `free`. Seats whose model the vendor serves at no cost to the allowance or credits go first, in listed order. The rest follow, also in listed order. Free means the vendor's own catalog.Model.Free word, or else a $0 list price on every count (provider.FreeModel). A pool with no free model behaves as In order. routes.Seat gains Free and Strategy gains ByFree. weighRouted works Free out only for a strategy that weighs by it, so other routings never read a model list for it. It is wired through every list a routing appears in: - both save whitelists; - plugins/rotation's Builtin; - app.js's ROUTINGS (appScriptBudget 1,269,000 → 1,271,000 for the description) and the Routing page's options, hints and trace text; - zh-TW, ja and de strings; - the TUI's routings; - the CLI's aliases (free, free-first). Written by keeuu (issue #3054, three commits), squashed onto |
||
|
|
d9c6a60d8a | Merge commit '791604559' into pf/serve | ||
|
|
3806014ac8 |
redact: Chinese personal names are masked, where the model misses or overreaches them (#1977)
OpenAI's Privacy Filter gives common Chinese names (张伟, 李娜, 陈建国,
黄晓明) almost no PERSON weight. Lowering the O label's emission by 2 or
4 in a patched pf-serve didn't bring them back. It also returns spans
that run past the name (「王芳,她下周一」, 「张伟先生」).
zhname.go adds a rule layer behind the model, only when personal data
is covered:
- a surname (single, compound, or 小/老 + surname) with a 1–2
character given name is masked when something around it says it is
a person:
- a role before it (客户, 联系人:, 我叫, 作者:, @);
- a verb before it (给, 告诉, 抄送) or after it (说, 反馈, 先生);
- a title or 总 (孙经理, 邓总);
- a name joined by 和/与/跟/及/、 to a name already found counts too;
- words that start with a surname (张量, 高度, 王国, 周五, 总是) are
never taken;
- the model's PERSON spans with Han in them are cut at punctuation or a
title, and only when at least two characters remain.
Run:
- Real model, end to end through MaskJSON (pf-serve q8, Metal):
- masked 张伟, 王芳 (cut), 李娜, 刘洋, 陈建国, 赵丽颖, 欧阳娜娜, 司马光,
黄晓明, 周杰伦, 小王, 老李, 马云, 王老板, 邓总, 孙经理, 刘总监,
吴敏, 郑浩, 何静, 唐宁, 许文强, 罗志祥, 林老师 and 郭靖;
- Japanese, Korean and English names are unchanged.
- Missed, with nothing around them that says person: 「模块是谢磊写的」
and 「和黄蓉团队」.
- False positives: none over 2237 lines of the repo's Chinese docs and
i18n, or 61 developer sentences.
- Cost: ~19ms CPU over 880KB.
- Broken by hand:
- with the layer off, TestChineseNames has 8 names unmasked;
- with the two-character guard off before a title, 感谢李老师 goes red.
- Checks:
- gofmt -l is clean;
- go vet is clean on darwin, GOOS=linux -tags nogui and GOOS=windows.
- go test ./... -timeout 45m at load ~750: 63 packages ok, redact
among them. internal/agent (TestReconnectKeepsTheLastPick) and
internal/gateway (TestLargeRequestEndpoints) hit the 45m timeout with
no failed assertion, and are being rerun alone.
|
||
|
|
7916045591 |
library: RTK's tag for Grok Build and Grok App gives their own reason and rtk-ai/rtk#2136, not DeepSeek Harness's (新v学员 on Discord)
Every agent RTK has no hook for got dsh's tooltip on the RTK tab: "{agent}'s
hooks can only allow or deny a command, not change it" with
rtk-ai/rtk#3847 ("FR: Support DSH"). For Grok Build that is wrong twice:
the issue is dsh's, and Grok's PreToolUse hooks can rewrite a command
(updatedInput, shown on rtk-ai/rtk#1890). What holds is that rtk init has
no Grok agent (src/hooks/init in rtk v1.0.1 has none), and
rtk-ai/rtk#2136 is the open request for Grok Build (#4513 was closed as
its duplicate). Each link was checked with gh issue view; the others in
rtk.go (#3847, #3934, #4311, #3898, #4187, #3404) are right.
rtkNoHookWhy in plugins/library/client.js gives each agent its own reason:
dsh keeps its text and #3847, Grok Build and Grok App cite #2136 (Grok App
runs Grok Build), and an agent with no entry gets a reason with no link.
New strings in zh, zh-TW, ja and de. rtk.go's grok and grok-app reasons,
which the CLI shows, cite #2136 too.
TestRTKNoHookIssuesAreEachAgents fails when an rtkNoHook agent has no page
reason (or the reverse), when the page and rtk.go cite different issues,
when two agents cite the same issues without a reason in sharedRTKIssues,
or when the fallback carries a link. library-rtk-nohook.test.cjs checks
Grok Build's tag says #2136 and never #3847, DeepSeek or "hook".
Run in a worktree rebased on origin/main
|
||
|
|
822f2b3042 |
agent: dsh lists a vendor's reply limit at most a quarter of the window, so it has room to compact (#2823, LoKi on Discord)
dsh takes a model entry's maxTokens as the output of every request. Before deciding when to compact, it reserves that output plus 65536 of headroom out of contextWindow (dsh-compaction-basic resolveCompactSpec). When a vendor's reply limit is close to its window, dsh compacts at a sliver of the window, or can't compact at all. magpie now lists a vendor's figure held to a quarter of the window (dshMaxTokens). It does this on every pi-ai route and in the legacy llm-deepseek entry, the same rule VS Code and Copilot in JetBrains already use. A Max output the user set stays as they set it (outputOr). LoKi's patch capped only an output >= the window. That misses #2823's own case (a group at 500000 / 393216) and outputs above window - 65536, such as 131072 / 65536. The quarter rule covers all of them, and a cap can only lower the reservation. Run: real dsh 0.2.0-rc.2 headless, sandbox HOME/DSH_HOME, a fake OpenAI SSE server with a tool-call step so pre-step compaction runs, and an observe-only loader hook on resolveCompactSpec. origin/main |
||
|
|
5f73537f5b |
gateway: Codex's own turn on one ChatGPT account is asked again on an overload, then its fallbacks (夜松云 on Discord)
Codex signed in to ChatGPT with magpie as openai_base_url, one account, no usage cap: Codex's own gpt-* turns go through codexUpstreamOn with no account, relayed as Codex sent them. That path was pass-through since |
||
|
|
5e30d5b5ae |
autostart, gui: Open at login says when the Mac's own switch for it is off (#2120)
Anoninz on #2120: Settings said Open at login was On while System Settings › General › Login Items › Allow in the Background had magpie switched off, so magpie never opened at login. autostart.Enabled now returns a State: off, on, or needs allowing. - macOS 13+: with the plist present, Enabled asks Background Task Management through SMAppService statusForLegacyURL: (cgo, ServiceManagement weak-linked, minos stays 12.0). RequiresApproval reads as needs allowing. Any other answer, a failed ask (-1), macOS 12 or a build without cgo (the darwin CLI release) leaves the plist alone deciding, as before: a failed read is never "off". launchctl print-disabled did not follow the switch on macOS 26.2, so it isn't used. - BTM matches the item by the plist's Label, not its path: the tests ask about a label of their own, and TestMain stubs the ask so no test reads the user's real item. - GUI: Settings › General keeps On and adds one line, "Switched off in System Settings’ Login Items…", with an "Open Login Items" button that opens x-apple.systempreferences:com.apple.LoginItems-Settings.extension through /api/open (that one URL is allowed; other x-apple URLs aren't). The window's focus reload clears it once switched back on. The row is hidden in magpie web, as before. Strings in zh, zh-TW, ja, de. - CLI `magpie autostart` says where to switch it on. The daemon counts a held-back record as on (it is the user's choice, held by the system). Part B (SMAppService.mainApp) is not in this commit: it can't be verified here without registering in the user's real login items and logging out to see a login launch stay tray-only. Run: - go test ./internal/autostart (cgo and CGO_ENABLED=0), cli, daemon, gui after rebasing on origin/main |
||
|
|
40d1661852 |
Merge remote-tracking branch 'origin/main' into pf/serve
# Conflicts: # internal/gui/core_budget_test.go |
||
|
|
9588501c02 |
provider: Ollama's and Ollama Cloud's decision models classify routing groups through System One (Nanka on Discord)
Ollama 0.35.0+ (0.40.5+ for cloud models) serves System One at
POST /v1/systemone, locally and at ollama.com with a key. Its body and
answers are System One's, so magpie's request is sent unchanged (a real
answer adds prompt_eval_cached_count, which is ignored). Its /v1/models
lists the decision models (Tev, Nimble, Clef) among the chat models with
nothing to tell them apart, so clef:27b showed up as a chat model on
Ollama Cloud. /api/tags, asked with the same key, gives each model
capabilities: "decision" (and "vision" for Clef).
- Both presets get Decide = their chat base, and a saved Ollama or
Ollama Cloud provider is backfilled with its chat base, as oMLX and
MLX-Serve are.
- ollama_decide.go: the decision list is /api/tags filtered by the
"decision" capability (ollamaDecides, listedOllamaDecide), kept under
<id>.decisions. Images come from "vision". The window is the list's
context_length, else the cloud's 65,536 from Ollama's docs. An Ollama
older than System One lists no capabilities, so none, and no Jev is
made up.
- decide.go: oMLX's, MLX-Serve's and Ollama's mixed-provider checks now
share serverMarksDecisions.
- internal/gui/local_address_test.go: an Ollama added at another address
moves its decision URL with it, as oMLX's does.
- docs/subsystems/providers-accounts.md says so.
Run, at origin/main
|
||
|
|
e4ac5e8712 |
zcode: models magpie writes have native web search on, and a model the user unticked stays off (Gearclickist on Discord)
Gearclickist (#help, 10-19): every model magpie writes into ZCode came
without web search, and each had to be ticked by hand in its settings.
ZCode 3.14 keeps the switch ("原生联网搜索") as
config.properties.supportsNativeWebSearch on a model rule in
provider_config.json (read from ZCode.app's own bundle). It only works
with an anthropic-messages provider, where ZCode sends a
web_search_20260209 tool, which the gateway already serves; on other
formats ZCode's WebSearch throws. Unticking writes nothing: ZCode drops
the key from magpie's rule because false is its default.
zcodeRules now:
- turns it on for each model magpie lists, on Anthropic Messages only,
including rules an older magpie wrote without the key;
- remembers which models it turned on in the stash (zcode.web_search),
so a model whose key went missing was unticked by the user and stays
off on every later sync;
- keeps any value already in the rule, true or false;
- leaves manualProviderModelRules alone and drops those ids from the list;
- on another format takes back only its own true;
- turns nothing on when stash.json can't be read or parsed (unknown);
- forgets the list on disconnect.
config.json (pre-3.14 shape) has no such field and is unchanged.
Known gap, not fixed here: other edits a user makes in ZCode to a model
magpie lists (JSON output, mid-conversation system, context window) land
in the same rule and are still rewritten on sync.
Run at this head:
- TestZCodeWebSearch (new) fails on the old zcode.go ("first sync: pro is
<nil>, want true"). Broken by hand, it goes red at each guard: the
untick check removed ("unticked: flash is true"), the take-back on
another format removed ("chat completions: pro is true"), and an
unreadable stash read as empty ("unreadable stash: flash is true").
- go test -run TestZCode ./internal/agent/: ok.
- gofmt -l .: clean. go vet ./... on darwin, GOOS=linux -tags nogui,
GOOS=windows: clean.
- set -o pipefail; go test -timeout 45m ./... (sandbox HOME, at
|
||
|
|
e5b57794e2 |
routing: a rule's agent picker lists agents heard from and takes a typed User-Agent name (raikyou on Discord)
A rule can match a client magpie doesn't know, such as SillyTavern or someone's own app with its own User-Agent. The gateway already names such a client by its User-Agent's product name (usage.AgentOf), and a rule compares agents in lower case (cleanRules, MatchesBesidesIntent, Pauses). Until now the editor's agent picker listed only the agents magpie knows. The picker now lists the agents magpie knows, then the agents /api/usage?period=30d heard from that it doesn't know, leaving out "other" and magpie. The note on those reads "heard from in the last 30 days". The usage call is made once per editor and reads the cached SummarizeTop. A name typed in the filter is read the way the gateway reads a User-Agent: the text before the first "/", space or comma, in lower case. "MyApp/2.0 (Linux)" is myapp. A typed name that is already an agent's id is that agent. The picked name shows in the chip as the others do and is saved in agents:[…]. app.js's openPicker gains field.placeholder and field.typed for this; other pickers are unchanged. zh label: 筛选,或输入 Agent 名称… (notes: User-Agent 开头的名称, 近 30 天有请求). Strings are added in en, zh, zh-TW, ja and de. No backend change. The TUI takes rules as text (agents=…), so it already accepts any name. A typed alias of a known agent (claude-cli) isn't mapped to its id in the picker. Only an exact id is. Run at |
||
|
|
d155ab1619 |
gateway: a relayed Responses item keeps the id it was added with, so Codex on Copilot shows a message once (echo_ts on Discord)
echo_ts (v0.1.1293, Codex desktop, a GPT model on GitHub Copilot): each commentary paragraph was shown twice; fine around v0.1.1280. Cause: since |
||
|
|
81a24cf8fe |
groups: a found group is listed as auto/<model id as the vendor spells it>
ZeroClover asked on X: Auto Group ids group/auto-<slug> can't be looked
up on models.dev. A found group is now listed and written as
auto/<model>, e.g. auto/claude-opus-5.5: /v1/models, the catalog, agent
configs, the GUI's Routing page and the CLI. Context and output limits
come from the model's metadata as before.
What stays the same:
- The internal id is still group/auto-<slug> (Group.Ref() gives the
public one). Every old form is still accepted as input forever:
provider.CanonicalRef turns auto/<model>[:level][[1m]] into it at the
gateway (validateModel), keys, stats, affinity and usage, so both ids
route to the same group and count as one.
- A key's model list allows a model by either id, group/* included
(allows() in key_models.go).
- Hand-made groups stay group/<id>.
- A provider whose stored id is "auto" keeps its models: while one
exists, found groups are listed by their old id (AutoRefsOn) and
auto/<x> means that provider's model. Documented in
docs/subsystems/gateway-routing.md.
Agent configs: SyncCatalog rewrites a field that holds a found group's
old id (renameFoundGroups), but only while the value is still what
applied.json says magpie wrote; a value the user set stays. A pick by
the old id written now is written as auto/<model> (Apply). Hidden,
picked and ordered model lists saved by the old id hold for the new one
(visible.go), and a bare model id still reaches its found group (bare.go).
Claude Code is given a dotted Claude version dashed (ClaudeSpelled), so
auto/claude-sonnet-4.5 sits in its settings as auto/claude-sonnet-4-5.
That routes to the same group, but with found groups off nothing reads
it back dotted, and Reseat took the field for changed and left the agent
on a group that was gone. Reseat now compares a group pick by its
canonical id (samePick). The old ids had no dots, so this is new with
auto/<model>.
Run at this tree (sandbox HOME, caches pinned):
- gofmt -l: clean. go vet ./...: clean on darwin, GOOS=linux -tags
nogui, GOOS=windows.
- go test -p 4 -timeout 45m ./...: every package ok except agent and
gateway, whose failures were the tests' expected ids (updated here)
and two regressions now fixed (bare ids; desktop models hiding groups
by prefix). Every failing test passes on rerun. Load average was
~210-290 from other sessions throughout.
- Reruns: provider, cli, codexcat ok. internal/gui: only
TestSetAnswersWhileDevinAndProvidersHang fails (set slow/slow-1 took
10.19s), and it fails the same in a git-archive export of
|
||
|
|
ef655acb40 |
gateway, gui: a console shows the routing of the magpie that serves the gateway (#2606, fatcutegg)
fatcutegg's patch (fatcutegg/magpie 40ceb22df). The routing trace is held
by the process that serves the gateway. A second magpie on this computer
(`magpie web`, or the app while a launchd `magpie serve` holds the port)
showed none of it. Now its console reads the serving magpie's
GET /v1/magpie/trace (and /v1/magpie/concurrency for the lanes) over
loopback, and plays that trace as its own. The heading names which magpie
is routing ("serve (pid N) is routing").
Reviewed as a community change. A trace names accounts and emails, session
ids, a folder's last two parts and error text. It holds no prompt text and
no key. The endpoint answers local(r) alone: a request from another address
gets 403, and so does a loopback request carrying a proxy or Tailscale
header, or a LAN request while the gateway is shared, whatever key it holds.
lanGuard and corsGuard stop rebinding Hosts, Origin: null and *.localhost
first, as on every route.
Changed on top of the patch:
- A gateway key held to a budget, models or accounts is refused with
KeyHeldCode (refuseHeld), as concurrency and quotas refuse it.
- The console reads loopback alone (ownerURL). A non-loopback MAGPIE_ADDR is
never asked, and 0.0.0.0, :port, [::] and localhost are read at
127.0.0.1.
- OwnerTrace lets a hung magpie go at wait+5s (was +20s). OwnerLanes waits
700ms like ServedBy (was 2s) and is asked only when a magpie answers.
- `/` tells pid and serves to a loopback request alone. A plain `magpie`
that opens the TUI reports itself as "tui".
- Takeover: in the real two-instance run, after B took the gateway over the
hub still read "serve (pid A) is routing", from the providers state. Now
the trace carries `by` (pid, serves), and the page names the router from
it. When `by` changes, the page drops its routes and reads the new
magpie's whole trace, so route ids from two magpies never mix. The
label's full text is in its title, because the node cuts it with an
ellipsis.
- Trace's doc comment, which the patch had orphaned, is back on it. Docs
(gateway-routing.md, gui-shell.md) say all of the above. Issue
references are #2606 (were #110).
- Tests: a proxy-header subtest, TestOwnerReadOnLoopbackAlone, the trace
added to TestHeldKeyToldNoAccounts, and `by` / pid / serves asserted in
both packages' peer tests.
Run:
- Each guarantee broken by hand, and its test went red: refuseHeld removed,
ownerURL returning MAGPIE_ADDR, local(r) replaced by a RemoteAddr check,
pid/serves dropped from the answer, `by` dropped in OwnerTrace, and the
console's OwnerTrace fallback turned off.
- A real sandbox (own HOME, ports 3591-3593, fake upstream on 3564):
- A `magpie serve`, B `magpie web`. B's Routing page played A's routes
live (the long poll counted 3 requests through A).
- Probes of A's /v1/magpie/trace. 200 from plain loopback. 403 for
evil Origin, Origin: null, evil.localhost, a rebound Host with and
without Origin, x.localhost Host, X-Forwarded-For and
Tailscale-User-Login.
- A LAN-shared instance answered 403 from 10.0.0.111 even with a valid
key, and gave no pid on `/`.
- Killed A: B took over in ~11s. The hub dropped the "is routing" label,
and the next request through B showed as a fresh trace (1 request).
- Chromium and WebKit screenshots at 1280 and 390 wide, in en, zh and ja.
No horizontal scroll.
- gofmt -l clean. go vet darwin, GOOS=linux -tags nogui and GOOS=windows
pass, and all three builds pass.
- go test -timeout 45m ./... at this tree (sandbox HOME, load 250-400):
every package ok except four.
- agent, gateway and library hit 45m in TestClaudeTierPickedAsTheMainModelStays,
TestQueuedStreamKeptAliveOnceSentToItsVendor and TestWellKnownKitGrouped.
- plugin failed TestGatewayHookMixedPiPackage (#2865).
- Rerun alone with -p 1: plugin ok (464s). gateway finished in 45m with
one red, TestRequestBuildsProvidersOnce, a 900ms/1s timing window under
load. It is 8/8 green alone here and on origin/main
|
||
|
|
b9d1cd36f5 |
agent: Hermes's api_key as "${VAR}" with the key in its .env reaches magpie (PaulT on Discord)
PaulT (magpie 0.1.1291) keeps Hermes's key the way Hermes keeps keys:
providers.magpie.api_key: "${MAGPIE_API_KEY}" in config.yaml, the key in
~/.hermes/.env. Hermes expands ${VAR} and ${env:VAR} as it loads the
config (hermes_cli/config.py _ENV_REF_RE, _env_expand_match), from the
.env beside it, which load_hermes_dotenv loads over the environment.
magpie compared the literal "${MAGPIE_API_KEY}" with its key, so Check
marked Hermes as needing attention, and a sync (mergeKept) wrote the
literal key over the reference.
Now hermesKey expands the reference the way Hermes does: the .env
beside the config (main or a profile's), then this machine's
environment. Check reads that key through keyHolds, so magpie's key or a
Gateway key is not drift. A variable magpie can't see (only a shell
profile sets it) or another secret source (${vault:...}) is unknown:
not drift, and kept. A sync or pick keeps the reference
(hermesKeptKey). When it names a key the gateway doesn't take, magpie
keeps the reference and writes its key into that .env under the
variable (made 0600 when there was none). A value with more than the
one reference in it is replaced by magpie's key, as before.
Siblings not covered here: other agents whose configs take env
references in the key (Droid's "${VAR}", OpenCode's {env:VAR}) still
compare literally.
Test: TestHermesWithAKeyInItsEnvFile uses the reporter's provider block
as written: a Gateway key and magpie's own (quoted, export) in .env,
${env:VAR} from the environment, an unseen variable, a wrong key (.env
rewritten in place, other lines kept), and a composite value.
Broken by hand: with hermes.go at origin/main it fails "a gateway key in
.env is drift: Hermes's api_key (config.yaml) was changed"; with only
the sync half removed it fails "the user's reference was written over".
Run (worktree, sandbox HOME, GOCACHE pinned, macOS, load ~300):
- gofmt -l internal/agent: nothing. go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./...: ok (at
|
||
|
|
94df239265 |
gateway: answers as an Ollama server, so Copilot in Visual Studio and VS Code lists magpie's models when given the gateway as its Ollama URL (wani on Discord)
Visual Studio 2026's Copilot (Agent preview, bring your own model) takes a
custom endpoint only for OpenAI and Ollama. wani's OpenAI attempt failed
with "Session was not created with authentication info or custom
provider". That error comes from the Copilot runtime in VS: the session was
created without a GitHub token or a BYOK provider config, and nothing
reaches magpie, so magpie can't fix it.
What an Ollama client needs, read from vscode-copilot-chat's
src/extension/byok/vscode-node/ollamaProvider.ts (5863f5a):
- GET /api/version, which must be at least 0.6.4, or no model is listed;
- GET /api/tags, from which it takes each model's "model";
- POST /api/show of each. A model without "capabilities" is skipped. The
window is model_info["<general.architecture>.context_length"] ?? 32768,
and the name is general.basename;
- chat on <url>/v1/chat/completions, streamed, with an empty
"Authorization: Bearer ". magpie already serves that.
It never calls /api/chat. The Copilot SDK under Visual Studio's agent
treats Ollama as an OpenAI API at <url>/v1 too.
ollama.go serves these three routes on Handler's mux, so every guard
/v1/* has covers them too:
- lanGuard: LAN sharing, a gateway key, rebound Host, forwarded loopback;
- corsGuard: a foreign Origin, Origin null and *.localhost;
- a key held to some models: catalogFor/keyAllowed.
/api/show tells:
- capabilities: completion and tools, plus vision from Images and thinking
from Thinks;
- the window, or 32768 when magpie doesn't know it, since VS Code would
take a 0;
- general.parameter_count and magpie.embedding_length, because the ollama
CLI 0.6.8's "ollama show" read them unchecked and panicked without them.
The real CLI found this.
/api/chat and /api/generate are not served, so "ollama run" doesn't work.
Tests (internal/gateway/ollama_test.go; lan_test.go lists the routes):
- TestOllamaModelRoutes, TestOllamaRoutesHoldAKey, TestOllamaRoutesGuarded
and TestOllamaClientChats each fail with 404 without the routes.
- Broken by hand, each went red:
- tags from provider.Catalog() instead of catalogFor: HoldAKey;
- vision dropped: ModelRoutes;
- corsGuard skipping /api/: Guarded (200 for a foreign page, Origin
null and a localhost subdomain);
- an unknown window told as 0: ModelRoutes;
- parameter_count and embedding_length left out: ModelRoutes.
Real use, in a sandbox HOME with MAGPIE_NO_ACCOUNTS=1:
- a nogui build on 127.0.0.1:3561, with a custom provider on a fake
OpenAI upstream (python, 127.0.0.1:3562);
- the real ollama 0.6.8 CLI with OLLAMA_HOST at it: "ollama --version"
(server 0.12.6), "ollama list" (both models) and "ollama show" all
worked. Before the model_info fix, show panicked;
- curl replaying VS Code's sequence (version, tags, show, then a streamed
/v1/chat/completions with an empty Bearer and VS Code's body) streamed
the upstream's reply, and the upstream got its own key;
- on the same server, a foreign Origin, Origin null and a rebound Host all
got 403.
Not tried:
- Visual Studio 2026 itself (no Windows VS here);
- VS Code's Copilot itself (VS Code isn't installed);
- JetBrains' Ollama client, which likely needs /api/chat.
Run at this head (macOS):
- gofmt -l .: nothing;
- go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet
./...: clean;
- go test -timeout 45m ./... at e89d6a4f9, load ~300 to 400: 59 packages
ok. These failed:
- internal/agent, internal/gateway and internal/library ran past 45m
(#2544, #2870, #2853);
- TestClaudeAccountsSpentFallBackToCodex in gateway (#2858);
- TestSetAnswersWhileDevinAndProvidersHang in gui, at 16s against its
bound (#1375);
- TestGatewayHookMixedPiPackage in plugin, starting plugins after 742s
(#2865).
Rerun alone:
- gui's and plugin's tests: ok (gui 35s, plugin 499s);
- internal/agent ok (2580s), internal/library ok (1112s);
- internal/gateway in two halves by test name, each ok (1406s and
1030s). Whole, it timed out again at 45m while starting
TestRouteKeepsItsFolderShort, not stuck.
No GUI file changed.
|
||
|
|
c863904338 |
gateway: Command Code's Zero Data Retention refusal rests nothing and goes to another member (plugins #246)
Command Code plugin 0.1.14 sends x-cmd-zdr: 1 when its Zero Data
Retention switch is on. A model with no ZDR upstream is refused with
the Provider API's 422 (code "cmd_zdr_no_providers") or, on Go, a 400
the plugin makes with type "cmd_zdr_no_providers". The refusal is about
that request's setting, not the model or the account.
Before, on the plugin path (moved commandcode-plan):
- Go's 400 was rewritten with type invalid_request_error, read as the
model unserved (unservedWords), rested commandcode-plan@<acct>/<model>
for a minute, and the account's second key was asked the same thing.
- The 422 went to the agent as api_error, and in a group the next
member was never asked.
- Raw bodies (restAfter, a decision group's decideFailed) read as
modelRefused too.
Now:
- zdrRefused (fallback.go) matches only that code as the error's type
or code, on 400/422. modelRefused and tooLongUnsaid leave it out.
- keepRetry notes it from the vendor's raw body (X-Magpie-ZDR-Refused)
since the Anthropic error shape keeps no code; pass/keepAlive strip
the note.
- The candidate loop skips the provider's mates at the same model
(notMates, they'd be sent the same header), tries the next member,
rests nobody, and returns the refusal alone.
- restAfterMarked and decideFailed rest nothing for it.
- docs/subsystems/gateway-routing.md says so.
Tests (internal/gateway/plugin_zdr_test.go), with the literal bodies
from plugins' zdr.test.mjs:
- TestCommandCodeZDRRefusalRestsNothing (422 and 400, plugin path,
two accounts): alone the agent gets Command Code's words and one
account is asked; group G answers from b over chat and over
/v1/messages; nothing rests; switch off, Command Code answers first.
- TestZDRRefusalIsCommandCodesCodeOnly: the same words without the
code, OpenAI model_not_found, unsupported_api_for_model and the code
named in a message still read as model refusals.
- TestZDRRefusalNeverRests: restAfter with the raw 422/400 and the
noted Anthropic body rests nothing; without the note it rests.
Broken by hand:
- old sources (zdrRefused stubbed false): e2e red in both subtests
("group: 422 ... (commandcode 1, b 0)", "alone: 400 ... (asked 2)"),
classifier table red.
- restAfter guard removed: TestZDRRefusalNeverRests red ("422 ...
rests: {Why:other Status:422 ...").
- loop branch removed: e2e red. keepRetry note removed: e2e red.
Run at this head: gofmt -l (clean); go vet ./...,
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... (clean);
go test -timeout 45m ./... (go1.26.8, load avg ~300 from other
sessions): every package ok except
- internal/agent, internal/gateway, internal/library: past -timeout
45m (TestClaudeTiers, TestMessageReasoningRefused,
TestProjectServersQoderCodeBuddyDroid running), as #2869;
- internal/gui TestSetAnswersWhileDevinAndProvidersHang (13.8s), #1375;
- internal/plugin TestGatewayHookMixedPiPackage, #2865.
After rebasing on
|
||
|
|
d5bc9f0009 |
gateway: a plain 403 never rests an account until its window, and two accounts' alike 403 on one request rest neither (plugins#243)
zygs1083-dotcom on plugins#243: Factory answered 403 to a Claude Code 2.1.292 request (a changed instructions wrapper factory 0.1.33 didn't adapt), and the accounts went into cooldown. On |
||
|
|
f73378365f |
gui: a filter a click set on Usage's Requests goes when they are left (TJHHHH on Discord)
TJHHHH: after a jump to Codex's requests on the Usage page, every later
visit listed only Codex's. The Requests' filters are module state in
plugins/usage/page.js and nothing ever reset them, so a click on Codex in
the ranking split by agent stuck for the app's lifetime.
Now a filter a click lent the Requests (a ranking click on an agent,
provider, model or gateway key, a chart day, the address's ?agent= and
the like, a route from Routing) is remembered in ledLent and given back
by ledLeave when the reader leaves the Requests: for another Usage tab
(renderUsageTab), or another page through a new page hook, `leave`, that
show() calls on the page it leaves. A filter picked in its own menu or
typed in the search stays, as a menu choice does in a Mac app. A route's
saved filters keep their lent marks, and leaving with a route on gives
back the route too. Docs: plugin-runtime.md's Usage hooks.
Siblings judged and left: the tray panel's Usage tab ranking (its own
view, not the page's Requests), the Sessions reveal (per agent, no "all"), the KPI
failed/retried jumps (shown in the status segment, read as own picks).
Test: tests/usage-ledger-leave.test.cjs, chromium and webkit, en zh
zh-TW ja de: ranking click leaves for a page and for a tab, menu pick
stays, ?agent= goes, a route goes. On the old app.js/page.js/client.js
it is red, 20 of 25 in chromium ("back from another page: last asked
period=today&agent=codex"); only the menu-pick case passes there.
Green with the fix, in both engines.
Run at
|
||
|
|
197849ad4d |
gateway: image generation's timeout is a setting, 1 to 60 minutes
neighbads on X: a slow image endpoint needed more than the fixed 5 minutes. Settings > Images > Image generation timeout (imageTimeout in settings.json, 5 when unset, 1 to 60 accepted, anything else a 400) now gives every drawing that long, on each route it takes: - drawTimeout() reads the setting; drawWithin marks the context as a drawing and sets its deadline. Error texts say the time it was given (givenTo), ModelScope's task polling too. - A marked drawing goes through a vendor transport with no ResponseHeaderTimeout (drawsApart), since an images API sends its headers only once it has drawn; everything else keeps the 10-minute upstreamHeaderWait, so a 30-minute setting isn't cut at 10. - An image answered as a link is downloaded within the same time (imageLongest, never under ImageLongest). - Videos keep 5 minutes per call (videoTimeout): a video is made between its calls, so the setting isn't theirs. - magpie mcp image waits on a call up to callLongest (2h1m, past the 60-minute bound twice over), since it may not read the settings (WSL); ToolTimeout, which agent configs carry, is unchanged. - The plugin path: Bun 1.4.2's fetch has no 5-minute cap (tried against a server answering after 330s), so nothing changes there. - api.go keeps the saved value when a page doesn't send imageTimeout; prefsKeep carries it on every other Settings save. GUI: a segmented row under Image generation (5, 10, 15, 30, 60 min; a value set by hand gets its own segment), in en, zh, zh-TW, ja and de. Three GUI tests clicked controls the new row pushed under the window's foot or past the viewport; they now wheel to them with reader.cjs's reach (disabled-models, search-api, refusal-retries-setting). searcher-pick checks the help has no title before reach's pointer passes over it (the app's mouseover sets one on cut-short text). Run, at |
||
|
|
b10788745a |
agent: Claude Desktop on magpie keeps the language picked signed in with Anthropic (memory, Osal on Discord)
Desktop's 3p mode runs in a userData of its own, Claude-3p, whose
config.json (Desktop's settings, not claude_desktop_config.json) starts
with no "locale", so after magpie turned 3p on Desktop came up in the
system's language. magpie never wrote Claude-3p/config.json before this
commit: it writes only claude_desktop_config.json (deploymentMode, merged
key by key) and configLibrary's _meta.json and its own profile. So the
hand-set locale that reporters saw lost on restart was not written over by
magpie; Desktop 2.7032's own main process sets "locale" back to en-US when
its UI asks for one with no bundled catalog (pit in its index chunk), and
resets an unparsable config.json to {}. Which of those hit them is not
known.
Turning Desktop onto magpie now copies the one key "locale" from the
signed-in userData's config.json (Claude, %APPDATA%\Claude on Windows,
the first set's before the others for an MSIX install) into
Claude-3p/config.json, only when that file is missing or a JSON object
with no locale, and only a name Desktop takes for a catalog
(^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$, as Desktop's lit). A locale already in
Claude-3p is never written over, no other key there is written, and an
unreadable or non-object file is left alone without stopping the
takeover. Off removes the file only when magpie made it and it still
holds nothing but the carried language. The key name "locale" was read
from /Applications/Claude.app 2.7032's bundle (Fo.get("locale") on its
config.json store).
Tests: TestClaudeDesktopCarriesTheLanguage, TestClaudeDesktopKeepsThe3pLanguage,
TestClaudeDesktopUserEditsThenReapply, TestClaudeDesktopLanguageOddValues.
Broken by hand, each went red: no carry (Carries red), overwrite an
existing 3p locale (Keeps3p and UserEdits red), no removal on off
(Carries red), no name check (OddValues red). UserEdits passes on the
old code too: it guards that magpie never writes the user's file.
Run at
|
||
|
|
8febe3a50c |
provider: a pick a plugin's list leaves for a while comes back when it is listed again (多喝热水 on Discord)
多喝热水 picked models of the Our Free Model plugin
(mu-zi-lee/magpie-our-free-model) and had to pick them again after every
magpie update. A minute after magpie starts, and hourly, KeepPluginsListed
reads every plugin's models again and dropGonePicks deleted for good each
pick the list didn't have. OFM, started again with magpie, lists its free
pools at once and its account channels' models ("qoder/...", "kiro/...")
only once it has read them, so the first list was short and the channel
picks were lost. A relay's Fetch models or RefreshEvery list that left a
model out once did the same.
Now a pick the list leaves out moves to Delisted (providers.json
"delisted"): not served while it isn't listed, put back in Models when a
list has it again (relistPicks), for plugins and fetched lists alike.
After a list left picks out, the loop asks again in 5 minutes
(relistSoon), not an hour. A provider whose every pick is set aside serves
none of its models (waitsForPicks), not the whole list. Editor saves keep
Delisted (delistedWith, withPicks, the account whitelist); Select none or
the vendor's list picked clears it. While picks are set aside, new picks
saved keep the earlier PickedFrom too, so a model seen and left unpicked
isn't served as new when the list has it again; a list short of no pick is
taken as it is, as TestClaudePicksOfEveryModelTakeOnesListedSince wants.
New tests: TestPluginPicksComeBackWithTheirList (through the real
KeepPluginsListed loop), TestEveryPickDelistedServesNone,
TestRelayPicksComeBackWithTheirList (through Refetch on an httptest
/v1/models). Broken by hand, each red: relistPicks returning false (the
old behaviour: picks not restored), relistSoon as relistEvery ("wasn't
asked for again soon"), waitsForPicks removed (pool-a served with every
pick set aside), the PickedFrom union off (kiro/claude-z served).
The plugin side, for its author: OFM's managed runner answers `models`
before its channels and first model refresh are read; awaiting them (with
a timeout) or answering fallback(previous) with the magpie.fellBack marker
would keep magpie's last good list. OFM itself was not run here (its
install scripts weren't run, by instruction).
Run at base
|
||
|
|
9fd80b2128 |
library: skills install from any git repository, GitLab and a company's own among them (sunset on Discord)
ProbeSkills took only a GitHub source or a folder. It now also takes any
git repository's address: https/http on gitlab.com or a self-hosted
server (any depth of groups), a GitLab or Gitea page of a folder
(/-/tree/<ref>/<path>, /-/blob/..., /src/branch/...), ssh://,
git@host:group/repo.git, a bare host.name/group/repo, and file://.
Such a source is kind "git" (gitSource, skillgit.go).
It is fetched with the user's own git (proc.FindTool), so their
credential helpers and SSH keys reach an intranet host: git init, then
fetch --depth 1 --no-tags -- <url> <ref|HEAD>, checkout FETCH_HEAD into
a magpie-skill-* folder, .git removed; the same keepProbe/maxFetch path
GitHub's tarball takes.
What the user typed is data: an address starting with - and any
transport:: address (ext::, fd::, file::) are refused before git runs;
the address follows --; git runs with protocol.ext.allow=never and
core.symlinks=false, no shell, GIT_TERMINAL_PROMPT=0, and ssh -o
BatchMode=yes unless the user set their own SSH command (GIT_SSH,
GIT_SSH_COMMAND, core.sshCommand), so a sign-in it can't make fails
instead of waiting. An address with a password or token in it is
refused: library.json is shown and backed up. Git missing, a sign-in
refused, an unknown host key, a missing branch and an unreachable host
each say so plainly (gitError).
Updates: Commit keeps the repository head the skill was fetched at. A
check runs git ls-remote; another head is fetched (once per repository
and ref) and the skill's folder hashed, so a commit elsewhere in the
repository leaves it current and moves Commit on. UpdateSkill and the
edited-skill refusal work as for GitHub; EditedError and the page's
Changed here / Update / replace question name the repository instead of
GitHub. findNew, Group again, icons and the market stay GitHub's only
(documented).
Page, TUI and docs: the add box's placeholder in en/zh/zh-TW/ja/de
(zh: owner/repo、GitHub 或 GitLab 链接、任意 git 仓库地址,或本机上的文件夹),
a git skill's source shown as a link (https) or text (SSH), its own
Update and Check for updates; the TUI's prompt; library.md's Skills and
Skill updates rows. GIT_SSH/GIT_SSH_COMMAND are listed in agentenv's
notAnAgent (TestFolderVarsAreListed).
Tests (fail on the old code: gitSource/gitPath don't exist there, and
skill-git-source.test.cjs fails on the old assets' placeholder, checked
by stashing client.js/i18n.js): TestGitSourceReads,
TestInstallFromGitRepo (a local bare repo over file://: probe, install,
check finds an update, update, a commit elsewhere stays current, an
edit here is refused naming the repo), TestGitTreeURLInstallsFolder,
TestGitMissingSaysSo, TestGitSignInRefusedSaysSo (a local httptest 401,
GIT_CONFIG_NOSYSTEM so no Keychain), TestGitRefusesOptionsAndTransports,
TestGitErrorsSaid. No test reaches the network.
Run (worktree at origin/main
|
||
|
|
eb3f174289 |
agent: Claude Code's auto mode classifier model is set on its Agents row (Linka on Discord)
Claude Code 2.1.302 reads CLAUDE_CODE_AUTO_MODE_MODEL for the model its client-side auto mode classifier checks each action with. It doesn't change server-side auto mode, and a classifier model Anthropic sets for the account comes first. The installed 2.1.303 binary has the variable: unset, Claude Code picks the sonnet tier's model, else Sonnet. It refuses claude-sonnet-5-5, claude-opus-5-5 and claude-opus-5 with a warning and uses its own pick instead. - Claude Code gets an "auto mode" field (key auto_mode, Quiet, follows nothing). It can be set only while Claude Code is routed through magpie, only to one of magpie's models, and is written dashed like the other model keys. Its options leave out the three models Claude Code refuses, and Set refuses them too. - A value the user had before magpie routed Claude Code is stashed with their tiers (claudeOwnEnv). It is taken out while wired in and comes back on Disconnect or Claude Code's own model, unless they have set one again since. The restore loop now skips any claudeOwnEnv key the user wrote again. - magpie's own value goes when magpie steps out. A value the user sets while wired in is never touched. - GUI: an "Auto mode" line in the opened row's Tiers, after Subagents, using the app's model picker. Default is noted as Claude Code's own pick. Strings are translated for zh, zh-TW, ja and de. - Docs: agent-wiring.md and reference.md. Run, in a worktree at origin/main |
||
|
|
f76201a84a |
plugins: a sign-in page the plugin's CLI opened isn't opened again, Grok's opened twice on macOS (andyfmyth on X)
"magpie里的grok 登录验证 在mac下 似乎每次都会弹两次验证, 在浏览器窗口里". Grok's plugin signs in through `grok login --device-auth`, and Grok Build (1.0.50, the webbrowser crate) opens the device page itself, through NSWorkspace on macOS and ShellExecuteW on Windows. Neither reads $BROWSER; the macOS binary has no "BROWSER" string. magpie then opened the same URL from /api/plugin-signin (desktop), startPluginSignIn/followSignIn (a browser tab) or `magpie plugin login`. Reproduced in a sandbox HOME/GROK_HOME: grok's device-code tab appeared in Chrome with magpie not involved, with and without SSH_CONNECTION. Built-in grok is retired ( |
||
|
|
94919109cb |
gateway: a silent HTTP/2 connection to a vendor is pinged and dropped (#2843)
pinewhite (#2843, v0.1.1279, Linux): for ~30 minutes every request to
group/auto-deepseek-v4-1-flash hung with no first byte. The WorkBuddy
member was resting on a 429, so they all went to ClinePass, and usage
shows only 499s with in=0. A restart answered the same request in 1.6s.
Cause: the gateway's transport (upstreamTransport) speaks HTTP/2 to
any vendor that offers it, so every request to api.cline.bot shares one
connection. It had no HTTP/2 health check. A connection that goes silent
without closing (a local proxy whose own way out died, or a NAT that
forgot the flow) stays in the pool. Every new request is multiplexed
onto it and waits for the 10-minute ResponseHeaderTimeout while the
kernel takes the writes. The agent gives up first, so nothing fails over
and nothing rests the member. Restarting dropped the connection.
Fix: netproxy.HTTP2Health() (SendPingTimeout 20s, PingTimeout 10s) on
upstreamTransport. Go now pings a connection that has had no frame for
20s and closes it when no answer comes within 10s. The requests on it
fail as a 502 ("http2: client connection lost"), so a group moves on,
and the next request dials a new connection. A live vendor answers a
ping whatever its streams are doing, so a long wait for a first byte is
not cut. The same setting goes on http.DefaultTransport in
netproxy.Install, the sibling pool that usage cards, catalogs and
sign-ins use. Not covered: requests a plugin sends from Bun.
Tests (new):
- TestSilentHTTP2ConnectionIsDropped: an HTTP/2 TLS httptest vendor
behind a TCP relay that can go silent on its open connections (it
takes writes, passes nothing). After the relay goes silent, a request
must end well inside 10s, and the next one must succeed on a second
connection.
- TestGroupMovesOnFromSilentHTTP2Connection: the same through the real
Handler, with an ordered group a/m then b/m. Once a's connection is
silent, the request must get b's reply.
- TestInstallChecksHTTP2Connections (netproxy).
What was run (worktree on origin/main
|
||
|
|
38f6bee23e |
sessions: the manage page reads its agents' files once, and only the agents it shows (#2776)
GET /api/sessions/manage went over every agent's session files three
times: sessions.Agents() for the counts, sessions.List(All) only to build
the set that keeps a gateway session its agent keeps too from being
counted twice, and sessions.ListAgent for the list. List(All) also read
every agent's changed files again and put every session together, prices
and titles included, to take its id. So a page showing Claude Code's
sessions parsed Hermes's and Codex's writes too.
sessions.Manage now does it in one pass over the files, under one hold
of the locks: the counts, the ids of the sessions of the agents that have
gateway sessions (nativeIDs: the id from the file's key, or from its
parse for the agents that write it inside the file, idInFile, which are
the only ones read), then the picked agent's list. The handler's pick
runs as a callback so the counts can include the gateway sessions. A
change to an agent not shown and with no gateway sessions waits for a
page that shows it. assemble's id rule moved into sessionID, which both
use.
That set was also wrong in two ways. List leaves out a session nothing
was said in and stops at 5000 (All), while the list beside it keeps
every one, so a gateway session whose agent's file was empty (or among
the oldest of more than 5000) was counted twice and listed once. The
set is now every native session, the same as the list's, and
POST /api/sessions/delete, which tells a listed gateway session from a
native one, uses it too (sessions.NativeIDs).
docs/subsystems/gateway-sessions.md says so.
Tests:
- TestManageReadsOnlyTheAgentsItShows: Codex's files changed, Claude
Code's page parses none of them; asked for Codex's ids it reads them;
the native ids equal the list's, the empty session included. Red with
Manage reading every file as List(All) did ("read 2 of them").
- TestManageCountsAGatewaySessionTheAgentKeepsOnce: a gateway session
whose Claude Code file has nothing said in it is counted once. Red on
the old handler: "one session listed, counted [{claude 2}]".
Measured on the synthetic sandbox HOME (3000 Claude Code, 1500 Codex,
2000 Hermes sessions; no gateway sessions), CPU time of the request
(load average ~250 from other sessions, so wall times are noisy), the
parent bbee24810 against this change, the same run of each:
first manage?agent=claude after a restart 2164 -> 627 ms CPU
(15697 -> 10554 ms wall)
warm manage?agent=claude 173-222 ms -> 64-88 ms CPU
warm manage?agent=hermes 176-243 ms -> 56-70 ms CPU
warm manage?agent=codex 237-269 ms -> 155-162 ms CPU (after its
first, which reads Codex's model/effort)
Run: go test ./internal/sessions -count=1, go test ./internal/gui -count=1;
gofmt -l clean; go vet. Full suite and cross-OS vet are recorded on the
last commit of this series.
|
||
|
|
ec7f474323 |
gateway: Codex on Copilot is relayed with its web_search, and a translated call's arguments stream (echo_ts)
echo_ts (magpie 0.1.1279, macOS): Codex on a GitHub Copilot subscription
through magpie was about 10x slower than Copilot directly. Two causes,
both in the gateway:
- Codex offers web_search on every turn, and magpie counted Copilot as a
provider that can't search, so every Codex turn on Copilot was
translated for magpie's search instead of relayed.
- On that translated path responsesDecoder held a call's argument deltas
until the call was done, so Codex saw nothing while the model wrote a
command or a patch, then all of it at once. A custom tool (apply_patch)
got no custom_tool_call_input deltas at all.
Fixes:
- search.go: searchesItself counts a Copilot account on Responses. Real
check on 2026-10-17 with the owner's account: gpt-5.3-codex,
gpt-5.4-mini, gpt-6-luna, grok-4.7 and mai-code-1.1-flash each answered
a request offering web_search with web_search_call items and cited
pages. searchRank never picks Copilot to search for another provider's
models (its premium requests).
- gateway.go: a Copilot Responses request whose tools mark an argument
"encrypted" (MultiAgentV2's spawn_agent message) is still translated,
marks left out (asksSealing in responses.go). Checked on the real
account: relayed, Copilot seals the message ("UlQC...", no
encrypted_function_args), and the subagent's turn carrying it came back
"Encrypted function output content could not be decrypted or
decoded". This was already broken for a Copilot turn without
web_search; it is fixed for that too. An unsealed agent_message relayed
with web_search answers normally (checked).
- responses.go: responsesDecoder gives argument deltas as they come. It
holds only the deltas that make the arguments whole JSON, until the
done events, so #613's case (deltas that disagree with done) still
ends with the fuller arguments. The encoder sends a custom tool's input
as custom_tool_call_input.delta, read out of the {"input": ...}
arguments as they stream (customStream in custom_tool.go, which waits
for cut escapes, surrogate pairs and UTF-8), and closes it with
custom_tool_call_input.done.
- docs/subsystems/gateway-routing.md says the above.
Not changed: the HTTP/2 connection. Head-of-line blocking from large
uploads on the one connection to Copilot was measured on the real
account with a Go client: a 4MB request and a small one 300ms later,
5 rounds x 2, same connection vs a new one. The small request's first
byte took 0.93-1.68s on the shared connection, 1.26-4.77s on its own
(handshake included), 0.66-1.08s alone. No sign of blocking.
Small requests slower while a long session runs (echo_ts, 42.8s vs
17-29s first text, xhigh): nothing in magpie serializes Copilot requests
by default (lanes need MaxConcurrency, the RPM gate MaxRPM; Go's h2
windows are 1GB per connection, 4MB per stream). Measured: small
requests beside a 412s xhigh stream (16,617 output tokens) were as fast
as idle, via magpie 0.8-1.1s first text, direct 1.3-2.0s, sent_ms
1-10ms. One global lock found: copilotMu is held across the token
refresh's HTTP call, which stalls every Copilot request only around a
refresh, filed as #2762, not changed here. usage.jsonl's own_ms,
queued_ms and sent_ms against ttft_ms tell magpie's time from Copilot's.
Tests:
- TestCallArgsStreamWhenTranslated (function and custom), through the
real handler with an upstream that holds the rest of the call until
the client has the first delta.
- TestResponsesCallArgsStream, TestCustomInputStreams (pieces of 1, 2, 3,
5, 7 bytes and whole).
- TestCopilotRelayedUnlessAskedToSeal; TestCopilotUltraSubagentWithWebSearch
now expects the subagent relayed with the search.
Broken by hand at this tree, each went red:
- decoder holding every delta: TestCallArgsStreamWhenTranslated,
TestResponsesCallArgsStream;
- no custom input delta: TestCallArgsStreamWhenTranslated/custom;
- Copilot out of searchesItself: TestCopilotRelayedUnlessAskedToSeal,
TestCopilotUltraSubagentWithWebSearch;
- the asksSealing check off: the same two.
Real use: a built magpie serve in a sandbox HOME (port 3461) with the
owner's Copilot account, Codex-shaped requests offering exec_command,
apply_patch and web_search to copilot/gpt-5.3-codex:
- unmarked: relayed (Copilot's own response ids), apply_patch gave 93
custom_tool_call_input deltas from 3.55s to 11.69s;
- with a sealed spawn_agent: translated, apply_patch 117 deltas from
1.45s to 11.73s, exec_command 92 function_call_arguments deltas from
1.55s to 8.16s.
Not tried with the Codex binary itself.
Run at
|