cybercaius on Discord: "能记录代搜 API 的用量信息吗,在使用过程中看不到它用了哪些代搜 API".
Nothing recorded which search API answered a search, how often, or whether
it failed.
Each ask of a search API (askSearchAPIKeys) and each search sent to Kimi
Code's or WorkBuddy's own search service (ownSearch) is now a row of
Usage › Requests, source "search" (usage.SourceSearch, kind web_search):
the vendor or plan, the host asked, ok / found nothing / refused / the
error, and the time. The row is a probe: it is listed, never counted in a
total or a chart, and never exported. Telemetry reads no usage rows, so
nothing is added to it. The query is not written: an error's text is
scrubbed of it (url.Error reduced to op and host, and the plain,
QueryEscape and PathEscape forms replaced). The Usage page badges the row
"Search API", or "Web search" under a plan's provider, muted.
Run (rebased on 3e5aa1151):
- go test ./internal/gateway ./internal/usage ./internal/settings
./internal/budget on Linux (WSL magpie-desktop): ok. With -tags nogui
there the root package is ok; internal/cli and internal/gui were still
running at the push (owner: ship at once), any red they show is filed.
- TestSearchAPIAsksAreLogged, TestSearchAPIFailureKeepsNoURL,
TestOwnSearchIsLogged, TestWorkBuddyPluginSearches,
TestSearchAPIRowsListedNotCounted; TestCoreScriptBudget ok.
- go vet for darwin, linux and windows on gateway, usage, settings; gofmt.
- usage-ledger-search.test.cjs in Chromium and WebKit, en zh zh-TW ja de,
wide and narrow; i18n-keys.
Broken by hand: without logSearch the gateway tests go red; with the
query left in an error's text TestSearchAPIFailureKeepsNoURL goes red;
with IsProbe not naming search, the totals test goes red; the old page.js
fails the GUI test.
Reds the same at base 3e5aa1151, filed: usage-ledger, -chart, -ttft,
-open-settled (#3104, #4078, #3001, #4263, #4489); internal/agent on Linux
(#4033).
Not tried: real Tavily, Kimi Code or WorkBuddy accounts; the Routing page
shows no search rows; the whole GUI suite.
ferock (Discord) asked to see calls to magpie's MCP tools, such as
magpie-image's generate_image, generate_video and generation_result, in
Routing > Requests.
Each tools/call to magpie's own MCP servers (image, vision, web search,
tools and the Library hub) is now a row of the request log. The row has
Source and Kind "mcp", the tool as its model, the server as its host,
how long the call took, and its error if it failed. The provider and
model it shows are those of the model requests the call made, collected
through the request's context in appendUsage. generation_result names
the model of the job it answers. The stdio Magpie Image server reports
each call it answered to the gateway as "magpie/toolCalled". That report
carries the tool, ms, model and error, never the prompt.
The arguments are never stored at all, so there is nothing to mask. The
rows go down the probe lane: they are listed, but no total, host list,
budget or key limit counts them. The model requests a call made are rows
of their own.
In the GUI the row reuses the Requests list. It gets a muted "MCP" badge
with a tooltip, the server beside the provider, and a Succeeded/Failed
status. The Purpose filter gains "MCP tool" in every language. There is
no new page, no <select> and no left border.
The core scripts went over their budget with the new purpose.
genpurposes now writes purposes.js as compact JSON, which makes the core
448 bytes smaller than main in all, and coreScriptBudget is lowered to
the new total, 1,538,975. No room is added.
Run on mote, at the rebased head:
- gofmt -l: clean. go vet -tags nogui ./... with GOOS darwin, linux
and windows: ok.
- go test -tags nogui -timeout 45m: ./internal/usage, ./internal/imagemcp,
./internal/usageapi and ./internal/gui ok. internal/budget has no test
files. ./internal/gateway (805s): every test ok except five Antigravity
and Codex/Grok tests. They fail the same on a clean origin/main
3bebc3839 and are filed as #4362.
- GUI, the usage-ledger*, routing-request*, purpose*, i18n* and
gui-zh/ja/de files (25). On mote, Chromium: 32 of 32 ok; WebKit
could not launch (10 other sessions' suites on mote). On Linux
(wsl-run), both engines: 335 of 355 ok. The 20 reds are
routing-request-model, usage-ledger, -ttft, -chart and
-open-settled, which fail the same at the parent 1534474c8 (#4120).
usage-ledger-mcp, purpose-filter and i18n-keys are ok in both.
The whole GUI suite runs after the push, and each red it finds gets
an issue.
- At the pushed head, rebased on 0804f2d97: ./internal/gui (the
budget and purpose asset tests among them), ./internal/usage,
./internal/imagemcp and ./internal/usageapi ok, and ./internal/gateway
-run "MCP|Purpose|Probe" ok.
- usage-ledger-mcp.test.cjs covers 5 languages, widths 1180 and 420,
light and dark, with no sideways scroll.
Broken by hand. Each break went red:
- sawHost's MCP skip removed: TestMCPCallRowsListedNotCounted (the hosts
list had magpie-image).
- Row/Record.IsProbe's MCP case removed: the same test (3 calls counted),
and TestMCPCallCountsInNoKeyLimit (Calls: 1).
- The callMCPTool hook removed: TestMCPToolCallIsARequestRow and its
siblings (no rows).
- The appendUsage hook removed: the row had no provider or model.
- imagemcp's report removed: TestToolCallsAreReported.
- The gateway's magpie/toolCalled case removed:
TestMCPCalledFromStdioIsARow.
budget's in-memory counts() now skips these rows too. Breaking only that
stays green, because budget.Of reads the file through usage.Visit, which
already skips probes, and limits count tokens and cost.
Not tried:
- no real agent calling a real vendor's drawing;
- no test run on Windows or Linux;
- the page not checked in the real app or in WebKitGTK.
A generate call that answers while its drawing still runs has no model on
its row. The generation_result row that follows names it.
ferock (Discord #general): Usage > Requests is full of rows like
"magpie · magpie's own · Remote magpie · API · Model list · 0 0 · 757 ms
· 200, GET /v1/models", which no tool of theirs sent.
Cause: ffe493773 (v0.1.1446) wrote every request magpie sends a
provider on its own into the request log (source "probe"): the editor's
Test and Detect APIs, and every model-list fetch. 0152f6696 then gave a
Remote magpie a 10-minute list schedule (KeepListsFresh), so each Remote
magpie added ~144 such rows a day. The same rows came from every other
automatic fetch: start-up's FetchNew, the panel's FetchNewSoon, the
Providers page's FetchNewBehind and any provider with a RefreshEvery.
They were already counted in no token, cost, chart, budget or quota
total, but they were listed and counted in the page's row total.
Fix: a model_list probe with a 2xx/3xx status and no error
(usage.quietProbe) is not written by usage's probelog.Sink, and is
skipped when the log's index parses one (logSnapshot.probes). This rule
covers every list fetch, whoever started it, so every sibling is
covered by one check. A list that failed is still a row (the Failed
filter finds it, and the row says why models are missing), and every
Test and Detect APIs row stays as it was. Older rows: the answered
model lists already in usage.jsonl stop being listed at the next start
of the index, with no rewrite. The lines stay in the file and nothing
reads them. Quota and usage polls and health checks were never written
there (only Test, Detect and list are marked by probelog), so nothing
else needed changing. The TUI and CLI have no request list. The heatmap,
Summarize, Load and the exports skipped probes already.
Tests:
- usage TestAnsweredModelListIsNoRow (new): 200 and 304 lists aren't
written; a 503 and a connection-refused list are listed and Failed
finds both; a 200 Test is listed; an old answered list line in the log
is not listed, and Total is 3.
- TestProbeRowsListedNotCounted and the rename tests now use a failed
list (a 200 one would no longer be a row).
Broken by hand, each red: quietProbe returning false (the 200 list
written and listed); the index's skip removed, Sink's kept (the old line
listed, total 4).
Run, on mote:
- go test -tags nogui -timeout 45m ./... at the pre-rebase head
(b4f2fa9d3 on 0a7633136): every package ok, 76 ok, exit 0 (gateway
547s, agent 298s, provider 167s, usage 48s).
- After rebase on origin/main 9ba3f049e (which touched neither usage
nor probelog): go build ./...; go vet for darwin, GOOS=linux and
GOOS=windows on usage and probelog; go test usage, probelog,
usageapi, and provider -run Probe|Detect|TestTestWrites: ok. gofmt
-l clean.
- GUI (no asset changed): usage-ledger*.test.cjs, ledger-*.test.cjs and
own-requests.test.cjs, chromium and webkit, each file's languages:
381 tests, 375 pass. The 6 reds are usage-ledger's "newest live route
needs no return-to-live button" (en, zh, both engines), which is
already filed as #3104. usage-ledger-probe passed in every language.
Not tried: a real Remote magpie over a day. The row filter was not
checked on a real usage.jsonl.
CyberCaius on Discord, on the latest release: the Usage page's provider
filter listed Leee and leee.baby, and leee.baby's rows were the model
lists ("模型列表", magpie 自身, 200) asked while Leee was being added.
In the first report the same shape was example on api.example.me with
example.me in the filter, which we had put down to another address typed.
The Add sheet's model list runs before the provider has an id, so
probelog records it under the host asked. 8e2ba36de (v0.1.1697) and
94c2aaecb (v0.1.1726) give such a row to the provider saved on that
exact host, or to the one the log's calls to it went to. The reporter
asks a relay's bare domain (leee.baby, example.me), which answers
/v1/models, and saves the provider on another host of it
(api.example.me). No provider is on leee.baby, no call went there, so
the row stayed the host.
Now a probe recorded under a host no provider is on, and no call went
to, goes by the host's site: its registrable domain (provider.SiteOf,
publicsuffix eTLD+1, port and case aside). The one provider saved on a
host of that site takes it (Renames.OnSite), and with none saved there,
the one the log's calls to that site went to (sitesOf over
logSnapshot.hosts), so it stays with a deleted provider too. A site two
providers are on stays the host; a tenant of a hosting suffix
(x.vercel.app), an address and a bare name (localhost) have no site and
stay as they were. It is done when the log is read: rows written before
this release, the reporter's 16:57 and 17:32 ones, are listed under the
provider too, with nothing to migrate and nothing to set.
Run (rebased on 97332140a):
- go test -tags nogui ./internal/usage ./internal/usageapi
./internal/probelog: ok.
- ./internal/provider -skip TestUnreadLoginsWriteErrorsKeepCredentials
(#3632 crashes the binary): ok but TestFetchAsksASharedBaseOnce,
TestFetchAsksOneListOnceForTwoBasesOfIt and
TestFetchUnionsProtocolListsWithoutChat, open as #3854.
- New TestProbesOfAProviderOnAnotherHostOfItsSiteListIt: model lists at
leee.baby, Leee.Baby and www.leee.baby:443 before Add on
api.leee.baby; two providers on *.two.example, mine.vercel.app beside
theirs.vercel.app, 127.0.0.1:7 beside 127.0.0.1:8. Providers are
[127.0.0.1:7 leee mine.vercel.app two.example] with no call made,
after a call, and after Delete; leee's filter has its 4 rows.
- New TestSiteOf.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows for
internal/provider and internal/usage.
- Sandbox HOME, real binary, `magpie web`: POST /api/provider/list at
http://leee.localhost:3488/v1 (a fake OpenAI-compatible server), then
/api/provider/save on http://api.leee.localhost:3488/v1 as Leee2.
Built at e54a7d50b, /api/usage/requests listed leee and
leee.localhost:3488; the fixed build, over the same usage.jsonl, lists
leee and leee2 with the row under leee2.
Broken by hand: probeProvider without the saved-site branch fails the
new test at "no calls" with [127.0.0.1:7 leee.baby mine.vercel.app
two.example www.leee.baby:443]; without the log-site branch it fails at
"deleted" with leee.baby and www.leee.baby:443 back. On e54a7d50b the
test fails with those two names, the reporter's extra entry.
Not tried: the reporter's own usage.jsonl and providers.json (Leee's
saved host is inferred from the example.me report, not seen); a
reporter whose two providers share one site (stays the host, by
design); the GUI suite (no GUI file changed); the full go test ./...
cybercaius on Discord: one custom provider (example, on api.example.me)
was listed in the Requests page's provider filter under its id and its
host, and the host stayed after the provider was deleted.
The Add sheet's Detect, model-list and Test requests are sent before the
provider has an id, so probelog records them under the host asked
("a provider being added has no id yet"). 8e2ba36de (v0.1.1697, yyddbds)
lists those under the provider saved on that host now (Renames.ProbeOf),
but a deleted provider is on no host any more, so its probes went back
to the host beside the id its calls are kept under.
Now the log's index notes, as it reads each line, the provider each
host's calls went to (logSnapshot.hosts; "" once two providers were on
one host). probeProvider lists a probe recorded under its host by the
provider saved on that host, and with none there, by the one the log's
calls to that host were made under. A host two providers are or were
on, or none, stays the host, lowercased, so one typed in two cases is
listed once. It is done when the log is read, so rows written before
this release are merged too. Renames.OnHost tells "no provider on this
host" from "two providers on it", so a host shared now is never given
to a deleted one.
Not added: deleting a provider's usage rows. usage.jsonl is the record
budgets, windows and totals are read from, and probe rows are counted in
none of them; with them under one name there is nothing left to clean.
Run:
- go test -tags nogui ./internal/usage ./internal/usageapi
./internal/probelog: ok, at the pushed head (rebased on 56de2d192).
- ./internal/provider, skipping the reds open on main
(TestUnreadLoginsWriteErrorsKeepCredentials #3632, TestFetchAsksASharedBaseOnce
and its two siblings #3854): the disk was full from other sessions'
temp files, and TestLoginUsageEachAccount failed on "no space left on
device"; it and the Rename tests passed on a rerun.
- New TestProbesOfADeletedProviderStayWithIt: probes under
api.example.me and API.example.me before provider.Add, a Test after,
a gateway call with the provider's Where, and twice.example used by two
providers; after provider.Delete the list is [example one
twice.example two] and example's filter has its 4 rows.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
Broken by hand: probeProvider without the log's hosts fails it with
"deleted: providers [API.example.me api.example.me example one
twice.example two]", the reporter's extra names.
Not tried: the reporter's own usage.jsonl; a host typed in the Add sheet
and changed before saving (its probes went to another host and stay
under it); the GUI suite (no GUI file changed; the filter lists what
QueryPage returns); the full go test ./... (disk full).
yyddbds on Discord added one custom provider, 大灰狼 on dahuilang.best,
and the Usage page's provider filter listed it twice: 大灰狼 and
dahuilang.best. The Add sheet's Detect and model-list requests run
before the provider has an id, so probelog records them under the host
asked (probelog.Note: "a provider being added has no id yet"). Those
rows are listed on the Requests page, and their provider went into the
page's provider list as a provider of its own.
Renames now also knows each provider by the hosts of its URLs, and
probeChunk reads a probe row through Renames.ProbeOf: a host exactly
one provider is on is that provider's id. It is done when the log is
read, so rows written before this release are merged too. A host no
provider is on (an Add given up) or two providers share stays as it
was recorded; a provider id is never taken for a host.
Run:
- go test -tags nogui ./internal/usage ./internal/usageapi
./internal/probelog ./internal/provider (-skip
TestUnreadLoginsWriteErrorsKeepCredentials, #3632) ./internal/gui:
ok.
- New TestProbesOfAProviderBeingAddedListItOnce: Detect rows written
through probelog.Note under dahuilang.best and DaHuiLang.best before
provider.Add("大灰狼"), plus a gateway call under its id; providers
are [dahuilang other.example shared.example:8443], and the filter on
dahuilang has its 3 rows.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
Broken by hand: probeChunk back on Renames.Of fails it with providers
[DaHuiLang.best dahuilang dahuilang.best other.example
shared.example:8443], the reporter's two entries.
Not tried: the reporter's own usage.jsonl; the full go test ./...
(other sessions' suites were on this machine).
cybercaius on Discord (#help, 10-25): "已经更改供应商 id 的也没有变更过来反而
分开显示了". Reproduced in a sandbox HOME (magpie web on 3582, fake upstream
on 3583): after renaming myrelay to newrelay in the editor, the Requests
page's provider list had both myrelay and newrelay, each named "myrelay",
because the model-list probe row was still under myrelay. The summary was
already folded; the probe chunk, the Sessions tab's vias and the gateway's
loggedAnswers (lead-first routing) were not renamed at all.
What changed
- provider.Renames (UsageRenames): Of(id, time) is the id a call recorded
under id at that time belongs to now. Every usage reader goes through it:
summarizeFrom (and its historical-key set), ledgerMatched, NewPricer,
NewCoster, the Requests page's gateway blocks, probe rows and other
computers' days, window holds and their history, buildVias, and
gateway loggedAnswers. Visit stays as recorded so Of is taken once.
The summary, Requests and vias caches key on Renames.Key.
- An id reused by another provider no longer pulls the new one's calls
into the old one. Rename onto, or Save of a new provider under, an id in
another's Was moves it into that one's Gave with the time (giveID):
calls before then stay the old provider's. freeID treats Was ids as
taken, so adding the vendor again gets "-2". Renamed() (refs) skips ids
a provider or subscription holds now.
- A providers.json that can't be read keeps the last renames read instead
of none (a failed read is unknown), so usage doesn't split meanwhile.
- History: nothing in usage.jsonl is rewritten. Calls from before this
release under a renamed id show under the new id at once. An id that was
reused before this release has no hand-over time, so its calls show under
whoever holds the id now, as before.
Siblings checked: budget keys by caller key; per-key limits, RPM and
concurrency count live requests by the current id; tray totals go through
QueryPage; codex_memory reads Requested refs. None needed a change.
Run at the tree before the rebase; rebased onto 894603bcd (GUI-only,
none of these files) and provider, usage, usageapi, the build and the
Rename/Answer/Lead tests of gateway and gui run again there: ok.
- TestRenamesByWhenTheIDWasTaken (provider), TestRenamedProviderShownOnce
(usage), TestRenamedProviderAnsweredItsLead (gateway): each red with its
piece broken by hand (Save's giveID, freeID's Was, the last-good renames,
probe rename, vias rename, block pricer's timed path, summarize's time,
loggedAnswers' rename), green with it.
- go test -timeout 45m provider usage usageapi budget middleware cli agent
gui gateway sessions profile tui: all ok.
- gofmt -l, go vet ./internal/..., GOOS=linux/windows -tags nogui vet of
provider/usage/gateway and build of the binary: clean.
- Sandbox: rebuilt binary on the same HOME; /api/usage/requests lists only
newrelay, the probe row included.
Not tried: the GUI suite (no JS or asset changed; /api/providers gains an
omitempty "gave"), Windows tests run on the Windows box, a real account,
and the full ./... suite (other sessions' suites were running).
neiko and gys619 on Discord: a provider's Test or Detect APIs left no
trace in Usage > Requests, so a failing test couldn't be read back.
The provider package marks the context of the editor's Test, Detect APIs
(and per-model detection) and a model list's refresh with a kind
(internal/probelog). Each request sent under the mark is written once:
by the provider's Do, or by probelog.Transport under http.DefaultClient
(netproxy.Install), whichever sends it first; the Claude Code run and
the gateway's translated test write theirs from their result. A row
keeps time, provider, account, model, host, path (no query, no
user:password), method, status, ms and the first 500 bytes of the error.
The row is usage.SourceProbe, agent "magpie", Kind provider_test /
api_detect / model_list ("Test", "Detect APIs", "Model list" in Called
for; purposes.js regenerated). The log index keeps probes apart
(logSnapshot.probes), so Visit, Load, Summarize, budgets, Vias, heatmap,
shared days, LastSeen and observers never meet one. The request page
lists them (probeChunk) and counts none: Row.IsProbe, since a packed row
keeps the row's Source and not its record's. The page shows a muted
badge "magpie's own · not counted in any total" (en, zh, zh-TW, ja, de);
no new control, no layout change.
Tests, each red on the old code:
- usage TestProbeRowsListedNotCounted: listed, clipped, and absent from
Sum, Through, every By group, Summarize, Load, LastSeen, OwnDays and
the observer; a provider filter lists it and sums 0.
- provider TestTestWritesItsRequestsDown / TestDetectWritesItsRequestsDown:
every request the fake server saw is exactly one row, with the right
kind, model and 401 text; an unmarked Do writes nothing.
- probelog TestNoteKeepsNoSecret, TestTransportOnce.
- GUI usage-ledger-probe: badge per language, both engines, 1180/420,
light and dark, no left border, no sideways scroll.
- gui TestProviderDetectDraft now expects the log line (source probe,
kind api_detect, no key) and leaves usage.jsonl out of the unchanged
config comparison.
Broken by hand, each went red: request_page's uncounted check,
log_index's probe skip, Append's observer skip, Do's Taken (6 rows for
4 requests), Test's and Detect's marks, probelog's query strip,
page.js's badge (11 GUI fails).
Run at this head (on origin/main 22a7f86c9): gofmt -l clean; go vet
./..., GOOS=linux -tags nogui and GOOS=windows clean; go test -count=1
usage, probelog, netproxy, usageapi, provider and gui packages ok (the
rebase over 22a7f86c9 applied cleanly; upstream's 8b460833e chunk
cache leaves probeChunk, built per query, alone).
Run one rebase earlier (on origin/main 0b72ccbef; request_page.go
merged by hand onto 7d67910f7/66b6d6ade's per-row Totals, with
uncounted rows skipping the caller and account groups too):
- go test -tags nogui -timeout 45m ./... in a sandbox HOME, log tee'd:
every package ok (gateway 640s, agent 514s, provider 278s, usage 77s)
but internal/gui's TestRestartHandsTheGatewayOver (7 of 8 requests
answered during the restart), 3 of 3 green alone after (#3451).
- gofmt -l clean; go vet ./..., GOOS=linux -tags nogui and GOOS=windows
go vet ./... clean.
- GUI usage-ledger-probe, usage-ledger-reported, i18n-keys,
purpose-filter, quota-pool-model: 72/72. usage-ledger's "newest live
route needs no return-to-live button" is red on origin/main 0b72ccbef
alone too (#3104).
- Whole GUI suite, both engines, at the pre-rebase base 761904b5a:
1313 tests; reds, each also red on origin/main 7b1faf99f alone:
account-discovery "agents' sign-ins read" (#3497), builtins
"Plugins > Built-in" (Masking page in the list, #3518 filed), and
context-map "two tiles overlap" chromium ja 420 (#3488; 1 of 2 red on
main alone, 3 of 3 green on this branch alone). Earlier package run:
TestRestartHandsTheGatewayOver red under load, passes alone (#3451).
- No size budget raised.
Not tried: no real vendor account (fake servers only); a plugin's model
list, fetched in the JS plugin host, isn't written down; the real GUI
app wasn't launched (Playwright only).