22d7ef08fedbb9bb61876dec0aa396af8d8fd0ed
645
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
743fcc0351 |
gui: a click at the view's top keeps the clicked control under the pointer, not the view at its top (#2134)
|
||
|
|
d0fcb8bcdf |
agent: an agent uninstalled with its folder left behind shows "CLI not found" with no live settings, Hermes and the shared-folder agents too (#2177, mengyianx; #2173, SkyTodInfi)
Detection goes by an agent's folder, and an uninstall leaves the folder
behind. Before this commit, Hermes with only its 37-byte
~/.hermes/config.yaml (custom_providers: [], mcp_servers: {}) was listed as
installed in `magpie ls`, the GUI and the TUI, with model and effort pickers
that no program reads. CLIMissing (#843) covered only agents that have an
install command and their own folder. Hermes and the agents whose folder
something else keeps too (claude, codex, cline, opencode, goose) were never
gone.
What changes:
- internal/agent/gone.go adds cliHeld, which asks whether anything here still
reads the folder:
- the CLI on PATH or in proc.FindTool's folders (for goose, a binary that
isn't pressly's Go goose);
- its desktop app (HasApp) or sign;
- the vendor installer's own place: ~/.claude/local, ~/.opencode/bin,
~/.codex/packages/standalone, Hermes' <home>/hermes-agent checkout;
- for the shared folders, an editor extension under
~/.<editor>/extensions (anthropic.claude-code, openai.chatgpt,
saoudrizwan.claude-dev), Claude.app or Claude Desktop, OpenCode.app or
Goose.app on a Mac, a JetBrains IDE's settings (its agents bring their
own program) or Zed's external_agents.
When magpie can't tell, the agent is never gone. That covers OpenCode and
Goose off a Mac, Gemini (its folder is Antigravity's and Code Assist's
too), agents with their own detect, and WSL and plugin agents. It also
covers Bin agents with no install command, except Hermes (cliOnly), since
their installers' paths aren't verified.
- GUI: a gone row shows "CLI not found" and none of its settings, and the
tag's tip says why. It offers no Apply again. While it is still wired it
keeps its switch and Disconnect. Once it isn't wired it folds under Not
set up, and Get started doesn't offer it (connectKind is "no"; the sandbox
run showed Hermes offered there before). The panel shows the words only.
The new tip is translated into zh, zh-TW, ja and de.
- The TUI leaves the agent out. `magpie ls` says "CLI not found" beside its
path.
- docs/subsystems/agent-wiring.md describes all of the above.
- aside-native.test.cjs drops cliMissing from an Aside fixture. That state
can't happen (Aside has no install command and isn't in cliOnly), and
that test is about runtime_unavailable.
What was run:
- Sandbox HOME holding only the reporter's ~/.hermes/config.yaml (37 bytes)
and a bare ~/.codex, with env -i and PATH=/usr/bin:/bin:
- `magpie ls` at base
|
||
|
|
644f4316f9 |
sessions, usage, gui: separate Codex thread relationships and consumption (#1591)
Preserve native Codex thread IDs and explicit parent chains. Associate gateway calls with their actual thread by unique response ID before legacy matching; fold identical native history copies and keep ambiguous actors unknown. Existing Sessions APIs expose optional Codex roles, parent/root relationships and per-thread model/effort consumption. The overview uses its existing calendar range. Usage request APIs expose query-time actor classification and reuse session/subagent/parent_agent for Codex. Other agents, pricing, gateway routing, UI assets, raw Usage logs and model-only aggregation retain their semantics. Verified after rebasing onto main |
||
|
|
0c1e9b79d3 |
agent: Claude Science runs on magpie's gateway, its daemon restarted with ANTHROPIC_BASE_URL (leesunrise2364)
Claude Science (Anthropic's research app, 0.1.62, "operon") has no
third-party inference setting, but its daemon reads ANTHROPIC_BASE_URL
(http allowed on loopback). It still requires its own Claude sign-in
(no API keys); magpie never bypasses, forges or forwards it.
- agent/claudescience.go: a claude-science agent, found in the Mac
bundle, %LOCALAPPDATA%\Programs\ClaudeScience or ~/.local/bin.
Connecting runs `claude-science stop` then
`serve --detached --no-browser --port <its port>` with
ANTHROPIC_BASE_URL set to the gateway, in that process only (no
user-wide env); disconnecting restarts it without the variable. A
mark in magpie's config notes the pid/port/URL; a daemon started
elsewhere shows as drift, never stopped behind the user's back.
KeepClaudeScience (WhileServing) starts it again on the gateway when
none runs (after a reboot). Setting the same value again is a no-op,
so Connect's connect+Apply restarts once.
- gateway/science.go: a request with X-Anthropic-Surface: operon is
Claude Science's. /v1/models lists every model by a
claude-magpie-<n> alias with a non-slug name (its picker drops other
ids); a Claude id magpie doesn't serve (its default, its haiku) goes
to the model last picked, else the first listed. Its sk-ant-oat
bearer is dropped like any Claude sign-in.
- Notice in 5 languages; agent-wiring and gateway-routing docs; README.
Run:
- go test -tags nogui ./internal/agent -run ClaudeScience and
./internal/gateway -run TestClaudeScience: pass; each broken by hand
(no variable in env, keeper touching a running daemon, no
scienceTurn, isClaudeScience off) went red.
- Real 0.1.62 binary in a sandbox HOME on macOS (from the dmg, port
8481): connect restarted it once with ANTHROPIC_BASE_URL (ps -E),
connect again was a no-op, disconnect restarted it without, the
keeper in `magpie serve` restarted a stopped daemon with it.
- Sandbox gateway with a mock provider, sent the app's post-sign-in
headers (a made-up sk-ant-oat bearer, X-Anthropic-Surface: operon,
oauth beta): /v1/models gave the aliases, model retrieve worked, a
streamed turn and a haiku request went to the mock's model, the
upstream saw only the provider key, sk-ant 0 times in its log.
- Windows 11: the real daemon runs in a sandbox profile against a
sandbox gateway; before sign-in it asks nothing.
- gofmt -l clean; go vet darwin, linux (nogui), windows clean; full
go test -tags nogui ./... green except six packages that hit the
10m timeout at load average 250-460 (other sessions); agent,
gateway, cli, gui, library, provider rerun with -timeout 50m: all
ok; GUI agent-notice-lang + i18n-keys in
chromium and webkit at 1100/420, 5 languages: 25/25.
- Rebased onto origin/main 6 commits back (874e4e8ad; 29 upstream
commits incl. gateway.go, i18n.js): vet darwin/linux(nogui)/windows
clean; go test -tags nogui agent, gateway, cli, gui: ok; GUI
notice/i18n 25/25. The Windows sandbox gateway was swapped to that
build and the app's headers replayed through it: the alias list, a
tools turn and a haiku request reached mock-sci-1, sk-ant 0 times in
the upstream log.
- Rebased again onto
|
||
|
|
86cc7ac56d |
usage, gui: keep refreshed cards and distinguish deferred readings (#1630)
A card refresh and a whole-page quota read could replace each other's entire snapshots. An older GET arriving after a successful refresh put the old number back on screen; two card refreshes could undo each other. Apply each POST's requested card alone and retain completed card readings against whole-page requests that began before them. Later reads can still update or remove cards. Failed refreshes do not block background results. A saved Claude account not asked for, or allowances held by When I ask, could also show "couldn't be read just now" without making a request. Carry readDeferred through the cached card and CLI/gateway report, and give that state a separate translated notice. Keep original read times, network-failure notices and authentication errors. Automatic saved-account reads and the existing 30-second floor are unchanged. Verification (macOS arm64, Go 1.27.2, Bun 1.4.3; isolated homes/API fixtures): - On base |
||
|
|
b9c589ebb1 |
gateway: the user's own Max output lowers a plain provider's max_tokens, not only a group's (YaCo on Discord)
Claude Code asks claude-opus-5-5 for max_tokens 128000. A relay that
holds back max_tokens x price from a key's quota answered 403 "token
quota is not enough ... need $2.59" for every turn (128000 x $20/M plus
~8K input x $4/M). Setting the provider's Max output didn't help: the
gateway lowered max_tokens with withMaxOutput only inside a group
(outputLimit), so a request routed straight to a provider went out as
the agent asked.
userOutput finds the Max output the user set for the provider's model
(provider > model or the provider's "*", Entry.OutputSet) and lowers a
larger request to it on any route. Only the user's own value does this
outside a group: a vendor's catalog figure may be stale. Group routing
is unchanged.
Run:
- TestUserMaxOutputLowersAPlainProvidersRequest (new): 128000 -> 32000
with Max output 32k on the model, 8000 kept, a sibling model with no
Max output kept at 128000. Red without the gateway.go change ("went
as 128000").
- go test ./internal/gateway -count=1 (whole package, -timeout 45m):
ok, 1200s, before rebasing onto 4e9335c96; after the rebase the
Output/MaxTokens tests again: ok.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: clean.
- A real Claude Code 2.1.29x against a fake server with the reporter's
env: it sends max_tokens 128000 for claude-opus-5-5 with or without
magpie. Not tried against the reporter's relay.
|
||
|
|
7f968b95dd |
gateway: auto affinity keeps a conversation on the cache its last reply wrote, not only one it read (vilicvane on Discord)
Affinity's auto mode kept a conversation on its last answerer across turns only while that reply had read at least cacheWorth (1024) tokens from the vendor's cache. A first turn reads nothing and writes the whole prompt (Anthropic's cache_creation_input_tokens), so the second turn was moved as "no-cache" and the cache just built was thrown away (vilicvane on Discord, 「会话保持 → 自动」: 「新的 cache 都建好了,再切走不可惜吗?」). answered() is now given the usage's CacheWrite beside CacheRead (both already parsed at that call site for every route: Anthropic, Chat's cache_write_tokens / cache_creation_input_tokens, Cursor, Command Code, plugins), and affine counts read + written against cacheWorth. The stick keeps cacheWrite in memory and in affinity.json (`cacheWrite`, omitempty); a file from before has no such field and reads as 0, so an old stick is judged by its read alone, as before. The trace's Affinity carries CacheWrite, and the Routing page's "cache" and "no-cache" explanations say what was read and what was written (en, zh, zh-TW, ja, de). Not covered: a vendor that caches without reporting a write (OpenAI's automatic prefix cache, Gemini) still reports CacheWrite 0 on a first turn, so its second turn may still move. Noted in gateway-routing.md. Docs: docs/subsystems/gateway-routing.md (affinity bullet), docs/reference.md (step 6 of how magpie picks an account). Run: - TestAffinityKeepsACacheJustWritten (new): an Anthropic Messages upstream streaming cache_creation_input_tokens 3000 / read 0; the second turn is kept as "cache", also across a restart (affinity.json reloaded); 600+600 is kept, 300+300 moves as "no-cache". Broken by hand twice and watched red: the old `st.cacheRead < cacheWorth` (written: why no-cache), and stickOf not reading CacheWrite from the file (restarted: no-cache). - routing-affinity-cache-write.test.cjs (new): chromium and webkit, 1100 and 420 wide, en/zh/zh-TW/ja/de, 20/20 pass; red on the old routing.js and i18n.js. i18n-keys.test.cjs and routing-account-identity.test.cjs pass. - gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows for internal/gateway. - go test ./internal/gateway/...: all pass except TestAgentGoneInTheRetryPause/group_replan, which failed in two full runs at load average 150-380 and passes alone (-count=3); its fixed 100ms sleep before cancelling assumes the pause has begun. Filed as #2175; it never reaches the affinity path this changes (a first request). - go test -timeout 40m ./... at load ~300-377: 50 packages ok; agent and gateway hit the 40m package timeout (no test failed before it); gui's TestSetAnswersWhileDevinAndProvidersHang (#1375) and TestMainWindowCorners (#1936) failed, both filed load reds. internal/agent rerun alone: ok (1008s at load ~200). - Not tried against a real Anthropic account. |
||
|
|
4e9335c96c |
plugin: Windows on ARM downloads Bun's native windows-aarch64 build and runs plugins, not "Bun has no build for windows/arm64" (#2183, EdwinDigital)
bunTargetFor turned windows/arm64 away, so magpie-windows-arm64.exe listed a plugin as on while its host never started, and its providers never showed. Bun publishes bun-windows-aarch64.zip (1.4.2 and later), so windows/arm64 now maps to it, with no baseline suffix (arm64 has no baseline build). Its SHA-256 a7a16b87…0cfd is added to bunSums, taken from Bun 1.4.2's SHASUMS256.txt, so the download is still checked and can come through a mirror. The provider-plugins page says so. What was run (macOS arm64, sandbox HOME, private GOCACHE): - TestWindowsOnArmGetsNativeBun (new): with windows/arm64 stubbed, Bun() downloads bun-windows-aarch64.zip from an httptest release and runs it; the checksum is the official one. Old bun.go: FAIL "bunTarget = "", Bun has no build for windows/arm64". - TestBunTargetForMusl gains windows/arm64 and now checks every target has a checksum; TestBunDefaultSums and TestBunTarget list bun-windows-aarch64. Both FAIL on the old code. - go test ./internal/plugin/ ok; gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean; GOOS=windows GOARCH=arm64 go build ok. - Downloaded the real bun-v1.4.2/bun-windows-aarch64.zip: SHA-256 matches, it holds bun-windows-aarch64/bun.exe, a PE32+ Aarch64 binary. Not tried: a real Windows ARM64 machine (the Windows box is x64), so the plugin host starting on that bun is not verified. |
||
|
|
d1c485f7e9 |
agent: a model at max without xhigh tells Claude Code it has xhigh, so Ultracode shows on GLM, DeepSeek and Kimi in Claude Desktop
leesunrise2364 on Discord: Claude Desktop on magpie has no Ultracode effort,
which cc-switch had, and Ultracode is what turns on dynamic workflows.
Desktop 2.7032.0 shows Ultracode only when the model's effort options
include xhigh and Claude Code takes it. magpie lists a model with known
levels to Desktop as mythos-magpie-<n>, whose options include xhigh, and
tells Claude Code what each model can do in CLAUDE_CODE_MODEL_CAPABILITIES.
That value said only the levels magpie knows the model has. GLM-5.3
(low/high/max), DeepSeek V4 (high/max), Kimi K3 and the like reach max
without xhigh, so they were written as "effort,max_effort", and Claude Code
refuses Ultracode there: "Ultracode isn't available on <model>". cc-switch
names its models as real Claude ids, which Claude Code already knows have
xhigh.
A model Claude Code doesn't know whose levels reach max now also gets
xhigh_effort. The gateway already runs xhigh at max for such a model
(fitEffort: a tie goes up), so no level the model doesn't take is sent.
Claude models Claude Code knows are unchanged: Opus and Sonnet 4.6 still
get no xhigh, as Claude Code's own table has it. Models that top out at
high, or have no known levels, are unchanged too.
Tests: TestClaudeModelCapabilities gets v/glm (low/high/max) and v/top
(high/max), both now "effort,xhigh_effort,max_effort", while
v/claude-opus-4-6 stays "effort,max_effort". TestClaudeCapabilitiesSync's
w/b (low/max) now has xhigh_effort. TestFitEffort covers xhigh to
[high,max] going out as max. With the change turned off by hand, both
agent tests go red on exactly those values.
Run:
- Real Claude Code 2.1.299 in a sandbox HOME, gateway mode
(CLAUDE_CODE_USE_GATEWAY=1), `-p '/effort ultracode'`, with the value
magpie's own code wrote for v/glm-5.3 at low/high/max
("v/glm-5.3=effort,xhigh_effort,max_effort") printed "Ultracode on (this
session only): dynamic workflows on every task". The old value
"effort,max_effort" printed "Ultracode isn't available on v/glm-5.3".
The same pair was run for Desktop's id mythos-magpie-7, with the same
two results.
- gofmt -l is clean. go vet passes for darwin, GOOS=linux -tags nogui and
GOOS=windows.
- go test ./internal/agent passes when run alone (1110s at load ~250),
and so do the caps and fitEffort tests.
- The full go test ./... ran twice at load average ~300.
- The first run hit internal/provider's 10m timeout (#2051).
- The second run (-timeout 30m) had these reds:
- internal/agent and internal/gateway passed 30m as whole packages;
- TestAgentGoneInTheRetryPause/last_one_left (#2175's sibling);
- TestMainWindowCorners was killed at its deadline (#1936).
- None of these is in code this commit touches.
Not tried: a live Claude Desktop. The packaged app won't start on a
sandbox user-data dir, and the live Desktop config is not to be touched.
So Desktop's effort menu showing Ultracode was not seen. It rests on
Desktop's renderer code (the Ultracode gate needs xhigh among the options
and the claude_code_workflows capability) and on the Claude Code probe
above.
|
||
|
|
22512cde53 |
provider, gateway: rest-cap off never rests a provider's keys after an unknown failure (Kismet Alan on Discord)
A relay or account pool fails now and then with errors that say nothing
of why (a 5xx, a dropped connection), and the next request often goes
through. Every such failure rested the key or account a minute, doubling
up to 10, and `rest-cap` could only move that cap (1 minute at least;
`off` read as `default`).
`magpie provider rest-cap <id> off` (provider.RestCapOff, restCap: -1 in
providers.json) now has a failure that says nothing of why (failOther)
rest nobody and not count toward the backoff: restAfterMarked returns a
Rest by "off" with no time left. What says why still rests as before: a
401 or 403, a model not served (restID), an account's window full, a
rate limit (magpie's own 30-minute cap; RestCapOr treats off as unset),
quota, credit, a restriction. `rest-cap <id> 30s` is turned away and names
1m and off (the first rest is a minute already). The Routing page tells a
try rested by "off" as not resting (one new string, zh/zh-TW/ja/de).
No "fail N times before switching" counter: a failed try already moves
the same request on to the next key or member, so a count would only
keep requests on a failing upstream longer.
Run:
- TestRestCapOff (gateway), TestRestCapCmd (cli), TestOwnRestCap: pass;
each goes red with the change taken out by hand (the early return
disabled: "#1 500: rests 59.99s by backoff"; restMinutes in place of
restCapMinutes: "off: <nil> 0").
- routing-rest-off.test.cjs: 20/20 (chromium, webkit; 1100, 420; en zh
zh-TW ja de); red 10/10 with the "off" case renamed.
routing-wb-restricted 20/20. rest-try-now and routing-model-rest fail
a varying few under load average 200-420 here, and fail more on
origin/main
|
||
|
|
5ccc05afe7 |
gateway: a plugin's non-streaming Responses request is relayed streamed and given back whole, so Grok's x_search runs (plugins#112, Watchyourback)
Plugin accounts only stream (Account.Stream), so a stream:false request was translated: parsed to the IR and rebuilt. The Responses parser keeps only function and web_search tools, so x_search never reached the Grok plugin, and Grok answered "let me look that up" without searching. The rendered reply also hardcoded "tools": [], dropped usage.server_side_tool_usage_details, and dropped web_search's open_page item. Watchyourback's capture of the plugin's fetch showed this (no tools field, input wrapped into message[], store:false); CodeAlex52's code read agreed. Now a plugin's request on Responses that asked for one body is relayed like a streamed one (gathers, used by serve's relay decision and by passthrough): - It is asked with stream:true, and the stream goes through the relay's usual tidies. - The client gets the `response` of the stream's response.completed (or response.incomplete) as one application/json body. Its output is filled from response.output_item.done items, or else the streamed text, when that event's output is empty (gathered.go). - A non-200 goes back as before. - A whole reply goes back as it came. - A stream that fails, or ends without its last event, is a 502, as a translated one is, never an empty 200. - Usage is counted from the stream, as for a streamed relay. Left as it was: - Messages: its stream has no event holding the whole reply, so gathering it means assembling the message from deltas. That is not a simple sibling. - Subscriptions magpie signs in to itself (ChatGPT backend, Qoder, MiMo...): their own code fits their requests, and their fakes end in a response.completed with no output. A first version that covered every stream-only account broke 7 Codex/ChatGPT-API tests, so it was narrowed to plugins. TestGrokPluginGetsNamespacedTools now expects the namespace's freeform custom tool to be left out (grokBody), as the built-in and the streamed plugin already did. The translation had offered it as a function. Tests (fake grok plugin through the plugin host): - TestGrokPluginNonStreamKeepsHostedTools: upstream SSE with a custom_tool_call, tools [x_search] and server_side_tool_usage_details. Asserts the plugin was asked stream:true with tools [x_search]; the client gets application/json with the custom_tool_call, message, tools and details; usage is recorded at 50/7. - TestGrokPluginNonStreamEndedShort: no response.completed gives 502. - TestGatheredTextOnlyStream: deltas only. Each was broken by hand and went red: - the relay condition reverted: "the plugin was offered null"; - the missing-completed check removed: 200; - the text fallback removed. Run: gofmt -l; go vet ./internal/gateway on darwin, GOOS=linux -tags nogui and GOOS=windows; go test ./internal/gateway -count=1 (ok, 1400s, load ~200). Not tried: a real Grok account or the real grok plugin; the reporter's allowed_x_handles case. |
||
|
|
e1dcd1e1d7 |
tune: a compaction window advised never makes you wait longer on compactions, and says the wait (HirotaNagai on X)
Tuned for you advised the compaction window by tokens alone, so a smaller
window that compacts far more often could be advised however long each
compaction keeps the user waiting.
What changed
- sessions: a call now carries how long a compaction took (Call.Compact).
Claude Code's compact_boundary line gives compactMetadata.durationMs,
which goes on the first call after it that isn't an error. Codex compacts
by a call of its own (the token_usage_record a compacted line names), and
that call's own time is the compaction's. Older rollouts with no such
record stay untimed. callCacheVersion is now calls-v13.
- tune: with 3 or more compactions timed for a model (minTimed), Facts.took
is their median in seconds, and each window's Point.wait is its
compactions x took. When compactions are timed, the advice never takes a
window that compacts more often than the current one. Of the windows that
don't, it takes the cheapest, and of those within 3% of that (sameCost)
the one that compacts least. Tokens and seconds share no unit the files
measure, so magpie doesn't trade one for the other at a guessed rate. The
token-cheapest window is reported (cheapest, wait_cheapest) so the user
can pick it. A model with fewer than 3 timed compactions is advised as
before, with no wait shown.
- GUI (Usage > Context): when timed, the advice is labelled
"Tokens + wait". The explanation says what a compaction took, the wait at
the advice against the window now, and the cheaper window that would wait
longer (if it saves 3% or more). The caveat says tokens and waiting only.
The picker shows each window's wait, with "Fewest tokens" on the
cheapest. Untimed rows are unchanged. The new strings are in zh, zh-TW,
ja and de.
- docs/subsystems/agent-wiring.md describes the timing sources and the
rule.
What was run
- go test -tags nogui ./internal/sessions ./internal/tune ./internal/gui
./internal/agent pass.
- internal/agent ran before the rebase. It took 1416s under a load
average of 120-300 and passed with -timeout 40m (the default 10m timed
out mid-suite). Its Tune/Compact/CacheTTL tests pass on their own.
- sessions, tune and gui ran again after rebasing on origin/main
|
||
|
|
8ea4fec90a |
tui: w changes a custom provider's base URLs (luluxiu_1_4392 on Discord)
On Linux, with no window, the TUI had no way to change an API-key
provider's base URL: w only moved a local server's address or a preset
with an endpoint, and for a provider of the user's own it only pointed
to `magpie provider set <id> url=…`.
w on a provider with no preset now asks each base URL it has (Chat,
Responses, Anthropic, Gemini) in turn, prefilled with the one there now;
Enter alone keeps one. Only http(s) addresses with a host are taken, a
trailing / is dropped, and only the URLs that changed are saved, the
balance cache forgotten. A vendor preset is still asked at its own
address, and the footer already said "w address".
TestTUIAddsARemoteMagpieWithItsAddress asserted w asks nothing on the
custom provider "a"; its vendor case now uses a DeepSeek preset.
Run:
- TestTUIEditsACustomProvidersBaseURL: one URL changed and saved
without the trailing slash, a bad URL refused, a two-URL provider with
one kept and one changed, Enter Enter = unchanged. With the new branch
disabled it fails ("w opened "" (mode 0)").
- go test -tags nogui ./internal/tui/ (the full run caught the old
assertion above, now updated).
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
Not tried: the TUI by hand in a real terminal on Linux.
|
||
|
|
ef0c515eb0 |
provider: a sub2api or new-api account query left without its token asks the key's query instead (lx_78654 on Discord)
The editor's "Use …/api/v1/user/profile" sets the Balance URL to the sub2api panel's account query, which only the login JWT can ask. Its Remove button clears the token but not the URL, so the profile query was then asked with the key, refused with 401, and the Usage card said "Allowance unavailable" for good. keyQueryOf now asks the same panel's key query when the Balance URL is an account query (sub2api /api/v1/user/profile, new-api /api/user/self) and no token is set: /v1/usage and /api/usage/token, with the key, their own default field unless the user wrote another. The saved URL is left as set, so pasting a token again asks the account query again. A provider whose Headers carry its own Authorization or Cookie is asked as set. It covers every reader: the Usage page and `magpie quota` (KeyBalances), the editor's Check balance, routing's key windows (sub2APIKeyLimits), and `magpie provider <id>`, whose "from" line now says the query actually asked (BalanceQuery). Run: - TestAccountQueryWithoutTokenAsksTheKey (httptest sub2api + new-api): JWT, removed, JWT again; new-api without token; custom field kept; account query never asked with the key; own Authorization kept. With keyQueryOf a no-op it fails with the reporter's 401 card. - Sandbox CLI (scratch HOME, fake sub2api on 127.0.0.1): old binary, after `provider set sub2 balance.token=`, `magpie quota` shows "401 Unauthorized…"; new binary shows "$7.25 left", from /v1/usage. - go test -tags nogui ./internal/provider/ ./internal/cli/ ./internal/tui/, and internal/gateway's balance, allowance, quota and key-limit tests. The full `go test -tags nogui ./...` passed every other package; internal/gateway and internal/agent ran out of time (10m, then 40m) with the machine at a load average of ~300-370, the tests running at the deadline seconds old, so not a hang; neither run finished. - gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows. Not tried: a real sub2api or new-api account; the GUI not clicked through (no asset changed, it reads the same KeyBalances). |
||
|
|
0506f011d7 |
agent: a Codex reaching the gateway from another machine is never joined beside its ChatGPT sign-in (#2145, lazydao)
A Codex in a WSL distro under NAT (or with MAGPIE_ADDR pinned beyond loopback) signed in to ChatGPT was joined beside its sign-in: it sent its ChatGPT token to <gw>/backend-api/codex, and from another machine the gateway takes a named key alone, so every request was a 401. chatGPT() is now false when onAnotherMachine(at.gw()): such a Codex is wired as one with no ChatGPT sign-in, magpie as its provider with gwKey() (the LAN sharing key). One of its own models picked still goes straight to OpenAI on its sign-in, as it does for a Codex with no sign-in. Run: TestCodexBeyondLoopbackNotJoined (new; fails on the old code with the joined config), go test -tags nogui -count=1 ./internal/agent (975s, ok), gofmt -l, go vet darwin / GOOS=linux -tags nogui / GOOS=windows. A first version forced magpie API under NAT and broke TestWSLCodexProvider (own model refused); this one keeps that path. Not tried: a real WSL distro under NAT with a ChatGPT-signed-in Codex. A NAT Codex already joined is rewired on the next connect or model pick. |
||
|
|
a4d580fa24 |
gateway: a group skips Antigravity for the system prompt it just turned away (#2156)
Antigravity answers Claude Code's and the Agent SDK's system prompt (the x-anthropic-billing-header line, "built on Anthropic's Claude Agent SDK") with 429 "Resource has been exhausted" whatever quota is left (#666). magpie already tells it as prompt_turned_away, rests nobody and hands it on, but each Claude Desktop turn in a group waited on the same refusal first (#2156: 429 in 1073ms, then cursor/composer-2.5 200). Now, once Antigravity has turned such a request away (any of the three paths that set holdWriter.turnedAway), for agForeseeing (6h) after, the candidate loop skips an Antigravity candidate for a request that carries the line, when someone is left after it (antigravityForeseen). The skip goes in Fallback with the hint, sets `other` as the asked path does, and changes no account state. The last one left is still asked and told the 400 with the hint. A request without the line (titles, Codex) still goes. An old refusal foresees nothing, so a block Google lifts is noticed. The lines are still neither rewritten nor hidden (#666). The stamp is per Server, in memory. TestAntigravityTurnedAwayRestsNobody's "asked first again" half now checks it with a turn without the line, since one with it is foreseen. Run: - TestAntigravityTurnedAwayIsForeseen: fails with the skip turned off ("Antigravity was asked again for the prompt it just turned away"), passes with it; TestAntigravity* -count=3 green. - gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok. - go test -tags nogui ./... in a sandbox HOME at load average 140-220: everything green except 10m timeouts in agent, cli, gateway, library, provider and TestSetAnswersWhileDevinAndProvidersHang (#1375, noted there); those six packages rerun with -timeout 45m: all ok. Not tried: the skip against the real Antigravity account (the refusal itself was reproduced with a real account before: 400 with the line, 200 without), nor Windows/Claude Desktop as the reporter uses. No GUI change. |
||
|
|
b75e21be31 |
agent: the Qoder app counts as Qoder again, found by the status file it writes to ~/.qoder (#2138, xiaozicoder)
xiaozicoder's Windows 11 has the Qoder app and the Qoder CN app (Qoder-win-x64-user.exe, Qoder-CN-win-x64-user.exe from qoder.com and qoder.cn) and no qodercli, and since v0.1.1220 magpie's Agents page lists no Qoder at all. Qoder-win-x64-user.exe is the Qoder app (com.qoder.app, qoder-app/releases/latest.yml at 0.4.7), not the Qoder IDE. Its app.asar runs Qoder's CLI as its agent (qodercli 1.1.64's worker runtime, config dir .qoder / .qoder-cn, QODER_CONFIG_DIR, with BYOK config management), so ~/.qoder/settings.json's providers.magpie reaches it. It writes the enabledPlugins of its bundled qoder-context plugin to settings.json, which alone stopped counting in the same change, so the app's Qoder was lost. The app also writes .qoder-app-status.json (-canary-, -dev- for its other channels) into ~/.qoder, or ~/.qoder-cn for the China product (the map is in its app.asar; this Mac's Qoder.app 0.4.3 wrote one). Agent gets sign, one more sign the agent is here for a dirShared folder, and Qoder's (both builds) is that file. The JetBrains plugin's folder of #1495 has none, so it still isn't Qoder. Run: TestQoderAppIsQoder (both builds: plugin-only settings.json not detected; each of the three status files detected; the status file with no settings.json detected; a folder of that name not) red on the old code (Qoder CN subtests fail), green now; TestQoderSettingsFromAnIDEPluginIsNotTheCLI still green; go test ./internal/agent -count=1 -timeout 45m ok (1576s, the machine at load ~350; a first run hit the default 10m package timeout mid TestCodexAgentsV1WarnsWhenCodexOwnV2IsOn at 1s, not a hang). gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean. A nogui build's `magpie ls` in a sandbox HOME (PATH=/usr/bin:/bin) with ~/.qoder holding the plugin-only settings.json and a copy of this Mac's real .qoder-app-status.json, and ~/.qoder-cn the same with a qoder-cn status, lists Qoder and Qoder CN. Not tried: the Qoder app on Windows itself, and whether its agent takes magpie's provider from settings.json in practice (would need a live ~/.qoder changed). |
||
|
|
1a33d22cca |
agent: an omp outside magpie's PATH (bun's ~/.bun/bin) is still found and asked its version on Linux and macOS, so its models offer max (whqtian on Discord)
whqtian: "ubuntu 24 版本的 omp 最大推理级别,还是xhigh,win版和 wsl版好了". omp
gets max in models.yml only when its version is known to be 16.4.0 or
later (ompTakesMax). The version comes from cliBin → binAt, which looks in
the user's tool folders (proc.FindTool: ~/.bun/bin, npm prefixes, every nvm
Node, mise, fnm ...) only on Windows. Elsewhere it uses the PATH magpie
was started with, and only the GUI and `daemon install` widen that. Under
`magpie serve`, web, tui, the CLI or a service, an omp installed by bun in
~/.bun/bin read as no version, so max was turned into xhigh.
|
||
|
|
8c5190a203 |
provider: a routing group keeps its thinking members' levels beside a member known not to think, so Codex shows its effort control (#2127, cnlove7777777-art)
#2127: with a routing group as its model, Codex showed an effort but no control to change it, and new sessions and subagents ran at medium. A group offers agents the levels its members have in common (groupEntries), and a member magpie knows doesn't think (Entry.Quiet: its vendor's list says no reasoning) counted as having none, so the intersection came out empty. The group still reasons when one member does, so Codex got its entry with reasoning but no supported_reasoning_levels and no default_reasoning_level: no slider, and Codex's own medium. Since #950 the gateway sends such a member no reasoning ask at all (withoutReasoningAsk, quiet.go), as it does a reasonless one ( |
||
|
|
bfef5d51b5 |
gui: Routing is back to v0.1.1231's layout; reverts dae2618ad (#1354)
v0.1.1233 shipped community PR #1354 ( |
||
|
|
4faa931325 |
provider: Vertex AI's preset offers Gemini 4 Argon at global, and its test asks it at low (#2155, TomXPRIME)
Gemini 4 Argon went live on Vertex AI's global location on 2026-10-13
(gemini-4-argon), and the preset's fixed list (Vertex has no list to ask)
didn't have it, so a fetch never showed it. It is added to the preset's
models, which are global's; us, eu and the regions are left as they
answered on 2026-10-06, since nothing says Argon is served there (typed
in by hand it still goes).
Its metadata (1,048,576 context, 65,536 output, low/medium/high, $2/$10)
comes from models.dev's google-vertex entry, which lists it as of today,
so nothing is hard-coded here. The gateway already tells Gemini 4 a
thinking level at the level asked (
|
||
|
|
7d4ad7c628 |
gui: the menu bar's total is every token, cache too, marked Σ, as the Requests tab sums it (NextCommit)
NextCommit on Discord: the menu bar's usage showed only input tokens, and
more input than the Usage page. It showed input + output, unlabelled, so
it read as the input and came out above the page's input. And it was summed
as the Overview sums (usage.SummarizeTop: the gateway's calls only, cache
aside), while a click opens the panel's Usage tab, which sums the ledger
(the agents' own session-file calls too) and counts the cache's tokens
in its Tokens. Two numbers under one name.
- trayTotalSum is the ledger's cached sum, usage.QueryPage(p, {}, 0, 1).Sum,
the one the panel's Usage tab and the window's Requests tab show.
- The cell's top row is every token (in + out + cache read + write, as
allTokens) prefixed Σ; the cost stays under it. The tooltip spells out
"N tokens (a in · b out · c cached)".
- With the window as the tray's, a click opens the Requests tab at the
period (quotaView), not the Overview, which sums differently.
- docs/reference.md and gui-shell.md say so.
Run:
- TestTrayTotalIsTheLedgers (new): a Codex session-file call of 1000 in,
200 out, 8000 cache read; the menu bar's sum equals ledgerPage's and the
cell reads Σ9.2K. With trayTotalSum put back to SummarizeTop it fails
(menu bar all zeros, ledger 1 call).
- TestTrayTotals/BesideCards updated for Σ, the cache and tab=requests.
- go test -tags nogui ./internal/gui (sandbox HOME via the package): ok.
- tray-totals, tray-usages, tray-cell-click .test.cjs, chromium and
webkit, five languages, 1100 and 420: 70 pass.
- The Mac cell rendered with trayImagePNG and looked at: "Σ6.3M" over
"$3.40", "Σ47M" alone, both inside the row width.
- gofmt -l, go vet darwin, GOOS=linux -tags nogui, GOOS=windows; builds.
Not tried: the real menu bar on the reporter's data.
|
||
|
|
3e812ebde4 |
gateway: a provider that refuses a tool_result holding only tool_reference blocks gets them said as text too (#2124)
OpenDesign's Anthropic-compatible endpoint answers 422 "messages[4]:
missing field `content`" when a ToolSearch result carries only
tool_reference blocks, so every Claude Code turn after a deferred tool
loaded failed there.
The fix is a learned shape, scoped to the provider that refuses it, like
the deferred-tools one: refuseShapes marks shapeRefsOnly when a 400/422
says "missing field `content`" and the request held such a result, and
withoutRefusedShapes then puts a text block ("Tool X is loaded and can be
called now.") before the references in each refs-only tool_result,
keeping the references. Every Anthropic upstream route goes through
forward/forwardOnce, so /v1/messages, count_tokens and a group's member
all get it; a provider that takes the references unchanged never sees the
text. Requests translated to another API already rendered a reference as
text in stringOrText; it now uses the same sentence (toolLoadedText).
Run:
- TestRefsOnlyToolResultRefusedGetsText (fake vendor answering the
reporter's 422 bytes, body from the reporter's repro.json): first ask
refused, retried with the text; group member and count_tokens get it at
once afterwards; a provider that takes them sees bare references.
- TestRefsSaidLeavesOtherResults: other results unchanged, two refs.
- Break checks: with the mark off, and with the mend off, the test fails
with "status 422 ... missing field `content`".
- go test -tags nogui ./internal/gateway/ -count=1: ok (1069s, loaded
machine; a first run with the default 10m timeout timed out under load).
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
Not tried: the real OpenDesign endpoint (no key); the fake follows the
reporter's own curl evidence.
|
||
|
|
54a2b0d05f |
gui: a provider kept for its usage alone is one click, Usage only, and its card says so (#2068, keleus)
keleus wanted a subscription's quota in the status bar without anything routed to it. That has existed since #1818 (noModels), but getting there took Picked only, then Select none, then Save, and the card then just said "no models exposed". The models' serves control now has a third option, Usage only: no picks, noModels on, nothing routed, balance and usage still read, models the vendor lists later not added. The card's line says "usage only" for such a provider. Picked only with none picked used to be the same state under another name; it now starts from the models the vendor's list serves (the dashed ones), so each of the three options is a state of its own. Unpicking the last pick still leaves none (#1831), which now reads as Usage only. Strings in en, zh, zh-TW, ja, de; the old Picked only tooltip's second half moved to Usage only's. Decision (owner delegated product calls): name the state rather than document the path; the backend, CLI (`magpie provider models <id> none`) and saved files are unchanged. Run: provider-none-picked.test.cjs and i18n-keys.test.cjs, Chromium and WebKit, 5 languages, 1100 and 420 wide: 33/33. With app.js put back, provider-none-picked fails ("+ 'Picked only' - 'Usage only'"). The test's saved-as-none fixture now has its models off, as /api/providers sends them (Exposed is empty for it). No Go changed. Not run: the whole GUI suite (no shared selector or API added). |
||
|
|
1a5128747b |
cli: magpie provider refresh-every and auto-include set a list's schedule and rules (#2135)
`magpie provider refresh-every <id> 6h|1d|off` and `magpie provider auto-include <id> 'gpt-*' 're:claude-.*'|none` set the fields the previous commit added; `magpie provider <id>` shows them, and `magpie provider refresh` prints the models its rules took. TestRefreshEveryAndAutoIncludeCmds: a too-short or unreadable time and a plain id as a rule are refused, the rule takes the current matches, and none/off clear both while keeping the picks. Run with the go test in the previous commit's body. |
||
|
|
ee4a7ab471 |
provider: a provider of your own can fetch its model list on a schedule and take newly listed models by rule (#2135, tianxia3111)
tianxia3111 runs a headless `magpie serve` with relays of 10–70 models. A model the relay adds never reached the list until Fetch models was clicked, and was then picked by hand. - RefreshEvery (a Go duration or Nd, at least 10m): the gateway (KeepListsFresh, started beside KeepPluginsListed, so serve and the app) looks each minute and fetches a list once Fetched is that old, through the same Refetch as Fetch models, so dropped models leave the picks exactly as they do there. A failure waits min(every, 15m). - AutoInclude (globs with *, or re: patterns, the same ones routing groups read; a plain id is refused): RefetchTaking adds a model the fetch newly lists that a rule matches. It starts from what is served now (Exposed), so nothing served is removed, and a model the user unticks stays out because it isn't new to the next fetch. Setting the rules takes the current list's matches. Rules only ever add. - Only providers of the user's own take them: an account's list is fetched for it, and a plugin's by the plugin. - Every save keeps them, the window's editor (/api/provider/save) among them, which has no fields for them yet. Tests (each fails without the change, broken by hand and watched go red: GUI keep line removed, takeMatching skipped, retry guard removed): TestAutoIncludeTakesNewlyListedMatches, ...KeepsWhatIsServedWithNothingPicked, ...RefusesWhatIsNoRule, TestParseRefreshEvery, TestKeepListsFreshFetchesWhatIsDue, TestSaveKeepsTheListsScheduleAndRules, gui TestProviderSaveKeepsListScheduleAndRules. Run: gofmt -l; go vet ./... (darwin), GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...; go test internal/provider internal/gui internal/gateway internal/cli with pipefail in a sandbox HOME. Not tried against a real relay; the GUI editor fields are not added. |
||
|
|
5fc2f87d13 |
gui: in colorblind mode a quota legend key is its window's dash, the even paces are dotted, and the balance curve and the good grade keep their look (#2073)
A review of db25c4ee found that colorblind mode reached past the quota
curve and that its legend shapes matched nothing on the plot:
- The fallback rules `.qc-line:not([data-series="0"])...` and the
matching `.qc-key` rule also matched elements with no data-series, so
the balance curve's solid line became dashed like its fitted line, and
its legend dot became a ring in var(--c4) while the line was var(--c1).
- A filled circle, hollow square or diamond in the legend appeared
nowhere on the plot, so it didn't tell a reader which line was which.
Series 3 and up shared one dash and one shape.
- The 7-day line's 6 2.5 dash sat beside its own 3 3 dashed even pace in
the same colour, while the tooltip still said "Solid: what was left.
Dashed: an even pace".
- The Context tab's "good" grade took var(--c2), which the palette turns
amber, next to "fair" in --amber (dark #fbbf24 vs #f2b544).
- omarchy.css made the first legend dot round with colorblind mode off.
- The legend set its colour twice (--sw and background) and undid it
with !important.
Now, with colorblind mode on:
- drawQuotaPlot tags each window's path.qc-line and line.qc-even with
data-series (its index mod 7, the same slot as its colour), and the
quota legend tags its key. Seven dash patterns, one per slot, apply to
`:is(.qc-line, .qc-dash)[data-series=N]`, so a line and its key can't
drift apart. Nothing else sets data-series, so the balance curve is as
on main.
- Each quota legend key shows a 22px sample of its window's line
(svg.qc-sample > line.qc-dash) in place of the dot; with the mode off
the sample is hidden and the dot is as on main.
- The even paces are dotted (0 4, round caps), unlike every window's
dash; the curve's tooltip, set in box.draw, says "Each window's line
has the dash shown beside its name. Dotted: an even pace, ..." in en,
zh, zh-TW, ja and de.
- `.ctx-ring.good` / `.ctx-grade-word.good` take --c1, the palette's
blue.
- omarchy.css is back to main's; the legend's `--sw` and !important are
gone.
- The Settings note now says what the mode does ("Colorblind-safe chart
colors, and each allowance window's line in a dash of its own"), and
gui-shell.md says the note is the Off/On control's tooltip, as the
code has it.
Run on db25c4ee + this change (upstream/main
|
||
|
|
a7a38193f5 |
gui, settings: colorblind mode for quota curves and chart series (#2073)
In Usage -> Allowances, the 5-hour and weekly quota curves and their
legend dots took --c1 and --c2, which are both shades of blue in light
(#4f46e5, #0ea5e9) and dark (#a5b4fc, #7dd3fc) themes, with identical
solid lines and 7px round dots and the 5-hour line dimmed to .45 over a
week (#2073, chenlz22550).
- settings.Colorblind ("colorblind" in settings.json), passed in GET
/boot.js when on and applied before first paint by theme.js and on
every state/settings read by applyPrefs as data-colorblind="1" on
:root.
- Settings -> General adds a Colorblind mode row (#colorblindRow,
#colorblindSegs) under Appearance, in en, zh, zh-TW, ja and de.
- Under :root[data-colorblind="1"], --c1...--c7 switch to an Okabe-Ito
qualitative palette in both light and dark themes so adjacent series
differ in hue and lightness across quota curves, tray sparklines, the
usage ledger and context charts.
- drawQuotaPlot and quotaCurve's drawLegend tag each series with
data-series on path.qc-line and .qc-key; in colorblind mode series 0
and series 1+ use distinct stroke-dasharray patterns and legend swatch
shapes (filled circle vs hollow square/diamond), and .qc-line.qc-short
keeps .85 opacity so short windows stay legible over a weekly span.
- docs/subsystems/gui-shell.md documents the boot and Settings contract.
Run (on origin/main
|
||
|
|
3b6ca05571 |
gateway: /v1/magpie/concurrency tells the whole gateway's requests in flight, waiting and tool turns, 0 when idle, with or without a limit (#2132, bigbitbox)
A status bar (SketchyBar) polling /v1/magpie/concurrency got
{"data":{},"object":"concurrency"} with no limit set: the lanes hold only
keys and accounts with a limit, so an idle gateway and a busy one with no
limits read the same. The answer now carries, beside data:
- requests: Busy().Requests, every agent request in flight, those waiting
for a slot among them; a GET (this poll included) is never counted;
- waiting: how many of those wait for a slot, summed over the lanes;
- tools: Claude subscription turns waiting on their caller's tool results.
Each is 0 when idle. Access is unchanged: this machine, another only with a
gateway key, a held key refused (refuseHeld). docs/reference.md says so
beside the usage API.
Run: TestConcurrencyTellsTheWholeGateway (new) fails without the change
("idle: tools = <nil>, want 0 (map[data:map[] object:concurrency])") and
passes with it, -count=5; it covers no limit anywhere (the reporter's
case), and three in flight on a one-slot provider with one waiting.
gofmt -l (nothing); go vet, GOOS=linux go vet -tags nogui, GOOS=windows go
vet on internal/gateway (ok). go test -tags nogui -count=1 ./internal/gateway
in a sandbox HOME: ok in 835s with -timeout 40m (on 0ad9661b6; the default
10m ran out while three other gateway suites ran on this machine), then
the concurrency, busy, held-key and LAN tests -count=3 after rebasing on
|
||
|
|
20350dafaf |
gateway, agent, gui: Claude Desktop's subagents can be held to one model, set in its row on the Agents page
Claude Code in a terminal holds every subagent to one model through
CLAUDE_CODE_SUBAGENT_MODEL (its "subagents" field), and Codex through
magpie's own setting (settings.CodexSubagentModel). Claude Desktop runs
its Code tab's Claude Code with CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1,
and Claude Code 2.1.295 then ignores CLAUDE_CODE_SUBAGENT_MODEL,
CLAUDE_CODE_SUBAGENT_MODEL_FORCE and the tier variables in its settings
files ("Ignoring … this session's provider routing is managed by the
host"). The env Desktop 2.31226 builds for the Code tab has no key for it
either. So Desktop's subagents ran on the lead's model or on a tier's, and
only the tiers could be picked.
Claude Desktop's row now has a "subagent model" square, the same square
and strings as Codex's. It is magpie's setting
(settings.DesktopSubagentModel), which the gateway applies
(desktopSubagentPick):
- Only a claude-desktop request with x-claude-code-agent-id and tools is
moved: a subagent's turn. The lead's turns, the tool-less helper calls
Claude Code makes inside a subagent (on the haiku tier's model),
terminal Claude Code and every other agent stay as asked.
- It is applied after desktopTurn, the tiers and the groups. A turn
already on the model set isn't marked as moved. Route.Subagent,
Route.Model and the ledger's Requested keep the model asked for; Kind
stays empty.
- The model set must be served by its exact id (Resolve takes any model
name under a provider that is on), enabled, and allowed to a gateway key
held to some models (groupAllowed for a group). Otherwise the subagent
stays on the model asked for and the trace says why, in the reasons
Codex's subagent model already has.
- count_tokens counts on the same model.
- It is read on each request, so Desktop needn't restart. The field is
Live (a new Field flag): /api/set and `magpie <agent> <field> <value>`
leave Desktop's restart notice out after it, unless the pick connected
Desktop. Codex's subagent model is unchanged.
- The getter follows a provider renamed since it was set (RenamedRef).
The setter takes any provider/model or group/<id>, also one not served
now (a restored profile), refuses a bare name, and keeps a Desktop
alias by its catalog id. Options are shown while Desktop is on magpie.
- POST /api/settings keeps it; a stopped WSL distro's field copy keeps
Live.
- The Routing page says why a Desktop subagent was moved or kept
(subagentWhy, for a route with a subagent pick and no kind). "it is
disabled in magpie" gets its zh, zh-TW, ja and de, which Codex's kept
reason lacked as well.
- Unset, the pick costs one held settings read (no body decode, no
catalog build).
Not changed: a Desktop on another computer that reaches magpie with a
named gateway key is read as Claude Code (agentOf), so none of Desktop's
routing applies to it, this included. There is no fallback when the model
set has a smaller window than the lead's.
Verified at this head, on
|
||
|
|
f70c0525aa |
access, gui, cli: a gateway key's limit can run every N hours, a 5-hour cycle among them (#2102)
A key's limit window was a calendar day, week or month, or every N days (#1509). #2102 asks for a shorter cycle, every 5 hours, like a vendor's own 5-hour window. Limit gains period "hours" with Hours (1..8760), counted in absolute time from Since, as the N-day cycle is; a change to N or from days restarts the cycle, a cap change keeps it, Reset starts a new one. Budget status, the 429's wording ("this 5-hour cycle"), X-Magpie-Limit-Reset, /v1/magpie/limit and a remote magpie's key card carry Hours. The GUI's window menu has "Every N hours" with an Hours field beside it (no native select); the CLI takes `<N>h` (magpie gateway-key limit <id> 5h --tokens 200k). Docs: reference.md and docker.html (en, zh, ja). Strings in zh, zh-TW, ja, de. Run: - go test ./internal/access (TestLimitHoursCycle across NY DST, UTC, UTC+8; TestLimitHoursSetAndReset), -tags nogui ./internal/cli (5h, rejects 0h/8761h/xh/1.5h/hours), ./internal/gateway (TestKeyLimitHoursCycle: 429 and reset header, /v1/magpie/limit, Reserve at the boundary, Reset; remote key card 5h), plus the full access, budget, cli, gateway, provider and gui packages. The gateway package hit go test's 10-minute default once with the load average near 270; rerun with -timeout 40m it passed in 1536s. - Broke cycle() for hours by hand: TestLimitHoursSetAndReset and TestKeyLimitHoursCycle went red; restored. - GUI: gateway-key-cycle (extended with the hours case: menu, field, validation, Save body, badge, Reset confirm, one-column at 500px) in chromium and webkit x en/zh/zh-TW/ja/de, 10/10; i18n-keys, gateway-key-limit, gateway-caller-keys, phone-rows, gateway-keys-off, gateway-own-key, api-key-theme 63/63; an ad-hoc check of the hours editor at 1100 and 420 in both engines and 5 languages (no overflow, screenshots looked at). - gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows. Not tried: a real gateway under load across a 5-hour boundary; the Windows box. |
||
|
|
f5083e8041 |
gui: a gateway key's account menu says a provider none of whose accounts is picked is used, and how to keep the key off it (#2077, KKKKKKKEM)
A key held to some accounts (#905) is held to the accounts of the providers its list names; a provider it names none of is used on every account. The menu showed that provider's accounts unticked like any other, so the reporter unticked every Codex account, ticked the rest, and was surprised that the key's remote magpie still listed and served Codex's models. The rule stays as #905 set it (a key held to one Codex seat keeps its other providers). The menu now notes each account of such a provider "Used: no <provider> account is picked", and the badge's tooltip says a key is kept off a provider by picking only other providers' models. en, zh, zh-TW, ja, de. Verified: - gateway-key-accounts.test.cjs (chromium + webkit, en + zh) checks the note on OpenAI's key under a key held to a Relay account, Relay's unpicked account still noting its provider, the tooltip, and a key held to no account showing neither. With the old keys.js it fails: expected 'Used: no OpenAI account is picked', actual 'OpenAI' (and the zh equivalent). - gateway-key-*, gateway-keys-off, i18n-keys, gui-zh-tw, gui-ja, gui-de in chromium and webkit: 62/62. - The menu at 420px in German (chromium) and Chinese (webkit): no horizontal overflow, the note wraps inside the menu. Not run: the whole GUI suite. |
||
|
|
d53a51cdfe |
gateway: the key's own limit on a remote magpie still rests the whole remote, and #2077's case is tested across two gateways (#2077, KKKKKKKEM)
#2077: server B used server A's magpie as a Remote magpie provider. A's Claude Code hit its session limit and answered 429; B rested its one key to A until the reset, so a request for A's Qoder model was refused on B with Claude Code's 429 ("... (out of its allowance: not asked again before 10:55)") and never asked of A. |
||
|
|
c8b4ac7755 |
fix(catalog): honor models.dev reasoning toggles (#1294)
* catalog: honor reasoning toggles as off effort Include none when models.dev reports both a reasoning toggle and effort levels. Keep toggle-only entries level-less, and leave effort-only entries unchanged. Validation: go test ./... with GOFLAGS=-tags=nogui; all packages pass. The new catalog regression failed before the fix and passes after it. No vendor API request was made locally. * catalog: limit reasoning off to DeepSeek * catalog: include verified Kimi reasoning toggles * fix(catalog): keep off effort provider scoped |
||
|
|
dae2618ade |
gui: make the Routing context lazy and align wide cards (#1354)
* gui: make the Routing context lazy and align wide cards (#1354) Rebuild the context and wide-layout change on main |
||
|
|
62378c5f84 |
cli, usage: magpie usage takes --last <dur> and --days <n>, a window ending now, with or without --csv and --account (#2075, tinysnake, fcy222fcy)
today, 7d and 30d begin at a local midnight, so a caller wanting "the
last few hours" just after midnight had to take 7d's CSV, seven days of
rows for one. `magpie usage [--csv [--account <name>]] --last 24h` (any
Go duration, 90m) or `--days 1.5` now reads a window that began that
long ago; the presets are unchanged.
From fcy222fcy's branch (usage-rolling-window, 60472c661): a rolling
window is a period "last:<dur>" (usage.LastOf / Period.Last) that Since,
Known, shown and the chart's timeline answer for, so the ledger, Direct
and the summary read the same window.
Review fixes on top:
- a summary of a rolling window is worked out each time, like a picked
range: kept, its start didn't move with the clock while the log
stayed the same (reachable through the web API's ?period=last:24h);
- the CSV export's file name has no colon from "last:24h0m0s", which
Windows refuses;
- `--last 24h 7d` is refused rather than silently taking --last;
- --days refuses NaN, Inf and over a century;
- the help line and docs/reference.md name the flags.
Run: new TestRollingWindowIsNotKeptStale fails with the cache fix taken
out ("an hour later: 1 calls, want 0"); TestCSVStamp fails without the
colon fix ("magpie-requests-last:24h0m0s-2026-09-30");
TestUsageRollingWindowRejectsJunk fails without the preset/--days
checks; TestUsageRollingWindow and the new ...WithAccount fail (3 rows,
want 2) with Since moved back. go test -tags nogui ./internal/usage/...
./internal/cli/... ./internal/usageapi/... ./internal/gui/... in a
sandbox HOME: ok. gofmt -l clean; go vet darwin, GOOS=linux -tags nogui,
GOOS=windows; go build darwin, linux nogui, windows.
Real use: the built binary on a sandbox HOME with a generated 50,000-call
7-day usage.jsonl: --csv 7d 47,233 rows / 6.97 MB; today 4,376; --last
24h 7,140 / 1.05 MB; --last 90m 444; --days 1.5 10,712; --account me@x
--last 24h 3,570 (that account's half); oldest row of each at the
window's start.
Not tried: the full go test ./... suite; the process still parses the
whole usage.jsonl into its in-memory index on each run (as every period
does), so the cut is in rows decoded and written, not bytes read.
Co-authored-by: fchengyan <3181088318@qq.com>
|
||
|
|
9f8ad6edb8 |
gateway: the model's text between a batch's tool calls goes ahead of the batch's first call, so OpenCode Go stops answering "No tool output found" (#2100, eugene1003)
What: joinToolRuns (responses.go), which mends a relayed Responses
request's tool runs in attempt before every destination, now moves an
assistant message the model wrote between its own calls, before the run's
first result, to just ahead of the run's first call, together with the
reasoning items right before it (so a reasoning item keeps the item that
followed it). The reporter's Codex rollout was
[text, call_A, text, call_B, out_A, out_B]; it reaches the upstream as
[text, text, call_A, call_B, out_A, out_B]. Reasoning alone between calls,
hosted calls and anything carrying a call_id stay where they were (#1752's
review note), and V2 (text after out_A, between whole exchanges) and V3
(calls together) go byte for byte.
Why: magpie relays deepseek-v4.1-flash at OpenCode Go to its /responses
(models.dev names no SDK for it, so every API may be tried, and #1822's
turn shows Go's DeepSeek answering there). Go builds a chat form in which
an assistant message after a call opens a new assistant message, so the
first one's tool_calls were followed by no tool message: 400 "No tool
output found for tool call call_aaaa1111" - the same text joinToolRuns'
comment already lists for Go. The translation to a Chat upstream was
already right on main (joinSplitCalls + mergeTurns join the step into one
assistant message); TestTextBetweenABatchsCallsStaysInItsStep now guards
it with the reporter's shape. Native ChatGPT sign-ins don't go through
joinToolRuns. Moved plugins get the relayed body after attempt, so they
get the change too; no plugin translator was touched.
Run:
- TestRelayedTextBetweenABatchsCallsIsAnswered (V1-V4, fake upstream that
checks the exchange as Go does) and the new TestJoinToolRunsOnlyMoves...
cases fail on origin/main
|
||
|
|
11b1fb1db7 |
cli: magpie quota refresh <provider> [<account>] reads that card again, as its refresh button does (#2104)
magpie quota refresh <provider> [<account>] [--json] runs the Usage card's
refresh (RefreshUsage's path) from a terminal and prints that card alone;
no other vendor is asked. provider.RefreshReport returns the read's own
cards (refreshCards, shared with RefreshUsage), since a fresh process's
caches don't hold a partial read's subscription and plan cards. A second
refresh of the same card within 30s asks nobody and prints the kept
reading, saying so on stderr; the times live in the cache dir's
quota-refresh.json, so the gap holds across processes. --json prints
magpie quota --json's shape, with readAt and error. The account may be a
login, an alias or <provider>/<account>.
Run:
- go test -tags nogui ./internal/cli ./internal/provider ./internal/tui:
ok (provider 591s under load ~200; an earlier run hit the 600s default
timeout, the rerun with -timeout 25m passed)
- TestQuotaRefreshReadsOneCard / TestQuotaRefreshGapPerCard; with the gap
check disabled by hand the first goes red ("asked a 2 times")
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on the
three packages
- the built binary in a sandbox HOME (MAGPIE_ADDR=127.0.0.1:47614) against
a local fake balance endpoint: refresh free-relay showed 12.50; a second
run at once didn't hit the endpoint and said so; after 31s it read 11.00;
"Free Relay" resolved by name; --json carried readAt, and a 404 gave
"error": "404 Not Found"; an unknown provider exits 1.
Not tried: a real subscription (Codex, Claude) or a remote magpie's cards.
Reading from the caches instead of RefreshReport doesn't turn the test red
for a key balance (its cache holds the read in-process); the subscription
path that needs it is covered by reading only, not by a test.
|
||
|
|
5654c8187c |
agent: while Claude Desktop is on magpie, Explore inherits Desktop's mythos-magpie model instead of being capped to Opus (#2087, NeuroPaw)
Claude Desktop lists models with effort levels as mythos-magpie-* so its
effort picker shows. Claude Code 2.1.295's built-in Explore (model:
"inherit") caps its inherited model at Opus when the session model's family
ranks above Opus (pge/BHn: {inheritCap:"opus"}), so an Explore with no model
of its own went to Desktop's Opus default, a different route. Claude Code
skips that cap when CLAUDE_CODE_DISABLE_EXPLORE_INHERIT_CAP is set.
magpie now writes CLAUDE_CODE_DISABLE_EXPLORE_INHERIT_CAP="1" into Claude
Code's settings env while this machine's Desktop is on magpie (writeExplore
in claudeIn: Desktop alone, model picks and Sync), and removes it when
Desktop is taken off, only if it is still magpie's own "1". A value the user
had (an empty one too) or changed later stays. The stash key
claude.explore_inherit_cap marks magpie's value. WSL twins don't get it.
Checked in the installed Claude Code 2.1.295 binary (read only): the env is
read in pge() before the cap, and it is not in the set host-managed sessions
(CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST, Desktop's Code tab) drop from settings
env (eu: oV, N$, F$, hdt model list, ... none hold it), so Desktop's Code
tab honours it. Renaming the alias was not chosen: Desktop's effort picker
needs it. The settings file is shared, so a terminal Claude Code session on
a real Fable model also inherits without the cap while Desktop is on.
Patch by NeuroPaw (1b480ef3), applied unchanged.
Run (sandbox HOME, pinned GOMODCACHE, private GOCACHE):
- TestClaudeDesktopExploreInheritCap, TestClaudeDesktopExploreKeepsUserValue
pass. Broken by hand four ways, each a real FAIL: no write ("value "",
present false; want "1", true"), overwriting the user's value ("user's
Explore value "0" lost: "1""), never removing ("value "1" ... want "",
false"), removing a value that isn't magpie's ("user's Explore value "0"
lost: """).
- go test -tags nogui ./internal/agent (1337s, load ~260) and
./internal/agentenv: ok. An earlier run of internal/agent hit the default
10m timeout under that load; with -timeout 45m it passed.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on
internal/agent; GOOS=linux -tags nogui and GOOS=windows go build.
Not tried: a real Claude Desktop Code session with the built magpie; the
full go test ./... suite.
Co-authored-by: NeuroPaw <link_xin@163.com>
|
||
|
|
caa5367336 |
gateway: a remote magpie's quota, credit or rate refusal rests only that model, not the whole remote (bigsteven on Discord)
A Remote magpie provider (LAN share) serves every model through one key. When it answered 429 "usage limit … resets in 3 hours" for one model, the key rested whole for those 3 hours. A group then never moved on to the remote's other models that still had quota, and the user had to ask again by hand. The remote magpie rests its own providers' models itself, so one model out of quota there says nothing of its others. remoteModelRest: on a Remote magpie provider, failQuota, failCredit and failRate rest c.restID() (the model) in restAfterMarked and rateRest. A refused key or an unreachable computer still rests the whole remote. Run: - TestRemoteMagpieQuotaRestsTheModel, against a fake remote whose codex model answers 429 quota, glm 429 rate, and kimi OK. A direct request, then two groups. It fails with remoteModelRest taken out. - go test -tags nogui -count=1 -timeout 30m ./internal/gateway: ok. - gofmt -l is clean. go vet passes on darwin, GOOS=linux -tags nogui and GOOS=windows. Not tried: two real computers on a LAN share. |
||
|
|
c77d198a81 |
gateway: a Google account's Code Assist 404 for a model rests that model, not the account (Packing1 on Discord)
Google's fetchAvailableModels lists models the account's plan doesn't serve (Argon on Google AI Pro). Asked for one, Code Assist answers 404 NOT_FOUND "Requested entity was not found." Its endpoint is the same for every model, so what is missing is the model, but the 404 counted as failOther and rested the whole Antigravity / Gemini CLI account, taking its other models down with it. codeAssistModelMissing (built-in antigravity/gemini accounts only, not a plugin) makes that 404 "unserved": only that model rests on that account, and the request moves on to the next candidate. Run: - TestCodeAssistMissingModelRestsTheModel. It fails with the check taken out, because the account rests. - go test -tags nogui -count=1 -timeout 30m ./internal/gateway: ok. - gofmt -l is clean. go vet passes on darwin, GOOS=linux -tags nogui and GOOS=windows. Not tried: a real Google AI Pro account, or the real 404 body. The fixture's body follows Google's documented NOT_FOUND error shape. |
||
|
|
79f64f028e |
gateway: Claude Code's advisor goes to a relayed Claude upstream under the upstream's own model name, or is left out (JackChou on Discord)
Claude Code (2.1.299, seen against a fake server in a sandbox HOME) declares
the advisor as Anthropic's server tool {"type":"advisor_20260301",
"name":"advisor","model":"claude/claude-opus-5-5"} with the beta
advisor-tool-2026-03-01. The model is magpie's id, which no vendor knows,
so a relayed Messages request carrying it was refused whole.
passthrough now runs advisorTools on Anthropic upstreams. An advisor model
that is one of the same provider's Claude models goes as that upstream's
own name for it (the wires, as the request's own model). So does a bare
Claude id that names no provider, and the [1m] mark is dropped. An advisor
the upstream can't run (another provider's model, a group, a model that
isn't Claude), and every advisor when the request's own model isn't
Claude, is left out. If no tools are left, tools and tool_choice go too.
Translated routes already drop server tools (anthropic.go). The Claude
subscription's bridge declares only magpie's tools, so it never has an
advisor. Nothing is sent to Anthropic with a user's token.
Claude Code's own gate: without CLAUDE_CODE_ENABLE_EXPERIMENTAL_ADVISOR_TOOL=1
it sends no advisor for a model with no advisor rank in its catalog ("Switch
to a public model alias (opus, sonnet, fable)"). That is unchanged here.
Run: TestAdvisorModelAsTheUpstreamNamesIt (same provider, [1m], bare
Claude id kept, another provider left out, vendor model left out, other
tools kept). It fails with advisorTools taken out of passthrough.
gofmt -l clean. go vet for darwin, GOOS=linux -tags nogui and GOOS=windows
on ./internal/gateway. go test -tags nogui ./... under a sandbox HOME at
load ~90: every package passed except agent and gateway, which hit the
10m timeout, and TestCopilotSecretToolUsername (its two 5s secret-tool
waits ran out under that load). Rerun with -timeout 30m, gateway, agent
and provider all pass.
Not tried: a real Anthropic or relay upstream, and a running magpie with
real Claude Code end to end.
|
||
|
|
88ce2cdd4c |
gateway: a web search's query is masked before it goes to a search API, Kimi Code's or WorkBuddy's search (lc on Discord)
lc on Discord: "mcp 搜索出去的脱敏了吗?" A searcher model is asked through serve, which masks its request, and the image and vision MCPs go through the masked routes too. But the search APIs (Tavily, Brave, Exa, Firecrawl, SearXNG, ...), a Kimi Code plan's search service and WorkBuddy's search were sent the query as it came. A model's own web_search writes its query from a request already masked, but an agent's call to the search MCP carries the query as the agent's model wrote it, with the values put back, so a secret or phone number in it went out as written. maskedQuery masks the query, as Settings say, where it leaves magpie for each of those three (a plan the user set to go unmasked, SkipsRedaction, keeps it), and searchMCPRun puts the values back in what it returns to the agent. Scoped by where the value goes (the query field of a search service's request), not by a key's name. Run: TestSearchQueryMasked; each of the four changes removed alone turns it red (search API, Kimi, WorkBuddy asked the phone number; the agent got the placeholder back). -run 'Search|Redact|Kimi|WorkBuddy|MCP' over internal/gateway (sandbox HOME); gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows. docs/subsystems/gateway-routing.md says it. Not tried: a real search API or a real agent's MCP call. |
||
|
|
2fbbd16945 |
gateway, gui: routing history keeps the last two levels of the folder an agent works in, and By session, the stage and the panel name it (#1068, emo172)
Routes now carry Folder: the last two levels of the working directory the agent states (Claude Code's "Primary working directory", Codex's <cwd>, Pi, OpenCode), cut by shortFolder before the route is stored, so no full path reaches the routing history, /api, or the GUI. It is kept in the routing history for as long as the history itself (30 days / 200 MB). A request that states no folder (title, side calls) takes the folder its session (or parent session) last stated; the per-session map is capped at 512 entries. GUI: By session headings read "Agent · folder · title", their tooltip and every request row's tooltip (page and tray panel) name the folder, the stage's agent subtitle lists the last level of each folder when an agent works in more than one, and the panel's agent node tooltip lists them. Run: - TestShortFolder (unix, trailing slash, C:\, D:\, UNC, CJK with spaces) and TestRouteKeepsItsFolderShort (real Handler, fake upstream: session inheritance, a moved Windows path, nothing of the full path in the marshalled routes, saveRoute -> History round trip), TestTurnDone. Broke it by hand: without the session lookup the title request has no folder; with the folder unshortened the full path shows. Both go red. - routing-session-folder.test.cjs: chromium + webkit x en, zh, zh-TW, ja, de x 1100 and 420 px, 20/20. Red on the old routing.js and with the stage's live routes left out. - GUI suites routing-*, panel-routing*, purpose-filter, reasoning-speed, gui-de/ja/zh-tw, click-scroll, number-units: 951/951. - gofmt -l clean; go vet darwin, linux (nogui), windows; builds for all three. go test -tags nogui ./...: all ok except internal/gateway, which hit go test's default 10m timeout at 611s on a loaded machine (#2108); alone with -timeout 30m it passes in 356s. - Real use: nogui build in a sandbox HOME, fake upstream, real Claude Code 2.1.299 (claude -p) run from .../workspace/magpie and .../src/dial: the day's routing jsonl has folder "workspace/magpie" and "src/dial" and no part of the sandbox path above them. Not tried: title/side requests' inheritance end to end with a real agent (claude -p made none), Codex, OpenCode and Pi with real binaries, Windows. |
||
|
|
d9ca84a2f4 |
gateway: built-in TLS, magpie serve/web/daemon install --tls-cert --tls-key, reloaded on renewal (RoderickZH)
magpie serve, magpie web and magpie daemon install take --tls-cert <file> --tls-key <file> (or MAGPIE_TLS_CERT / MAGPIE_TLS_KEY). The gateway and the web UI on its listener then serve HTTPS to other computers. Without them nothing changes. - Half a pair, a file that doesn't parse, or a flag with no value is refused at start with a message naming the missing flag. - The pair is re-read when either file's mtime or size changes (certbot renewal), with no restart. A renewal that doesn't parse keeps the certificate already served and is logged once. - Other computers get HTTPS only. Plain HTTP from them gets net/http's 400 "Client sent an HTTP request to an HTTPS server". - This computer (loopback, or a peer address equal to the local one) may still use plain http on the same port. Its connections are sniffed on their own goroutine (a first byte of 0x16 is TLS) for up to 10s, so a silent client holds nobody else up. gateway.URL() stays http://127.0.0.1:<port>, which agents, MCP servers, ServedBy, the healthcheck and daemon status all use, and no certificate covers loopback. - WSL NAT and containers count as other computers. - ALPN is http/1.1 only (hijacked connections and websockets need it), with TLS 1.2 as the minimum. - Printed links, LAN addresses, publicURL, the serve/web banners and daemon install show https:// for other computers' addresses. - The DNS-rebinding Host checks (foreignPage, rebound, the MCP loopbackHost) don't depend on the scheme and are unchanged. - daemon install carries MAGPIE_TLS_* into the unit or plist. A reinstall or `daemon web on` that names no certificate keeps the installed pair, and --no-tls removes it. - Docs: reference.md gets an HTTPS section that names Caddy as the alternative, gateway-routing.md gets a TLS row, and docker.html (en, zh, ja) gets the env rows. What was run: - New tests: internal/gateway/tls_test.go (others HTTPS-only, this computer both, a silent local client holds no other, renewed certificate served, CheckTLS, addresses, Relisten keeps TLS), internal/cli/tls_cli_test.go and daemon TestInstallCarriesTLS (linux and darwin, paths with space, %, & and "). - Each was broken by hand and went red: no wrap in listen, no reload, a synchronous sniff, a bad renewal dropping the certificate, http in publicURL or the pinned LANURLs, the carried entries removed, and keepTLS as a no-op. - Real use under a sandbox HOME, with a self-signed pair, on 0.0.0.0:3461: - Half a pair, a garbage certificate, a flag with no value, and the env set to half a pair each exit 1 with the message. - curl -k https://127.0.0.1 and https://<LAN IP>/v1/models with a key: 200. Plain http on loopback: 200. - The cert files were swapped for a second pair while it ran. openssl s_client then showed the new CN and serial, and curl --cacert with the new pair got 200. A junk key file then kept the second pair, logged once. - From the Windows box over the LAN: plain http got 400; https with the key got 200, and without it 401. - magpie web --addr 0.0.0.0:3462: https network links. From Windows, http got 400 and https with the key got 303. - gofmt -l clean. go vet passed on darwin, GOOS=linux -tags nogui and GOOS=windows. - go test -tags nogui for ./internal/cli, ./internal/daemon, and the TLS tests of ./internal/gateway and ./internal/gui: all pass at the rebased head. - Two reds in the full suite (`go test -tags nogui ./...`) are the same on origin/main f074996d9; both are filed: - TestGatewayHeldByAContainer failed 2 of 5 there (#2107). - The gateway package runs past go test's default 10m under load: 1208s on main and 1221s here, both passing with -timeout 40m (#2108). |
||
|
|
579de3baa0 |
agent: enabledModels lose a deselected model's entries after the catalog sync (#2055)
misaka9981: models deselected in a provider's editor left magpie's provider in Pi's models.json, but their magpie/<provider>/<model> entries stayed in settings.json's enabledModels, and Pi warned "No models match pattern" for each at every start. Pi's resolver (model-resolver.js resolveModelScope, 1.1.0) only warns, never prunes. After the sync writes magpie's provider block, an enabledModels entry that names one of magpie's models outright (no glob; a thinking level read off) whose model the block no longer has is taken out. As the entry may be the user's own, it is remembered in stash.json (<agent>.scope.gone) and goes back on the list's end once the model is offered again; a provider rename moves the remembered entries too and a disconnect forgets them. Globs, entries on other providers and on models still offered stay, in order, comments kept. A list left with nothing is removed (never written []) and made again when its entries come back, with the model picked meanwhile; a list the user removed isn't made again. When the agent's model list can't be read, nothing is taken out. The same holds for the siblings with such a list: OmO and Prime Agent (piLike), StepCode (config.toml; its wiring state's last scope follows, so a disconnect still puts the user's list back) and omp (config.yml's plain entries; folder-scoped entries are left alone). Run: - TestPiEnabledModelsLoseDeselected (pi, omo, prime-agent) with the reporter's provider and four models, beside the user's own entries (another provider at a level, a magpie glob, a model still offered at a level): deselect, select again, rename. TestPiEnabledModelsEmptiedAndBack: emptied and back; removed by the user stays removed; other providers' and globs' file byte for byte; an unreadable models.json prunes nothing. TestStepCodeAndOmpEnabledModelsLoseDeselected, StepCode's disconnect putting the original list back included. - TestPiEnabledModelsFollowRename and TestStepCodeEnabledModelsFollowRename keep a magpie/deepseekx/flash entry to show a rename leaves a name sharing a prefix alone; deepseekx is now a real provider there, as the sync would otherwise (rightly) take an entry naming nothing out. - Broken by hand, each red: Pi's, StepCode's and omp's Sync hook off; the put-back off; the rename of remembered entries off. - Real Pi 1.1.0 (@earendil-works/pi-coding-agent) under a sandbox HOME, `pi -p`: the stale exact entries gave the reporter's warnings; the list as pruned gave none. - gofmt -l clean; go vet darwin, linux -tags nogui, windows; go test -tags nogui ./... green on origin/main |
||
|
|
353464f161 |
gateway: a translated Anthropic or Responses reply that said nothing and counted no token is asked again, then fails, not completed (#2086, tensornull)
tensornull's Codex turn on an Anthropic-compatible proxy (baseAPI anthropic, claude-opus-5-5) ended as response.completed after 21s with no output: the route had status 200, no usage, no served model, no ttft. Codex took it as its turn's end (last_agent_message null) and didn't ask again. No usage and no served model mean the proxy never sent a message_start Claude would have (it counts the prompt and names the model), yet the stream said it ended (message_stop or a stop_reason), so 320af9858's replyEnds read it as whole and errEndedShort didn't apply. Now a reply from an Anthropic or Responses upstream (repliesCounted) that said nothing (no text, call, search or image) and counted no token at all (uncounted) is the empty reply #667 already handles for Gemini: asked again in place, then failed with "an empty reply (the model answered nothing; try again)", which Codex retries. Same in streamTranslated and the unstreamed translate path, for Responses, Messages and Chat clients. Claude's own empty end_turn (after a tool's result) counts its prompt and still completes, as does a Responses reply with usage and no output. Not changed: a reply passed through in its own protocol (Codex asking a Responses provider, Claude Code an Anthropic one) isn't read for this; the passthrough has no empty-reply rule at all, Gemini's included. Verified: - New stream_uncounted_test.go. TestUncountedEmptyReplyFails (message_stop only; pings then message_stop; message_start with no usage then a stop_reason; zero usage), TestUncountedResponsesReplyFails and TestUncountedEmptyReplyFailsEveryClient (Chat streamed, Responses and Chat unstreamed) all FAIL on the old code ("ended response.completed \"completed\", want response.failed", "status 200, want the empty reply's failure") and pass with the change. TestCountedEmptyReplyStillCompletes and the #1933 tests (TestWellFormedStreamsStillComplete, TestMalformed*) pass. - The full go test -tags nogui ./internal/gateway run failed only TestCodexHeadersReachKeyedRelay and TestStandaloneNativeAccounts, whose fake Codex backends answered response.completed with output [] and no usage, which the real backend never sends; their fakes now count tokens, and both pass. Run in a sandbox HOME with pinned caches; gofmt -l; go vet ./internal/gateway for darwin, GOOS=linux -tags nogui and GOOS=windows; GOOS=linux go build -tags nogui and GOOS=windows go build. - Not tried: the reporter's proxy or its real bytes (the report has none); the fixtures are the shapes its route record allows. Not run: the full go test ./... (only internal/gateway changed). |
||
|
|
e710c5accd |
gateway: the built-in Kiro tells Kiro where to cache the prompt (magpie-community/plugins#110)
plugins#110 ("kiro cli cache 率为 0"): a Kiro subscription read nothing
from its prompt cache. Kiro's generateAssistantResponse takes Bedrock's
cachePoint {"type":"default"} on a userInputMessage (the CodeWhisperer
streaming model in aws/amazon-q-developer-cli; Kiro CLI 2.27's model list
carries PromptCaching with up to 4 checkpoints), but neither the plugin
nor the built-in ever sent one. The plugin's fix is kiro 0.1.10
(plugins 386a2ba); this is the same for users who haven't moved.
buildKiro now marks the first message when there is a system prompt
(which it folds into that message) and the current message, the two
places buildAnthropic marks for Anthropic. gateway-routing.md says how
each Kiro path places them.
Run: gofmt -l (clean); go vet on darwin, GOOS=linux GOARCH=amd64 -tags
nogui and GOOS=windows for internal/gateway and internal/provider; go
test -count=1 ./internal/gateway ./internal/provider (ok; both isolate
HOME in TestMain). TestBuildKiroMarksTheCache fails with the current
message's mark taken out by hand, and passes with it back.
Not tried: a real Kiro account (none signed in here), so whether Kiro
then reports cache reads is for the reporter to confirm; kirocc#83 notes
Kiro often sends a metadataEvent with no token counts.
|
||
|
|
33da86c71a |
provider: removing a plugin sets its providers' model picks in providers.json aside, and adding it again puts them back (#2057, dawn1095)
A plugin's provider leaves a record in providers.json once the user picks its models: its id and nothing of its own (OnlyPicks). Removing the plugin left those records behind. Nothing listed them, `magpie provider rm` couldn't reach them, and a sync or backup asked for a sign-in to them on every run. RemovePlugin now finds the ids the plugin's providers are stored under (PluginID of each provider plugin.Listed gives for its spec), and moves the records with those ids that hold only picks into providers.json's new pluginLeft, under the plugin's package name. Left alone: - any record with an endpoint or a key (the user's own provider, whatever its id); - a built-in's ids (accountIDs) and "magpie"; - an id another installed plugin serves too; - everything, when the plugins' listing isn't known (no cache and no plugin-providers.json): unknown is not "none is the user's". provider.AddPlugin (CLI, GUI, backup restore) puts the set-aside records back, each one whose id has no record now; one the user has given to a provider since stays aside. plugin.Listed is new: the cached listing, or plugin-providers.json. Run: - plugin_left_test.go, four tests with user-owned records beside the plugin's (a user "zap" with an endpoint next to the plugin's zap-plugin, a hand-made "mine", a built-in's picks, another plugin's and a shared id). Each guarantee broken by hand turned its test red: no set-aside, no OnlyPicks check, no other-plugin exclusion, no unknown-listing guard, take-back over the user's record, no take-back. - go test ./... in a sandbox HOME; gofmt -l; go vet darwin, linux (-tags nogui), windows. Not done: records left by plugins removed before this change stay where they are; turning a plugin off (not removing it) sets nothing aside; `magpie provider rm` still can't name such a leftover. The move flow (installPlugin) still adds through plugin.Add, since its own migration owns those records. Not tried with a real plugin removal in the GUI. |
||
|
|
3a7d0314a9 |
usage: a window's Pace as a number on its card, and in the menu bar when asked (fflake33)
fflake33 on Discord asked for the pace as a figure, "+12%" or "−8%"
against an even pace through the window, on the Usage cards and in the
menu bar.
- provider: QuotaWindow.Pace(readAt, now) is the share used (0-100) less
the share of the window gone by, from Bounds (reset less span; a
month's window a calendar month); none for an unlimited window, one
whose span or reset isn't known, or outside it. WithWindowStarts sets
startsAt on copies of the cards for the GUI (the caches' cards are
left alone); /api/usage/quotas and its refresh send it.
- Usage page: "Pace +20%" on the reset line after the wait (quotaPace,
paceLine), its sign turned with the meter in Left mode, amber while
more is used than an even pace would have, what it means in its
tooltip. Past cycles and windows with no known start show none.
- Menu bar: Settings > Menu bar pace (settings.TrayPace, off by default;
hidden on Windows, whose tray shows no text) puts " +12%" beside each
figure ("42% −14%", at most 10 runes, trayRowMax) and "pace −14%" in
the tooltip. KeepOwn keeps it device-local like the other tray
settings; the Settings save keeps it (prefsKeep).
- Strings in en, zh, zh-TW, ja, de. gui-shell.md says it.
Run:
- go test -tags nogui ./internal/provider ./internal/gui ./internal/settings
./internal/usage: ok; ./internal/davsync: ok (now covers TrayPace;
red with TrayPace taken out of KeepOwn). go test ./internal/gui -run
Tray (darwin, with the tray image tests): ok.
- New TestWindowPace, TestWithWindowStarts (input not mutated),
TestTrayUsagePace (off unchanged, used and left, rows, tooltip).
- quota-pace.test.cjs, chromium and webkit: 4 pass; cards in en, zh,
zh-TW, ja, de at 1100 and 420px, used and left, amber, tooltips, no
sideways scroll, a click moves nothing; the Settings row in all five
at both widths, On posts trayPace, a currency save keeps it, no
scroll; hidden with no card and on Windows, shown on Linux. Red with
paceLine not called, with trayPace out of prefsKeep, and with the
Left-mode sign not turned.
- gui-de, gui-ja, gui-zh-tw, i18n-keys: 12 pass; tray-bird 6, quota-holds
2, quota-read-at 4 pass.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean.
Not tried: the real menu bar on a Mac or Linux tray.
|