workbuddy 0.2.14: the free model's ledger estimate is shown, not routed on (#641, XiaoFeiyu9)
XiaoFeiyu9's China account (paid credits, deepseek-v4.1-flash at x0.11)
read 99% of the free model's window in routing: 187,701,367 of the 1.9e8
soft cap, from 937 answered calls and no 429, while the credits meter had
2,457 credits left. The window is this machine's ledger summed against a
cap measured on two other accounts; neither is the vendor's word for this
account, yet the card was a routing window and would have stopped the
model at 190M.
Now the summed card is set aside (aside: true): magpie shows it beside the
account and never counts it as the allowance (allowanceOf skips aside
windows). Only a refusal's card (refused: true, used 100, the vendor's
reset) stops the model. Nothing is lost by waiting for the refusal:
magpie's gateway already reads WorkBuddy's 429 reset ("将在 … 重置",
"reset at …") and its "switch to the other models" (resetsWhen,
otherModels in internal/gateway/routing.go) and rests this model alone, on
this account alone, until that time. Both builds, as both read the sum
the same way.
The China cap goes from the soft 1.9e8 to the measured 2e8 (#625's
refusals at 200,389,043 and 200,485,923). The 5% headroom only existed so
routing would stop before the vendor; with the sum aside it would only
make the card read high. The reporter's sum now reads 187.7M / 200M.
Run at this head (fa144e4 + this), on mote:
- packages/workbuddy bun test: 314 pass, 0 fail (one new test with the
reporter's numbers; the China cap tests moved to 2e8; the card test
checks aside on both builds).
- bun scripts/check.mjs workbuddy: ok.
Broken by hand: the card without aside -> 2 fail (the new test and the
card test), 312 pass.
Not tried: a real China account. Whether paid-credit accounts share the
Free plan's window is still unknown; the refusal decides either way.
This commit is contained in:
@@ -612,7 +612,7 @@ test("a model list that can't be read leaves the credits counting every model",
|
||||
// #299: the free model's window, read from magpie's usage ledger, reaches
|
||||
// the WorkBuddy AI card beside Credits. Both builds carry it now: the China
|
||||
// build refused at about 2e8 on 2026-11-02, and its card counts its own
|
||||
// ledger rows against the 1.9e8 soft cap — one phone number signed in to
|
||||
// ledger rows against 2e8 — one phone number signed in to
|
||||
// both must see its spending twice apart, not summed (see freeWindowOf)
|
||||
test("a WorkBuddy AI card carries the free model's window from the ledger", async () => {
|
||||
const dir = join(home, ".config", "magpie")
|
||||
@@ -632,13 +632,14 @@ test("a WorkBuddy AI card carries the free model's window from the ledger", asyn
|
||||
const auth = { type: "oauth", access: "ai-access", expires: later(), uid: "ai3", accountId: "me@example.com", domain: "www.codebuddy.ai" }
|
||||
const out = await usageOf(WorkBuddyAIAuthPlugin, auth)
|
||||
expect(out.windows.map((w) => w.name)).toEqual(["Credits", "Free model tokens"])
|
||||
expect(out.windows[1]).toMatchObject({ amount: 30_000_000, limit: 1e8, unit: "tokens" })
|
||||
// the ledger's sum is set aside: shown, never the allowance (plugins#641)
|
||||
expect(out.windows[1]).toMatchObject({ amount: 30_000_000, limit: 1e8, unit: "tokens", aside: true })
|
||||
serve({ "/billing/meter/get-user-resource-summary": () =>
|
||||
ok({ IsPaidUser: false, Packages: [{ CycleTotalCapacity: "500", CycleUsedCapacity: "0" }] }) })
|
||||
const cn = await usageOf(WorkBuddyAuthPlugin, { ...auth, domain: "" })
|
||||
expect(cn.windows.map((w) => w.name)).toEqual(["Credits", "Free model tokens"])
|
||||
// the China card counts the workbuddy rows alone, against the soft cap
|
||||
expect(cn.windows[1]).toMatchObject({ amount: 90_000_000, limit: 1.9e8, unit: "tokens" })
|
||||
// the China card counts the workbuddy rows alone, against 2e8
|
||||
expect(cn.windows[1]).toMatchObject({ amount: 90_000_000, limit: 2e8, unit: "tokens", aside: true })
|
||||
} finally {
|
||||
rmSync(ledger, { force: true })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user