Files
magpie/internal/library/testdata/bili/overview-0.1.213.json
T
yetone 97fcbe3540 library: billion-context's card shows the tokens it saved (Scott__D on X)
The RTK tab says what RTK saved (rtk gain); the billion-context tab said
nothing of its effect. bili 0.1.213 has no command that prints its
savings. Its running proxy serves its dashboard's numbers at
GET /__bili/overview, summed over every session in its one store, and
each bili that runs registers in <state>/instances/<id>.json
($XDG_STATE_HOME or ~/.local/state, then billion-context, on every
system; read from bili's dist and its Hermes plugin's twin reader).

readBiliSaved (internal/library/bili_saved.go) asks the registered
bilis newest first, loopback http origins only, 3s in all, and puts the
first answer on BiliView.Saved: netSavedTotal (bili's headline "net
savings", after post-fold rebuilds and the summaries' cost, only with
hasFoldData), grossSavedTotal (which bili calls an upper bound),
foldsTotal, sessions, requests. The answer is kept in bili-saved.json
in magpie's config folder and shown "as of" its time when no bili runs;
a kept file that doesn't parse is no answer. magpie never starts a bili
to ask (it would auto-update and start watchers). The card says
"166.3k tokens saved over 7 folds in 1 session", bili's own count over
every session on this computer, the gross before costs; "Nothing folded
yet over N requests" before a fold; and that it shows once bili has run
when no bili ever answered. zh, zh-TW, ja and de; site docs (en, zh,
ja) and docs/subsystems/library.md.

Run:
- Real bili 0.1.213 on mote in a sandbox HOME (ACP_AUTO_UPDATE=0, 20000
  token window, bili start on 18799, a fake OpenAI upstream answering
  usage = bytes/4): ten turns of a growing conversation through
  /bili/<upstream>/ gave overview net 166285, gross 166390, 7 folds,
  1 session, 10 requests. That literal answer is the Go fixture
  (testdata/bili/overview-0.1.213.json) and the GUI test's numbers.
  readBiliSaved/ReadBili run on mote against that live bili with that
  HOME read the same numbers (Live true, Version 0.1.213).
- go test -tags nogui ./internal/library ./internal/gui on mote: ok.
- win-run go test -run 'TestBiliSaved|TestBiliLoopback'
  ./internal/library on xiaomi-gpu: ok.
- library-bili, i18n-keys and i18n-en-no-cjk in chromium and webkit
  (every language, 1100 and 420 wide): 92 pass, 0 fail.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui and
  GOOS=windows for internal/library and internal/gui: ok.
- site/public/llms-full.txt regenerated (node llms-full.mjs); site
  worker.test.mjs: 38 of 38 ok.

Broken by hand:
- the loopback filter taken out: TestBiliSavedFromRunningBili red
  (192.0.2.7 asked first, the 3s budget gone, nothing read).
- net read from tokensSaved, and a kept answer marked live:
  TestBiliSavedFromRunningBili and TestBiliSavedOnThePage red.
- the card's line taken out: library-bili 40 of 42 red (chromium).

Not tried: a real agent session with a real model through bili (the
upstream was a fake with made-up usage, so only the plumbing of bili's
numbers is checked, not how much a real session saves); a bili with
money data (hasMoneyData; its dollars are passed as usd but not shown);
the card on Linux WebKitGTK.
2026-11-10 15:47:32 +08:00

191 lines
4.5 KiB
JSON

{
"overview": {
"sessions": 1,
"live": 1,
"requests": 10,
"inputTokens": 175279,
"cachedTokens": 0,
"outputTokens": 200,
"tokensSaved": 38128,
"savedEstimated": 0,
"grossSavedTotal": 166390,
"netSavedTotal": 166285,
"hasFoldData": true,
"repayTotal": 0,
"summaryCostTotal": 105,
"coverageLostFoldTotal": 0,
"coverageLostFrozenTotal": 0,
"costUsdTotal": 0,
"savedUsdTotal": 0,
"savedUsdGrossTotal": 0,
"foldsTotal": 7,
"hasMoneyData": false,
"missNewTotal": 0,
"missCompTotal": 0,
"missTtlTotal": 0,
"missInputTotal": 175279,
"hitPct": 0,
"blocks": 7,
"byProtocol": [
{
"protocol": "openai",
"sessions": 1,
"requests": 10,
"inputTokens": 175279,
"cachedTokens": 0,
"savedNet": 166285,
"folds": 7,
"hitPct": 0,
"missDropNew": 0,
"missDropComp": 0,
"missDropTtl": 0
}
],
"recent": [
{
"id": "pfa-21b65d77ab41c422",
"contextBest": {
"tokens": 19122,
"kind": "usage",
"at": 1794295277161
},
"title": "Turn 0: fact0_0 is value 0 fact0_1 is value 7 fact0_2 is …",
"label": "prefix-affinity b69b8b38",
"protocol": "openai",
"upstreamOrigin": "http://127.0.0.1:18801",
"snapshotShadow": {
"turns": 13,
"errors": 0,
"lastClass": "degraded",
"lastReason": "transcript-empty"
},
"live": true,
"requests": 10,
"contextTokens": 19122,
"contextTokensSource": "usage",
"tokensSaved": 38128,
"inputTokens": 175279,
"cachedTokens": 0,
"outputTokens": 200,
"cacheHitPct": 0,
"blocks": 7,
"contextWindow": 20000,
"lastSeen": "2026-11-10T07:21:17.134Z",
"hasLedger": true,
"firstBlockHint": "preflight overflow compress",
"grossSaved": 166390,
"netSaved": 166285,
"repayCost": 0,
"summaryCost": 105,
"foldCount": 7,
"model": "fake-model",
"newContent": 0,
"compRepay": 0,
"ttlRepay": 0,
"clientHint": "Python-urllib/3.9",
"engineLane": "server"
}
],
"hiddenEmpty": 0
},
"version": "0.1.213",
"origin": "127.0.0.1:18799",
"commit": "133f3525c",
"diskVersion": "0.1.213",
"stale": false,
"updateReady": null,
"autoRestartOnUpdate": false,
"advisory": null,
"resolverWedge": null,
"updatePolicy": {
"source": "unknown",
"fetchedAt": null,
"hold": false,
"pinned": null,
"blocked": [],
"error": null,
"plannedUpgrade": null
},
"pluginAdvisories": [],
"hostPluginNotices": [],
"notices": [
{
"source": "builtin",
"id": "pck-default-off",
"tone": "warn",
"keys": {
"on": "pckoff.on",
"desc": "pckoff.desc",
"hint": "pckoff.hint",
"dismiss": "pckoff.dismiss_btn"
},
"priority": 50
},
{
"source": "builtin",
"id": "wm-fastpath-intro",
"tone": "ok",
"keys": {
"on": "wmfast.on",
"desc": "wmfast.desc",
"hint": "wmfast.hint",
"dismiss": "wmfast.dismiss_btn"
},
"priority": 50
}
],
"inFlight": 0,
"blindTunnels": {
"total": 0,
"hosts": {}
},
"conflicts": {
"sessions": 0,
"events": 0,
"active": 0,
"historical": 0,
"lastAt": null,
"kinds": {},
"latest": [],
"sibling": 0,
"suspected": 0,
"displayOnly": 0,
"activeConfirmed": 0,
"clients": []
},
"passthrough": {
"enabled": false,
"source": null
},
"alerts": [],
"pckSuppressions": [],
"storage": {
"requested": "full",
"effective": "full",
"degraded": false,
"intentionalOptOut": false,
"reason": null,
"engine": {
"name": "node:sqlite",
"source": "builtin"
},
"bootstrap": "not-needed",
"bootstrapFailure": null,
"cooldownRemainingMs": null,
"sidecarDisabled": false,
"verifyDrift": 0,
"driftedSessions": 0,
"integrity": {
"ok": true,
"checkedAt": 1794295272948,
"durationMs": 0,
"detail": "/Users/yetone/runs/bili-savings/home/.local/share/billion-context/sessions/index.db: verdict cache hit (file set unchanged since the last check)"
},
"secondProcess": null,
"splitBrain": null,
"backup": null,
"frozenEnvelopeSessions": 0,
"frozenEnvelopeDetails": []
},
"attribution": {}
}