fe08c8ddb58b1af5e8cb4e34deb10c29bb319cee
489
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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 | ||
|
|
aabdd6126a |
gui: a model's speed leads with the figure from more replies, counts written out, TTFT on its own line
Fallmonkey (Discord) read "75 tok/s (3) · ≥54 tok/s (289)" on the Output
speed card and the Usage ranking as the 3-reply figure being the model's
speed, with the 289-reply floor tucked behind it, and "(3)" not saying
what was counted.
Now, everywhere a group's speed shows (the Output speed card, the
overview lists and the Usage ranking by speed):
- the figure from more replies comes first and is the big one; a tie
keeps the measured one first. The ranking orders and bars by it.
- counts are written out, without parentheses:
"≥54 tok/s · 289 replies; 75 tok/s · 3 timed replies"
zh "≥54 token/秒 · 289 次回复;75 token/秒 · 3 次计时",
with zh-TW, ja and de strings of their own.
- on the card the second figure is its own line, and the average wait
for the first token is a line of its own with its count
("first token in 1.2 s on average · 3 timed replies"), wrapping rather
than cut off. In the big figure the count is a muted caption without
the dot, so a wrapped count never starts a line with "·".
- the tooltips are unchanged; the threshold for the floor is unchanged.
What was run:
- usage-speed and usage-ttft-rounding now expect the TTFT line's
count; green in both engines.
- usage-speed-count.test.cjs (rewritten for the new rule) in Chromium
and WebKit, 5 languages x widths 1400/983/789/700/560: 26/26 each.
On origin/main's assets it fails ("125 tok/s (1) · ≥50 tok/s (259)").
- 55 related suites (usage-*, ledger-*, reasoning-speed, routing-*-speed/
metrics, panel-usage, gui-de/ja/zh-tw, i18n-keys, click-scroll,
tray-usages) in both engines: all green.
- gofmt -l, go vet darwin, GOOS=linux -tags nogui, GOOS=windows on
internal/gui; go test -tags nogui ./internal/gui: ok.
- Screenshots of the card and ranking at 560 and 1400 in en, zh, de.
Reported-by: Fallmonkey (GitHub MonkeyLeeT)
Co-authored-by: MonkeyLeeT <MonkeyLeeT@users.noreply.github.com>
|
||
|
|
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
|
||
|
|
d4c2512d2d |
usage: apps report their own calls with POST /v1/magpie/usage/requests, backfill included (#1874)
What changed
- POST /v1/magpie/usage/requests (internal/gateway/usage_ingest.go) takes
one record or an array, in usage.jsonl's shape:
- the post may carry up to 5000 records and 32 MiB;
- t, agent, provider, model and rid are required.
Each field is checked: unknown fields, quoted numbers, negative or absurd
counts, a status outside 100-599, a cost over 10000 USD, and a t more
than an hour ahead or before 2000-01-01T00:00:00Z. Any fault refuses the
whole post with a 400 that names error.index and error.param, and nothing
is written. A past t is otherwise taken as given, so history can be
backfilled. The reply gives accepted and skipped counts and each
record's index, rid and status.
- Access: lanGuard's rule (this machine, or another with a key while
shared, behind the Host check). A browser page also needs a key, since
corsGuard lets localhost pages and Origin null through. A held key is
refused.
- usage.IngestReported writes under usage.mu to the same file as
usage.Append. Rows carry source "reported" and no caller key. A rid
already reported is skipped, as is one repeated in the post. The set of
reported rids is read back from the log: one scan after a restart (lines
without the reported mark aren't parsed), then only what was appended.
- Pricing: a record with cost keeps it (Record.OwnCost, the rowOwnCost
flag; packed flags widened to uint16). Otherwise it is priced at
magpie's prices.
- Display:
- SourceReported is a source of its own: RequestPage.Reported,
?via=reported, and Ledger now honours via.
- The Requests tab gains a fourth cell "reported by apps", shown once
there are some, and a "Reported" badge (en, zh, zh-TW, ja, de).
- Nothing live: Record.IsReported keeps reported rows out of:
- a key's budget/spend limit (budget.counts);
- window holds, and the log start that decides whether a window can be
reckoned (logSnapshot.firstOwn);
- gateway sessions and Vias;
- Codex's sealed answers and remembered model.
There is no OTel span, rate limit, rest or alert for them.
- Docs: gateway-sessions.md, reference.md (with a curl), integrating.md,
site integrate.html (en, zh).
Why: the reporter's apps call vendors directly, and their usage (and
history) should show on the Usage page without becoming live traffic.
Run, in a worktree with sandbox HOME and a private GOCACHE
- gofmt -l: clean.
- go vet ./...: darwin, GOOS=linux -tags nogui, and GOOS=windows.
- go test internal/usage, usageapi, budget, gateway, gui: ok.
- -race -count=3 of the new usage/gateway tests: ok.
- GUI with playwright 1.62.0:
- usage-ledger-reported.test.cjs, 26/26 in chromium and webkit (5
languages, 1180 and 420 wide, light and dark);
- usage-ledger*.test.cjs, ledger-*.test.cjs, usage-sum-whole,
usage-unpriced-sum and i18n-keys: all pass.
- Timings with 200k reported rows (47 MB log, darwin):
- 40 posts of 5000 took 0.40 s (worst batch 18 ms);
- the first post after a restart took 0.45 s (rid rescan), a later one
1.6 ms;
- the cold index build took 2.1 s (as for gateway rows);
- page all took 27 ms warm, page 30d 39 ms, all via=reported 0.53 s;
- summary all took 215 ms, 30d 20 ms.
Broken by hand, each went red, then restored
- Go: dedupe against stored rids; the restart scan; CostAt ignoring own
cost; the block pricer overwriting own cost; the Reported split;
fromBrowser's key rule; skipping bad records instead of refusing; the
max-records and body limits; the ingest lock (race); both locks;
firstOwn -> first; the IsReported guards in windowHolds,
buildGatewaySessions, buildVias, budget.counts and loggedAnswers.
- GUI: the fourth cell, the --vias column count and the badge class.
Not shown red on its own: the remote-no-key and evil.example refusals come
from lanGuard and corsGuard before the handler, so breaking only the
handler's own check stays green. The codex_memory guard is not tested
alone: a reported row has no Requested there anyway. Not tried: a real
client against a live gateway, Windows/Linux runs of the tests, the full
GUI suite.
|
||
|
|
abdc4b113d |
netproxy, provider, gateway: every request to the ChatGPT backend goes over HTTP/1.1, magpie's own too, not only the gateway's turns (#1700)
|
||
|
|
d0e412e7a6 |
library: a checked MCP server's PWD is home too, and #1727's cwd test holds on macOS (#1727)
The previous commit starts the check's server in home. Its own test failed on macOS with that fix in: the child reported /private/var/folders/.../magpie-test-home-N and HOME was /var/folders/.../magpie-test-home-N, the same folder spelled through macOS's /var symlink, compared as strings. The test now compares the folders with os.SameFile. exec sets PWD to Dir by itself only when Env is nil, and the check sets Env, so the server ran in home with PWD still naming magpie's own folder; a shell-script server that reads $PWD would see the folder the fix moved it out of. The check now sets PWD=home with Dir (not on Windows, which doesn't use PWD, as exec does), before the server's own variables so one it sets still wins. The two subtests now give each run a home of its own (t.Setenv HOME and USERPROFILE) and move the process with t.Chdir, so the "needcwd" fake's ./logs goes with the test instead of staying in the package's shared test home, and nothing is left in another cwd when a subtest fails. The read-only-cwd subtest also checks that ./logs landed in home: Windows doesn't enforce a folder's read-only bit, so that is what makes it fail there without the fix. Run (sandbox HOME, private GOCACHE): TestCheckStdio -count=3 on macOS; the whole internal/library package. Broken by hand: without cmd.Dir both subtests fail (wrong folder; "mkdir logs: permission denied"); without the PWD line the cwd subtest fails on its PWD. On the Windows box (windows/amd64 test binary): TestCheckStdio passes, and without cmd.Dir both subtests fail there too (the server ran in the test's temp cwd, and ./logs wasn't in home). Co-authored-by: ump45nose <52391318+ump45nose@users.noreply.github.com> |
||
|
|
f31ae38aeb |
provider: Xiaomi MiMo is priced at xiaomi's list price, not its Token Plans' $0, and pay as you go looks only in xiaomi (#1873)
mengyianx found every pay-as-you-go MiMo call counted at $0.000: models.dev's xiaomi-token-plan-cn, -sgp and -ams list all nine models at cost 0 (the plan's per-token charge, not the model's price), the preset's catalog was "xiaomi-token-plan-cn, xiaomi" at every region, and catalog.PricedBy takes the first catalog with a cost field. makerCatalogs puts the plan catalog ahead of xiaomi too, so the maker fallback gave $0 as well. What changed: - membershipCatalogs (never read for a price) gains the three xiaomi-token-plan catalogs, as #1370 did for Kimi Code. That covers ListPrice, MakerPrice and PricedName through makerPriceCatalogs. kimiCodeMember now checks a list of Kimi Code's plans of its own (kimiCodePlans), so a Xiaomi provider isn't taken for Kimi Code and its ids aren't mapped to Kimi's. - Each Xiaomi region names its own catalog: plan-cn/sgp/ams "xiaomi-token-plan-<r>, xiaomi", pay as you go "xiaomi" alone. A plan user is priced at the API-equivalent price, the same meaning as #1370. - PricedBy is unchanged: a catalog that lists a model at $0 still prices it at $0 (nvidia, modelscope have truly free models). - docs/subsystems/providers-accounts.md says so. Providers saved before this: the preset's own catalog stays "xiaomi-token-plan-cn, xiaomi", the same string an existing provider saved with the old default holds. normalize already lets a catalog that equals the preset's or one of its regions' follow the region the provider is at (the Tencent Cloud mechanism), on every read, so an old default at pay-as-you-go reads as "xiaomi" and at Singapore as "xiaomi-token-plan-sgp, xiaomi"; nothing is written to providers.json until the user next saves it. Any other catalog the user typed is kept as typed, and is priced right anyway because the plan catalogs are out of pricing. The one value that can't be told apart is a bare "xiaomi" typed at a plan region (the issue's workaround, which was for pay as you go): it equals the pay-as-you-go region's catalog, so it reads as that plan's "xiaomi-token-plan-<r>, xiaomi". Its prices are identical either way; only the model-metadata lookup order differs. That is the existing rule for every preset with region catalogs, kept rather than special-cased. Siblings: scanned the models.dev cache (read only) for catalogs whose priced models are all or mostly $0. Of those, only kimi-code-plan-* and xiaomi-token-plan-* are named by any preset or region. stepfun's *-step-plan catalogs carry no cost at all, so they never shadowed a price. alibaba/minimax/zai/zhipuai/volcengine/tencent coding and token plan catalogs are all-$0 on models.dev but no preset uses them. Tests (internal/provider/xiaomi_price_test.go, fixture testdata/xiaomi_catalog.json cut from models.dev's real entries): - TestXiaomiListPrice: every region, the old default, a user's own catalogs: mimo-v2.6-flash $0.14/$0.28/$0.0028, mimo-v2.6-pro $0.435/$0.87/$0.0036; MakerPrice; EffectivePrice of a saved provider; a relay's own $0 model ahead of xiaomi stays $0; a Xiaomi provider is not a Kimi Code member. - TestXiaomiRegionCatalogs: each region resolves to its catalogs from the preset's, the old default and another region's; import links at each region; FromPreset; a user's catalog kept at two regions. Broken by hand, each red, then restored: - membershipCatalogs back to Kimi only: TestXiaomiListPrice FAIL, plan regions and MakerPrice at $0. - region catalogs removed: TestXiaomiRegionCatalogs FAIL (api with the old default stays [xiaomi-token-plan-cn xiaomi], imports at sgp/ams get cn's). - both: TestXiaomiListPrice FAIL, api with the old default at $0 (the reported bug). - kimiCodeMember on membershipCatalogs: FAIL "a Xiaomi Token Plan provider counts as a Kimi Code membership". - PricedBy's exact match skipping all-zero costs: FAIL "relay mimo-v2.6-flash: ... want its own $0". Run: gofmt -l (nothing); go vet ./... on darwin, GOOS=linux -tags nogui, GOOS=windows; go build on all three; go test -tags nogui -count=1 ./internal/provider ./internal/catalog ./internal/cli ./internal/gui ./internal/usage, all ok, in a sandbox HOME with pinned caches. Real use: built binaries before and after, sandbox HOME with a copy of the real models.dev cache and a providers.json holding the reporter's saved state. `magpie model price xiaomi/mimo-v2.6-flash` printed $0/$0 before and $0.14/$0.28 after; an old-default provider at Singapore went $0 -> $0.14/$0.28 and shows catalog "xiaomi-token-plan-sgp, xiaomi"; one with the user's "openrouter, xiaomi" kept it; providers.json was byte-identical afterwards. Not tried: a real MiMo key or call, the GUI editor's region switch, the full go test ./... suite. Co-authored-by: mengyianx <106875577+mengyianx@users.noreply.github.com> |
||
|
|
841af36bfc |
gateway: models the user disabled are refused on every route, and leave every list (#1867)
oxsean asked for one place to turn a model (claude-fable-5) off for good:
not reached by a direct request, an old session, a routing group member,
a fallback, a sub-agent, count_tokens or a decision model.
What changed:
- settings.DisabledModels: patterns, an exact id or a glob (* any run, /
included; ? one), matched ignoring case against provider/model, the
bare id and its last segment (provider/disabled.go). Empty by default,
so nothing changes for anyone who doesn't set it.
- Lists: buildEntries (entriesOff) leaves a disabled model out of the
catalog, so /v1/models, agents' model files and pickers, Codex's list
and every group go without it; membersIn skips it as a member, Deciders
as a decision model; codexModels drops Codex's own disabled slugs and
codexListTag changes so Codex refetches.
- Requests (gateway/disabled.go): 403 "model <id> is disabled in magpie"
in each API's error shape, at #882's choke points: serve (idOff),
perKeyBarred (no candidate: group next member, provider Fallback),
count_tokens and Gemini :countTokens, serveSystemOne,
serveDecisionGroup and postDecide, draw/video/embeddings, and
codexBackend for Codex's own bare models. A group with a member left
goes on without it; one with none left is refused naming them. A bare
id the catalog no longer has is refused as disabled, not 404. A Codex
sub-agent pick onto a disabled model stays on its lead's model.
- An unreadable settings.json is never "none disabled": the list read
last stays; with none read, every request is refused; nothing is
written over the file.
- CLI: magpie model disable <model|glob>..., enable ..., disabled
(list-disabled).
- GUI: Settings > Models > Disabled models: each pattern with the models
it matches now and Enable; Disable... opens the model picker, which
also takes a typed glob. Says only requests through magpie are covered.
POST /api/settings/disabled-models; POST /api/settings keeps the list.
Strings in zh, zh-TW, ja, de.
- docs/subsystems/gateway-routing.md: Disabled models section.
What was run (worktree at origin/main
|
||
|
|
1f0ff81dfc |
agent: Grok App's own route picked in magpie is taken, and Disconnect can put one back; a sync that isn't connected writes nothing (#1625)
Follow-up to fjrtdk's commit before this one, which this keeps: magpie never names itself as Grok App's route. - Set refused every own route (errGrokAppRoute) while Options still offered them, so the picker showed choices that only errored. It also broke Disconnect: when unwire leaves no route (Use set it to magpie, nothing stashed), Disconnect sets connect.was's route back through Set, got the error and stopped half done. An own route now takes magpie's channel out and is written as [models] default, the way picking another provider leaves magpie on other agents. That route can't be magpie, so the App's sign-in is never touched. - Sync ran rememberRoute/releaseRoute before checking for the channel, so every user with Grok App installed but not connected got stash entries. Now it returns before them unless the channel is there or the route is still magpie (an older magpie's takeover to put back). - Check again warns when the route is magpie and the channel is gone, which that commit dropped. - The notice uses the App's own labels (Settings › Account, Use; ja 「使う」, de Einstellungen › Konto / Verwenden, from grok-app 0.2.40's settings.nav.account and prov.useThis) and says a chat can pick magpie's models in its model picker (composer_prefs_set, which doesn't move the route). - Sibling: rtk init has no grok agent for Grok Build either (rtk 311ebcb agents: claude codex copilot cursor droid gemini hermes opencode pi trae vibe antigravity), so Grok Build is in rtkNoHook too. Run: gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and GOOS=windows clean; go test ./internal/gateway ./internal/agent ./internal/library -count=1 pass; node --test i18n-keys and agent-notice-lang pass. Broken by hand: that commit's grokapp.go fails TestGrokAppOwnRouteStays, TestGrokAppDisconnectPutsTheRouteBack and TestGrokAppSyncUnconnected; dropping the Check branch fails TestGrokAppSyncUnconnected; dropping rtkNoHook["grok"] fails TestRTKNoHookGrokBuild. Not tried: the Grok App GUI itself; the config format and behaviour are from grok-app 0.2.40's source. Co-authored-by: fjrtdk <fjrtdk@gmail.com> |
||
|
|
ea3d480edf | agent: Grok App keeps its own route; magpie is a custom provider under Accounts, and the Library writes instructions, MCP and skills on agent-home (#1625) | ||
|
|
125dad5cbb |
gateway: a codex provider used only through routing groups keeps the ChatGPT account's own models out of Codex's list (#1602)
With Codex signed in to ChatGPT, Codex asks magpie's /backend-api/codex/models
for its list, and codexModels passes the backend's own models through,
narrowed only by the codex provider's picks (CodexNativePicked) and the
Agents page's hides (CodexNativeHidden, built from Catalog()). A provider
set to "Only through routing groups" (Provider.Unlisted) has none of its
models in Catalog(), so neither filter saw them: all of the account's
models stayed in Codex's picker, and the Agents page had no Codex group to
hide. Every other agent's list is Catalog-based and already left them out.
provider.CodexNativeUnlisted says which of the account's models are kept
out of agents' lists: every one when the codex provider is Unlisted, and by
slug those a group with Unlists names. codexModels drops them (hidden
entries such as codex-auto-review stay, as with picks; a Codex reached for
failover alone keeps them, as it is handed no groups), spawnChoices drops
the same ones from spawn_agent's list, and CodexListTag carries them so
Codex refetches. gateway-routing.md says so.
Test: TestCodexModelListUnlistedForGroups (a group unlisting gpt-5.5 takes
gpt-5.5 alone; the provider Unlisted takes gpt-6-sol and gpt-5.5 and keeps
codex-auto-review; ETag changes; spawn_agent offers neither; own-only keeps
them). With codex_backend.go and codex_spawn_models.go reverted it fails on
all three checks. Not tried with a real ChatGPT sign-in and Codex app.
Run (sandbox HOME, private GOCACHE, worktree at origin/main
|
||
|
|
97dfed0f3e |
library: a site's well-known kit of skills is one group, by the lock's sourceBaseUrl (#1862)
WardLu (#1862): skills that `npx skills add` got from a site's /.well-known/agent-skills/ index were one group per skill. That was Feishu's lark-base, lark-doc and lark-sheets, and Fish Audio's fish-audio-api and fish-audio-sdk. readSkillLock grouped them by each skill's own sourceUrl (".../lark-base.tar.gz", ".../fish-audio-api/skill.md"). Now a lock entry with sourceType "well-known" is grouped by its sourceBaseUrl, read as host/path (wellKnownBase/siteOf): - the user, query and trailing slash are dropped, and the host is lower-cased without "www."; - so Feishu's three are open.feishu.cn/lark-cli/skills/regular and Fish Audio's two are docs.fish.audio; - a kit on the same host with a different base URL stays apart. Hosts are not merged. Fallbacks: - an older lock with no sourceBaseUrl takes the part of its sourceUrl before /.well-known/; - an entry with neither is grouped by its sourceUrl, as before. Two things this new key would otherwise get wrong: - Group again (RegroupSkills) tried every owner/repo-shaped key on GitHub. A kit one folder down a site (docs.example.com/kit) has that shape, so a key whose owner has a dot is skipped now. GitHub owners have no dot. - the heading's link sent a key with no path ("docs.fish.audio") to github.com. repoURL now opens it at https://docs.fish.audio. Run: - go test ./internal/library (all pass). New TestWellKnownKitGrouped uses the issue's base and source URLs for 3 Feishu + 2 Fish Audio skills, plus another kit on open.feishu.cn, an entry with no base, and a docs.example.com/kit kit that Group again must not fetch. - With the well-known branch disabled it fails, with the reporter's five one-skill groups. - With the dot check removed it fails on a GitHub fetch. - new TestWellKnownBase: a table of base and source forms. - skill-repo-groups.test.cjs now has a docs.fish.audio group that opens the site. It fails with origin/main's assets, which say "on GitHub". It and skill-regroup/skill-groups pass in chromium and webkit. - gofmt -l; go vet for darwin, linux -tags nogui and windows on internal/library. Not run: the reporter's real ~/.agents/.skill-lock.json. The issue quotes only these three fields of it. A row's own link still isn't its sourceUrl. |
||
|
|
9a34a784dc |
library: Collapse all / Expand all for the skill groups (#1862)
WardLu (#1862) asked for a way to fold every skill group at once in a library of many groups. Library > Skills now has a Collapse all / Expand all button beside the sort (foldAllButton in library.js): - without a filter it sets every shown group's kept fold (magpie.libSkillFolds), the same as clicking each heading; - while filtering it folds or opens only the groups the filter shows, until the filter changes (unfiltered), and leaves the kept folds alone; - it says Collapse all while any shown group is open, else Expand all; - it is hidden with fewer than two groups (A->Z, or a filter only one group matches); - a part inside a group keeps its own fold, and nothing is sent. skillHits/groupFolded pull out the rules drawSkills already used, so the button and the headings can't disagree. Strings in en, zh, zh-TW, ja, de. docs/subsystems/library.md's Skill groups row describes it. Run: - new internal/gui/tests/skill-fold-all.test.cjs: chromium and webkit, en/zh/zh-TW/ja/de, at 640 and 1180. 22/22 pass, three times. With origin/main's assets it fails in every case (no button). - the skill-*, library-* (skills side), pick/remove/import skill tests and i18n-keys, at concurrency 4: everything passes except pick-skills.test.cjs in WebKit. That test is red with main's own assets too (#1672, being fixed separately). - screenshots in German at 640 and 1180: the button sits in the heading row and wraps with it. Not run: a real library with many groups in the app window. I didn't check by hand that the scroll check fails when something scrolls. |
||
|
|
76c6580ea6 |
gui: a skill group's agent chips count only the skills magpie decides, and a row's chip for one an agent reads from ~/.agents/skills itself is locked (#1862, WardLu)
A skill kept in ~/.agents/skills is had by every agent that reads that
folder itself (SkillView.Always), whatever is ticked. Its row's chip said
so only on a click, greyed like a chip that can't take the skill, while
the group's chip counted s.agents alone. Turning the group off for Codex
then said "off for Codex" and left the row lit.
What changed:
- groupChips (group headings, parts and the Select bar) counts, gives and
takes only the skills magpie decides for each agent. agents-some is
sent, per agent, the names it doesn't read itself, so a skill Codex
reads from the shared folder is never sent for Codex.
- A chip whose agent reads only some of them itself says how many, in its
tooltip. After a click, the status says "Codex still reads 1 of them
from ~/.agents/skills itself".
- An agent that reads every one of them itself has a lit, locked chip, as
the row's is. It sends nothing, and a click says why.
- The group's heading says "N in ~/.agents/skills", with a tooltip naming
the agents that read it, before any click.
- A row's locked chip is lit, with a small lock on its corner, rather
than greyed out at .35.
- Nothing deletes from the shared folder or touches another agent's
config. Servers and hooks keep their own reach rules unchanged.
- Strings in zh, zh-TW, ja and de. docs/subsystems/library.md (Skill
groups) says it.
What was run:
- New skill-group-shared.test.cjs, in Chromium and WebKit; en, zh, zh-TW,
ja and de; 640px and 1180px:
- heading note;
- partial chip tooltip;
- the locked row chip's opacity and its lock;
- the post sent, the status, and parents and rows agreeing after a
click;
- All;
- a fully locked group chip sends nothing;
- no sideways scroll.
22/22 pass, twice. It fails on the old code (no heading note; Codex is
sent mango too).
- group-skill-chips, skill-parts, skill-groups, shared-skills,
every-skill, library-all, i18n-keys, library-own-folder,
skill-repo-groups, library-pick-remove and library-null-agents pass in
both engines.
- pick-skills is red in WebKit on origin/main's own assets too, the same
as here. It is out of date since
|
||
|
|
091593f7d3 |
gateway, gui: a WorkBuddy account the vendor restricted (403 11140) rests 2 hours as restricted, and Routing names the appeal as the way back (#1849)
WorkBuddy answers an account it restricted for unusual activity with
403 {"code":11140,"msg":"request illegal","displayMsg":{"en":"Your
account has been restricted due to unusual activity",...}}. failure()
read it as an unknown failure, so the account rested 1-10 minutes and
was asked again, refused, all day.
What changed:
- provider: WBRestricted knows the refusal by code 11140 (top level,
data or error; number or string; whole, so 111400 isn't it) or by its
displayMsg words. wbExplain ends the built-in's error with
WBRestrictedHint.
- gateway: a new failRestricted ("restricted") rests restrictedRest, 2h:
one refused request per account per 2h, and a lifted restriction (or a
misread refusal) comes back the same afternoon; Unrest lifts it at
once. It is read from the hint in the error (restrictedSaid; both the
built-in and the plugin translate the vendor's body before failure()
sees it, so the raw JSON never reaches it in a chat try), or from the
raw body only for a WorkBuddy candidate (restrictedRefused,
isWorkBuddy), since another vendor's 11140 is its own. Bare "request
illegal" is not matched. 11128 stays promptRefused and rests nobody.
The stale-allowance shortcut skips it, as it does model refusals.
drawsWorkBuddy now uses isWorkBuddy.
- plugin: @magpie-community/opencode-workbuddy-auth 0.1.17 (plugins
caf3908) ends the error with the same hint; the mover's min is 0.1.17
so keepMovedCurrent brings moved users to it.
- gui: Routing labels the try "account restricted by the vendor", says it
rests because only the vendor lifting it brings it back and to appeal,
shows the hint translated, and the account's row has "The restriction
is lifted — try it again" (POST /api/gateway/unrest). en, zh, zh-TW, ja,
de.
- docs/subsystems/gateway-routing.md says the above.
Run: gofmt -l (clean); go vet darwin, GOOS=linux -tags nogui, GOOS=windows
on gateway, provider, gui; go test ./internal/gateway ./internal/provider
./internal/gui (ok). New Go tests use the reporter's literal body through
the vendor's shape, the built-in's and the plugin's, a string code and the
words alone; another vendor's 11140, a non-WorkBuddy account with the same
body, 11128/14018/111400 not restricted; an e2e through the fake plugin
host where the restricted account is skipped by the next request.
Broken by hand, each went red: rest case removed, restrictedSaid removed,
the match unscoped, the raw match removed, the provider hint removed.
GUI: routing-wb-restricted (chromium and webkit x en/zh/zh-TW/ja/de x
1100/420px, 20 pass), routing-wb-refused, i18n-keys; after the rebase
every GUI test of the Routing page (107 files, both engines): 103 green.
The 4 red ones fail the same in WebKit on origin/main
|
||
|
|
5ca9dc19db |
usage, gui: a model says how many of its replies were ended for looping (#1858)
#1858 asked for recovery across turns when a model loops. magpie is a gateway and can't rewind the agent's session, so that is not planned now. What it can do is let the reader see which model loops. Each reply the loop guard ends (#1359) is logged with err_type "reply_loop", but Usage only counted it among the failures. usage.LoopErrType is now that type (the gateway's loopErrType is it), and Totals.Loops counts, among the failed requests, those ended for looping. A handed-on try is still no request. The Overview's model, agent, account and key rows and the Requests ranking say "{n} looped" beside "{n} failed", and the ranking's "Other" adds them up. Translated into zh, zh-TW, ja and de. Run: TestLoopsCountedPerModel (Overview groups, the ledger sum and Breakdown; red with the increment removed). go test ./internal/usage ./internal/gateway ./internal/gui; gofmt -l; go vet on darwin, linux -tags nogui and windows. The new usage-loops.test.cjs ran in chromium and webkit, 5 languages at 360 and 1100px, 20 pass; it fails 10 of 10 on HEAD~ assets. usage-*, ledger-*, own-requests, i18n-keys and gui-zh-tw/ja/de in both engines: 565 pass. Not run: a real looping model through the gateway (the logging path is unchanged from #1359). |
||
|
|
0102915fe0 |
gui: Tuned for you lets a compaction window be picked, each with its estimated extra tokens and compactions (#1860)
MrMengJ applied the advised 200K auto-compaction window and wanted 250K or 300K instead, seeing what each costs against the cheapest. A compaction row now has "Other window…", which opens the app menu (never a native select) with every value of the curve the card already replays. Each says its estimated extra tokens over the fewest (or "Fewest tokens" / "As few tokens") and about how many compactions it would have made over the range. The head says it is estimated from the reader's calls. The one picked is put in through /api/tune/apply like Use, with Undo. tune.Point gains compacts, counted by the same replayCompact that prices the point, so tokens and compactions come from one model. Run: go test ./internal/tune ./internal/gui; TestCompactCurveCountsCompactions (compactions fall as the window grows; the last point is close to Facts.Compacts). gofmt -l; go vet internal/tune on darwin, linux -tags nogui, windows. GUI: context-*, gui-zh-tw/ja/de, compact-at, click-scroll, i18n-keys in chromium and webkit, 144 pass. The new context-tune test covers 5 languages at 360 and 1100px: menu inside the window, 300K ticked, notes for 250K and 160K, picking 250K posts apply with no page scroll, Escape posts nothing. On HEAD~ assets context-tune fails 22 of 23. Not run: against a real Claude Code settings.json (the apply path is unchanged from Use). |
||
|
|
6e5f4fc97f |
gui: Tuned for you names its advice "Fewest tokens" and says a compaction window is a token estimate, not what the agent keeps (#1854)
cnlove7777777-art: the card called 230K -> 150K "best for you" on token savings alone, while compacting sooner may lose more of a long coding task. A retention benchmark isn't built now; the card says what it measures instead: - the advised value's label is "Fewest tokens", not "Best for you"; - a compaction row that advises a change adds "A token estimate only: it doesn't measure how well the agent keeps the task after a compaction. The lower the window, the more often it compacts." Not on a window already the leanest, nor on the cache lifetimes. - zh, zh-TW, ja, de translations; agent-wiring.md says the same. Run: context-tune.test.cjs (new assertions on label and caveat) passes in Chromium and WebKit, 360 and 1100 wide, en/zh/zh-TW/ja/de; on origin/main's assets it fails 11 of 12. context-*.test.cjs, gui-zh-tw, gui-ja, gui-de, compact-at, i18n-keys: 99 pass, 0 fail. Not tried in the real app window. |
||
|
|
8b9d63f58a |
usage: a cost total says how many calls it couldn't price, never reads them as free (#1856)
cnlove7777777-art's Kimi K3 Auto and GLM-5.3 Max calls had "no price",
and Usage's sum counted them as $0 with nothing beside it but a "+" and a
tooltip. Now every total that sums cost says the count:
- GUI: Overview's and Requests' heads read "≈$0.001+ 2 calls unpriced";
with nothing priced, the count alone (Requests showed nothing at all
before). Overview's calls tile adds "2 unpriced". Sessions, which prices
by model, says "1 model unpriced" in its head and cost tile. The count
stays at every width: the narrow and .tight rules no longer hide it,
and the head goes tight when the count would be cut, sum or not.
"no price for these models" is no longer shown, its key removed.
- CLI `magpie usage`: "≈$0.001+ (2 calls unpriced)". TUI Usage page: the
same after its cost.
- docs/reference.md: unpriced calls are left out, said beside the total;
magpie doesn't guess a variant's price from a similar name.
No variant price is mapped: models.dev lists neither "Kimi K3 Auto" nor
"GLM-5.3 Max", Zhipu's "Max" is a Coding Plan tier, and -fast variants
are 1.5x their base, so a suffix strip would be a guess. The existing
per-model price override (provider editor, `magpie model price`) covers it.
Run: go test ./internal/cli ./internal/tui ./internal/gui (ok);
TestUsageSaysCallsUnpriced and TestUsagePageSaysCallsUnpriced fail with
the fix taken out. usage-unpriced-sum.test.cjs (new) passes in Chromium
and WebKit, en/zh/zh-TW/ja/de, 360-1240px, and fails 5 of 5 on
origin/main's assets. Related GUI files (every test naming usageCost,
unpriced, effective prices, usage-head or "{n} failed", plus i18n-keys,
gui-zh-tw/ja/de, number-units, text-size, usage-ledger, ledger-protocol,
usage-range, mobile-web, phone-web, view-no-sideways): 655 pass; the
WebKit text-size foot case and routing-sessions fail the same run alone
on origin/main
|
||
|
|
2c30e5cee7 |
usage, gui: revert def3a41e3 until Fallmonkey says what context it missed
Fallmonkey asked on Discord (#feedback, 10-12 19:55) to hold the
single-call Codex threshold: "先别做?感觉你漏掉context了". It is not in a
release yet, so take it off main until the rule is agreed, rather than
ship a speed rule its own requester has paused.
This reverts commit
|
||
|
|
e0ecf01610 |
mcpauth: an MCP server's own OAuth app is called back at Claude Code's http://localhost:<port>/callback, so an app made for Claude Code signs magpie in as it is (新v学员 on Discord)
What changed:
|
||
|
|
05ef7bcec7 |
gateway: Cursor's built-in shows the model a tool's images, in the message after its results (#1861)
Found while checking every translation of a tool's images for #1861. cursorMessages wrote a tool result's text alone, so an image Codex's view_image (or any tool) returned never reached a model behind the Cursor built-in. Cursor's plugin already gets it, since magpie hands it a Chat body (seeLater: the result says the image follows, and a user message after the results carries it). The built-in now does the same: a result with images says "[The tool returned an image; it follows in the next message.]", and a user message after the results holds "[From the result of <name> (tool call <id>):]" and each image as Cursor's image block (cursorImage, the same block a user's own image already used). gateway-routing.md names Cursor among the translations. TestCodexToolImageCursor, from codex-rs 0.162's view_image output, fails on the old cursor.go and passes now. Run: gofmt -l; go vet darwin, linux -tags nogui, windows on internal/gateway; go test -tags nogui ./internal/gateway ./internal/provider (sandbox HOME, ok). Not tried: a real Cursor account. Whether Cursor's backend shows the model an image in a user message that follows tool results is taken from how it takes a user's own image, not seen. |
||
|
|
285e17b061 |
provider: a moved Kiro shows the model a tool's images, Codex's view_image among them (#1861)
simonsmh (v0.1.1215) saw Codex's view_image and screenshot results come back empty on a Kiro subscription. magpie hands Kiro's plugin an Anthropic body whose tool_result holds the image as a base64 image block, but the plugin (@magpie-community/opencode-kiro-auth up to 0.1.8) read only a tool_result's text, so the image was dropped and the model was told "(no output)". #369 had fixed this in the built-in for Claude Code; the plugin never got it. Kiro plugin 0.1.9 (magpie-community/plugins 66facac) sends a tool's images with the userInputMessage that answers the call, latest images only, as the built-in does. This raises the mover's min to 0.1.9, so keepMovedCurrent updates every moved user. tool_images_1861_test.go builds the request from what codex-rs 0.162 sends (FunctionCallOutputContentItem, view_image's input_image data: URL with detail "high") and checks the handoff to the plugin (the image in the tool_result, bytes intact) and the built-in Kiro body. Both pass on the old code too: the bug was in the plugin, whose tool-images.test.mjs fails 3 of 4 on 0.1.8. gateway-routing.md says how a tool's images reach the model on each translation. Run: gofmt -l; go vet darwin, linux -tags nogui, windows on internal/gateway and internal/provider; go test -tags nogui ./internal/gateway ./internal/provider (sandbox HOME, ok); the plugin's bun test (1152 pass) and scripts/check.mjs; npm view on registry.npmjs.org shows 0.1.9. Not tried: a real Kiro account, or real Codex against it. |
||
|
|
d01635797a |
gui: a window made wider or narrower keeps the reader where they were, or at the foot, while the page is laid out again, so Settings no longer ends 6px short of its foot across the sidebar's width in WebKit (#1672)
Cause: |
||
|
|
def3a41e36 |
usage, gui: a Codex turn of one call is measured only over a second and 100 tokens after its first token, else told as the least it wrote over the whole turn (Fallmonkey on Discord)
Fallmonkey's repro: a Codex turn whose first token came at 6.8 s (the model working) and the rest 0.2 s later in one network push read as thousands of tok/s from its session file. The promised rule, now in: - A Codex turn of one call read from its session file (source "log", turn TTFT known) tells a measured speed only when the window after its first token is 1 s or more and its body 100 tokens or more (usage.CodexWindowMs, CodexBodyTokens; Row.Decode, app.js ledDecode). - The floor from |
||
|
|
da085e3f78 |
gateway: joinToolRuns leaves the model's own step and every call-carrying item in place, and a result written before its call opens no run (#1752, #1822)
What: follow-up to Edward4226's joinToolRuns (previous commit), after review
against Codex rust-v0.162.1 and the code around it.
- An item carrying a call_id is never moved, whatever its type. Before, only
function_call/custom_tool_call/tool_search_call counted as calls, so a
local_shell_call (or any call type Codex adds) inside a run was moved after
results, its own output's among them.
- Before the run's first result, what the model wrote between its own calls
(reasoning, assistant text, a hosted tool's call) stays where it is. Before,
[call_a, reasoning, call_b, out_a, out_b] sent the reasoning after the
results, where it reads as the next step's: DeepSeek, whose step must lead
with its reasoning (reasonFirst,
|
||
|
|
accc8c0903 |
library: an MCP server whose sign-in has no client registration (GitHub's) is signed in to as the user's own OAuth app (新v学员 on Discord)
What changed: GitHub's remote MCP server (api.githubcopilot.com/mcp/)
points to https://github.com/login/oauth, whose metadata has no
registration_endpoint, so magpie's sign-in, which always registered
itself (DCR), could never sign in to it. A server now carries an
optional OAuth app, `oauth: {clientId, clientSecret, callbackPort}`,
Claude Code's names for --client-id/--client-secret/--callback-port
(oauth.clientId in its .claude.json). mcpauth.StartWith signs in as
that app without registering: PKCE S256, a loopback callback
http://127.0.0.1:<port>/callback (any port unless callbackPort is set),
client_secret_post with a secret (basic only when the server lists
basic alone), "none" without one.
Without an app, a server with no registration endpoint now fails with
mcpauth.ErrNoRegistration, which says to make an OAuth app with the
vendor (GitHub's under Settings > Developer settings > OAuth Apps, with
http://127.0.0.1/callback) and give it under "OAuth app" in the editor.
The editor opens those fields with Client ID focused when that error
comes back. Filling them makes Sign in read "Save and sign in", and
Cancel asks before dropping them, as the earlier Cancel fix does.
GitHub answers token errors with 200 and {"error": ...}; tokenRequest
now reads a 2xx body with `error` as the error, and bad_refresh_token /
incorrect_client_credentials count as a dead sign-in as
invalid_grant/invalid_client do.
Secrets: the client secret sits in library.json like header and env
values. A backup without keys blanks it; WithSecrets puts this
computer's secret back only for the same client ID. No agent file is
given the app. The TUI editor, which doesn't show it, keeps it on save.
check() keeps it only on an HTTP server, requires a client ID when a
secret or port is given, and a port 1-65535.
Run (worktree at
|
||
|
|
55e81bce40 |
gui: Cancel in an MCP server's editor leaves the server as saved, after a Sign in too (新v学员 on Discord)
GitHub's remote MCP server, brought in from CC Switch with its token as an Authorization header: removing the header, picking Sign in, then Cancel (even with Discard asked and picked) left the header removed in library.json and every agent's file. Cause: Sign in calls ready(), which saved the whole form whenever its name, transport, URL or headers differed from the saved server. The sign-in (mcpauth.Start) uses only the name and URL, so the headers never needed saving for it. Now ready saves only when the sign-in is to another server than the saved one (new, name, transport or URL changed); the button then reads "Save and sign in" (zh, zh-TW, ja, de), and what it saved becomes the form's saved state, so Cancel doesn't offer to discard what is already written. Audited the page's other sheets for the same thing: the hook editor, paste-many, the server sheet, the skill how-to, By agent (Done only) and the confirm dialogs save nothing before their own Save. Env and command arguments in this editor only ever saved through Save; the new test covers them too. Run: - New mcp-editor-cancel.test.cjs: Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and 390 wide, 22/22 twice. Broken by hand each: the old headers-count rule, the saved state not updated after the save, and the button not saying it saves; each 0/11 in Chromium. - mcp-signin (updated for the new label), mcp-signin-health, library-mcp-health, library-mcp-copy-config, library-servers-bulk, library-env-refs, i18n-keys, ux-safety: pass. - library-mcp-tools and library-mcp-tool-switch have WebKit reds (the footer over the clicked switch) that come and go, 1 to 7 per run, the same with this commit's parent's assets. - Sandbox HOME, rebuilt magpie web: header removed, Sign in (GitHub answered with its no-registration refusal), Cancel, Discard: the header is still in library.json and ~/.claude.json, and no save request was sent. |
||
|
|
eb1fab34c7 |
library, gateway: an MCP server magpie is signed in to no longer shows "Signed in" beside "needs sign-in" (新v学员 on Discord)
What was wrong, reproduced in a sandbox HOME with mcpauthtest's fake OAuth server behind a sandbox magpie: - A server no agent has is checked only on a click (#1597). Clicked before its sign-in it said "needs sign-in"; after signing in, the page rechecked only servers in use, so the row kept that result beside the new "Signed in" tag. The page now rechecks any server it has a result for once its key (sign-in included) changed. - The check sent magpie's token but never renewed it on a 401, so an expired access token with a good refresh token read "needs sign-in" beside "Signed in". checkHTTP now renews once and asks again, as the gateway's relay does. - A server that refuses even a just-renewed token was still "Signed in". mcpauth.Rejected marks such a sign-in run out, from the check and from the gateway's /mcp/<name> relay; ServerHealth.SignIn carries the status back (only for a server magpie has a sign-in record for) and the row's tag turns to "Sign-in ran out". mcpauthtest.Fake gains RefuseTokens for the last case. Run: - go test -tags nogui ./internal/mcpauth/... ./internal/library ./internal/gateway (HOME and GOCACHE in scratch): ok. - gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on the touched packages: clean. - New TestCheckRenewsMagpiesSignIn, TestCheckSaysSignInRanOut, TestMCPProxyRefusedAfterRenewalRunsOut. Broken by hand: renewal removed from checkHTTP, Rejected removed from the check, and from the gateway; each went red. - New mcp-signin-health.test.cjs: Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and 390 wide, 22/22. Each of the two library.js changes reverted on its own: 0/11 in Chromium. library-mcp-health, mcp-signin and i18n-keys pass. - Sandbox repro before and after with the fake server: both cases now show one tag; forget+revoke shows "Sign-in ran out · needs sign-in". Not run: a real vendor's server refusing a renewed token; the fake stands in for it. |
||
|
|
689edbd6be |
gateway: a Codex subagent refused for a sealed task is told the task itself is sealed, which fork_turns="none" doesn't change (#1855, hanekoo)
hanekoo's Codex Desktop lead on gpt-6.1-sol (Codex's own ChatGPT sign-in)
spawned a subagent on antigravity/gemini-3.8-flash with fork_turns="none"
and got the sealed-task refusal, which read as if the lead's turns were
the problem and fork_turns="none" should have avoided it.
What Codex rust-v0.162.0-alpha.17.2 sends (read from its source, not the
reporter's bytes, which aren't available): spawn.rs's fork_mode is None
for "none", so no turn of the lead's is copied in. The subagent's task is
spawn_agent's `message` argument; the ChatGPT backend returns it sealed
(the function call's encrypted_function_args), router.rs's direct_source
makes it ToolCallSource::Direct, agent_message_from_tool makes it
AgentMessage::Encrypted, and to_model_input_item writes it as the
agent_message's encrypted_content under the NEW_TASK header. So the one
sealed thing in the subagent's first request is the task itself: there is
nothing magpie can leave out and still give the subagent work, and no
request flag in Codex asks the backend for plaintext arguments. The
refusal stays; it now says why.
- codex_backend.go: sealedTaskItself, added to all three sealedTaskError
variants (lead unknown / Codex's own sign-in, a relay that sealed it,
plugins#70's earlier chat provider): what is sealed is the task the
spawning agent wrote in spawn_agent, and fork_turns="none" keeps only
the lead's turns out, not the seal. The existing advice (the lead's
model for the subagent, or a lead not on the ChatGPT backend) stays.
- docs/subsystems/gateway-routing.md: the same, under sealed tasks.
- sealed_fork_none_test.go: the fork_turns="none" first request rebuilt
from Codex's source (developer + environment_context + the sealed
NEW_TASK with Task name/Sender lines), a lead first on Codex's own
sign-in, the subagent on a chat provider. It is refused before the
provider is asked, with no ciphertext in the reply, and says the task
itself is sealed whatever fork_turns says.
Run: with the old codex_backend.go put back,
TestSealedTaskWithForkTurnsNoneSaysTheTaskItselfIsSealed fails ("the
refusal doesn't say the task itself is sealed whatever fork_turns
says"); with the change it passes. gofmt -l (empty), go vet / GOOS=linux
-tags nogui / GOOS=windows go vet ./internal/gateway, go build, GOOS=linux
-tags nogui and GOOS=windows go build ./..., go test -tags nogui
./internal/gateway (ok, 353s) under a sandbox HOME with a private GOCACHE.
Not run: the whole `go test ./...` (only the gateway package changed);
no real Codex Desktop or ChatGPT account was used, so the reporter's
bytes are not reproduced; the GUI's sealedKept text is unchanged. The
502 "context canceled" on gpt-6.1-sol in the report is Codex's own
sign-in request most likely cancelled by Codex itself (the client went away), a separate
request, and wasn't chased.
|