4794de398ea8337d223a91e207181c56fcf4ad76
442
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3a9d73c5c6 |
gateway: a plugin's deferred usage is billed with its step, never told as the prompt
The Cursor plugin collects a tool step's late usage event with the conversation's next step. It used to add it to that step's prompt_tokens, which agents read as how full their context is: pi saw 366940 tokens (181270 + 185670) on a 300k window where 185670 were in use, and compacted. The plugin now reports it apart, as usage.magpie_deferred (yetone/magpie#1053). The gateway parses the field into Usage.Deferred and adds it only where it bills: the usage records (6 sites in serve), the OTel attempt span and route pricing, as a tier before the request's own, so promptCounted still reads the request's own prompt. What a client is told (Usage.chat, the Anthropic encoding) stays the request's own. A reply without the field is handled as before. docs/subsystems/provider-plugins.md describes the field. Verified: go test -tags nogui ./... (50 packages ok, sandbox HOME, caches pinned); gofmt; go vet on darwin, linux (nogui) and windows; go build on the same three. The new tests were broken by hand and each went red: billed() ignoring Deferred, cUsage dropping the field, routeUsage without the tier, Usage.add forgetting it, the decoder ignoring a usage with only a deferred part, the usage records and the OTel span not using billed(). Not tried: a real Cursor account on this checkout; the plugin side was run against real Cursor (composer-2.5, forced late events), where the deferred totals matched the dashboard's events token for token. Picked from geoqiao/magpie cursor-deferred-usage (595d6384c), as PRs here are collaborators-only. Rebased over the service-tier logging (#1784), keeping its TierAsked/TierSent/TierServed beside billed() at the three usage.Record sites, and Usage's Tier beside Deferred. Run on this tree: go test -tags nogui -timeout 40m ./internal/gateway and ./internal/provider (sandbox HOME); gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows. billed() forced to ignore Deferred: 3 tests and 5 subtests of deferred_usage_test.go go red. |
||
|
|
ab1006bb80 |
gui: each WorkBuddy, Trae CN, MiniMax, Qoder or plugin account's daily check-in can be turned off on its own (#1902, magicLaLa)
settings.CheckinOff lists the accounts left out, by their entry in the
vendor's check-in file ("workbuddy|<uid>", "trae-cn|<uid>", a plugin's
"<provider>|<account>"). checkinNow skips them, both in the loop and on
Check in now. provider.CheckinAccounts() lists every account a check-in
reaches; /api/settings carries it as checkinAccounts, and
POST /api/settings/checkin-account {key,on} turns one off or on. A full
/api/settings save keeps the list. Settings shows an Off/On switch per
account under each vendor's Daily check-in row when it has 2 or more
accounts; the Usage card says "Auto check-in is off for this account" and
offers no Check in now for it. en, zh, zh-TW, ja, de.
Run (on 63a361b5f's tree, then targeted again on
|
||
|
|
d6fd9b3a36 |
provider, agent, gui, cli: Codex can switch only its own sign-in between accounts, never through the gateway (#1907, foobra)
foobra wants Codex Desktop and the CLI kept on their own ChatGPT subscription, moved to the next saved account when the signed-in one is used up and back when it resets, without magpie's gateway in the way. magpie already did the switch (codex_switch.go: 98%, 100% In order, back under 90%, unknown usage never switches), but with more than one Codex account on it also wrote openai_base_url into config.toml so a refused request fails over through the gateway (codexFailover). There was no way to have the first without the second. Now Codex's subscription has SwitchOnly (providers.json "switchOnly", opt-in, off by default so nothing changes for anyone who doesn't tick it): - provider.SetSwitchOnly / provider.SwitchOnly; only Codex's own subscription takes it. An unreadable providers.json reads as on, so magpie's own failover is never written on a guess. - agent.codexFailover is false when it is on: no openai_base_url, no failover note, no magpie models in Codex's list. A base URL the user wrote stays. - The account Save copy keeps it. - GUI: "Only switch Codex's sign-in" tick under Providers > Codex's accounts (with more than one on), posting provider/switchonly; the Agents row's failover title points at it. zh, zh-TW, ja, de. - CLI: magpie accounts switch-only codex [on|off]. - docs/reference.md and providers-accounts.md say what it does and that an open Codex app or app-server stays on its account until reopened. Run (darwin, sandbox HOME, -tags nogui): - go test ./internal/provider -run 'TestCodexSwitchOnly|TestCodexSwitchedWhenUsedUp|KeepLogin' - go test ./internal/agent -run 'TestCodexSwitchOnly|TestCodexFailover|TestCodexOwnModelThroughMagpie|TestCodexHandWritten' - Broken by hand, each red: codexFailover guard removed (agent test), SwitchOnly dropped from the Save copy, SwitchOnly reading false on an unreadable file (provider test), the tick drawn unticked (GUI, 16/16). - GUI: switch-only (new), keep-login, agent-failover, gui-ja, gui-de, gui-zh-tw in Chromium and WebKit, en/zh/ja/de at 1100 and 420: 77 pass. - The built binary's `accounts switch-only` in an empty sandbox HOME: reads off, refuses on with no Codex provider, refuses claude. - gofmt -l clean; darwin go vet. Reviewed and rerun after rebasing onto |
||
|
|
30869e35a7 |
usage, gateway: each request's log row says the service tier asked, the one each try was sent at, and the one the vendor said it ran at (#1784, zhenghaowen0967)
What changed
- usage.Record has tier_asked, tier_sent and tier_served, and the CSV gets
them as its last three columns.
- tier_asked is the client body's service_tier (Claude's speed fast reads
"fast").
- tier_sent is the tier the try's last request actually went out at. It
is noted in forwardOnce after every rewrite (a fast pick's priority,
Ultrafast turned to priority on a plan without it, buildResponses
dropping a tier the host can't take) onto the per-attempt wireAt. So a
handed-on try's own row has its own tier.
- tier_served is only what the reply said: service_tier at the top level,
in response.service_tier, or in an Anthropic usage. It is read by the
relay sniffer and by both translated readers, and is empty when the
reply says nothing. It is never filled in from the ask.
- Codex's own relayed sign-in (codex_backend) records the same three.
- /v1/magpie/route: Route.tier (asked), and each Try has tier and
tierServed. The session route has asked_tier, tier, tier_served and each
try's tier and tier_served.
- docs/reference.md (CSV columns) and gateway-routing.md describe them.
Why
zhenghaowen0967 asked that a request whose Ultrafast was sent as priority
to an account without it show that in usage, per try, without calling
the served tier confirmed unless the reply says so.
What was run
- TestTierRecordedPerTry. With Pro out, the first try is recorded
ultrafast, the second priority, and the final record has asked=ultrafast,
sent=priority and served empty while the fake doesn't echo. With an
echoing fake, served is what it said ("ultrafast", and "default" when
none was asked). It also checks the CSV columns, and the Codex relay path
with priority.
- TestUpstreamTierShapes covers the Chat chunk, Responses
response.completed, a Responses body, an Anthropic message_start and
message_delta usage, null, an over-long tier and non-JSON, as well as
bodyTier per protocol.
- Broke it by hand:
- with forwardOnce's noteWireTier removed, TestTierRecordedPerTry goes
red (route tries' tier empty, TierSent empty);
- with the sniffer's Tier line removed, TestUpstreamTierShapes goes red,
and so does the Codex relay case of TestTierRecordedPerTry.
- go test -tags nogui ./internal/gateway ./internal/usage ./internal/cli;
ledger_test's CSV expectations gain the three empty columns.
- gofmt -l; go vet on darwin; GOOS=linux and GOOS=windows go vet -tags
nogui.
Not done
- The served-tier fixtures are built from the shapes OpenAI and Anthropic
document, not from saved replies. Whether chatgpt.com's Codex backend
echoes service_tier wasn't tried against a real account.
- Bridges that don't go through forwardOnce (the Claude subscription,
Cursor's built-in) leave tier_sent empty.
- There is no price multiplier for priority/ultrafast and no GUI column.
|
||
|
|
62390fe92e |
redact: a masked word is never masked inside tool definitions or schemas, so Codex's apply_patch grammar reaches OpenAI intact (#1911, loveNangua)
What changed: MaskJSON masked custom words as raw substrings in every
string of the request, tool definitions included. A word "pd" turned
apply_patch's Lark rule name update_hunk into u{{TERM_..}}ate_hunk and
OpenAI refused the request with 400 "Invalid lark grammar". Definitions
are now kept by where they sit in the protocol, not by a key's name:
the request's top-level tools, tool_choice, functions, function_call,
toolConfig/tool_config, response_format, text (an object), reasoning,
include, output_format, output_config and generationConfig, and the
tools of a Responses input item of type additional_tools or
tool_search_output. Inside them only "description" strings are still
masked. A "tools" or "text" key in tool-call arguments, a message, a
Gemini part or a Responses message item is masked as before.
Run: go test ./internal/redact/ ./internal/provider/ (ok). The new
tests use Codex 0.162.1's real request (copied from the gateway's
testdata) with the top-level tools and as a Responses Lite
additional_tools item, plus Anthropic/Chat/Responses/Gemini schema
cases and negative cases. With the old json.go both tests fail
(update_hunk masked, every schema case changed). gofmt -l clean; go vet
-tags nogui on darwin, linux and windows. Not tried: a real request to
OpenAI with the word set.
|
||
|
|
488569227e |
zhipu: a GLM Coding Plan key at the pay-as-you-go endpoint is asked again at the plan's, and the provider moves there
@cleverpigo on X: "glm coding plan放在codex/chatgpt里显示余额不足没法用". The editor
showed OpenAI https://open.bigmodel.cn/... red with 429 · 余额不足或无可用资源包,
请充值。 next to a green Anthropic https://open.bigmodel.cn/api/anthropic.
Root cause: the zhipu and zai presets start on their first region, Pay as
you go, whose OpenAI URL is /api/paas/v4. The Anthropic URL is the same in
both regions, and it bills the Coding Plan when the account has one. So a
Coding Plan key left at the default works in Claude Code, while Codex goes
to /api/paas/v4 and Zhipu answers 429 code 1113 (no balance). A provider
made by pasting the paas/v4 URL hits the same wall. Nothing in the key
says which kind it is. LESSONS.md's
|
||
|
|
81f587d7be |
sessions: omp's sessions in a WSL distro are listed on Windows, on the Sessions page and in Usage's Sessions tab, as Claude Code's, Codex's and Pi's there already are (#1150, #1138)
omp keeps its sessions under ~/.omp/agent in the distro's home, and in
a profile's own folder for omp --profile. wslAgents now names omp, and
allFiles reads wslFiles("pi", "omp"), so a distro's omp sessions show on
Windows marked with their distro and resume through wsl.exe. A session
under a profile resumes with omp --profile <name> --resume <id>; a
profile name that isn't plain ([a-z0-9][a-z0-9._-]{0,63}) gets no resume
command rather than one built from it (resumeCommand takes the session's
path for this).
Squashed from yetone/magpie#1150 at d7968f11b2ef419e30e1a6a169554b12e58c885a
onto main; docs/subsystems/gui-shell.md conflicted and keeps main's
"Streamed output speed" section and the PR's "Stored agent sessions in
WSL" section.
Run at this tree: gofmt; go vet darwin, GOOS=linux -tags nogui,
GOOS=windows; builds for all three; go test -tags nogui on
internal/sessions, internal/gui and internal/agent (agent with
-timeout 45m, it took 17 min on a loaded machine) green.
Broken by hand: with omp taken out of wslAgents, TestWSLSessionsListed,
TestWSLOmpSessionDeleted, TestWSLOmpProfiles, TestWSLStoppedDistroKept
and TestWSLStoppedSinceNotOpened go red.
Not tried: a real WSL distro with omp on the Windows box.
|
||
|
|
79099d6adb |
provider, gui, tui: Ollama, LM Studio and oMLX take an address, so a server on another port or computer is the preset's provider (#1165)
The three On this machine presets were pinned to localhost and their default port: one started on another port, or on another computer on the LAN, had to be rebuilt as a custom provider or typed URL by URL in the CLI. They now take an Address (scheme, host and port), and each of their URLs keeps its own path there (provider.AtAddress, AddressOf; no scheme means http, only http/https, port 1-65535, a pasted path is dropped, anything else refused with nothing changed). - GUI: the add and edit editors have a Server address section under the key, folded unless the saved address isn't the preset's, opened and focused on a refused one. The Endpoints, Test and Refresh follow what is typed; URLs are sent only when the address changed, so ones set apart (an import, the CLI) are left alone. zh, zh-TW, ja, de. - TUI: adding a local preset asks for its address before the key (Enter keeps the default), and w edits it. - CLI: the usage shows provider add ollama url=... anthropic=.... - LM Studio's and oMLX's notes say "port N by default". timonwong's PR head e63cf18e, merged onto main, which had given oMLX a decision API (#1641) since: presets.go keeps main's oMLX Decide; app.js keeps both the Vertex block and the address one; the docs row and -run list take both. Run: see the next commit. |
||
|
|
eba7187368 |
gateway, provider, cli, gui: a group can route By weight, each member's share set beside it (#1910, DD on Discord)
DD asked for weighted round robin as a group routing, next to In turn.
A provider's keys could already route by weight (#841). Groups could not.
What changes:
- provider: Group.Weights maps a member's spelling to its weight, 1 to
1000. A member left out, or set to 0, weighs 1. SaveGroup accepts
routing "weight". It also cleans weights the way it cleans fast and
off: it strips :fast, drops weights of members that are gone and of
members weighing 1, and refuses a weight below 0 or above 1000.
Weights follow a member when it is renamed (RenameMember, Rename,
RenameGroup) and survive Share/Import.
- gateway: planLevel treats each member of a weight-routed group as one
unit: a model with its keys in its provider's order, or a nested group
routed its own way. weightedUnits orders the units by smooth WRR on a
round per group ("group/<id>"), sharing wrrPick with the keys. The
round's pick goes first and the rest stay in member order for
failover. A unit whose head is resting leaves the round. When a
conversation is kept on another member (session/turn/cache/strict),
the charge moves to that member (wrrSeat, wrrMove).
- cli: routing=weight (also weighted, wrr). weight=<model>=<n>[,...]
sets weights and keeps the rest; weight= on its own clears them. The
group view shows "· weight N" for each member.
- tui: By weight is in the group routing list.
- gui: the group editor offers By weight. Each member then shows
"Weight N · S%", its share among the members that are on. Clicking it
edits the number in place: Enter or blur keeps it, Escape cancels,
and a value outside 1 to 1000 shows a warning. The trace header uses
group wording for a weight-routed group. Strings are added in zh,
zh-TW, ja and de.
- docs: reference.md, gateway-routing.md, and site start pages in en,
zh and ja.
Run:
- go test -tags nogui ./internal/provider ./internal/cli ./internal/tui:
ok.
- ./internal/gateway: ok in 988s with -timeout 45m. The first run hit
the default 10m timeout at load average ~170. The test running at
that moment had been running for 2s; it was not a hang.
- go vet -tags nogui on those packages, for darwin, GOOS=linux and
GOOS=windows: clean. gofmt -l: clean.
- New group-member-weight.test.cjs: 8/8 in Chromium and WebKit, en and
zh at 1100, en and de at 420. The WebKit de 420 case also passed six
runs at once.
- gui-zh-tw, gui-ja, gui-de, i18n-keys, routing-*, group-*,
panel-routing*, settings-groups and agent-model-groups: all green
except two.
- routing-steady (WebKit) is #1804. It is red 2/3 alone on origin/main
|
||
|
|
63a361b5ff |
gui: a plugin that took over Trae's, WorkBuddy's, MiniMax's or Qoder's check-in keeps that switch after a state refresh (#1912)
The previous commit reads the saved pluginCheckins map before /api/settings' list, but /api/state has neither the list nor, for a provider whose own switch was never set, a map entry. Such a plugin follows the built-in check-in it took over (provider.PluginCheckinOn: traeCheckin for trae-cn, workbuddyCheckin, minimaxCheckin, qoderCheckin), so a refresh still drew it off while the scheduler kept checking in. pluginCheckinOn now falls back to that built-in's switch, from PLUGIN_CHECKIN_INHERITS. Run: plugin-checkin.test.cjs gains cases for the inherited switch in /api/state's shape (red with the fallback removed) and a test that the map names the same ids and settings keys as Go's PluginCheckinOn (red with an extra entry); plugin-checkin, i18n-keys, gui-zh-tw, gui-ja, gui-de in Chromium and WebKit: 32 pass. No new strings. |
||
|
|
762db7c5a2 |
gui: a plugin's saved auto check-in stays on after a state refresh (#1912, 1939323749)
Reported by 1939323749 with a custom provider plugin on Windows. Read the persisted pluginCheckins map before the derived settings-only list, preserving explicit false and the existing default fallback. Verified plugin-checkin tests in Chromium and WebKit across en, zh, zh-TW, ja and de, plus all three translation GUI suites. The WebKit English Usage-card regression fails without the fix: saved auto check-in stays on after a state refresh (false !== true). Reviewed and landed from the reporter's branch (755c1f0): with the old pluginCheckinOn the new refresh assertion fails in WebKit for every language; with it, plugin-checkin, i18n-keys, gui-zh-tw, gui-ja and gui-de pass in Chromium and WebKit. |
||
|
|
5e5b6a5ac3 |
provider: every account of a provider keeps its queue, limits and routing, not only the first (#1899)
A second WorkBuddy AI account queued requests for 62s with the provider's queue wait set to 1s. The gateway takes each candidate's QueueLimit, QueueWait, LaneLimit (MaxConcurrency) and Routing from the Provider value it is handed. The account the agent is signed in to comes from All, which lays the user's saved picks from providers.json over it. The other accounts on beside it come from AlsoOn. For Claude and Codex, AlsoOn copies p, so they had the picks. Every other sign-in builds its extra accounts afresh: all plugin accounts (pluginAlsoOn) and the built-in extras (WorkBuddy, Grok, Copilot, ZCode, Kiro, Devin, Command Code, Qoder, Zed, Factory, MiMo, the Gemini sign-ins). They had none of the picks. A few getters (LaneLimit, RPMLimit, AccountCap, proxy) already fell back to providers.json. The queue, the provider-wide concurrency and routing did not, so an extra account waited forever on a full lane. The overlay All does is now withPicks. AlsoOn calls it on every account it returns, from p as All has it. This one choke point covers every sign-in's extra accounts, plugin and built-in, moved or not. The LaneLimit, RPMLimit and AccountCap comments now say what still reads providers.json, and so does gateway-routing.md's Limits row. Tests: - TestPluginSecondAccountKeepsTheQueue (gateway, fake plugin under bun): two accounts, one at once each, a queue of 1 and a wait of 1s, every request pinned to the second account. The third request gets 429 "queue is full" at once, and the queued one gets 429 "waited" after its second. The vendor sees only the second key. - TestWorkBuddyAI: the second account from AlsoOn has the provider's queue 1/1s, MaxRPM 7, Routing ordered and LaneLimit 2. Broken by hand (AlsoOn returning alsoOn's accounts as they are): - The gateway test fails at its AlsoOn check. With that check off, it fails on "no reply in 10s", which is the reporter's symptom. - TestWorkBuddyAI fails with "queue 0, wait 0s, rpm 0, routing "", at once 0". Run (sandbox HOME, private GOCACHE, worktree): gofmt -l; go test -tags nogui on ./internal/provider, ./internal/gateway, ./internal/gui, ./internal/cli and ./internal/agent; GOOS=linux and GOOS=windows go vet -tags nogui on internal/provider and internal/gateway. Not tried with a real WorkBuddy AI account. |
||
|
|
7df0a5bf32 |
catalog: a vendor's own model name is kept ahead of the catalog's, and fallback names never collide (#1188, fixes #1119)
Command Code's Flash Fast showed the catalog's "Flash", the same name as plain Flash, so the picker had two "Flash" rows. An unprefixed `name` from a vendor's /models now wins over the catalog fallback (magpie_label and display_name still come first). A `Vendor: Model` name such as OpenRouter's falls through to the catalog as before, so OpenRouter's names don't change. A catalog fallback that would give two ids one name keeps the id instead. Exposed fills names only for unlisted picks and checks every available name and id for a collision; listed picks keep exactly what Available returned, Antigravity's id-only names among them. TestNameOf's case-variant expectation changes on purpose: glm-5-turbo and GLM-5-Turbo together keep their own ids. Kenoia's PR head f538b19e, which conflicted with main in internal/catalog/live.go and live_test.go; the conflict was resolved keeping both main's live-name changes and this one. Run on this tree (origin/main |
||
|
|
657e48abbf |
routing: a request whose agent left in the retry pause says it was canceled, not "tried again in 2s" (#1894, heng91)
heng91's relay was unreachable while their proxy was off; magpie answered the relay's 503 with its short same-one retry (or a group's replan), and they closed the Claude Code / Codex window in the pause. The gateway already stopped there: the pause selects on the request's context, the route ended with 499 and the upstream was asked nothing more. But the trace never said so: the last try kept only its Again, so the Routing page's story ended on "... it is tried again in 2.0 s" and the list said "499 · failed", which reads as the closed session still retrying. - gateway: the three pauses (the last one left asked again, the same after spentAfter, and the group's replan through pauseAlive) mark the try whose pause it was `Gone` when the agent leaves in it. - Routing page: such a try says the agent canceled the request before the retry and nobody is asked again (en, zh, zh-TW, ja, de); the request list and the outcome label say canceled; the replay's dot goes home. - docs/subsystems/gateway-routing.md says so. Reproduced first with a fake upstream (httptest) answering 503 and one hanging, a real gateway server and a client that disconnects: single provider, group replan, streamed and not, hang mid-try. In every case the route ended at once with nothing in flight and the upstream saw no further request (the hanging one saw its request canceled); only the trace's last line was wrong. The plugin fetch path already sends the host an abort on cancel (host.js "abort"). Run: - TestAgentGoneInTheRetryPause (new, -race): agent leaves in the pause, single and group; upstream count stays, route done 499, no try in flight, last try Gone. Red with the Gone marking removed (Gone false), and red with the pauses ignoring the context (route not done). - routing-agent-gone.test.cjs (new): Chromium and WebKit, en/zh/ja/de, 1100 and 420 wide, 16/16; red (0/4) with the story and label change reverted. - go test -tags nogui ./internal/gateway ./internal/gui; routing-*, rest-try-now and ledger-retried GUI tests on both engines; gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui on both packages. Not tried: the reporter's own relay and proxy, or a real Claude Code / Codex window closed mid-pause. The one other red in that GUI run, routing-wb-restricted at 420 in Chromium under the full run (passes alone 3/3), is filed as #1905. |
||
|
|
1d927bcfe9 |
gui: a copy nothing could make says so, with the text to copy by hand (#1881, BabyLy233)
copy() tried /api/copy, then navigator.clipboard.writeText, then the copy command, and when all three failed it put the bare text in the footer with no word that nothing was copied. Now that magpie refuses a copy it can't read back (the commit before), that last case is reachable in the app on Linux, so it reads "Couldn't copy. Select it here and copy it yourself: <text>" as an error (role=alert, 8s) and the button isn't flashed as copied. Translated in zh, zh-TW, ja and de. The order of the tries and the success path are unchanged, on macOS and Windows too. docs/subsystems/gui-shell.md: the host's copy row says how a Linux copy is made and checked, and where the page takes over. Run: - tests/copy-fallback.test.cjs (new): /api/copy 204 (no page copy), 501 + clipboard API, 501 + API refused + copy command, all refused; en, zh, zh-TW, ja, de; Chromium and WebKit: 40 pass. With the failure line put back to status(text), the 10 "nothing copies" cases go red. - copy-command, key-copy, model-copy-id, library-mcp-copy-config, i18n-keys: pass. - go test -tags nogui ./internal/gui: pass. Not tried: WebKitGTK's own clipboard API and copy command inside the real Linux app window when /api/copy refuses (the container run drove the host's copy directly). |
||
|
|
6d7e5b53a0 |
library: the Library page opens without looking at the same folders thousands of times (#1771, oxyuan)
oxyuan's profile after v0.1.1214: every page opens at once but the
Library, ~1.3s a visit on Windows, 68% of it in library.resolve and the
read 97% system calls.
Cause: resolve follows links a part at a time, and for each part it
called linkTarget (an Lstat, and a Readlink for a link) and then Lstat'd
the same part again. One read of the page resolves a few hundred paths,
most of them many times over (each agent's skills folder for each skill,
CC Switch's folder and the source for each skill, home and the shared
folder once per skill), so the same ~150 folders were looked at
~10,000 times a read. On Windows each look is a cgocall.
Fix: while a read of the page (Read, Glance) holds the library's lock,
lookPart (linkmemo.go) keeps what each entry was found to be, one Lstat
and a Readlink for a link, for the rest of that read; linkTarget and
resolve both go through it, so the second Lstat is gone too. No change
runs while the read holds mu, so nothing the read keeps can be changed
by magpie under it. Nothing is kept past the read: the next visit looks
again, so a link made or moved on disk between visits shows. A look that
failed for another reason than "not there" is unknown and isn't kept. I
looked at a cache across visits keyed on the folders' times; checking it
costs one stat per folder on the way, the same as the memo's single look,
so it would save nothing over this.
Numbers, 11 agents, 40 skills from a linked folder given to all of them,
10 MCP servers (the package's sandbox, test binary built for each):
Windows 11 x64 box, median of 7:
Glance 10,144 looks, 116ms -> 117 looks, 26ms
Read 10,473 looks, 150ms -> 284 looks, 61ms
macOS (arm64), median of 7:
Glance 11,660 looks, 41ms -> 159 looks, 13ms
Read 12,040 looks, 53ms -> 360 looks, 28ms
The rest of a full Read (comparing the agents' copies, found skills)
runs without the lock, as before, and isn't memoized.
Tests: TestReadLooksAtEachFolderOnce (red with the memo taken out, and
with it outliving the read), TestLinkChangedBetweenVisitsShows (red with
a memo kept across visits), TestUnreadablePartIsLookedAtAgain (red when
an unknown look is kept).
Run: go test -tags nogui ./internal/library ./internal/gui (ok);
gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui
./internal/library; node --test internal/gui/tests/library-*.test.cjs,
chromium and webkit: 450/450 on the second full run. The first full run
had library-mcp-tool-switch red in WebKit (#1609, filed) and
library-chip-fan red once in Chromium under --test-concurrency=4; it
passed 3/3 alone and in the second full run. Not tried on oxyuan's
machine or with their library.
|
||
|
|
2d721f7f3d |
library, gui: the skills in your agents can be picked and removed together
wongxy on Discord: 资源库技能支持批量删除 (batch delete for the Library's skills). The library's own skills already have this: Select, then Remove…, since #1852 ( |
||
|
|
e528aeb3ce |
agent: DevEco Code, Huawei's OpenCode, as an agent (#1885)
foobra asked for DevEco Code (npm @deveco/deveco-code), Huawei's
HarmonyOS coding agent. It is OpenCode underneath, so it joins through
openCodeLike as MiMo Code did (
|
||
|
|
c3bbf16022 |
agentplug: an agent plugin's keys are written in the order it gave them (#1890)
What: connect's result is taken from the module as JSON text (moejs AppendJSON keeps JS insertion order) instead of rt.ToGo, which made a Go map at every level. An object or array connect returns reaches the writer as a json.RawMessage, so edit.SetJSON writes it in the plugin's order; strings, numbers, booleans and null are their Go values as before (the gateway-key mark still matches a string). edit.SetYAML now takes a json.RawMessage too, as a block-style node in the text's order (it would have written the bytes as a list of ints), and the env format writes it compact as before. Why: Kilo's agent plugin (magpie-community/plugins#90) returns each model's effort variants weakest first, low, medium, high, the order Kilo lists them in. Go maps marshal sorted, so Kilo showed high, low, medium. magpie's own OpenCode wiring already keeps order (openCodeVariants). The key paths connect returns are still applied in sorted order: each is a separate edit, and the user's file around them is untouched. Siblings: rt.ToGo's other caller (middleware's string lists) writes no file; the Library's MCP block for a plugin agent is built by magpie, not returned by the plugin. Run: - TestPluggedKeepsPluginOrder (Kilo-shaped connect, a kilo.jsonc with a comment, a theme, $schema, a provider of the user's own with keys zeta, alpha and a trailing key) and TestPluggedKeepsPluginOrderYAMLAndEnv. With agentplug.go put back: FAIL, variants written high, low, medium and provider keys sorted. With yaml.go put back: FAIL, the object written as a list of byte values. Both pass with the change. - gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., the three builds: OK. - go test -tags nogui -timeout 40m ./... under a scratch HOME: all ok. (A first run with the default 10m timeout timed out in internal/gateway while four other sessions' suites ran on this box and the disk was full; the gateway package took 973s under that load and passed.) - Real use, sandbox HOME: this build, `magpie plugin add` of packages/kilo at plugins PR #90 head b67360cb7, a provider whose fake-chat has efforts stored high, low, medium; `magpie kilo magpie/fakeup/fake-chat` wrote variants low, medium, high with the user's comment, $schema, theme and own provider in place, and @kilocode/cli 7.8.8 `kilo models magpie --verbose` lists them low, medium, high. `magpie kilo default` put the file back; the only difference is Kilo's own one-time permission migration. |
||
|
|
b0e3177d9d |
provider: Ollama Cloud shows its plan's included allowance and its bought credits in Usage and magpie quota (#1888)
What: an ollama-cloud key (any provider whose base is on ollama.com) is read at GET https://ollama.com/api/balance with Authorization: Bearer <key>. included.{balance_usd, allowance_usd, period} becomes a plan card (PlanQuotas, planQuotaSourceOf) with one window in USD: spent of the allowance, named Month when the period is a month long, resetting at period.until. purchased.balance_usd becomes the key's balance card (KeyBalances, balanceSourceOf). Routing weighs the key by that window as it does other plan keys (keyWindows), and the window is Aside while bought credits are left, since spending past the allowance draws on them. Absent fields are unknown, never $0: no included, no allowance, an allowance of 0 or no balance_usd gives no window (and, as for MiniMax and Command Code, no plan card); no purchased gives no balance card (new errNoBalance, which KeyBalances leaves out instead of showing an error); null period gives a window with no reset. A reply with neither object says its shape. A refused key's balance card says Ollama's reason. Why: #1888 asked for Ollama Cloud's balance and plan quota beside the other key-bought plans. Run: - go test ./internal/provider -run 'Ollama|TestPlanQuotaSource|TestBalanceSourceByHost|TestKeyBalances' in a sandbox HOME: pass. Broken by hand five ways, each red: no ollama.com plan source (TestOllamaCloudCards, TestPlanQuotaSource), missing purchased read as $0.00 (TestReadOllamaBalanceMissing, TestOllamaCloudCards), KeyBalances not skipping errNoBalance (TestOllamaCloudCards), missing included.balance_usd read as 0 (TestReadOllamaBalanceMissing: a $20 allowance shown 100% used), Aside dropped (TestReadOllamaBalance). - The built binary in a sandbox HOME with an ollama-cloud provider and a fake key: `magpie quota` asked the real ollama.com and showed `ollama-cloud balance 401 Unauthorized: {"error":"invalid credentials"}`, no plan card. - gofmt -l, go vet (darwin), GOOS=linux go vet -tags nogui, GOOS=windows go vet, go build for darwin, linux (nogui) and windows: clean. - go test -tags nogui ./... in a sandbox HOME at load ~27: 48 packages ok; internal/agent and internal/gateway hit the 10m timeout, and in gateway TestIntentClassifierGroup (#1813, 3.63s against its 3s bound) and TestHistoryKeepsDaysAndDropsOld (filed #1892) failed. Rerun with -timeout 40m both packages pass (1032s, 1138s). Neither package reads ollama.com or these readers. Not tried against the real API with a real key: the owner's magpie has no ollama-cloud provider, so the fixtures are the issue's literal JSON and the free-plan and missing-field shapes are guesses from it. Whether a spent allowance really falls through to bought credits (Aside) is not verified either. Reported-by: yangmingyuan380 |
||
|
|
fa44fde461 |
netproxy: a proxy's user and password stay out of every log line, error and status that names it (#1886)
What: netproxy.Redact is the one place a proxy address is made fit to show. It is the rule |
||
|
|
88f237e91b |
gui: the Agents list's footer has Manage, to hide or unhide many agents at once (#1302, eryajf)
Users who use a few agents had to hide the others one row menu at a time, and disconnecting doesn't help: most are unconnected already. The Agents list's footer now has Manage beside the fold control (shown even when nothing is folded). Its dialog lists every agent, folded and hidden ones too, with search by name or id, select or invert the search results, select the unconnected ones, and clear. Hide selected / Unhide selected save one arrangement each through the existing POST /api/agents/arrange, keeping the order and every agent outside the selection; a failed save keeps the selection for a retry. While it saves, Done, Escape and the backdrop can't close it, and a state read that left before the save can't put the old arrangement back (agentsVisibilityRevision). Nothing connects, disconnects or edits an agent's files; the tray panel is unchanged. Strings in en, zh, zh-TW, ja and de. docs/subsystems/gui-shell.md says how it works. mobile-web's desktop comparison leaves the new footer out while the baseline hasn't it. Squashed from PR head 2a24d59e onto main, without the PR's unrelated parts: the plugins.js search redraw and its plugin-market test change, the purpose-filter and redact-rule-row test workarounds (main fixed those flakes at their cause), and a .warm-at input min-width. Conflicts: load() keeps main's reads with the PR's revision guard, i18n.js and app.css keep both sides, the gui-shell doc keeps main's window-corners note. Run (both engines; every agent* test, gui-de/ja/zh-tw, i18n-keys, mobile-web, panel-fold, library-mcp-tools, click-scroll): 516 pass. Two webkit zh-TW agent-failover failures were ENOSPC launching the browser and pass on a rerun. mobile-web's 1280 comparison and a narrow-width measure in agent-bulk-visibility needed fixes, in the next two commits. Broken by hand: without closeConfirmAsk's saving guard, "saving blocks Escape and backdrop" fails (success and failure); without the visibilitySince block in load(), "an older state read cannot undo a completed bulk save" fails. Not tried: the real app with real agents. |
||
|
|
b6831d83e1 |
gateway, gui: Codex's thread descriptions go to a model picked in Settings, apart from its titles (#1198, congee949)
Codex asks its own model, through its ChatGPT sign-in, for each thread's description (thread_description), even while the conversation runs on magpie's models. Settings › General gets "Codex thread descriptions" beside "Codex thread titles". It defaults to Codex's own, which sends the request as Codex sent it, or it can name one of magpie's models or a routing group. The answer is wrapped as description-only JSON. The titles setting is untouched. Usage and Routing show these requests under their own Description purpose. The setting is kept across unrelated Settings saves. There is no Off yet, because Codex's handling of an empty description hasn't been checked. This is a first slice of #742. Squashed from the PR and merged onto current main. Conflicts resolved: - codex_backend.go: the description branch comes after the title branch, ahead of main's subagent pick. - gateway.go: main's CC Switch #1301 comment above the compaction block is kept; the PR had shortened it. - app.js: the gateway-mode list of hidden rows takes the new row. - i18n.js and settings_keep_test.go: both sides kept. - purposes.js: regenerated with go generate ./internal/usage. Run on the merged tree: - gofmt -l is clean. - go vet passes on darwin, linux -tags nogui and windows; the builds on all three succeed. - go test -tags nogui passes for ./internal/gateway, ./internal/gui, ./internal/settings and ./internal/usage. - GUI, chromium and webkit: codex-titles, gateway-mode, purpose-filter, routing-purpose-state, gui-de, gui-ja, gui-zh-tw, i18n-keys, settings-general/-groups/-sections/-search and click-scroll: 118/118. Broken by hand: with the description branch removed from codexBackend and handle, TestCodexDescriptionsSetting, TestCodexDescriptionFallbackOnMagpie and TestNoDescription fail. Not tried: a real Codex thread_description request, and whether Codex's sidebar takes the answer. |
||
|
|
7cc393bcc1 |
gateway: a relay reading thinking off as effort none, refused naming its levels, is asked with thinking left to the model (#1465)
MengXiangxi's Claude Code auto mode on a Sub2API's gpt-6.1-sol blocked
every action: "Sub2API: gpt-6.1-sol does not support reasoning effort
"none"; use low, medium, high, xhigh or max" (400).
Cause: Claude Code's classifier (and every side query magpie turns
thinking off for, thinkingOffUnlessAsked) goes to Sub2API's Messages API
as it was sent, with thinking {type: disabled}. Sub2API's
anthropicReasoningEffort reads disabled as effort "none", and
ValidateGPT61SolReasoningEffort turns none away for gpt-6.1-sol
(Wei-Shaw/sub2api, backend/internal/pkg/openai/constants.go). magpie's
Anthropic retry for a refused thinking-off knew only the alwaysThinks,
mandatoryReasoning and thinkingOffRefused wordings, so this 400 went to
Claude Code. The refusal is about the model on that relay, not the
account: the same request with thinking left out is taken.
Change:
- refusesThinkingOff (anthropic.go) is the one list of thinking-off
refusals, now also one turning a quoted "none" away while naming the
levels taken (effortLevelsNamed && noneQuoted). Both routes use it: a
relayed Messages request (passthrough) and a request translated to an
Anthropic endpoint (forwardTranslated, thinkingBackOn).
- The relayed route now remembers the refusal (markUnfit(offRefused),
the mark the translated route and passthrough effort fitting already
read) and sends that model's later requests with thinking left to the
model at once, so the classifier, which asks on every action, doesn't
pay a 400 round trip each time.
- Chat/Responses routes already retried this wording through
effortLevelsNamed (reasoning_effort none -> lowest level); unchanged.
- docs/subsystems/gateway-routing.md says so.
Tests: TestSub2APIThinkingOffRefused (the reporter's literal message;
the classifier relayed is refused once, asked again, then sent without
thinking at once, title asks included; a 400 for another level stays the
agent's), TestRefusesThinkingOff, and the Sub2API wording added to
TestTranslatedThinkingOffRefused. Broke the fix by hand twice (the new
clause off; the remembered send off) and watched each go red.
Run: gofmt -l internal/ (clean); go vet ./internal/gateway on darwin,
GOOS=linux -tags nogui, GOOS=windows; go test -tags nogui
./internal/gateway -count=1 -timeout 40m: ok in 669s (load ~40 from
other sessions; an earlier run hit the default 10m timeout under that
load). Not tried against a real Sub2API.
|
||
|
|
2c31129692 |
gui: on macOS 26 the main window has a plain title bar's corners (TextEdit's, not Finder's), its traffic lights still in the header (waitingsnow) (#1042)
* gui: on macOS 26 the main window has a plain title bar's corners (TextEdit's, not Finder's), its traffic lights still in the header (waitingsnow) From macOS 26 a window with a toolbar has larger corners than one with a plain title bar: 26pt, Finder's, against 16pt for TextEdit or an Electron app. The main window has an empty toolbar only to inset its traffic lights into the page's header (Wails' MacTitleBarHiddenInset), so its corners were a toolbar window's. On macOS 15 a toolbar doesn't change them (12pt either way, measured on 15.8). On macOS 26 and later plainTitlebar now takes the toolbar off (insetLights, titlebar_darwin.go), and MagpieLights keeps the lights and the title bar's 66pt height where the toolbar had them. AppKit lays the title bar out again at its own 32pt after a resize or zoom, a new title, a new appearance and leaving full screen; the lights are put back once it is done, and AppKit's hover tracking is told where they went. Their autoresizing mask keeps their distance from the top: AppKit draws a new system appearance (light or dark, more contrast, less transparency) before the run loop turns, which drew them 8pt above the window for one frame. A sheet, such as the folder chooser, still begins below the title bar (Wails' window delegate gets window:willPositionSheet:usingRect:, which places this window's sheets only). A first press while another app is in front still moves the window from anywhere in the 66pt title bar, as AppKit moved it with the toolbar (firstPress, a local mouse-down monitor). AppKit's own band is now a plain title bar's 32pt; below it the page doesn't take a first press, so the press would only have brought the window forward. A press on a view that takes a first press (a traffic light, a resize edge) is left alone, as AppKit leaves it. The macOS version is asked at run time. go build and go test build the cgo objects for the Mac's own macOS, where @available(macOS 26.0, *) is compiled away: a test binary built so on 26.7.1 took the toolbar off on 15.8. An older macOS, the lights on the right (a right-to-left language) or a title bar not laid out as expected keep the toolbar. Linux and Windows are unchanged; the GTK 3 comment now says its corners stay square. TestMainWindowCorners (new; darwin, run by CI's macOS job) measures the main window beside a plain and a toolbar window in a process of its own (runAppKit, so WebKit's data stays out of the real ~/Library): once shown, after a new title and size and a new system appearance, as AppKit draws that appearance, a first press 20, 40, 60 and 70pt below the top while no window is key, and where a sheet begins. TestMainWindowRightToLeft launches it right to left. Both pass on macOS 26.7.1 (3 runs in a row), 26.6.2 (CI's) and 15.8 Intel, where the toolbar stays. With each part taken out, they fail: - the change itself: "corners of 26.00pt; a window with a plain title bar has 16.00pt, one with a toolbar 26.00pt"; - putting the lights back: "traffic light 1 at [16 16] (x, y from the top left), the toolbar had it at [26 26]"; - the height: "a title bar 32pt tall, the toolbar's was 66pt"; - the mask: "as AppKit draws a new system appearance, traffic light 1 is at [26 -8]"; - the sheet's place: "a sheet on a short window begins 16pt below its top; below the toolbar it began 66pt"; - the press monitor: "a first press 40pt below the top, with another app in front, began 0 window drags; with the toolbar it began 1"; - the right-to-left check: "the traffic lights are on the right, and the main window's toolbar was taken off"; - the run-time check (@available instead), on 15.8: "a toolbar doesn't change the corners on this macOS, yet the main window's was taken off". The presses are sent within the test's own process, and a drag is counted, not begun; no system setting changes. The real app on 26.7.1, built from this commit and driven through Accessibility under a HOME of its own, has 16.25pt corners (26.50pt on main) and its lights where main has them, through resize, zoom, light and dark, a new title, full screen, minimise, close and show, a maximised start, and the window lightweight mode makes again. A real pointer and a key window's press were not tried. go vet, the three builds and go test -tags nogui ./... pass. * gui: where AppKit gives magpie the Mac's earlier design (an SDK before macOS 26's, or UIDesignRequiresCompatibility), the main window keeps its toolbar (waitingsnow) The main window's toolbar comes off only in the design of macOS 26, where a toolbar gives a window larger corners. AppKit gives a program that design from macOS 26 when the program is linked against the macOS 26 SDK or a later one and its Info.plist doesn't set UIDesignRequiresCompatibility; the last commit asked only for the macOS version. A program linked against an earlier SDK gets the earlier design on macOS 26 too: yetone's test binary (Go 1.26.3, Xcode 26.2) names SDK 11.0, and on 26.2 every window there had 12pt corners, yet the main window's toolbar was taken off and TestMainWindowCorners failed at every stage. designOf26 now reads each at run time: the macOS version (NSProcessInfo), the key (NSBundle) and the SDK the program names. The SDK is in LC_BUILD_VERSION, or in LC_VERSION_MIN_MACOSX in a program that runs on macOS 10.13, as go build links one for an Intel Mac. The header is read through _NSGetMachExecuteHeader (crt_externs.h): dyld_get_program_sdk_version is declared only in dyld's private header, and it doesn't see the key (27.0 in a bundle that sets it, where AppKit gives the earlier design). The comment no longer says go build builds for the Mac's own macOS: the program names 11.0, and it is clang that compiles the cgo code for the Mac's own macOS (ld: "built for newer 'macOS' version (26.0) than being linked (11.0)"), where @available(macOS 26.0, *) would be compiled away. TestMainWindowCorners now runs the windows' program twice, as linked against the macOS 26 SDK and against macOS 15's (runAppKitSDK; stampSDK rewrites the SDK in a copy and signs it again), so on macOS 26 it checks both designs whatever SDK the toolchain names. In the earlier design it checks that the main window keeps its toolbar. gui-shell.md says which design gets the change, which SDKs the test runs with, why the key has no test, and how to run it as for an Intel Mac. Both subtests and TestMainWindowRightToLeft pass on 26.7.1 (arm64, 3 runs in a row, and amd64 under Rosetta), 26.6.2 (arm64, as CI) and 15.8 (Intel). With each new part taken out, its subtest fails: - reading the SDK (designOf26 answering yes after the macOS and the key): "a toolbar doesn't change the corners in this design, yet the main window's was taken off", with macOS 15's SDK; - 26.0 itself (> for >=): "corners of 26.00pt; a window with a plain title bar has 16.00pt, one with a toolbar 26.00pt", with the macOS 26 SDK; - reading LC_VERSION_MIN_MACOSX, or 26.0 there, built for amd64: the corners message, with the macOS 26 SDK; - the macOS version, asked with @available instead, built on 26.7.1 for amd64 and run on 15.8: the toolbar message, with the macOS 26 SDK. Taking out the last commit's parts fails the macOS 26 SDK subtest or TestMainWindowRightToLeft as before. UIDesignRequiresCompatibility is checked by hand, not in a test: AppKit reads it from an app bundle's Info.plist, LaunchServices registers each bundle that runs (and keeps a temporary one after it is deleted), and in a process run from a bundle a press sent within it began a window drag in only 3 of 12 runs. On 26.7.1 the test program in a bundle whose Info.plist sets the key has 12pt corners like every window there, and keeps its toolbar; in a bundle without the key it has 16pt and no toolbar, as when run on its own. With the key's check taken out, the toolbar is taken off although AppKit gives the earlier design. The bundles were unregistered (lsregister -u) and deleted. go vet, the three builds, go test -tags nogui ./... and go test ./internal/gui/... pass. The real app wasn't run again. * ci: run the checks again (waitingsnow) test (macos-latest) failed in TestRelayKeepsClientAlive (internal/gateway, 1 ping in a 150ms gap), a timing test this PR doesn't touch; it passes on main and 5 times of 5 locally. |
||
|
|
1d8134605a |
plugin: a plugin pinned to a version, or turned off, keeps both throu… (#1076)
* plugin: a mover installs the version its user pinned, not @latest
plugin.Add installs the spec it is given and appends @latest to a bare
package name, so installPlugin — the mover's installer, for
keepMovedCurrent, Move and HandOver — handing it a bare name quietly
replaced <pkg>@1.2.3 with <pkg>@latest in plugins.json. The pin was the
user's choice, and it was destroyed behind their back every time the
mover's min was raised.
installPlugin now hands Add the entry's own spec when the user has one.
A pin older than the move needs is left pinned and reported by the check
that was already there below it ("%s %s is installed; moving needs %s
or newer"), whose remedy is to unpin it; a pin that satisfies min still
returns early and is not reinstalled. A user with no entry for the
package keeps the bare name, which is a first install and there is no
pin to keep. A plugin the user turned off is still refused before any of
this, as it was.
TestInstallPluginKeepsTheUsersPin pins fake@0.1.5 with the move needing
0.2.0 and writes the version plugin.Version reads into the plugins folder
it is read from. It asks Add for fake@0.1.5 — against installPlugin as it
handed over the bare name it fails with "asked Add for [fake], want the
pinned fake@0.1.5" — and gets "needs 0.2.0 or newer" back rather than a
silent install of @latest. It also checks that a plugin the user turned
off is refused and not asked for at all. addPlugin is a var beside
pluginProviders and removePlugin so the test can read the spec handed
over without the Bun that Add runs.
Rebased on main as of
|
||
|
|
4419ebf7d6 |
cli, agent: magpie <agent> <field> shows that field and a field's name or DEFAULT is no longer written as the agent's model (#1129, waitingsnow)
What: `magpie codex model` wrote model = "model" into config.toml (and
applied.json, stash.json); any agent's field name given alone, or as a
value, was set as its model, and `magpie codex DEFAULT` wrote
model = "DEFAULT". Now:
- `magpie <agent> <field>` (any case) prints that one field and writes
nothing;
- a field's name given as a value is refused with a hint
(`magpie claude effort Ultracode`);
- DEFAULT in any case takes magpie out, as `default` does;
- Claude Code's tier names (opus/sonnet/haiku/fable) still set the model,
since agent.ModelAliases marks them, and the agent's help says so.
agent.Field matches key and label in any case; agent.Running is a var
so the cli tests can say Codex isn't open.
Why: ported from waitingsnow's #1129 (commits bbe75c91f, 00bb38581,
244b24a67) onto internal/cli, where the CLI moved after the PR was
opened. The PR's --help part landed earlier as
|
||
|
|
184f9184d3 |
gateway: a Chat turn's thinking is read in every spelling the client … (#1075)
* gateway: a Chat turn's thinking is read in every spelling the client sends it back in A client sends the previous assistant turn's thinking back in reasoning_content (DeepSeek's, which OpenCode and most clients send), reasoning (OpenRouter's) or reasoning_details (OpenRouter's structured one). parseChat read only reasoning_content, so a request translated to a non-Chat upstream lost the thinking of every turn sent another way and the model went on without its own reasoning, which a tool-calling session shows from its second turn on. chattidy's passthrough has read all three since mistralThinking (#494); the parse layer never got the same reader. The assistant branch now reads the thinking through reasoningText, messageReasoning's own reader, in the order the passthrough keeps it: reasoning_content, else reasoning, else reasoning_details' text. TestParseChatReadsEveryReasoningSpelling (a tool-calling turn per spelling) and TestParseChatTakesTheFirstReasoningSpellingSent fail without the change ("the assistant turn's parts: [{Kind:tool_call ...}]"). go vet -tags nogui ./internal/gateway/..., builds for windows, darwin and linux, and the package's chat/reasoning/thinking tests pass. * docs: the Chat parse layer reads the thinking's spellings too The change reads a Chat turn's thinking through messageReasoning and reasoningText, so parseChat takes the same three spellings the passthrough has taken since mistralThinking (#494). AGENTS.md asks for the owning reference to be updated in the same PR, and gateway-routing.md said nothing of it: its reasoning bullets are about holding a reply's own reasoning for a failover and about what a translated Responses reply gives Codex, not about what a client sends back. A bullet beside the held-reasoning one now records the spellings, the order they are read in, and the gap that was there: the parse layer read reasoning_content alone, so a tool-calling session whose client spelled it another way went on without the model's own reasoning. --------- Co-authored-by: TryWorld <TryWorld2026@users.noreply.github.com> |
||
|
|
fe08c8ddb5 |
gateway: a Claude run started for a tool loop with no history chunks its messages too, so AgentSummary reads the last one's cache (#1716)
#1716 chunked only the history: the messages before historyEnd's split. A conversation with no reply that calls no tool, as a sub-agent's loop of tool calls that Claude Code's AgentSummary asks a summary of with its last results (JinJieBeWater on #1716), has split 0, so it was told in one block and its one mark stayed on the instructions: every such request wrote the whole loop again. Such a conversation now has its every message but the last chunked. A later request with a history is told it wrapped from its first message, so it never matched past the instructions before either. What was run: - TestClaudeToolLoopCachedAcrossNewRuns (new), TestClaudeHistoryCachedAcrossNewRuns, ClaudePrompt*, ClaudeInstructions*: pass. - Broken by hand, each seen red: no split-0 chunking; the last message chunked when it ends a chunk (a 32-message loop); boundaries counted from the end; the mark left on the instructions too; no chunk mark. - Real Max account, claude-haiku-5-5, Claude Code 2.1.296 through a recording proxy, each run started anew with magpie's rendered prompt, a loop of 20 then 24 tool rounds (42 then 50 messages): origin/main: second run read 3,790, wrote 70,764 #1716 alone: second run read 3,791, wrote 70,813 with this: second run read 48,661, wrote 25,993 Grown history (21 then 41 messages) and same history with a new ask are unchanged from #1716 alone (22,348/28,178 and 40,848/9,678). Every request kept to four marks, all 1h. - Not tried: a long turn to answer after a history is still one block, and images count toward Anthropic's 20-block lookback. Co-authored-by: deephbz <13776377+deephbz@users.noreply.github.com> |
||
|
|
96eb536f85 | gateway: a Claude Code run started anew marks its history's last whole chunk of messages, not only the instructions, so a later run for the same conversation reads the history from the cache instead of writing it all again | ||
|
|
5b14ebf49a |
gateway: a Claude subscription run is told the user's words after a tool result as theirs, not the tool's (#1878)
JinJieBeWater found that Claude Code's AgentSummary label request ("Describe
your most recent action in 3-5 words. Do not use tools.", sent as a text
block after the sub-agent's last tool_result) reached the inner Claude as
tool output, so it went on with the task instead of answering the label.
Two paths had it:
- renderParts (a run started anew, or a resumed turn) wrote the text right
after the tool's last line. A text or file part after a tool result in the
same message now closes it with "[end of tool result id=…]" and is marked
"[user message]". A result followed by nothing or by another result is
told as before, so existing prompts and their cache prefix don't change.
- match folded the text into the last result, and continueWith handed it to
Claude Code as the MCP result. It no longer folds; saidWithResults takes
the words, and continueWith writes them to Claude Code's stdin as a user
message before handing the results over, waiting for Claude Code's
command_lifecycle "queued" for that uuid (2s at most). Claude Code then
tells its model the message with the result as one the user sent while it
worked, in the same turn.
Going on in the run, rather than starting a new one for such requests, keeps
the cache prefix (#1716/#1717) and #872's mid-turn messages, which use the
same shape. #872's text is now queued as the user's instead of appended to
the result. Words in a message that holds images (pi-ai's "Attached
image(s) from tool result:" captions) still fold into the result, decided by
the message's parts, not its text. A tool whose output says "Do not use
tools." keeps it inside its result. The fork test's fake Claude now models
mid-turn absorption the way Claude Code does.
Run: gofmt -l; go vet on darwin, linux (-tags nogui), windows for
./internal/gateway; go test -tags nogui ./internal/gateway/ -count=1 green;
-race -count=3 on the new tests. Broken by hand, each red: no end marker;
an end marker after every result; the words not passed to continueWith; the
old fold into the result; the words queued after the result is handed over.
Real Claude Code 2.1.296 driven through the gateway in a sandbox HOME
against a local mock of Anthropic: on continuation the next request's
tool_result holds "SOURCE_LAST_LINE" then the "user sent a new message
while you were working" reminder with the label request; on a new run the
prompt holds the closed result and "[user message]".
Not run: the owner's real Claude subscription (its credentials are in the
Keychain, off-limits here), so the real model's answer to the label isn't
seen; Windows tests; the full ./... suite.
|
||
|
|
1502433978 |
gui: a key's value can be changed in place, keeping its name, place and settings, and its rest is lifted (#1869)
A key rotated at its vendor had to be removed and added again, which lost its name, its place in the order, its weight, protocol, models, proxy and concurrency, and any gateway key restricted to it. As decided on #1869, in multi-key mode the row now has a Change key action, with a double-click on the row as a shortcut. - provider.ReplaceKey(id, ref, key) sets the key's new value and moves what providers.json keys by the key's fingerprint (AccountModels, AccountProxies, AccountConcurrency) to the new one. An empty value, an unknown key and a value another key of the provider already holds are refused. The same value is a no-op. - access.ReplaceAccount moves gateway keys' Accounts entries from provider/old to provider/new, under the caller-keys lock. - gateway.Server.UnrestAll lifts a rest key and every per-model rest under it. The GUI's keys/replace lifts the key's rest (provider#key, and the provider's own rest key when it is the only key on), so the new value is asked from the next request. - app.js: a pencil beside the key's copy button opens a password field in place of the masked value. Enter saves, Escape leaves it, and a double-click on the row away from its controls opens it too. The button has its own class (.key-edit) with the copy button's look. - i18n: four strings in zh, zh-TW, ja and de. - providers-accounts.md: ReplaceKey in the Keys table. Past requests keep the old fingerprint in history, under the same name. A rest is lifted only in the gateway this magpie serves. Run: - go test ./internal/gateway ./internal/provider ./internal/access ./internal/gui -count=1: ok. New TestReplaceKeyKeepsItsPlace, TestKeysReplaceKeepsTheKeyAndLiftsItsRest and TestUnrestAllLiftsAKeysModels each fail with their change taken out. - gofmt -l clean; go vet darwin, linux -tags nogui, windows. - key-replace.test.cjs (new): en/zh/zh-TW/ja/de, chromium and webkit, 1100 and 420px. Checks the post, order, note, no sideways scroll, and no scroll on change or on double-click plus Escape. - With key-copy, rest-try-now and key-import: 96/96. - 72 key*/routing*/rest* GUI files at concurrency 6: 863/871. The 8 reds were key-copy, whose button.copy locator matched the pencil; that's why it has its own class now, and key-copy passes. - Under load, about one run in 300 saw the editor body go back to the top after the copy button's double-click, with no script scrolling it. That is #1504 (findings added there). The test checks scroll before that step. |
||
|
|
fd907c986e |
gui: every resting key or account can be tried again by hand, on Routing and in the provider's key list (#1869)
A key resting after a 429 with a long Retry-After (a relay's 3600s) came back only by waiting or a restart, though relays often recover in a minute or two. The Routing page offered the lift (/api/gateway/unrest, which already takes any rest key) only to verify and restricted rests. - routing.js: every resting row with a rest key gets the button: "Try now" for quota, rate, retry-after and backoff rests, the old wording for verify and restricted. A lifted rest is remembered by key and the time it was lifted (liftedAt), so the history re-render, which reuses the try's rest, doesn't show it again; a newer rest still shows. - app.js: "Try now" beside the "resting · back at …" note in a provider's key list, posting the key's own rest key; not hover-only. - i18n: the three new strings in zh, zh-TW, ja and de. - gateway-routing.md: any rest can be lifted; only the rest ends, the backoff count stays. Run: rest-try-now.test.cjs (new: Routing row with the issue's zx retry-after rest, key list row; en/zh/zh-TW/ja/de, chromium and webkit, 1100 and 420px; asserts the post, the note gone, no sideways scroll, reached by wheel, the click doesn't scroll) 40/40, red on the old app.js/routing.js. 71 key*/routing*/rest* GUI files at concurrency 6: 826/831; the 5 reds (key-balance-card, routing-group-fold) pass alone and are timing under load (routing-group-fold fixed in the next commit). go test ./internal/gui passes. |
||
|
|
a68d2ac944 |
gateway: a held stream lets through only text, reasoning or a call, so a 200 that only framed a reply fails over (#1418)
Aliceonly's trace on #1418: sub2api answered 502 "Upstream HTTP/2 stream failed", then Codex account A answered 200, sent only the frames before a reply, and failed server_is_overloaded 37s in. Five candidates after it were never asked, and Codex ended the turn. The stream had been let through (h.passing), so holdWriter.failed() was false and neither the next candidate nor a replan was tried. Two ways a frames-only stream went through: - streamEvent's default was eventContent: any event it didn't know (and an item of a type said() didn't know) counted as the reply begun. Now only the events of each protocol that carry text, reasoning, a call or a reply's end (replyEvent) count; anything else is eventLead, held as a ping is. An unknown item counts only when it is a call or a tool's (web_search_call, server_tool_use, mcp_*). A stream that ends well is still released whole, so this can only delay, never drop, a reply. - a reply under a Content-Type that says neither JSON nor a stream, once the agent had a stream's headers, went straight through when its first bytes were SSE (sseStart -> pass()). It is now held as a stream from there and read event by event. Which event Codex's backend actually sent isn't in the trace; the test uses a keepalive, response.rate_limits.updated and an unknown item type. Run: go test ./internal/gateway -count=1, green (428s). TestFramesThenOverloadedGoesToTheNext (new: 502, then 200 frames + unknown events + server_is_overloaded, then a third member) and TestStreamEventUnknownOnlyFrames (new) fail on the old fallback.go: the overloaded stream reaches the agent and c is never asked. TestHeldUnsureStreamPasses/KeptAlive now expect the stream held until its first word, and TestHeldUnsureStreamFailsHeld (new) a failure among held frames; all fail on the old code. Not tried against the real ChatGPT backend. |
||
|
|
4a6c81e038 |
gateway: a group's Patience is waited out in full, not cut at 90s by the round count (#1418)
A group asks its busy members again after pauses of 2s, 4s, 8s, 16s, then 30s, for as long as its Patience lasts, but replanRounds stopped it after 6 rounds: 90s of pauses whatever the group was set to. real-jacket's trace on #1418 shows patience=240 with replan=6 and ~103s in all. replanRounds is now 12, a backstop sized so that the pauses alone reach PatienceLongest (240s) in 11 rounds, and the patience is what ends the wait. It stays bound by kept.tooQuiet, as before. The longest pause is now 30 x retryPause (30s in use), so the tests' 1ms retryPause doesn't grow a 4s pause at round 12. Run: TestPatienceIsUsedUp (new) counts replan's pauses for 30s to 240s of patience, and TestReplanRoundsOutlastPatience (new) sums the backstop's schedule. With replanRounds back at 6, both fail: patience 3m0s and 4m0s pause 1m30s. go test ./internal/gateway -run 'Overload|Patience|Replan|WaitsOut|Busy|Codex' is green. Not tried against a real overloaded vendor for 240s. |
||
|
|
3b4063e75e |
gateway: a 400 for a tool schema past a model's nesting depth goes to the group's next member (#1870)
OpenCode Go answered Claude Code's MCP tools on muse-spark-1.3-contributor
with 400 "JSON schema exceeds the maximum nesting depth of 10 levels", and
group/intent-auto returned it to the agent instead of asking the next
member. shapeWords didn't know the wording, so shapeRefused was false and
the error ended the turn. It now matches "schema exceeds the maximum
(nesting) depth" and "schema ... nesting depth". The schema isn't
truncated, nothing rests, and plain parameter errors ("Field required",
"not a valid type") and a 200 that mentions the depth still don't fail
over.
Run: go test ./internal/gateway -run 'TestGroupFailsOver' -count=1, green.
With the new alternatives removed, TestGroupFailsOverARequestShape fails
on both depth bodies and TestGroupFailsOverASchemaTooDeep gets the 400
back with b never asked (a 1, b 0).
|
||
|
|
23c6e865a7 |
plugin: a musl Linux (Alpine) runs plugins on Bun's musl build, kept apart from the glibc one (#1877)
emptyteeth found it: bunTarget picked Bun's build from GOOS/GOARCH alone, so Alpine got bun-linux-x64-baseline, a glibc build whose interpreter (/lib64/ld-linux-x86-64.so.2) Alpine lacks. exec then said "fork/exec …/bun/1.4.2/magpie-bun: no such file or directory", which reads as a missing file, and no plugin could be added or run. - bunTarget: a musl Linux gets bun-linux-x64-musl-baseline or bun-linux-aarch64-musl. The musl check moves out of internal/claudecode into internal/libc (libc.Musl, unchanged rule: Anthropic's installer's /lib/libc.musl-*.so.1), which claudecode, the plugin host and the CLI test that skipped on musl now share. - bunSums: the two musl builds' checksums, checked against Bun v1.4.2's own SHASUMS256.txt (downloaded from the GitHub release; they match the issue's numbers). - Cache: a musl Linux keeps its Buns and state.json under bun/musl, so a machine whose C library changed never runs the other build, nor takes its state, whose Bad may list versions only the glibc build failed (CheckBun on Alpine set aside every newer Bun). glibc, macOS and Windows stay in bun/<v>, so a Bun downloaded before is used as it is, with no new download. - A bun on disk that exec can't start with ENOENT says it is a build for another C library and names MAGPIE_BUN (cantStart), for the host's start and for bun add/bun update. The same for a $MAGPIE_BUN. - Bun's musl build needs libstdc++ and libgcc, which a bare Alpine lacks: the loader then prints "Error loading shared library libstdc++.so.6" above ~40 "Error relocating" lines, and bun add cut it off. bun add, bun update and a host that died starting now say which library is missing and `apk add libstdc++ libgcc` (missingLibs, whyDied). Decided: a Bun that can't be started at all is not counted as crashed. The fallback goes to the version before, which is the same build for this system and fails the same way, and setting the current one aside would mark a good version bad for good. The libc check happens before the download instead (the target), so Alpine never fetches the glibc build. Run: - docker alpine:3.20 (arm64, and amd64 under emulation), sandbox HOME in the container, linux nogui builds. origin/main's binary reproduces the report: "bun add …: fork/exec /sbx/.cache/magpie/bun/1.4.2/magpie-bun: no such file or directory". This one on bare Alpine downloads bun/musl/1.4.2 and says "this system lacks libstdc++.so.6 … apk add libstdc++ libgcc"; after apk add, `magpie plugin add @magpie-community/opencode-cursor-auth` adds it and `plugin list` starts the host and lists cursor (arm64 and amd64), with the old glibc bun/1.4.2 left beside it unused. With libstdc++ removed again, plugin list says the library; MAGPIE_BUN pointed at the glibc build gives the C library message. - New tests (bunmusl_test.go, libc_test.go), each broken by hand and seen red: no musl branch (TestBunTargetForMusl, TestMuslBunKeptApartFromGlibc), no bun/musl root (TestMuslBunKeptApartFromGlibc), cantStart returning the error as is (TestCantStartSaysCLibrary, TestHostOnUnstartableBunSaysCLibrary, which fails with the reporter's exact message), host.go without it, no musl sum (TestBunDefaultSums), no hint in bun add (TestMissingLibsNamesThem) or in the host's start (TestHostOnBunLackingLibsSaysWhich), muslAt always false (TestMuslAt). -race -count=20 on them: green. - gofmt -l; go vet ./... on darwin, GOOS=linux -tags nogui, GOOS=windows; go build for darwin, linux nogui, windows; go test -tags nogui for internal/plugin, libc, claudecode, cli in a sandbox HOME, and go test -tags nogui ./... (all green). One earlier run of internal/plugin with the other three packages went red, and its output was lost to a tail; four reruns of it, alone and together, were green, and the new tests were green under -race -count=20, so which test it was isn't known. Not tried: a glibc Linux end to end after the change (the unit test covers that its Bun stays at bun/<v>); a musl Linux other than Alpine (the detection is unchanged and looks for Alpine's libc.musl-*.so.1). The old glibc bun/<v> on an Alpine machine stays on disk (~90 MB); it isn't removed, as a volume shared with a glibc container could be using it. |
||
|
|
067f39f406 |
sessions: Desktop titles read once per second, from every handle Desktop keeps, and reach stats and Context (#1675)
Follow-up to Koohoko's 3d6f8b8e, after review. - Cost: assemble asks DesktopTitles once per native Claude Desktop session, and each call globbed and stat'ed every local_*.json, so a list of N Cowork sessions looked at the metadata N times. The names are now one index, rebuilt at most once a second (desktopTitlesHeld); a rename in Desktop shows within that second. Files are read through filememo, the shared reader the usage resolver already uses for these same files, which also catches a same-size rewrite inside one mtime tick (the patch's own size+mtime cache didn't). - A record that is there but doesn't parse (Desktop midway through a write) keeps its last parse instead of dropping to the bare id; a record gone still takes its names with it. - Handles: Claude.app 2.7032's LocalSessionManager (app.asar, read-only) counts unarchivedCliSessionId as a live handle beside cliSessionId and preClearCliSessionId as lineage beside priorCliSessionIds, and runs a record with no cliSessionId under its sessionId without "local_". All are named now; the raw "local_..." id no longer is (no usage record carries it). - Siblings: MergeExternalStats (the Sessions page's stats summaries) and the Context page named gateway-only Desktop sessions by the recorded prompt or nothing; both use the Desktop name now. - docs/subsystems/gateway-sessions.md says all of the above. Real layout: no Desktop session records exist on this Mac or the Windows box (only claude_desktop_config.json), so field names and types were checked against Claude.app 2.7032's own reader/writer code: a string title, string cliSessionId/unarchivedCliSessionId/ preClearCliSessionId, an array priorCliSessionIds, files <account>/<org>/local_*.json under claude-code-sessions and local-agent-mode-sessions. Dirs come from desktopdir.Everywhere, the resolver the other Desktop session readers use (Windows %APPDATA% and MSIX LocalCache, Linux ~/.config); Windows/Linux not run. Run: new tests TestDesktopSessionTitleHandles, TestDesktopSessionTitleInStats, TestDesktopTitlesReadOncePerList, and context checks in TestDesktopSessionTitlesOnPages. Each broken by hand went red: rescan per call -> "metadata looked at 12 times, want once"; no last-good -> "a half-written file lost its names"; no unarchived/stem -> missing ids; stats without the name -> "stats titles map[cli-s:Recorded prompt ...]"; Context without it -> "context titles map[...: ...]". go test -race -count=20 -run TestDesktop ./internal/sessions; go test -tags nogui ./... (sandbox HOME, pinned caches): all ok but internal/plugin's TestPiPackage (pi-codemode export missing; passes alone, doesn't import sessions or gui), filed as #1879; gofmt -l; go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...; go build, GOOS=linux go build -tags nogui, GOOS=windows go build. GUI: routing-sessions, session-identity, sessions-overview, sessions-bar-names, sessions-gateway-delete, sessions-manage, context-window in Chromium and WebKit (84/84 each). Real binary: magpie web under a sandbox HOME with Claude-3p Code and Claude Cowork fixture records and five claude-desktop usage records; the Sessions page (Chromium, WebKit) showed both titles on current, prior and unarchived ids and the bare id on the unmatched one; /api/gateway/session-titles named them; a rename showed after 1.3s; a half-written file kept the name; deleting the record went back to the id. Co-authored-by: Koohoko <koohoko@gmail.com> |
||
|
|
d46a5635c0 |
sessions: Claude Desktop uses its saved conversation titles (#1675)
Read Code and Cowork metadata when native CLI transcripts are absent, including current/prior CLI IDs and renames. Keep gateway identity, accounting and capabilities. Desktop titles take precedence over the recorded first-prompt fallback added upstream; unknown names keep it. Rebased onto |
||
|
|
1a44670302 |
gateway: a long Codex session full of images is read up to 512 MB, and magpie's 413 says it is magpie's limit and to /compact (#1422, NeoPengZhile)
NeoPengZhile's Codex (signed in to ChatGPT, through /backend-api/codex/ responses) got "413 Payload Too Large: request body exceeds gateway limit" on all five reconnects in a long session that had read many images; a new session worked. Codex sends the whole conversation every turn, screenshots inline as base64, zstd-compressed; magpie's limit is on the decoded body and was 128 MB, while magpie compresses a ChatGPT turn again on the way out, so the backend sees about what Codex alone would send. The message didn't say whose limit it was or what to do. What changed: - request_bounds.go: defaultBodyLimit 128 MB -> 512 MB (decoded, which also sets the zstd decoder's memory cap). Every route that reads with the default gets it, keyLimited's read among them, so a limited key isn't held to the old number first. Routes with their own lower limit (System One 16 MB, a Claude subscription's 16 MB) keep it. - overLimit: magpie's own 413 says "request body is over magpie's gateway limit of 512 MB (decoded); the provider was not asked". - gateway.go writeError: the hint added to a 413 now says it is a byte limit, not the model's context, and to /compact (Codex, Claude Code) or start a new conversation. - request_bounds_test.go: TestRequestBodyTooLarge uses defaultBodyLimit+1 in place of a literal 129 MB. - docs/subsystems/gateway-routing.md says so. Run: go test ./internal/gateway/ -count=1 (ok, 354s), with the new TestImageHeavyCodexTurnIsRead (a zstd body of inline images decoding to 136 MB on Codex's backend path, read with the default limits) and TestOverLimitSaysWhoseAndWhatToDo; go test ./internal/gui/ (ok); go vet ./... on darwin, GOOS=linux -tags nogui and GOOS=windows; gofmt -l. Broken by hand: the limit back at 128 MB -> TestImageHeavyCodexTurnIsRead fails with the 413; the old "exceeds gateway limit" message, or the old hint, -> TestOverLimitSaysWhoseAndWhatToDo fails. Not tried: the reporter's real session, or how big a turn the ChatGPT backend itself takes; the test's images repeat, so its wire size is far smaller than real screenshots'. Peak memory for a turn near 512 MB was not measured. |
||
|
|
c6da41b04c |
agent: an IDE plugin's ~/.copilot or ~/.qoder-cn isn't taken for the CLI (#1495, v5tech)
v5tech traced two agents listed with no CLI installed to the JetBrains
plugins that write the CLI's folder:
- GitHub Copilot's JetBrains plugin writes ~/.copilot (ide/, instructions/,
prompts/, agents/, skills/, hooks/; the paths are in its jar). Copilot
CLI was detected by that folder alone.
- Qoder CN's JetBrains plugin fills ~/.qoder-cn (its indexer in
shared_client/, app/, plugins/) and writes a settings.json holding only
{"enabledPlugins":{...}}, which is the CLI's Path, so the CLI was found
by its "config file".
What changed:
- Copilot CLI sets dirShared, as omp does for Pi's folder: settings.json
or the copilot command still finds it.
- Agent gets pathOwn: when set, the file at Path counts only if it says
the file is the agent's. Qoder (both builds, one qoderAt) sets dirShared
and pathOwn = !qoderPluginOnly: a settings.json that parses as an object
of enabledPlugins alone is the plugin's. Any other key, {}, or a file
that can't be read or parsed still counts (unknown is not "the
plugin's"), and so does qodercli / qoderclicn on PATH. The global build
is held to the same because the code and the plugin are shared; that
the intl plugin writes ~/.qoder the same way is by analogy, not seen.
- docs/subsystems/agent-wiring.md says so.
Run: go test ./internal/agent/ -count=1 (ok, 226s), including the new
TestCopilotFolderFromAnIDEPluginIsNotTheCLI and
TestQoderSettingsFromAnIDEPluginIsNotTheCLI (the reporter's folders,
then the command on PATH, then the CLI's own settings).
Broken by hand: Copilot's dirShared off -> the Copilot test fails; Qoder's
pathOwn nil -> both qoder subtests fail; Qoder's dirShared off -> both
fail.
Not tried: a real JetBrains plugin or Qoder CLI; WSL (its probe counts the
distro's folder and isn't changed; a Windows JetBrains writes the Windows
home, not the distro's).
|
||
|
|
bf60d32bde |
gateway: a key set to a protocol its provider has no URL for is said on Routing and in the editor, not passed over quietly (#1702, edussss)
edussss set a relay key to Responses only on a provider with a Chat URL
and no Responses URL. perKeyBarred skipped the key (no endpoint for its
protocol), every key was skipped, so the provider was tried whole and the
request went out on Chat with nothing saying why. The owner: it shouldn't
fall back quietly.
Requests are still served on the URLs the provider has (so working setups
keep working), but now it is said:
- fallback.go: perKeyBarred remembers the protocol of the first key it
skipped for having no URL, and the whole-provider candidate carries it
as noURL.
- trace.go: Weighed.NoURL, so the Routing page sees it.
- routing.js: the row and the activity line say "key set to {api} only,
no {api} URL · sent on the others".
- app.js/app.css: the editor's key row shows an amber "No {api} URL" chip
(keyLacksURL) with a title that says how to fix it.
- i18n.js: the three strings in zh, zh-TW, ja and de.
- docs/subsystems/providers-accounts.md: the Keys row says so.
Run: go test -run 'TestKeyForAProtocolWithNoURLIsSaid' ./internal/gateway/
(the reporter's case: upstream /v1/chat/completions with k-resp, NoURL
"responses"; with an Any key added it goes to k-any and NoURL is empty);
key-nourl.test.cjs in chromium and webkit, en/zh/zh-TW/ja/de, at 420 and
1000 wide, no click-scroll, no sideways scroll: 40 pass; with i18n-keys,
gui-zh-tw/ja/de, key-copy, key-weight, key-weight-fit, key-import,
routing-key-windows, routing-keys-fold, proto-menu-overflow, nokey-editor
and ledger-protocol: 174 pass, 0 fail.
Broken by hand: without the noURL mark the Go test fails (noURL = "",
want "responses"); with keyLacksURL/noURLWord removed chromium fails 20
of 20.
Not tried: a real relay, or the GUI against a live gateway.
|
||
|
|
d3d1605c2c |
sessions: Kimi Code's own calls reach Usage, read from its wire files (#1607, infinitr0us)
Usage counts the gateway's calls and the calls the agents' own session files record (sessions.Calls). Kimi Code had no reader, so its calls straight to api.kimi.com on Kimi's own sign-in never showed (the reporter's 47 k3 calls of one session on 2026-10-11). The reader (calls_kimi.go) is built from the redacted real wire files infinitr0us shared from two machines (protocols 1.0, 1.4, 1.5; text replaced, every id, model and number kept) and their notes from Kimi Code's source. It reads every agents/*/wire.jsonl under $KIMI_CODE_HOME/sessions, else ~/.kimi-code/sessions (as agent.KimiDir finds the new Kimi Code), main and subagents, ses_* folders included. One call per usage.record: inputOther, inputCacheRead and inputCacheCreation go to Input, CacheRead and CacheWrite, output as is, the record's own model and time. Nothing is paired with step.end, since 1.4 and 1.5 write them in opposite orders and the June 1.4 build has no messageId or llm.request. A model beginning "magpie/" (magpie's own entry in Kimi's config) is skipped: the gateway counted it. kimi fork copies the parent's records unchanged, so a call is keyed by agent (agentId, else its agents/<id> folder), time, model and usage, and Calls counts a key once. It is a whole-file call source (callSources, wholeCallReaders) and the folder is watched (Dirs). The subsystem page gets the list of call readers. Fixtures (testdata/kimi-code) are the reporter's files cut to the lines a call is read from, each line verbatim (50 KB; one of the July session's eight agents kept). Run: the reader over the reporter's whole, untrimmed files gives exactly their README's totals (32/2,841,972/12,283; 151/7,025,587/122,782; 6/147,822/2,009; 10/338,328/2,176; 0 for the four others). TestKimiCodeCalls (both homes), TestKimiCodeSkipsCallsThroughMagpie, TestKimiCodeForkCountsOnce, TestKimiCodeBrokenFiles (cut mid-record, empty, junk, null/negative/timeless usage) pass. Broken by hand, each goes red: no magpie skip, no key, key without agent, no negative or time guard, main only, KIMI_CODE_HOME ignored, cache read dropped. go test -tags nogui ./internal/sessions ./internal/usage ./internal/cli ./internal/gui under a sandbox HOME, gofmt -l, go vet (darwin), GOOS=linux go vet -tags nogui, GOOS=windows go vet. Not tried: a live Kimi Code run (fixtures are the reporter's real files, not a sandbox capture), a successful call through magpie (the magpie-routed record in the test is the reporter's quoted 1.5 line with a magpie/ model), a compaction record (usageScope "session", none in the files), Kimi Code in WSL (not read), Windows paths at runtime. A subagent's calls carry the session but no Subagent field. Thanks to infinitr0us for the write-up from Kimi's source and the redacted wire files. Reported-by: infinitr0us |
||
|
|
a43fa6809b |
library: two changes in one millisecond each get a backup folder of their own (#1743)
liubing reported on #1743 that TestRemoveFoundEntryEveryFormat failed in a full run on Linux, the backup read holding another format's content, on an unmodified main too. The backup folder was named by the millisecond and taken as this change's own: a second change in the same millisecond wrote into the first's folder, its file kept under its folder's name since the first's held the name, and the copy at the name the change wrote was the other change's. The test's loop runs one change per format, all named config.json, and on a fast machine two land in one millisecond. A user's two quick changes did the same: the backup the second change named wasn't its own. freshBackup makes the folder with os.Mkdir, adding -2, -3... when the millisecond's is taken. pruneBackups' sort keeps them in order. Siblings checked: the skill backups (keepLibrarySkill, keepReplaced, setAside, carry's and RemoveSkills' aside) use per-skill paths under the stamp; setAside already steps past a taken name, and the others only collide on the same skill in the same millisecond, where move fails loudly rather than mixing; they are left as they were, since a folder each would split one change's skills over many folders. Run: go test -tags nogui ./internal/library/ ok on macOS and in Docker golang:1.26.8 GOTOOLCHAIN=local (also -count=30 of the two tests). The original red didn't show in Docker in 100 runs; it was reproduced by injecting a minute-wide stamp, which turned TestRemoveFoundEntryEveryFormat red on the old code and leaves it green with the fix. Broken by hand: os.Mkdir -> os.MkdirAll (no claim on the folder) turns TestBackupsInOneMillisecond red. |
||
|
|
9935119f1d |
sessions: search finds Cursor and OpenCode sessions read from their stores, and a Cursor chat's system prompt isn't shown as said (#1743)
Follow-up to liubing's #1743 patch, which put cursor and opencode in HasTranscript. That moved their search from magpie's recorded transcript to SearchSession, whose byte prefilter (mayHold) reads s.Path. For these agents s.Path isn't the conversation: - OpenCode's JSON storage: the session info file, without messages, so every word missed; - OpenCode's and Cursor's SQLite stores: the newest pages are in the -wal, so a live chat's latest turns missed. linesFile now skips the prefilter for them (a Cursor .jsonl still gets it). cursorTranscript also handed the CLI store's system message ("You are a coding agent.") to the transcript as a said part; system messages are skipped, as the listing already does. The patch's tests commit left TestSearchSessionWithoutATranscript red (it used cursor as the agent without a transcript; now gemini). sessions-empty-range.test.cjs runs in every language, de at 420px. Run: go test -tags nogui -count=1 ./internal/sessions/ ok, and -race ok; sessions-empty-range 10/10 (Chromium+WebKit, en zh zh-TW ja de); sessions-today/overview/toolbar/search/manage/calendar-fill/paging GUI tests pass. Broken by hand: prefilter always on -> TestSearchOpenCodeFiles and TestSearchCursorLiveChat red; system skip removed -> TestSearchCursorLiveChat red. Also broke the patch itself: editor files not appended, readOnly Delete guard, stats message dates, CLI dedupe, HasTranscript entries, parseCursor readOnly dispatch, and the "All sessions" button (via MAGPIE_TEST_APP_JS); each went red. Co-authored-by: liubing <lb0806@foxmail.com> |
||
|
|
1cd8140047 |
sessions: read Cursor editor history and Cursor/OpenCode conversations (#1743)
Discover editor project transcripts and cursorDiskKV histories without modifying the source. Share one SQLite/WAL snapshot across a scan, refresh metadata changes, deduplicate CLI histories, and reject deletion of read-only sessions. Count message-only sessions and expose an all-dates action when a filter hides existing history. Read Cursor CLI text, reasoning and tool parts, and OpenCode v1/v2 transcripts through the existing transcript API. |
||
|
|
296b63f8d6 |
usage, gateway: tests for the #1463 rebase: a priced row keeps its reasoning evidence, and a summary after an endpoint fallback stays hidden
Follow-up to congee949's rebased dfc24632 (#1463, streamed reasoning speed). - TestPricedRowKeepsReasoningEvidence: the Requests page reads gateway rows through blockPricer, which sets swapKnown (64) on every row. The patch put ReasoningHidden on bit 64 too; on main that would have read every priced row as hidden, so a tool-only reply with no reasoning, and paced visible reasoning, lost their speed on the Requests tab. The rebase gave ReasoningHidden its own bit (256, Flags widened to uint16); this test prices visible, tool-only and hidden rows, raw and packed, and checks the flag and the speed read back. - TestSummaryAfterEndpointFallbackStaysHidden: a Messages client, a model answered on /responses after /chat/completions said it isn't served there. call.To still reads Chat, so hidesReasoning(call.To) doesn't see the summary; only streamTranslated's summaryUpstream marking does. With no reasoning count the 1500 output tokens were otherwise timed from the first summary delta. Nothing covered that marking before. - reasoning-speed.test.cjs: the "no reasoning: 500 in 5 s" comment had been joined onto the redacted row; put back on its own row. - docs/subsystems/gui-shell.md: the flag bit, the fallback marking, the two tests. Run: go test -tags nogui -count=1 ./internal/usage/ and the gateway's reasoning tests; reasoning-speed.test.cjs in Chromium and WebKit (en, zh, zh-TW, ja, de), 10/10. Broken by hand: rowReasoningHidden = 64 turns TestPricedRowKeepsReasoningEvidence red (visible and tool-only rows read hidden, 0 tok/s); summaryUpstream forced false turns TestSummaryAfterEndpointFallbackStaysHidden red (1500 tokens in 314 ms). Co-authored-by: congee949 <c86474321@gmail.com> |
||
|
|
2d3b33bb78 |
usage: time tool-only replies only with visible reasoning evidence
Revises #1463 after the hidden-reasoning inflation review. Keep answers separate, retain evidence in routes and cached ledger rows, and exclude sealed or summary-only reasoning even without a token breakdown. Sync the backend and both GUI formulas. Checked real WorkBuddy DeepSeek, Codex and Claude bridge responses in an isolated HOME; sanitized timings and failures are in docs/verification. Chromium/WebKit speed regressions pass (20 tests, five languages). New edge regressions and loop-order check pass under race repetition. Restoring the old formula or removing the hidden guard fails TestVisibleReasoningSpeed. macOS/Linux/Windows vet/build pass. Full-suite verification is recorded in the issue at this head; inherited proxy/Bun 1.3.14 failures are retained, with clean Bun 1.4.2 rerun in progress. No installed app replacement. Rebased onto main by yetone (#1463). Conflicts with main's Own/Retried/ Queued/Tries row fields, HandedOn and the Codex speed floors were resolved by keeping both. The packed row's ReasoningHidden bit was 64, which main has since given to block_price.go's swapKnown, and main's rowHandedOn took 128, filling the uint8: Flags is now uint16 and ReasoningHidden is bit 512 (rowReasoningHidden; #1874's rowOwnCost took 256), read back in row(). The docs/verification notes and their sample JSON are left out of the tree; they stay on the contributor's branch and the issue. Run after the rebase: go test -tags nogui ./internal/usage/ and the gateway's reasoning/speed/TTFT tests, ok. |
||
|
|
cc93b566e2 |
gateway: Zed's test still checks is_error true on a real result, beside the mended orphan (#1558)
What changed: d1d45dd3 made TestZedToolResultSaysIsError's toolu_2 result an orphan turned to text, and its assertion went from [false true] to [false]: nothing checked any more that a result with is_error true goes to Zed's cloud with it (yetone/magpie-releases#9). The fixture's assistant now makes toolu_2's call, so both real results keep [false true], and a separate toolu_9 result with no call checks the orphan goes as its text. The pairing tests also check the synthetic result is is_error, and a new TestMessagesSecondAnswerDropped checks a call answered twice keeps only its first answer. docs/subsystems/gateway-routing.md gets a bullet for the Messages build's mending, beside the Gemini and Responses ones. Why: the patch's tests passed with is_error dropped from the synthetic result and with the second-answer rule removed. Run (sandbox HOME, private GOCACHE): - go test -tags nogui -run 'TestMessages|TestZed' ./internal/gateway/: ok - pairToolBlocks call removed: the six TestMessages tests and TestZedToolResultSaysIsError fail ("is_error: [false true false]", "what the lost result said is not kept"). - IsError dropped from the synthetic result: TestMessagesUnansweredCall GetsSyntheticResult fails. The duplicate's continue removed: TestMessagesSecondAnswerDropped fails ("user[A,A]"). Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
44b5b2b96b |
provider: a Claude usage ask invalidates an older read even in the same clock tick
Refs #1228. The original test fails with "a reading from before the ask
was kept". A temporary diagnostic measured identical UnixNano values for
the read's start and the later ask; that diagnostic is not shipped.
What changed:
- Count both whole-page and manual-card Claude asks with a generation.
Advance it under subscription then login cache locks, so publication
cannot check the old generation and then commit after the ask.
- Capture the generation before launching LoginUsage/SubscriptionUsage;
reject an older account read or leave the cards due for another read.
- Record each Claude /usage run's ask generation. Keep timestamps, the
zero sentinel, floor, idle behavior, saved-account scope and fallbacks.
- Document ordering and lock ownership in the providers/accounts design.
No tests, routing.go, account files or dependency versions changed.
Run on upstream
|