kensenzhao saw a subscription's allowance spent by requests the agent
didn't make: a routing group's classifier, set to a subscription's model,
asks it as every turn begins, and those calls looked like the agent's own.
What changed
- usage.Group has an own share (calls, tokens, cost) of the calls magpie
made by itself, filled for models, keys and accounts. Record.ByMagpie
is the test: agent "magpie", or one of its own User-Agents
(magpie-router/1, magpie-search/1, magpie-vision/1) where the agents
aren't loaded. The calls still count in the group's totals, as they
went to the same key or account. A group with none sends no "own".
- The classifier's calls are Kind "routing": callKind marks RouterAgent's
requests, and the decision model's record (Jev / System One) is written
with it. A "Routing classifier" purpose names them in the ledger.
- Usage page: magpie's row among the agents and its ledger rows carry a
"magpie's own" mark; an account's, key's or model's row adds "{n} by
magpie itself"; an account's card says how many of the period's
requests were magpie's own, drawn again once the summary arrives after
the allowances.
- Routing page: /api/groups marks a model a subscription account serves
(modelRef.Sub, servedRef). Beside a classifier on such a model, or a
group whose first member is one, the editor says every turn starts
with a request to that subscription, two when it picks both intent and
effort in words. A classifier on a key or a free model says nothing.
- New strings in zh, zh-TW, ja and de. The mark is a muted chip with an
even border all round (no left stripe).
Tests
- TestSummaryCountsMagpiesOwnCallsApart, TestByMagpie (usage).
- TestIntentRoutesATurn and TestJevPicksTheIntent (gateway) now check
the classifier's records are Kind routing and magpie's own, and the
agent's records are not.
- TestServedRefSaysASubscription (gui).
- own-requests.test.cjs: Chromium and WebKit, 1100 and 390 wide,
en/zh/zh-TW/ja/de, the API faked; no click scroll, no sideways page.
- Broken by hand, each turned its test red: addOwn counting nothing;
callKind's routing case removed; decide.go's Kind blanked; the ledger
mark, the agents' mark, the "{n} by magpie itself" line, the card's
line, its redraw after the summary, the Routing hint, its group case
and modelRef.Sub each removed.
Run: gofmt -l; go vet on darwin, linux -tags nogui and windows; go test
for usage, access, catalog, gui (-tags nogui) and gateway in full; the
GUI tests above, the ledger, routing-intent and translation tests.
Not done: the warmups (warmClaude/askClaude) write no usage record at
all, so they can't be marked; that is left as it was. Not tried with a
real subscription classifier against a live account.
What: in ruleFor, when the classifier errs (an error, no answer within
classifyTimeout, an answer that isn't a number, or resting classifyRest
after a failure) and the conversation's turn before had an intent that
is still one of this turn's (Classified.After), the turn keeps it:
Classified.Intent is that intent, the new Classified.Fallback
(json "fallback") is "previous", and Error is kept. With no intent
before, nothing changes: no rule with an intent matches. The Routing
page's classWhy says "… but couldn't — {err} — so the turn keeps
“{intent}”, as turn {prev} was.", in zh, zh-TW, ja and de too.
Why: #1826 section 3: two timeouts in a row (20:54:43, 20:55:20) sent
turns of a known 复杂 conversation to the group's cheap first member.
Not done: persisting turnRules beside the sticks (the issue's idea 3).
After a restart a turn under way still waits for the next turn, with the
stick holding it meanwhile; with the previous commit the stick's key no
longer changes mid-conversation, which was how the reporter lost both.
Run: TestIntentClassifierFailsKeepsThePreviousIntent (down, then resting,
then a conversation with nothing to keep) fails with the fallback line
taken out and passes now; routing-intent-fallback.test.cjs (Chromium and
WebKit, en/zh/zh-TW/ja/de, 1100px and 390px with no sideways scroll)
30/30, and 10 of 15 red on Chromium with the old routing.js;
routing-intent-entry, routing-effort, panel-routing, routing-folder,
i18n-keys and gui-de pass; go test ./internal/gateway -count=1 green
(295s); go test -tags nogui ./internal/gui green; gofmt -l clean; go vet
on darwin (gateway), GOOS=linux -tags nogui ./... and GOOS=windows ./...
clean.
Not tried: a real classifier timing out in a live session.