8a4e32febef69bb797cdf3003ec1395e725d5d63
1412
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3af592f587 |
gateway: the overflow memory is read under its lock, so two requests of one conversation don't crash the gateway (#3453)
Review follow-up to ggbdpq's 075aaef62. behindOverflow took the conversation's inner map under overflowLearned's lock, let go, and then read it, while noteOverflow and forgetOverflow write that same map under the lock. Two requests of one conversation at once (a turn beside its title ask, a client's retry) read and wrote one Go map together, which is a fatal "concurrent map read and map write", the whole gateway gone. The loop now runs under the lock. TestOverflowMemoryReadWhileNoted notes and forgets on one goroutine while another orders members by the memory. Before this commit, on mote: go test -tags nogui -race -count=1 -run TestOverflowMemoryReadWhileNoted ./internal/gateway/ -> "--- FAIL: TestOverflowMemoryReadWhileNoted ... race detected during execution of test". With it, -race -count=20 of that test, TestOverflowRefusedOnceIsAskedLast and TestRelayInputCapGoesToTheNextMember: ok. Also: behindOverflow's comment said resting members keep their order; the code moves a refused member behind every other one, resting or not, so the sentence is dropped. gateway-routing.md now describes the memory beside withRoom's overflow paragraph. |
||
|
|
9a4eaab82a |
gateway: a Chat body relayed to Gemini's OpenAI-compatible API goes without Ollama's options (#3097)
What changed: a client that takes the gateway for an Ollama server (its
/api/show is answered in Ollama's shape) sends Ollama's per-request
options beside its Chat fields. The google preset serves a model on
Gemini's OpenAI-compatible endpoint, so such a request is relayed as it
came, and that endpoint reads proto JSON: an unknown name turns the
whole request away with 400 "Invalid JSON payload received. Unknown
name \"options\": Cannot find field", every call, whatever the effort.
A body relayed to a Gemini OpenAI-compatible upstream (geminiCompat)
now goes without the top-level options, whose runner settings have no
place on a Chat API, as the Ollama route's own body builder already
leaves them out (ollamaChatBody). Another vendor's Chat upstream still
gets the body as the client sent it, and translated requests are
unchanged: they are built from the request's own fields, which never
carried options. geminiCompat is worked out once where the thought
signatures ask for it too.
Run: TestGeminiCompatRelayLeavesOutOllamaOptions fails on the old code
with "Ollama's options reached Gemini's OpenAI-compatible API" and
passes with the change; a request to another vendor's Chat upstream
still carries options there. go test ./internal/gateway/ ok (346.6s);
go test ./... -timeout 45m: 66 packages ok, internal/agent TestMothX
and internal/gui TestProxyCheckSaysAProxyPassedBy red, both red with
the change stashed on
|
||
|
|
026d4423d0 |
gateway: a Command Code stream that ends with no finish_reason is a cut (#2471)
What changed: a Chat stream of Command Code's whose reply ends with no finish_reason anywhere - esp32gallery's day had 665 requests, 624 ended with one, and the 20 that didn't were turns its slow starts lost to a killed worker, each a ledger 200 with no stop and no error while the client read "Stream ended without finish_reason" - was taken for a turn that ended as it should, silence in the ledger and a bare half-reply for the agent. Its API joins Gemini's OpenAI-compatible one in saysItsEnd: every whole reply of its says its end, so a stream that stops short of a finish_reason is said as the cut it is, in the stream, the same way a relayed Gemini one is (#1644) - and one still held, with nothing of the reply said yet, fails there for the group's next candidate. Another vendor's Chat stream may still end whole with neither a finish_reason nor [DONE]: nothing changes there. Run: Four new tests, the first two red on cef8c1a4a before the change (the cut passing as a whole reply, the next member never asked): TestCommandCodeRelayEndedShort, a half-reply cut ends with "the reply ended before it was complete", no finish_reason filled in; TestCommandCodeTaillessFailsOver, a held lead-only stream fails 502 for the next member; TestAnotherChatStreamWithoutAFinishReasonStaysAsItCame, another vendor's tailless stream goes as it came; and TestCommandCodeRelayWholeStaysWhole, a finished reply is never given a second end. TestGeminiCompatRelayEndedShort and TestGeminiCompatTranslatedEndedShort green throughout. Not tried: a real Command Code upstream (the frames are the reporter's ledger shapes, the host the one balance.go reads). Generated-by: GLM-5.3-Flash (ZCode) |
||
|
|
eb7e72cc7f |
gateway: a response.completed with no output and no tokens fails over (#2471)
What changed: a Responses upstream that ends its 200 stream with a
response.completed carrying no output and counting no token - WorkBuddy
AI's account answered Codex's request with created, in_progress,
completed and `output: []` three times running (MurmuredVelpro) - had
the completed event taken for a reply's end: the held stream went to the
agent as a completed turn, the try stood as a 200 success, and the
group's healthy members were never asked. streamEvent now reads a
completed with an empty output and a zero usage as the no reply it is -
the same shape a translated reply that said nothing and counted nothing
has failed as since #2086 (repliesCounted) - and fails the held try for
the group's next candidate, in the candidate walk as an empty reply's
does: nobody rests, as the reply's shape failed, not the account. A
completed that counted a token stays a reply, as Claude's own empty
end_turn does; and an event this reaches is one nothing was said before,
since the hold lets the first content through and reads no event beside
it, so nothing of the try has reached the agent when it fires.
The fields said are what is read: a completed that names neither field
goes as it came, as the streamEvent table pinned it
(TestStreamEventRefusals, which caught the first draft reading an
omitted output as an empty one), and a completed that counted a token
stays a reply.
Run: TestEmptyCompletedFailsOver (new) red on
|
||
|
|
c991733dca |
docs: the Claude bridge's tool_choice none, asides and cut-copy branches (bbfatx on X)
claude-subscription-bridge.md now describes the four commits before this one: - a tool_choice none turn is offered every tool, and what it may call is kept apart (subscriptionRun.allowed, mcpCall's refusal); - an aside of a run that was told tools neither retires the conversation's run nor is taken as rewritten (asideOf); - a branch is a cut copy of its run's session (cutSession), resumed in its run's mode (savedSession.tui), in place of --fork-session --resume-session-at, with the cache numbers measured on mote; the "-p because it is a branch" reason is only for a -p run's branch; - an interactive run behind a prompt suggestion is cut at the line before it (branchAt, lastLine/backLine/behindLine), not told whole. Verification lists the new tests. Run at this tree (mote, the whole stack 252006e87..this): - go test -tags nogui -count=1 -timeout 45m ./internal/gateway ./internal/claudetui: ok (gateway 1045.8s, claudetui 9.6s) - go vet -tags nogui, GOOS=linux go vet -tags nogui and GOOS=windows go vet of both packages: clean; gofmt -l internal/: clean Every symbol and test named was checked against the tree with grep. Not run: the full go test ./... ; queued behind other sessions' suites on mote, it was lost before it started. Not changed: gateway-sessions.md's --fork-session line, which is about Claude Code's own forks of a user's sessions, not the bridge. |
||
|
|
1adff37796 |
claude: a refusal Claude Code falls back from goes on to the fallback model's answer (Chixi_Fang on X)
Claude Code 2.1.316 doesn't end a turn at a refusal. It asks the same
model again, then its fallback model (claude-opus-4-8 for Opus 5.5),
whose answer ends the turn with result success. The bridge ended the
reply at the first stop_reason refusal, so the client got "Partial "
plus a refusal, and the gateway's hw.refused moved to another account
or handed the refusal back. That is the "model error" the reporter saw.
readOutput now holds a refusal from Claude Code's own model and goes on
with the next message as one reply. Not held: a client tool call, or a
schema reply. The refusal's stop_details are held too. The refusal is
told only if it stands: at a result with no API status (Claude Code's
model_refusal_no_fallback, -p or TUI) or at the end of output. Then
hw.refused and b01766d13 see it as before. A result with a status after
a refusal is that error, not a refusal. The continuing message's model
goes on the KUsage as Model and Served. The try records the fallback
model, and a reply told whole names it. A stream's message_start can't
change it. Prompts and system text sent upstream are unchanged.
Real behaviour: Claude Code 2.1.316 on mote, in a sandbox HOME and
CLAUDE_CONFIG_DIR, against a fake Anthropic upstream that refuses
claude-opus-5-5 (or every model). The -p and TUI stream-json lines were
captured and trimmed into the fixtures in
claude_refusal_fallback_test.go.
Run (mote-run, worktree at base
|
||
|
|
5416fdb76b |
agent: Claude Code on magpie keeps its MCP tools deferred (ENABLE_TOOL_SEARCH)
cybercaius on Discord (#help): the MCP router's 245 tools took 124K
tokens of a 341K context ("Magpie ×245" in Usage › Context). Claude Code
before 2.1.304 keeps tool search off behind an ANTHROPIC_BASE_URL that
isn't Anthropic's, so every router tool's definition went on every
request. 2.1.304 (10-19) turned it on for gateways itself, but a
conversation begun without it stays held off.
While Claude Code is routed through magpie, magpie now writes
env.ENABLE_TOOL_SEARCH="true" into ~/.claude/settings.json: Claude
Code's own documented switch, no prompt or identity change. The gateway
carries deferred tools to every upstream already (#2660,
withoutDeferredTools). It follows the auto-mode review's ownership:
magpie's value is stashed (claude.tool_search), a value the user set,
an empty one too, is theirs, and magpie's goes in desktopOnly/unroute.
T3 Code's magpie instance gets the same "true" in its environment
unless the user gave it a value there.
Not changed, filed as #4755: agents with no tool search of their own
(OpenCode, Gemini CLI, ...) still get the router's whole list; a lazy
router mode for them needs an owner decision. Not changed: Codex, which
already sends tool_search on magpie's catalog (0.165.0 measured: 14
tools, no MCP ones), and newmax/claudescience, which run Claude Code
through the SDK and set no gateway env of this kind.
Run:
- Real Claude Code 2.1.290 on mote, sandbox HOME, sandbox magpie serve
on 127.0.0.1:3563 built from this tree, a fake Anthropic upstream, a
245-tool stdio MCP server in the Library behind the router, wired
with `magpie claude up/fake-1`: first /v1/messages had 12 tools,
27,443 bytes of tools JSON (+~9KB of deferred names in the messages).
The same with magpie's ENABLE_TOOL_SEARCH taken out (the old
wiring): 266 tools, 245 of them MCP, 242,346 bytes.
- Without magpie, against a capture server: 2.1.200 to 2.1.303 send
every MCP tool (239-257KB); 2.1.304 to 2.1.316 defer them (~28KB);
ENABLE_TOOL_SEARCH=true in settings.json env or the process env makes
2.1.200, 2.1.260 and 2.1.290 defer them too.
- TestClaudeToolSearchOn, TestT3CodeToolSearchOn (new); #4755 filed.
- go test -tags nogui ./internal/agent on mote; GOOS=linux and
GOOS=windows go vet ./internal/agent; gofmt -l.
Broken by hand: writeSearch stashing nothing and writing nothing, and
T3's entry left out: both new tests red. The user-value check skipped:
TestClaudeToolSearchOn red on the user's "false".
Not tried: a real model loading a deferred router tool through
ToolSearch and calling it via magpie (gateway tests cover deferred
tools); Claude Code on Windows/Linux; T3 Code's real app.
|
||
|
|
de74cb53f7 |
mcp router: each caller gets its own Magpie Browser session
The router keeps one backend per Library server for every agent, so all agents behind it shared one `magpie mcp browser`, one browser session and so one tab (packinggoodsllc_07668 on Discord: two agents through a remote router fought over one tab). - serveMCP gives a client that initializes an Mcp-Session-Id (nothing is kept or checked by it). - hubSession names each tools/call's caller: _meta magpie/session from a router in front, else hub-<agent>-<Mcp-Session-Id>. - The router passes it in _meta magpie/session to `magpie mcp browser` and to another magpie's router only (keepsSession); the bridge sends it as that call's X-Magpie-Browser-Session (callerSession). A call naming none goes as the bridge's own session, as before. Run (mote-run): go test ./internal/browsermcp; ./internal/gateway -run 'MCP|Hub'; ./internal/library -run 'TestHubTellsMagpieBrowser|TestKeepsSession|TestHubGivesMagpieImage'. ok. Broken by hand, each red: no meta from the library (library test), no Mcp-Session-Id from serveMCP and ignoring _meta in hubSession (gateway test). Not tried: a real remote router chain between two machines. |
||
|
|
5dfbca6274 |
cli: magpie settings list|get|set|reset, through the window's own save (#4745)
Stage 1 of #4745 (StringKe): every setting POST /api/settings saves can be read and set from the terminal. - internal/settingsapi holds the save the handler made: Merge (the carry of keys a page leaves out, moved verbatim from api.go, plus upstream's RouterNote line), the vision/imageGen/searcher checks, settings.Save's own checks, catalog.Touched. POST /api/settings and `magpie settings` both call settingsapi.Apply, so a value is checked and saved one way. It sits outside internal/gui so the nogui build has it. - `magpie settings` (list, the default, with value, default and choices; get; set; reset to settings.Defaults()), --json on list and get. Body sends the whole file with one key changed, so a key the save keeps when absent (noBird, refusalRetries, ...) is set even to off. A flag where a key or value goes, an unknown key (with near matches named) or a refused value writes nothing and exits 1; --help prints usage. - Parity guards: TestKeysAreWhatTheSaveWrites (each Settings field sent changed on its own; what the save takes must equal Keys), TestSettingsCLISetsWhatTheWindowSaves (every key the page's prefsKeep and savePrefs send is a key), TestEveryRouteHasACommandOrIsNamed (each /api route has a command or a reason in notYet, which later stages shrink; 36 have one now). - Item 3 of the stage (per-provider CLI-only fields in the window) is left for stage 2. - The open app's in-process follow-ups (fonts, Dock, tray menu, alerts, language, update re-check) run only from the window's save: #4752. Run (mote, at the pushed head |
||
|
|
403323af7f |
claude: a switch waits for another magpie's runs in the account's directory (#4532)
StringKe's audit, item 2. claudeDirRun is an in-process RWMutex, so
`magpie accounts switch` from the CLI never waited for the app's /usage,
warm-up or keep-alive run in the saved account's directory: it handed
Claude Code the refresh token that run could still spend, and removed
the directory under it. And the gateway's hand-over let go only of idle
runs; a run in a turn when the switch came was kept for its next turn,
waiting up to idleLongest in the removed directory with the same token.
- inSavedClaudeDir also holds a lock file of its own beside the
account's directory (markClaudeRun, <dir>.run-<pid>-<n>.lock,
filelock), removed as it ends.
- switchSavedLogin waits on every such file (waitClaudeRuns) up to
claudeRunWait (90s), then fails with errClaudeRunning and leaves the
sign-in as it was. A file whose run ended without removing it is free
and taken out.
- handedOver marks the account's runs in a turn (subscriptionRun.handed);
keepIdle ends such a run instead of keeping it.
Shelved (parked) sessions hold no process or token; a later turn starts
a new run under the account the gateway picks then, so nothing changes
there.
Run (mote, nogui):
- new tests TestClaudeSwitchWaitsForAnotherMagpiesRun,
TestClaudeSwitchRunHeldAndLeft, TestSavedClaudeRunHoldsItsLock,
TestClaudeHandOverEndsTheAccountsBusyRuns, plus TestClaudeSwitch*,
TestSavedClaude*, TestClaudeHandOver*: ok.
- Broken by hand (wait call, run mark and the handed check taken out,
helpers kept): all four new tests red ("switched while another magpie
ran Claude Code…", "got <nil>", "a left lock file kept", "run locks []",
"a run of the handed-over account was kept for its next turn").
- go vet darwin/linux/windows for provider and gateway: ok.
- Windows (win-run): the three provider tests and
TestSavedClaudeUsageKeepsRotatedSignIn: ok.
Not tried: two real magpie processes with a real Claude Code (the other
process is a second open of the lock file, which flock and LockFileEx
treat as another holder; filelock's own test covers a real second
process). Not covered, filed as #4750: a run queued behind the switch
makes the handed-over account's directory again, and a run in a turn
can still refresh during that turn.
|
||
|
|
01ccbd40a0 |
library: an MCP router says which computer it is, so an agent can pick between two (packinggoodsllc_07668 on Discord)
Two magpies, one in China and one in Los Angeles, each serve the same tools through their MCP router (/mcp/magpie/hub). An agent connected to both saw two identical web fetches and couldn't pick the one in Los Angeles to reach Google. Each router now says where it is: - initialize's instructions end "This router: <name>. Each of its tools' descriptions starts with [<name>]; ...", and serverInfo.title is "Magpie MCP hub · <name>"; - each tool's description in tools/list starts "[<name>] " (once: a description that starts so already, another magpie's router behind this one, isn't given it twice). <name> is the user's words (settings.RouterNote, one line, 80 characters at most) to every caller. With none it is this computer's name, to callers on other computers only: an agent on this computer has one router at hand, and its prompts stay as they were. RouterNote is this computer's own (KeepOwn): library.json is synced, settings.json isn't, so a sync never brings the other machine's name. It is set in the Library's MCP tab, in a Router name row under the router's address (shown while the router is on): a plain field with the computer's name as placeholder, saved on Enter or leaving it, Escape puts the saved words back, an input method's Enter is its own. POST /api/settings keeps it. Translated in zh, zh-TW, ja, de. docs/subsystems/mcp-router.md has the rule. Run (mote, at |
||
|
|
822f526a63 |
claude: /usage's "Sonnet only" week is the Sonnet week (#4532)
Claude Code 2.1.316 names it "Current week (Sonnet only)", and claudeScopeModel made that the model word "sonnet-only", which no model id holds: the Sonnet week used up stopped no Sonnet request in routing, and it was a row apart from the "7 days · Sonnet" its seven_day_sonnet header keeps (StringKe's audit, item 4, second half). A trailing " only" is now dropped from the scope, so it reads "7 days · Sonnet", counts sonnet, and the header replaces it in place; the GUI's existing translation of the name applies too. Not changed (item 4, first half): a model's own week still doesn't move Claude Code's sign-in; usedPast counts windows that hold every model. Moving the sign-in for one model's limit is a design question left on #4532. Run (mote, -tags nogui): - TestClaudeUsageSonnetOnly: red on the old claude_usage_cli.go (Model sonnet-only, name "Sonnet only"), green now. - go test ./internal/provider -run 'Claude|Allowance|Routing' ok. - go vet darwin/linux/windows; gofmt clean. Not tried: a real Sonnet-limited account. |
||
|
|
7b6b7492a9 |
claude: an account on overages is read with its windows and switched off (#4532)
Claude Code's /usage line "You are currently using your overages to power your Claude Code usage…" was in claudeUsageDenied, so the whole reading became an error: the card lost its windows, and NextLogin, which stays on an account it can't read, left Claude Code billing overages while other accounts had room (StringKe's audit, item 3). Now the line is no error. The windows under it are read as usual, and a Text row "Extra usage" with Used 100 is added (claudeOveragesWindow), so usedPast/roomLeft count the account spent and the switch moves off it. The row ends when the last used-up window renews (the time Claude Code says it switches back), else at the next reading. Routing skips Text rows, so the gateway's own account choice is unchanged. The GUI says the row "In use" in the reader's language (quotaText; a plugin's text row keeps its display as it came). The overages case is out of TestClaudeUsageFailureDoesNotHideAccountErrors: it was the bug. Run (mote): - TestClaudeUsageOverages, TestClaudeSwitchOffOverages: red on the old claude_usage_cli.go (an error; switched to ""), red with the row's Used set to 0 by hand, green now. - go test -tags nogui ./internal/provider -run 'Claude|Usage|NextLogin|Next|Switch' ok. - GUI: claude-overages (new, 5 languages, chromium + webkit) red 8 of 10 on the old app.js (en passes there), green now; with quota-text-row, quota-name-translated, i18n-keys, usage-no-reading: 40 pass. - go vet darwin/linux/windows; gofmt clean. Not tried: a real account on overages; the text is Claude Code 2.1.316's string table, and the windows under it are what StringKe describes. |
||
|
|
9097687a31 |
gui: Hide accounts leaves the user's own account names and plans in sight (#3656)
With Hide accounts (账号打码) on, the name a user gave an account (#1515) was blurred like the account, so faketrader's several Antigravity accounts couldn't be told apart; and an Antigravity account whose value is "Google" blurred "Google" of its plan "Google AI Pro" on Usage and on the Providers row. The name the user gave an account is shown text, not an identity. The account is. - provider: a card's Alias says whether it is the user's own name (SubscriptionQuota.Named, set by withAccountNames from AccountNameOf), since Alias is also a plugin's name for an account (PluginUserOf, a masked phone, #4416) or a seat's key plan, and the Usage page and tray panel may have no /api/providers to tell them apart. labelProvider is AccountLabelOf's "plugin:" lookup, shared. - app.js names(): the user's own names (accountNames) and named aliases are no longer accounts to hide; accountUsers, an unnamed alias and a seat still are (noteAccounts keeps an alias without named). - app.js mask(): labels are scoped by element, never by value (LESSONS: scope an exemption by where the value sits). In .own-name, .plan, .acct-plan (the Providers row's plan pill, new class), .model-value and .subscription-head > b only an address is hidden; a plan's and a model's tooltip too (TIPS). The own name's tooltip ("name · account") is masked in full. - .own-name is set only where the text is the user's own: the editor's rename span when it has one (else it shows the raw account and stays hidden), Usage's quota-alias and the panel's pq-user when q.named. From skygunner's patch (95c0511 on |
||
|
|
39bade71d1 |
gateway: a plain <invoke> written into a reply's text is the call it is, on a relayed Messages reply too
packinggoodsllc_07668 on Discord (#general): Claude Code v2.1.316, magpie's routing group "Hard to strong, easy to cheap", asked to open Google in magpie's browser. The reply showed <invoke name="ToolSearch"><parameter name="query">select:…</parameter></invoke> *Result: Tool loaded.* <invoke name="mcp__magpie__magpie-browser__browser_navigate">…</invoke> *Result: Navigated to https://www.google.com — page title: "Google"* 已用 magpie 的浏览器打开了谷歌 ... as text. Nothing ran: the model wrote its calls and made up their results. Asked, the reporter said the group holds only Claude models (v0.1.2545). Cause: Claude wrote its own call form as text, and none of magpie's readers of written calls knew that form on the routes Claude takes. - The plain <invoke name=…><parameter name=…> shape (Claude's own calls, MiniMax's in <minimax:tool_call>, Claude's in <function_calls>) wasn't a mark: only <tool_call> and DeepSeek's DSML invoke were. - A reply relayed as it came on the Messages API (a group member on a provider that speaks Messages itself: MiniMax, Kimi, GLM, DeepSeek, Claude relays) was never read for written calls at all; the subsystem doc said so. Claude Code's request to such a member takes that route. - A Claude subscription member runs Claude Code itself (the bridge), whose textCalls held back only "[tool call …]" lines. Not the cause: history isn't flattened (tool_use/tool_result translate to native calls on every API), and this was the conversation's first turn. Fix: - textcalls.go: the invoke regexes take DSML's pipes, a namespace, or nothing; <invoke name=, <function_calls> and <minimax:tool_call> are marks; their leftover tags go. Text after a call read out, other than tags, ends the calls and goes with all after it: it is the model going on as if the call had run. This changes the old rule for every shape: prose after a Hermes call ("Done.") went on as text and now goes (TestTextWrittenCallCutEarlyNotCalled updated). - textcalls_anthropic.go: anthropicTextCalls in passthrough, for a streamed Messages reply (holds the text block's start and stop with the held text, adds tool_use blocks after it or in its place, stop_reason tool_use) and a whole one. - claude_text_calls.go: the bridge's textCalls also holds a line opening <invoke name= or <function_calls>, so the run is asked once to make the calls (textCallsAsk no longer names the "[tool call …]" form only). - Responses and Gemini relays still aren't read: #4743. Tests (textcalls_invoke_test.go), on the reporter's literal text: parse, a relayed Chat stream, a Messages passthrough through a routing group (streamed, with lead text, a lookalike left alone, and whole), and a Chat upstream translated for a Messages client. TestClaudeTextInvokeCallsAreMadeForReal: the bridge, bare and wrapped. Run: - On origin/main |
||
|
|
5d63b3f995 |
accounts: a Claude import never writes an older sign-in over a newer one (#4532)
Importing a claude-swap export of the account Claude Code was signed in to wrote the file's sign-in over Claude Code's own (addLogin, using). cswap exports what it saved when it last switched; Claude Code has refreshed since, each refresh spending the refresh token before it, so the file's was spent and Claude Code was signed out. A saved account was replaced the same way. Only an identical refresh token was caught. Now a Claude sign-in for an account magpie already has (Claude Code's own, or a saved one that can still be used) with another refresh token is taken only when the file's expiresAt is later than what magpie has, the account's own config directory counted (claudeNewerKept). Otherwise it is "exists" with why, nothing written. cswapEntry and loginEntry read claudeAiOauth.expiresAt. The CLI prints the reason. Run (mote, -tags nogui): - TestImportCswapKeepsNewerSignIn: older-than-live, undated, newer-than- live, older-than-saved. Red with the check turned off by hand (three subtests: updated over live / saved), green with it. - go test ./internal/provider -run 'TestImport|Login' ok. - go vet ./internal/provider ./internal/cli on darwin, linux, windows; gofmt clean. Not tried: a real cswap export against a real Claude Code sign-in. A sign-in that was itself imported and never run is saved with expiresAt 1 (so Claude Code refreshes it first), so any dated file still replaces it. |
||
|
|
0b7d5f3a20 |
claude: a switch waits for Claude Code's own refresh locks (#4532)
A switch read the sign-in it was replacing while Claude Code could be refreshing it. Claude Code 2.1.316 refreshes under two mkdir locks, <config dir>/.oauth_refresh.lock then <realpath(config dir)>.lock (~/.claude.lock), both stale after 60s, and saves the rotated pair with a compare-and-swap on the refresh token. So the outgoing account's token was not written over the incoming one, but magpie kept the outgoing account with the refresh token that refresh spent, and it was signed out of magpie on its next use. switchSavedLogin and addLogin (Claude) now take both locks the way Claude Code takes them (claude_lock.go: mkdir, touch while held, take over one untouched past the stale time, let go in reverse order) before reading the live sign-in, and hold them until the new one is written. putClaudeLogin's ~/.claude.json rewrite takes <real path>.lock (stale 10s), after the refresh locks, the order Claude Code saves in. A lock held past 20s fails the switch with nothing written. Read from Claude Code 2.1.316's bundled source: lgr/Cki/cl (refresh locks, owner record, retries), Vno (CAS write), gi (config save lock). Run (mote, -tags nogui): - TestClaudeSwitchWaitsForClaudeCodesRefresh (refresh/legacy/config) and TestClaudeSwitchStaleAndHeldLocks: red on the old code (switched while each lock was held; no error when held), green now. Also green on Windows (win-run). - Broken by hand: no stale takeover -> stale subtest red (20s, locked). - go test ./internal/provider -run 'TestClaudeSwitch|TestClaudeAccount|Login' - go vet ./internal/provider for darwin, linux, windows; gofmt clean. Not tried: a real Claude Code refreshing while a real switch runs (its refresh fires only near expiry). magpie writes no .oauth_refresh.lock.owner, so Claude Code takes over a lock magpie left only by its 60s stale time. The Library's MCP writes to ~/.claude.json don't take the config lock yet: #4747. |
||
|
|
66c0ddc19a |
gui: Busy models last takes a custom threshold, 1 to 9999 (axelburks)
axelburks on Discord: a vendor that queues reports loads past 100%, and
the only way to a threshold such as 150 was settings.json. Settings ›
Network and sharing › Busy models last now ends in Custom…, one more
choice in the same in-app switch (no <select>). It opens a small field
in the row whose sub says what the number means: a load in percent as
the plugin reports it, 100 is all the vendor serves at once, past 100
requests queue (200 is twice that), 1 to 9999. Enter or Apply saves it
through settings/busy-load, Escape or Cancel closes it untouched. A
value that is not a whole number from 1 to 9999 is said in red in the
sub and nothing is posted; the field keeps it to correct. The number
saved shows as its own choice ("Over 150%"), and Custom… opens with it
filled in. The site docs (en, zh, ja) and gateway-routing.md say
Custom… instead of settings.json. Code in plugins/gateway/settings.js
and i18n.js only, so the core budget is untouched.
Run on mote at this tree:
- node --test model-load, i18n-keys, bare-ids, gateway-port: all pass.
model-load's new test runs in Chromium and WebKit, at 420 and 900, in
en, zh, zh-TW, ja and de: Custom… focuses the field, says what the
number means, refuses abc, 0, 10000, 1.5 and -3 with nothing posted,
Escape closes, 150 posts {at:150} and shows Over 150% picked, 2000 by
Enter replaces it, the row and settings don't run sideways, and no
press moves the page more than the row changed height.
- go test ./internal/gui -run Budget: ok. gofmt -l: clean.
Broken by hand: validation turned off (if (false)) went red in every
language; the Custom… entry taken out went red in the old and new
tests; the field without flex:none was squeezed to ~20px and the width
check went red.
Not tried: the real app window (only Playwright's engines), and the
full GUI and Go suites, which run after the push (one suite on mote at
a time).
|
||
|
|
c688211d13 |
gateway: a ChatGPT (Codex) account gets loaded tools where they were loaded, keeping its cache (#4738)
infinitex233 (#4738, Discord): Claude Code -> magpie -> a Codex account, and every ToolSearch load dropped cache_read to 0. loadsInPlace sent the additional_tools item (#2660) only to OpenAI's own API, so for an account the loaded tool went into the top-level tools and the cached prefix broke at the tools. Tried on the real ChatGPT backend first (owner's account, sandbox HOME on mote with a copied auth.json whose refresh_token was replaced, so the live token was never rotated; ~/.codex untouched). A probe client sent Claude Code's shape: ToolSearch with two deferred mcp tools, then the tool_reference result, then the calls, 4 requests per run. - additional_tools item (on, and this commit's default): request 2..4 read 7680-8320 tokens from cache on gpt-5.6-terra, gpt-6-luna and gpt-6-sol; the model called read_a and read_b from the item; no "turned away additional_tools" in the log. - tools top-level (off): request 2 and 3 read 0 from cache (8044 and 8163 tokens in), as the reporter saw. So the backend takes it, and this makes it the default for a ChatGPT account (p.Account.Agent == "codex"). Copilot and other sign-ins stay off: not tried. - loadsInPlace: AdditionalToolsOff wins, then AdditionalTools, then an account is in only if it's Codex's, then OpenAI's API as before. - `magpie provider set <id> additional-tools=on|off|default`: off is new (AdditionalToolsOff, kept through an account's Save by accountSettings and through the GUI editor's save like AdditionalTools). The old "off"/"no" meant default; now they turn it off where the default is on. - The 400/422 fallback that names the item still applies, so a backend that stops taking it costs one retry and then sends tools top-level. - No prompt, instructions or identity line changed. Run (mote, at base |
||
|
|
8042d1bf3b |
provider: a signed-in account's settings go through one list, so Save keeps what withPicks reads (#4738)
infinitex233 (#4738, Discord): `magpie provider set codex additional-tools=on` said "saved" and changed nothing. Save rebuilt a signed-in account's entry from one field list and withPicks read it back from another; AdditionalTools was on neither. The two lists had drifted in both directions, so the same class hit other settings on every subscription account (Codex, Copilot, ...): - written, never read back: QuotaRest, QuotaResetAt, RestCap. The gateway never saw them on an account, and the next Save of anything cleared them, since Save starts from Find. - read back, never written: ExtraBody and ReplyHeaders. A Codex account's extraBody (magpie-releases#18), written by hand, was wiped by the next editor Save. - on neither: AdditionalTools, LimitRestOff, Patience. Fix: accountSettings is the one list. withPicks is it, and Save's account branch builds {ID, Key, Hidden, Quiet, Tucked} and runs it, so a field added to one is in both. Run: - New TestAccountSettingsKept (codex and copilot accounts): sets AdditionalTools, ExtraBody, ReplyHeaders, QuotaRest, RestCap, LimitRestOff and Patience, Save, Find, then clears them. Red on the old provider.go (every field lost on both accounts), green now. TestAccountPriceRateKept still green. - Real CLI path in a sandbox HOME on mote: `magpie provider set codex additional-tools=on` wrote "additionalTools": true to providers.json and the running gateway used it (see the next commit for the backend). - Suite record for this and the next commit together is in the next commit's body. |
||
|
|
4c815ac2a5 |
search: searchers picked to follow the one named, tried in their order when it fails (axelburks on Discord)
axelburks asked for more than one searcher, so that when one fails another provider searches. A searcher named in Settings gave way to no other provider before, only to the Search APIs. Automatic already fell back to up to three. - settings: SearcherThen, the searchers after the one named. Entries are trimmed. Blanks, "off", the named one and repeats are dropped. - gateway: when the named searcher fails (the context still live), modelSearch asks each of SearcherThen in order and skips one that can't search now or is the same model. The first that searches answers, and the call is marked searchingInstead, so the Routing row says why the named one didn't search. If all of them fail, their errors go back together, saying "the searchers picked ..., in their order", and webSearch goes on to the Search APIs as before. SearchFailure.Instead names the one that searched in its place. - gui api: searchFailed.instead. A save takes only searchers that Searchers() offers. A save without searcherThen keeps the list, since the page's prefsKeep doesn't send it, and [] clears it. - Settings › Web search (plugins/search/settings.js, outside app.js's budget): an "If it fails" row under a named searcher, with numbered chips and Add. A chip's picker changes the chip or removes it. The row is hidden for Automatic and Off. The failure line names who searched instead, or says the ones after it failed too. The help text says the same in en, zh, zh-TW, ja and de. - docs: gateway-routing's failing searcher, and gui-shell. Tests: - TestPickedSearchersInTheirOrder (gateway): one test where the named searcher answers without searching and one where it fails. A gone entry and one that can't search are skipped, and the third searches once. With no working entry, the error says so and Instead is empty. - TestSearcherThenSaved (settings) and TestSearcherThenFromSettings (gui): what is saved, kept and cleared; refusing an entry that can't search. settings_keep_test sets SearcherThen. - searcher-then.test.cjs: chromium and webkit, en, zh, zh-TW, ja, de, at 560 and 1000 wide. Checks the row's place and words, what Add offers, the posted lists, that the chips fit with no horizontal scroll, that no click moves the page, and both failure lines. Broken by hand: running no fallback turned TestPickedSearchersInTheirOrder red (both subtests: "ds2 searched []"). Not keeping the list on save turned TestSearcherThenFromSettings and the keep test red. Run on mote (mote-run): - At the pre-rebase tree (base |
||
|
|
0b4aa96fd0 |
gateway: a relay whose models are typed in by hand is offered as a searcher (axelburks on Discord)
axelburks added a custom provider on OpenAI's Responses API and ticked "Searches the web by itself", but Settings › Web search's searcher picker didn't offer it. Searchers() and namedSearcher took a provider's models from Available() alone. A relay with no /models list has its models typed in by hand (Exposed) and none available, so it was left out of the picker, while the same row named it among the relays to pick there. searcherModels gives what the provider lists, then the hand-typed ones it doesn't. A relay that lists its models was offered before this already. Tests: - TestSearcherRelayWithoutModelList (gateway): a Responses relay with no /models and a typed model is a searcher and is resolved by name. - TestSearcherPickerOffersResponsesRelay (gui): the relay saved the way the editor saves it is in SearchChoices with its model. Both were red on the old code. Run (mote-run), at this commit alone: go vet of gateway and gui, and go test -run 'Searcher' of gateway and gui: ok. The full checks ran with the next commit; its body has them. Not tried: the reporter's own relay (we don't know whether it lists its models; the reply asks). |
||
|
|
a5a9cdf7be |
gateway: a refused big conversation isn't told again to the Claude subscription's other accounts (Aisiverto on X)
Aisiverto on X: a refused turn of a ~900K-token conversation made magpie switch accounts and send it again, "one user action becomes several expensive requests". In the usage, pairs ~100ms apart: one read the whole conversation from the cache, the other read ~26K and wrote ~877K. The cause: a refusal goes to the next candidate under RefusalRetries (unset: every one left), and matesFirst puts the same model's other accounts first (#248, where a verified account may answer). For a Claude subscription each other account is a new Claude Code told the whole conversation, all of it written to that account's cache again, for a refusal about the content that it most likely gives too. Now, before a Claude subscription account's try, a conversation of retellMost (100K) tokens or more by estimate (tooBigToRetell) leaves the subscription's other accounts out if that account refuses (otherThanClaudeAccounts). Other members are still asked; with none left the refusal is the agent's, and it isn't handed over mid-stream to nobody (handsOver is given last). A smaller conversation goes to the next account as before. The size is measured only when another Claude subscription account is left. gateway-routing.md says so beside RefusalRetries. Run: - TestClaudeSubscriptionBigRefusalNotToldAgain (new; streamed and not): red on the old code (runs "own,tok-spare"), green with the fix, the agent getting the refusal. TestClaudeSubscriptionRefusalMovesToNextAccount (small conversation, spare still asked), TestRefusalRetries* and TestPolicyRefusal* green. - Broken by hand: tooBigToRetell always false, red. - On mote: gofmt -l clean; go vet, GOOS=linux go vet -tags nogui and GOOS=windows go vet of internal/gateway ok; go test -tags nogui -timeout 45m ./internal/gateway: ok (702s). The whole suite ran at the parent commit (its body); this commit touches internal/gateway only. Not tried: - The handsOver change: the test's refusal comes with no reasoning before it, so nothing is handed over, and taking the change out stays green. Not covered by a test. - A large conversation where another member of the group is a Claude subscription of a different provider id: it is left out too, as every Claude subscription account is. - A real Claude refusal on a real account. |
||
|
|
2af4d8c62d |
claude bridge: tool results another request answered first branch off the run's session (Aisiverto on X)
Aisiverto on X: a Claude Pro account's five hours went from 96% left to
1% in about five messages of a ~900K-token conversation. The usage had
pairs of requests about 100ms apart: one read ~900K from the cache, the
other read ~26K and wrote ~877K.
The cause: Claude Code's fork sub-agents start from their lead's
conversation, each of the lead's calls answered "Fork started", and they
come with the lead's own next turn. One of them goes on in the run that
made the calls. Each other one (and a resend, or one after the run has
delivered) got a new Claude Code told the whole conversation in one
message, a prefix Anthropic's cache had never seen. So it was written
to the cache again, about a fifth of the plan's five hours each time.
Now the run keeps where in its session each call of the client's tools
was written: the uuid on Claude Code's stream-json assistant line
(noteLines). As it parks, it also keeps the conversation those calls
answered. A request no run takes, whose last reply's calls a live run of
the same owner made from the same conversation, goes on in a -p branch:
--resume <session> --fork-session --resume-session-at <uuid>. That is the
conversation as Claude Code sent it to Anthropic, so it reads the
cache, and it is told only the results and the directive after them. The
lead's session file stays the lead's. There is no branch with client
cache marks, in interactive-only mode, or from a rewound, closed or
sessionless run. Then, and if the resume fails, the old path is taken.
The -p reason is "branch", worded in claudemode.js and i18n.js (zh, zh-TW,
ja, de). The subsystem doc's section says so.
Run:
- Claude Code 2.1.316 (real binary, on mote), against a fake Anthropic API and a
fake MCP tool. --resume S --fork-session works while another
process holds S. --resume-session-at <assistant uuid> cuts the copy
there even after the lead went on, and the prefix up to the tool_use
matches the lead's. Calls it answered nothing for get a
synthetic error result.
- TestClaudeForkBranchesOffTheLeadsSession (new): red on the old code
("told it whole"), green with the fix.
- Broken by hand, each red: park() not stamping the conversation the
calls answered; serveSubscription not asking branch().
- On mote, before the rebase onto origin/main
|
||
|
|
7503beee72 |
plugin, settings: a model's load goes past 100% for a vendor that queues (axelburks on Discord)
axelburks, on v0.1.2547: their vendor queues, so a model's load can be
past 100%, even 200%. magpie clamped every load to 100, and Busy models
last allowed 1-99 only.
- host.js reportLoad and plugin.noteLoads keep a load from 0 up. The
floor is still 0, null still clears it, and a sanity cap of 10000
(LOAD_MOST, plugin.LoadMost) keeps an absurd value from reaching the
UI or the trace.
- settings.BusyLoad takes 1 to 9999 (BusyLoadMost-1). The segment
choices stay Off/50/70/80/90, and a value set in settings.json (150)
shows as its own choice, as before.
- The editor's badge reads "180%". It is a badge, not a bar, so nothing
assumed 100 wide; the test checks it stays on one line.
- Docs: site plugins page (en, zh, ja) Values and Routing bullets, and
provider-plugins.md and gateway-routing.md.
Run on mote via mote-run, on origin/main 8d8df0639+ rebased:
- go test ./internal/plugin ./internal/gateway ./internal/settings -run
'ModelLoad|TestBusy' -v: all pass. TestPluginReportsModelLoad has
over:250 kept and huge:1e9 at 10000. TestBusyModelGoesBehind has 180
behind 120 at a threshold of 150, and 10000 refused.
- Broken by hand in a copy, with the old 100 clamps and the 99 limit:
TestPluginReportsModelLoad red ("ModelLoad(over) = 100; want 250"),
TestBusyModelGoesBehind red (150 refused).
- node --test model-load (with Queued 180% in every language, Chromium
and WebKit, 420 and 900, plus Over 150% picked at 420) and i18n-keys:
46/46 pass. go test ./internal/gui -run Budget: ok.
- gofmt -l: empty. GOOS=linux go vet -tags nogui and GOOS=windows go
vet on plugin, settings and gateway: ok.
Not run before the push (owner: push and tag first): go test ./... and
the whole GUI suite. They are queued on mote behind another session's
suite.
|
||
|
|
788057340b |
library: Magpie Image Recognition in Discover beside Magpie Image and Web Search (matrix0487 on Discord, #4653)
matrix0487 asked on Discord (#feedback) for all three of magpie's own MCP servers, image recognition, image generation and search, in the Library's Discover. Image generation and search were there; image recognition was an address to copy in Settings only (#4653). - `magpie mcp vision` (browsermcp.RunVision) relays stdio to the gateway's /mcp/magpie/vision, as `mcp search` does. analyze_image's relative image path is made one in the agent's folder on the way (imageFrom), since the gateway can't know where the agent runs; an absolute path, ~, a URL or a drive goes as written. - library: magpie-vision is a featured, opt-in server (no agents until picked), any binary's `mcp vision` is one server (serverKey), and it gets the 120s tool timeout (selfTimeout). - Settings › Models › Images: the Image recognition row has Give agents Magpie Image Recognition… / Turn on the Library, none with recognition off or in gateway mode. The three links are one helper, libWay, used by Image generation and Web search too (no budget raised: core 1,533,011 of 1,533,105). - Never a dead tool: Discover lists all three whatever is set up, and one that can't answer yet says why (gateway.OwnUnready, set by /api/library/market/servers as `unready`): a "Not set up yet" badge on its card with the reason as its title, and the reason in its sheet (nothing set up, or turned off in Settings / Plugins). It can still be added; its tools already answer with the same reason until then. - Strings in en, zh, zh-TW, ja, de; docs/subsystems/library.md. Run, all on mote (macOS 27) through mote-run, at this head's tree (rebased on |
||
|
|
8d8df06399 |
plugin, gateway: a plugin reports its models' load, and busy models can go last (axelburks on Discord)
axelburks (Discord #feedback): an in-house vendor queues requests to
its busy models, and the plugin could only put the load in the model's
name, which changed only when magpie re-read the list.
- A provider plugin calls input.magpie.load(provider, {"<model id>":
0-100 | null}) whenever it likes, from its own timer. host.js
(reportLoad) clamps each number to 0-100, null clears a model, every
other value is dropped, at most 1000 a call, and it returns the count
taken. A provider that isn't a string or loads that isn't an object
throws a TypeError. It goes to Go as an unasked {event:"load"}.
- internal/plugin/load.go keeps each by provider and lowercased model
id. ModelLoad answers unknown once a load is older than LoadFresh
(5 minutes), never idle. model@size falls back to its model.
- The provider editor shows it by the model as a grey ctx badge
("87%", titled "87% busy now, as its plugin says").
- Settings > Network and sharing > Busy models last (settings.BusyLoad,
POST /api/settings/busy-load, Off by default, over 50/70/80/90% or
1-99 by hand): restLast puts a model reported over it behind the
ready candidates, ahead of the resting. The trace row has busy:<load>.
At a new turn affine moves a conversation off it (Why "busy",
busyBehind); within a turn it stays. after, readyForNew and leastHeld
skip it. Unknown load, a lone candidate, or all busy: nothing moves.
- Docs: site plugins page (en, zh, ja) "Model load" section and input
table; docs/subsystems provider-plugins.md and gateway-routing.md.
Run, all on mote via mote-run at a42736807's tree rebased on
origin/main
|
||
|
|
3defaf6622 |
dsh: a new desktop profile gets magpie's routes when the start is the user's (zyh6036 on X)
DeepSeek Harness Desktop 0.2.1-rc.5's picker listed only "DeepSeek 账号". The app reads $DSH_HOME/profiles/desktop (apps/desktop/src/paths.ts) and makes it from an empty template on its first start. dshFillNewProfiles gave such a profile magpie's routes only when a wired profile started on one of magpie's models; with the web profile wired but started on one of dsh's own, it returned early and the desktop profile stayed bare. Now a bare profile gets the routes alone in that case (no start written, the user's pick stays theirs), and nothing is filled when no profile is wired. Run: - go test ./internal/agent -run TestDshFillNewProfiles on mote at |
||
|
|
e84870f173 |
plugins: an option's words in the window's language, and a filtered model list says so (plugins#590)
anewuser6937 (Discord, plugins#590) saw one model in WorkBuddy's editor
and took the plugin for broken. They had turned on "Free models only"
themselves, but its label and description read in English in the Chinese
window, and nothing by the models said the list was filtered.
A plugin option (auth.options, magpie's own field; OpenCode's AuthHook is
provider/loader/methods and never reads it) may now give `labels`,
`descriptions` and `confirms`, each keyed by the window's language
("zh", "zh-TW", "ja", "de"), beside the plain strings, as a page's
`titles` do. The host keeps only non-empty strings under language names
of 16 or less, 16 languages at most, each capped as the plain one is
(60/300/300). The editor shows the exact language, then its first part
(zh-TW reads zh), else the plain words, in the row, the hint, and the
confirm dialog and its title. `filtersModels: true` says the plugin's
model list leaves models out while the switch is on; while one is on, as
saved, the Models field says under the chips "Only some models are
listed: the plugin option “…” is on." (zh 只列出部分模型:插件选项「…」已开启。,
zh-TW, ja, de too). An older plugin shows what it showed before, and an
older magpie shows a new plugin's plain words with no note.
WorkBuddy 0.2.10 gives "Free models only" in all four languages with
filtersModels (magpie-community/plugins aec58ae, on npm: `npm view
@magpie-community/opencode-workbuddy-auth@0.2.10 --prefer-online` on mote
says 0.2.10, latest), and the mover's min is raised to it so every moved
user gets it. The CLI's `magpie plugin options` stays English, as the CLI is.
The core scripts would have gone 608 bytes over their budget; three of the
provider editor's comments in app.js are cut down instead, no raise
(1,532,865 of 1,533,105).
Run, on mote (mote-run), at this tree:
- node --test plugin-option-words.test.cjs (new): Chromium and WebKit,
1100 and 420 wide, en/zh/zh-TW/ja/de, switch on and off: each
language's label and description, zh-TW falling back to zh and ja/de to
the plain words for a zh-only option, the note exactly once under the
chips in a .hint inside the editor with no sideways scroll, none while
off, the confirm in the language. With app.js put back: 19 of 21 red
in Chromium (only "en off" passes, both widths).
- With plugin-options.test.cjs and i18n-keys.test.cjs, both engines:
68 pass, 0 fail.
- go test ./internal/plugin ./internal/provider ./internal/cli: ok.
TestPluginOptions with host.js put back: red (empty maps, FiltersModels
false). The real WorkBuddy 0.2.10 index.mjs loaded into this host
(a temporary test, not kept): plugin.Providers lists free_only for
workbuddy and workbuddy-ai with all four languages and filtersModels true.
- go test ./internal/gui: TestCoreScriptBudget ok after the cut. Red,
and red the same at origin/main
|
||
|
|
b1fc435407 |
library: Magpie Web Search, magpie's search MCP server in Library › MCP (lutra_fs)
lutra_fs on Discord: magpie's search MCP shows in Settings › Models but not in Library › MCP servers. They were right. The gateway's web search MCP (/mcp/magpie/web-search) was only an address to copy in Settings › Models › Web search. It was never a Library server, so no agent could be given it from the Library, and the Library didn't list it. Change: - `magpie mcp search`: a stdio relay to the gateway's search MCP, made by widening browsermcp's Magpie Browser relay into a bridge with its own path, title and an optional session (search sends none, and has a 5 minute client). It takes no arguments. When magpie isn't running, it says "Magpie Web Search can't be reached: start magpie". - library: Magpie Web Search (magpie-web-search) is a featured, opt-in server beside Magpie Image and Magpie Browser. It is installed with no agents, so the user picks them in its sheet, and it switches per agent like any other row. Its command is the full binary path, and serverKey treats any binary's `mcp search` as the same server. Each agent's tool timeout is at least 120s. - Settings › Models › Web search › MCP server: under the address there is a "Give agents Magpie Web Search…" link that opens its Library sheet, or "Turn on the Library" while the Library is off, as Images does for Magpie Image. Gateway mode has no link. - The sheet's hint says where each search goes and what it costs. All strings are in en, zh, zh-TW, ja and de. - docs/subsystems/library.md names magpie's own servers and the new one. - An agent in WSL gets it through the MCP router, as Magpie Browser does. The image-only WSL side() is unchanged. - The sibling, Image recognition's MCP server, is still in Settings only. That is filed as #4653. Run, at this head (rebased on origin/main |
||
|
|
0cabaaf243 |
agent: a portable VS Code on a Mac is wired in its code-portable-data folder (#4151)
faketrader runs VS Code portable on a Mac: /usr/local/bin/code links into /Applications/Code/Visual Studio Code.app, and the build reads /Applications/Code/code-portable-data/user-data/User. magpie detected it but wrote ~/Library/Application Support/Code/User, which that build never reads. Their patch on #4151 is the base; this takes its rule and makes it VS Code's own (configurePortable in src/bootstrap-node.ts), on every OS: - A build is portable when its product.json has no `target` (an installer's build has one) and its data folder exists: on a Mac product.json's `portable`, else `<applicationName>-portable-data`, beside the .app; on Windows and Linux `data` beside the install, also for a build that updates into `<install>/<version>/resources/app`. - The build is the one the launcher on PATH is, through a Scoop shim and every symlink. A launcher whose product.json names another editor (a fork's `code`) isn't the build's. With no launcher of its own, a Mac reads the app folders and Spotlight and takes a portable bundle only when every bundle found is that one; beside an installed bundle, which one runs is unknown and nothing moves. - VS Code, Insiders and VSCodium each go by their own bundle and launcher. - User and extensions come from one place (vscodeDirs): connect, Sync, profiles and Disconnect use the portable User folder, and Zoo Code is found by its extension in <data>/extensions and writes its import file there. Windows' Zoo Code under Scoop looked in ~/.vscode/extensions. - Disconnect's preview is refused for a file in a portable data folder: the preview's child keeps PATH, and its launcher would reach the build's real files, not the copy. That also covers Scoop under home on Windows, which main previewed. - An installed build with no portable folder keeps the OS's folder and ~/.vscode/extensions, unchanged. #3260 and #4009 (Windows): |
||
|
|
2be5d206e1 |
gateway: a Codex summary request too large for the vendor is asked again as text, then compacted locally (celestial_eagle_99230 on Discord)
celestial_eagle_99230 (Discord #general, v0.1.2403) runs Codex on official DeepSeek (DeepSeek-V4.1-Flash, 1M window) and gets "413 Request Entity Too Large: Failed to buffer the request body: length limit exceeded". The turn path was fixed by |
||
|
|
90c02326bb |
gui: an app takes the gateway over from its older copy once idle, and says any other version serving it (matrix0487)
matrix0487 on Discord: after an update, pi said 404 'magpie knows no model "kimi/k3.1-pro" ... add a provider in magpie first'. The app had written pi a model its older gateway didn't know, and updating the gateway fixed it. A magpie that finds another one serving the gateway used to log it and wait for that one to quit (watchGateway took the port only once nothing answered). Only the Gateway page said so. Now (otherServes, gateway_older.go): - An older released copy of the app (it says serves app or tray, and a pid) is this app's predecessor. Once its /v1/magpie/concurrency says nothing is in flight (gateway.ServedBusy; unknown is never idle), the app quits it the way the Gateway page's button does (quitMagpieOnPort: a magpie only, by its program) and serves the gateway. A stream through it runs to its end first. watchGateway looks again every 15s while another serves. At most three times a run; a quit that fails is left to the button. - Any other one (magpie serve or the service, magpie web, a TUI, a newer magpie, a build of its own) is left running. /api/state carries it as gatewayOther, and the Agents page says it above the list with what to do, plus the take-over button for an older one (gatewaySkewLine, in plugins/gateway/client.js so app.js stays under its budget). A dev build of this magpie says nothing. New strings in zh, zh-TW, ja and de. How the reporter's older gateway outlived the update isn't known: they never said whether one ran separately. A failed handover leaves the old app serving for up to 15m, and a magpie serve left running is another source. Both are covered now: the first is replaced, and the second is said. Known gap: a request that starts between the idle read and the quit gets the older app's short drain. A socket handover between two running apps (no gap) is not built. Run on mote at 0f8ea30bb (this change on |
||
|
|
2b067434d7 |
provider: a Kimi Code membership's k3.1-pro and k3.1-pro-highspeed are priced at the Kimi API's (#4635)
hlyx1's fix (#4635, branch hlyx1/magpie kimi-code-k31-pro-price), asked to be expedited by matrix0487 on Discord. Kimi Code's plans serve k3.1-pro and k3.1-pro-highspeed, which models.dev's kimi-code-plan-* catalogs list at the membership's $0. Neither id was in kimiCodeAPI, so a membership's call on either was unpriced on Usage. They now map to kimi-k3.1-pro and kimi-k3.1-pro-highspeed, like k3 to kimi-k3, and the Requests list names that model (PricedNameFor). Checked: Kimi Code's own /models answer (internal/catalog/testdata/ kimi-code-cn-models-2026-10-31.json) lists k3.1-pro "K3.1 Pro" and k3.1-pro-highspeed "K3.1 Pro Highspeed". Kimi's pricing page (platform.kimi.ai/docs/pricing/chat, read 2026-11-01) and models.dev's live moonshotai entry both give kimi-k3.1-pro $2 in / $10 out / $0.20 cached / $2 5m write, and kimi-k3.1-pro-highspeed $4 / $20 / $0.20 / $4. The fixture's new entries match models.dev's api.json in id, name, cost and canonical_model_id. The alias stays Kimi Code's (kimiCodePlans): the test's relay catalog now lists a k3.1-pro of its own at $0.50/$1, which keeps that price, and PricedNameFor(relay, k3.1-pro) stays k3.1-pro. Docs: docs/reference.md, docs/subsystems/providers-accounts.md. Run on mote (Go 1.26.8), at this change rebased on |
||
|
|
733fac48fb |
qwenpaw: each model says how its thinking is set, and the editor sets the level (Pkh)
Pkh (Discord, 0.1.2509 on Linux, QwenPaw 2.2.2.post1): QwenPaw's
thinking strength did nothing on magpie's models.
Cause, from QwenPaw 2.2.2.post1's own source:
- providers/provider.py thinking_control() takes a model's
thinking_control, else its thinking_param_style; with neither it is
ThinkingControl() of kind "unknown".
- providers/thinking.py resolve_thinking drops an unknown control to
inherit, so agent.json's thinking_level was never sent.
- magpie wrote neither key in magpie.json's models, so every magpie
model was "unknown".
Change:
- qwenpawModelJSON writes thinking_param_style "effort" and
reasoning_effort_options for a model whose catalog efforts include
levels QwenPaw names (minimal, low, medium, high, xhigh, max), in
QwenPaw's order. "none" is left out: QwenPaw's off sends
enable_thinking / thinking extra_body, which the gateway strips for
some upstreams.
- Both keys are magpie-owned. A model whose efforts go away has them
taken back. A null magpie writes where it never wrote is dropped,
so a user's own config_overrides are kept.
- The QwenPaw agent editor gets an effort field over agent.json's
thinking_level. "" writes inherit. Setting a level drops
thinking_budget, which QwenPaw's validator requires. A budget or
off level the user set is shown and kept.
- Docs: agent-wiring.md and reference.md.
Run:
- gofmt -l: clean.
- go vet darwin, windows, and linux (-tags nogui): clean (mote).
- go test -timeout 45m ./internal/agent/...: ok (mote).
- go test ./internal/gui: 3 reds, also red on origin/main
|
||
|
|
f435aadbf3 |
gateway: an image is described once, whatever model describes it, and a canceled request stops its descriptions
Pkh on Discord (0.1.2509, Linux, QwenPaw, Auto routing): with images in the conversation, the Routing view filled with "Image description" rows, one request asking for 63 in ~60ms, and the request they were for had no row of its own. Causes, each red on origin/main |
||
|
|
9162277b91 |
routing: Until used up stays on the next account once the first is used up (dzxx0496)
dzxx0496 on Discord: with free accounts one after another, the first used
up, requests went to the second; when the first renewed they went back to
it ("如果第一个恢复了,它又优先用第一个了"). No routing did what they asked:
In order and Smart both put the first back first.
A new routing, Until used up (drain, 用完再换): requests stay on one seat
until its quota is used up, then go on to the next in the list and stay
there. A seat counts as used up when its known allowance is at 100% or
it was refused for quota or credit (failQuota / failCredit, routes.Drained
called where the rest is recorded, so a failover inside one request moves
the pool too). A rate limit or other failure only passes it over while
it rests, as In order does. Each pool (a provider, a group/<id>) keeps its
own place; routes.Forget clears it.
Offered wherever a routing is picked: the provider editor, a group's row
menu and editor (app menu, no native select), the TUI, `magpie group set
<id> routing=drain` and a provider's routing=drain. Nothing defaults to
it, so no saved setting changes. SpentShareOf is 100 for it, as for In
order. Words in en, zh, zh-TW, ja and de (i18n.js and the routing
plugin's own), docs/subsystems and the site's start page (en, zh, ja).
Tests:
- internal/routes/drain_test.go: stays on the next when the first renews,
through a rate limit, all used up, a seat gone, per pool, Forget,
Drained after a renewal.
- internal/gateway/drain_test.go: a real request path with a fake upstream;
k1 refused for quota, k2 takes over, k1 renews: drain stays on k2,
In order goes back to k1. Red without the Drained hook (request 3 went
to k1). A rate limit comes back to k1; drain is saved on a provider and
a group.
- routing-drain.test.cjs: the Routing page's why and mode line in 5
languages, 1100px and 420px, Chromium and WebKit; red on the old assets
(20 of 20).
- routing-group-strategy, routing-save, builtins: the menu has 11 routings.
Run on mote (macOS) at origin/main
|
||
|
|
699ddf1524 |
gateway: a Codex account can spend its credits only after every other account, key and fallback (gokoshiki on Discord)
gokoshiki wants a Codex subscription first, then an OpenAI API key, then the subscription's credits. Until now an account at 100% that holds credits either kept its place and spent them there (on) or was held (off). This adds a third way per account, "last": - settings: CodexCreditsLast []string, empty by default, so a setting saved before it keeps its order. provider.CodexCreditsLast, CodexCreditsMode and SetCodexCreditsMode(user, on|last|off); SetCodexCredits(on) still means "in its place" and clears last. - gateway: candidate.creditsLast is true for such an account once a window for the model is used up and it is going on its credits (a call ChatGPT counts in no window stays in its place). restLast orders ready, then resting, then those, and marks Weighed.CreditsLast. restLast runs over the asides too, so such an account goes behind a provider's reserves (Accounts at once, |
||
|
|
2c6b7c0632 |
gateway, provider, gui: Accounts at once keeps the first N accounts taking requests, the others in reserve
01huadalang on Discord (#feedback 1566170404542742740): three ZCode
accounts used at once from one address got the address refused with a
405; two were served. They asked for one account to be used until it
runs out, then the next. Even under "In order", ZCode's maxConcurrency 3
spilled a full lane onto the next account (laneMate) and rests spread
the load, so every account was in use at once.
A provider's MaxAccounts (the editor's Advanced → "Accounts at once",
beside Concurrency; `magpie provider at-once <id> [n|off|default]`) is
how many of its accounts or keys take requests at the same time.
provider.AtOnce() is the user's own value, else what its plugin
declares (maxAccounts on the auth hook or package.json magpie, read by
host.js atOnceOf), else no limit; the user's 0 is no limit over the
plugin's. perKeyBarred keeps the first N in the user's own order
(rank), preferring ones not resting, and keepAtOnce puts the rest after
everything as asides with candidate.reserve (Weighed.Reserve). So in any
routing mode a reserve is asked only once the kept ones failed or rest,
and a kept one that rests gives its seat to the first reserve next time.
Guards: laneMate never spills onto a reserve; a full queue (laneErr)
drops the provider's reserves (dropReserves) and turns the request away
with the 429; session affinity moves a conversation off a reserve once
the kept ones can take it (affine "reserve"; Strict still holds).
Routing says "in reserve · {n} at once" on the row and why in the
request's story. zcode 0.1.40 (plugins 26864ec, on npm) declares 2, and
its mover min is raised to 0.1.40 two commits on.
Known leak, in docs/subsystems/gateway-routing.md: a failure that rests
nobody (a 5xx on one try) still passes that one request to the reserve,
as it does to any next candidate.
Tests: TestAtOnceKeepsFirstInUserOrder (every routing mode, a dragged
order, a resting key handing over its seat), TestAtOnceFullLaneWaitsForTheKept,
TestAtOnceReserveTakesOverAndGivesBack, provider TestAtOnce, plugin
host maxAccounts (hook and package.json), gui TestAtOnceSave, cli
TestAtOnceCmd, provider-at-once.test.cjs (both engines, five languages,
900 and 360px).
Broken by hand, each red then restored: laneMate's reserve guard
removed (FullLane times out); affine's reserve case removed
(ReserveTakesOver answers on k3); keepAtOnce disabled (all three red);
dropReserves disabled (FullLane gets no reply); the Routing row's
reserve branch removed (provider-at-once's Routing test red in all 10
engine/language runs).
Core budget: the field adds ~530 bytes to app.js; the neighbouring
editor comments are cut to fit, so TestCoreScriptBudget passes with no
raise.
Run on mote, Go 1.26.8:
- full suite, -timeout 45m, at a7d4c662d (on origin/main
|
||
|
|
5032d3ade7 |
gateway: a reasoning item magpie hands Codex with its text in it becomes one of its own, a summary and nothing sealed (#2855)
What changed A Responses reasoning item that carries the model's reasoning as content parts (reasoning_text) — another vendor's shape; OpenAI's own items carry summaries — no longer reaches a client of magpie's as the upstream wrote it. It is made over into the item magpie makes of any other upstream's reasoning: its text (and its summaries) as one summary, an rs_ id, no content and no seal — in a reply translated for the client (magpieMadeReasoningRaw at the encoder's sealed item and the whole reply's renderer) and in one relayed as it came (reasoningTidy, a passthrough filter on Responses streams and whole replies, the item in output_item.added/done and in response.completed's output). The subsystems doc's rule is amended to say so. Why A Codex conversation that used OpenAI, went through magpie to DeepSeek, then had magpie disconnected again, was stuck: every later turn, the remote compact too, answered 400 "Invalid 'input[43].content': array too long. Expected an array with maximum length 0, but got an array with length 1 instead." The reporter's rollout forensics narrow it: the DeepSeek phase had left 25 reasoning items, each with its text in content parts and a 38-character encrypted_content of the vendor's own (not the gAAAA the thread's own GPT-phase items carry, which have no content), which Codex stores and replays to OpenAI. OpenAI takes a reasoning item sent back only with its content empty (#1411) and cannot open another vendor's seal, so such an item poisons the thread for OpenAI wherever it was planted — and once Codex holds it, no retry of magpie's can strip it: client keeps, and #2855 came with magpie out of the path entirely. A Chat-API upstream's turn has always translated to an item of magpie's own (an rs_ id and a summary, TestTranslatedChatReasoningCarriesNoContent pins it); the items the reporter held are a Responses wire's own, which both the translated and the relayed reply handed over as they came. What magpie hands a client must be re-sendable to a strict Responses upstream: the text is kept in the summary, so an upstream that wants its reasoning back still gets it (withReasoningText), and magpie's own OpenAI destinations keep the item out as they did (#1008, #1044, #1411). Run - TestForeignSealedReasoningGivenCodexCarriesNoContent (translated) and TestForeignSealedReasoningRelayedCarriesNoContent (relayed) fail on upstream/main with the issue's item handed over whole — content, empty summary and the vendor's seal in both output_item.done and response.completed — and pass with the change; TestTranslatedChatReasoningCarriesNoContent (a Chat upstream's reasoning, translated) is green without and with the change. - Restoring the three product files alone to upstream/main (tests kept) fails the two again; restoring them back passes. - Attaching content to the made item fails both again ("carries its text"), and dropping the made summary fails both ("carries no summary"). - go test -tags nogui -count=1 ./internal/gateway: ok 312.4s; -run 'TestTranslated|TestReasoning|TestSealed': ok 7.9s; go test -race -tags nogui -count=1 -run 'TestTranslated|TestReasoning': ok 9.4s. gofmt -l internal/gateway empty. go vet -tags nogui and go build -tags nogui -o /dev/null . on darwin, GOOS=linux and GOOS=windows: pass (a pre-existing cgo -Wenum-conversion warning in internal/gui/trayimage_darwin.go on darwin, untouched). Not tried against real OpenAI or DeepSeek accounts; the reporter's rollout reading is taken from the issue, not re-derived from a live thread. Reviewed and landed as one batch of 12 commits (gua's #4593, #3269, sibling, and four review follow-ups). Run for the batch, whose last commit's tree is 5d58a75f3: - Full suite before the rebase (base |
||
|
|
cbefb65987 |
gateway: a compaction summary answered 502 for ending short compacts locally too (#3526)
#3526's patch compacts locally when the summary ask ends short with an error. The same cut can come back as a recorded 502 whose error says it ended short (errEndedShort), with no error returned, and that still went to the client as a 5xx. The local fallback now runs before the status check, for both shapes (summaryEndedShort), and says why from the recorded error. A 502 that says anything else still goes to the client as it did. Edward4226 pointed at the 502 shape in the thread. TestCodexCompactCutShapesCompactLocally covers a stream error, a 502 saying it ended short (compacts locally) and a 502 saying more (stays 502). Landing record (yetone): Run at the pushed batch head (tree a6b084d0b, on origin/main |
||
|
|
45385f0eed |
redact: a secret's field name masks only in a tool's arguments and result, with secrets on (#2946)
#2946's patch masked any JSON value whose field name looks like a secret's (api_key, password, *_token) anywhere in a request body outside tool definitions. That is an exemption, and a mask, keyed on a field's name: it rewrote what the agent itself sends (mcp_servers' authorization_token, a top-level api_key, metadata.session_token) as well as the user's data. The name check now runs only where the user's data sits in the protocol: a tool call's arguments (Anthropic tool_use input, OpenAI arguments, Gemini functionCall args) and a tool's result (Gemini functionResponse.response is added to the places scan reads), and only with secrets masking on. The Authorization/Cookie rule masked the word after the header name in prose too ("Authorization: required for this route"). It now masks only a value with a credential's shape: one token, or a scheme word and a token, of 8 or more characters with a non-letter and not a ${VARIABLE}; or name=value cookie pairs. Tests: TestMaskJSONNamedSecrets puts its values in tool_use input, functionCall args and functionResponse response; TestMaskJSONSecretNamesOnlyInToolArgs holds the agent's own fields as written and nothing masked with secrets off; TestMaskAuthHeaders gains prose rows (no mask) and a Cookie row. docs/subsystems/gateway-routing.md says where the name check runs. Landing record (yetone): Run at the pushed batch head (tree a6b084d0b, on origin/main |
||
|
|
78632d4b84 |
gateway: a Codex compaction cut short with no candidate left compacts locally (#3526, Edward4226)
A summary wanted whole whose stream every candidate broke off reached codexCompact as an error none of its fallback conditions name: not a 404, not an unreadable item, not "Upstream request failed", not "response protection is unavailable". The relay ends such a stream with a response.failed event saying "the reply ended before it was complete" (#2274), and with nobody left to fail over to, that error fell out of the 404/protection family and went to Codex as a 502. Codex asked the same huge summary over, three times, each paying for the whole conversation, until compactFails answered 400 and held it: the conversation could neither compact nor go on. That is the no-candidate case #2274 left, after it made a cut summary fail over where there was someone to fail over to. The summary is magpie's own then, as when no model can be asked at all (#866, #1008, #1270 end so). The summary as text isn't tried either: the cut was in what the model wrote, not in what it was asked, and that would be another ask of the same huge prompt. The words before the cut are never taken: the local summary is built from the request's own items. A summary that failed halfway, or ended incomplete — the output limit's own event — is still told to Codex as it came and still counts the guard; only the bare break-off turns local. 401, 403, 429 and request-shape refusals are untouched. Run: TestCodexCompactCutAloneCompactsLocally (new) is red on the parent with the issue's 502 ("the reply ended before it was complete, so there is no summary") and green here — 200, one magpie compaction holding the local handoff, the cut stream's words in none of it, the last ask the fake saw still the original summary request (no plain-text retry). The #2274 tests keep their shape: TestCodexCompactCutSummaryFailsOver (a whole fallback summary still wins) green unchanged; TestCodexCompactCutSummaryIsNoSummary now covers the halfway and incomplete shapes alone (the cut one moved to the new test); TestCodexCompactKeepsFailingIsHeld holds on the incomplete shape, which still fails and rests nobody. Ablation: only codex_backend.go put back to the parent, tests kept — the new test is red again, restored, green. go test -tags nogui -p 2 -count=1 ./internal/gateway: ok (350.8s). Targeted TestCodexCompact with -race -count=2: ok. ./internal/usage: ok. gofmt -l clean; go vet -tags nogui on darwin, linux and windows clean; CGO_ENABLED=0 go build -tags nogui on all three ok. docs/subsystems/gateway-routing.md says the new terminal state. Refs #3526 Landing record (yetone): Run at the pushed batch head (tree a6b084d0b, on origin/main |
||
|
|
3f2faef620 |
gui: the Providers page has its own Hide accounts switch
Routing's Hide accounts (账号打码) also masked the Providers page, where nothing showed it was on or let you turn it off (Discord #feedback, 1566189346665799752). The Providers page now has its own switch beside its search box, placed and drawn like Routing's (.rt-mask moved from routing.css to app.css), and each page follows its own switch: Routing, Usage and the tray panel follow magpie.maskEmails, Providers follows magpie.maskProviders. The user's own choice is kept: when maskProviders was never stored, it is seeded from maskEmails and written at once, so someone who had masking on stays masked on both pages after the update, and someone who turned it off stays unmasked. A switch with a stored choice is not changed by Mask personal data's follow(); turning Mask personal data on still masks both (hideAccounts.set(true, true), in app.js and plugins/redact/page.js). show() asks hideAccounts.page() to re-mask when the page in sight follows the other switch. No new strings: the button reuses Routing's translated label and title. app.js 1,310,438, core under its budget, no raise. Run: - New internal/gui/tests/provider-mask.test.cjs, both engines, all 5 languages, at 1000 and 420 wide, plus the touched window-mask, account-eye, privacy-hides-accounts, mask-emails, plugin-name-unmasked, masking-demo-unblurred: 134/134 on mote. At the rebased head (origin/main |
||
|
|
a6de2a15ea |
gateway: an allowed_tools choice reaches the Grok plugin's fetch, end to end (#3153)
Follow-up to ggbdpq's grokShaped change: its test reads grokPluginBody alone. skygunner's TestAllowedToolsReachesGrokPlugin (852182f6 on their fork, from the #3153 thread) posts a /v1/responses request with an allowed_tools choice through the gateway to the fake Grok plugin and checks its fetch gets that object as sent, which is where the plugin decides on x_search. Taken as written; provider-plugins.md names it. Broken by hand: with internal/provider/grok.go at |
||
|
|
ca183561f7 |
gateway: an allowed_tools tool_choice reaches the Grok plugin (#3153)
grokShaped dropped a tool_choice object whose type isn't among grokTools on the plugin's path too, the same as for the built-in: a Responses request relayed to the Grok plugin in its own protocol reached the plugin's fetch with no tool_choice, so with the X search option on (grok 0.2.0) the plugin added x_search over a client's allowed_tools and a tool outside the allowed list went out. The plugin reads the choice and leaves an unsupported one out before Grok itself (every version since the TOOLS filter, the mover's min 0.1.18 among them), so grokPluginBody now keeps such an object, as it keeps the lone "none" (#3110); grokShaped's keepNone is forPlugin, since keeping is no longer only about "none". The built-in, which is Grok's last stop, still drops it. Run: - gofmt -l on the changed files: clean - go vet ./...: darwin and GOOS=windows clean; GOOS=linux vet needs -tags nogui (the GUI's wails doesn't vet without it), clean with it - go build: darwin, GOOS=linux -tags nogui and GOOS=windows: ok - go test -tags nogui ./internal/provider: ok 167.3s, no FAIL - go test ./internal/gateway -run 'TestToolsOffWithoutTools|TestGrok': ok - TestGrokPluginBodyKeepsUnsupportedToolChoice fails without the change ("plugin: tool_choice {Type: Mode: Tools:[]}"), passes with it; broken by hand, each way red then green on restore: deleting the choice whatever the path (plugin red), deleting only a supported type (built-in red) Landed (yetone): the next commit adds the end-to-end test through the gateway to the fake Grok plugin. Run at the pushed head on mote: go test ./... -timeout 45m on mote with this branch on |
||
|
|
c26d16018f |
gateway: a plugin model that refuses temperature is asked without it, relayed or translated (#2492)
What changed: the plugin host carries a model's temperature where it is said - the config model's temperature (Factory 0.1.31's configModels, plugins#154), models.dev's own, or a models hook's model field - into plugin.Model and pluginCatalog's catalog model, where RejectsTemperature reads it as it reads a built-in's. A Chat or Responses request relayed as it came to a model whose list refuses temperature and top_p now leaves them out (passthrough), as the translation of one (build) already did. A model nothing says so of keeps what the client sent. OpenCode's capabilities.temperature is not read: its false is what it reads a models.dev silence as, not a refusal said. Docs: the sampling row of gateway-routing, and provider-plugins' new "A plugin model's sampling". Run at |
||
|
|
1cf66e4b17 |
agent: a tool asked on Responses says strict: false, its optional parameters stay optional (#3055)
What changed: OpenAI's Responses API takes a function tool whose strict is left out as a strict-mode one and normalizes its schema, where every property is required, so a tool's optional parameters came back filled (#3055, ArakawaHenri). pi-ai (dsh's llm-pi-ai, Pi and its kin) says strict: false on an ordinary tool only when the model's compat says supportsStrictMode, which it takes as false where the compat is left out. magpie now says it: every model of a dsh route whose api stands as openai-responses carries compat.supportsStrictMode, by the api the route has now (the one the user picked in dsh's Models page kept), not by its name, beside the keys they set there (dshKeepCompat); and piModelJSON says it for a model best served on Responses, which Pi's and StepCode's models.json carry (Pencil's entries stay on Chat throughout). omp's models.yml is left alone: omp turns a models.yml away over a field its schema doesn't name (16.3.5 over a max), so the compat needs an omp version of its own pinned first. docs/subsystems/agent-wiring.md says so. Run: new TestDshTellsAResponsesToolsStrictIsOff and TestPiTellsAResponsesToolsStrictIsOff fail without the change (the first with "a model asked on Responses isn't told strict is off: Compat:<nil>", the second with "resp/gpt-5.5 is asked on Responses and isn't told strict is off") and pass with it; removing only the dsh case turns the first red and only it, removing only the piModelJSON compat line turns the second red and only it. go test ./internal/agent/ (TestMothX fails the same with both files back at the baseline here, so not from this change), gofmt -l on the changed files (nothing), go vet ./..., GOOS=linux GOARCH=amd64 go vet -tags nogui ./..., GOOS=windows GOARCH=amd64 go vet ./..., go build . (darwin arm64), GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -tags nogui ., GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -tags nogui ., GOOS=windows GOARCH=amd64 go build -o /dev/null . Landed (yetone). Broken by hand on mote: with the dsh case and piModelJSON's compat line taken out, both new tests are red ("a model asked on Responses isn't told strict is off: … Compat:<nil>", "resp/gpt-5.5 is asked on Responses and isn't told strict is off"). Run at the pushed head: go test ./... -timeout 45m on mote with this branch on |
||
|
|
5bfa9f0762 |
gateway: a group's backup gives the conversation back once the member listed ahead of it is ready again (01huadalang on Discord)
01huadalang on Discord, after |
||
|
|
5a56bc7d73 |
gateway: a CI job trades its OIDC token for a short-lived key (#4531)
xazaj on X asked for GitHub OIDC: a GitHub Actions job should get a
gateway key without a long-lived magpie key in the repository's secrets.
A rule (magpie gateway-key oidc add --key <id> --repo owner/name
[--ref …] [--environment …] [--claim k=v] [--ttl 1h] [--issuer URL]
[--audience a]; oidc list, oidc remove) names an issuer (GitHub Actions'
by default, any https issuer), an audience (magpie-<rule id> by default,
so a token asked for one rule opens no other, and the workflow needn't
know the gateway's address), claims (exact or path.Match globs) and the
gateway key the keys are issued under, which must be let issue. A GitHub
rule names the repository or its owner with no wildcard, or every
repository on GitHub could get in. No rule, no exchange.
POST /v1/magpie/keys/oidc with Authorization: Bearer <token> and an
optional {"ttl","models"} verifies the token (RS256 only, keys from the
issuer's discovery document's https jwks_uri, exp required, nbf/iat with
a minute's leeway, the rule's aud and claims, a jti traded once) and
issues a key through access.IssueKey under the rule's key, named
repo@ref (run N), living no longer than the rule. Everything issued keys
guarantee holds: bounded by the issuer's models and accounts, its spend
counted against the issuer, stopped when the issuer is turned off.
- A token is judged only against rules naming its iss, so it can't make
magpie fetch from a URL of its choosing.
- Keys are cached an hour per issuer, read by one request at a time with
no lock held across the fetch, asked again for an unknown kid at most
every 10s, and kept while the issuer is down; with none ever read,
nothing is let in.
- The route is lanGuard's one exemption from remoteKeyed (that exact
path, POST, no gateway key): only while shared, past the allow list,
and a refused token counts against tooManyAuthFails (429 past the
burst). A read-only key is refused it.
The issue's open questions, decided: rules are generic from the start
(the GitHub repository rule applies to GitHub's issuer); rules are CLI
and file only for now (oidc-rules.json), no GUI.
Docs: docs/subsystems/gateway-routing.md (Trading an OIDC token for a
key, routes table) and site/public/docs remote in en, zh and ja, with
the workflow snippet.
Tests: TestOIDCTokenTradedForKey (no rule, a traded key that works on
chat with its TTL capped and its name, a model past the issuer, another
branch, no token, 51 bad tokens -> 429, issuer turned off, a token on a
model route, loopback, not shared -> 403); TestMatchEachCheck (14 bad
tokens, list aud, replay, the refusal naming the claims);
TestKeysCachedAndKept (8 concurrent tokens one fetch, rotation, a made-up
kid inside and past the gap, the issuer down 2h later, an unnamed issuer
never fetched); TestUnreadKeysLetNothingIn; TestAddRefuses;
TestGatewayKeyOIDCCLI; TestReadOnlyKeyEveryRoute with the new route.
A JWKS from an httptest TLS server, never the network.
Broken by hand, each red then restored: the signature check, the claims
match, the jti check, the exp check, the refetch gap, the GitHub scope
rule, the lanGuard exemption, the throttle and the TTL cap.
Run at this head (rebased on
|