A Claude Code turn relayed on Messages with its advisor on has the advisor
run at the vendor. The reply's top-level usage is the executor's alone;
each advisor call is an advisor_message entry of usage.iterations, billed
at the advisor model's rates (Anthropic's advisor tool page, "Usage and
billing"). magpie read only the top level, so an Opus advisor beside a
Sonnet executor was in no row and priced nowhere.
aUsage reads iterations, whole and from a stream's message_delta (whose
list is cumulative, so the latest stands for the reply). Each advisor call
becomes its own row (advisorRows, written by appendAdvised at every row of
a try that reached a provider, and on the native route): under the
advisor's model by magpie's id (advisorKeyModel of the request's advisor
tool), Served as the vendor names it, Kind "advisor" (named Advisor in
Usage's filters, already translated), the request's route, agent, account
and session, status 200, counted as its own request as magpie's own
advisor calls already are. The executor's row is unchanged. Routing prices
the calls too, before the request's own usage so the prompt is still read
from the last entry. Iterations with no advisor entry (Copilot) leave
Usage as it was.
The fixture is Anthropic's documented example word for word; no real
reply with an advisor call was captured.
The core script budget is raised by 52, the Advisor entry in the
generated purposes.js (the base had no room; 1 byte less is red). The
kinds are read wherever Usage and Routing draw a row, so there is no page
to move it to.
Run at this commit's tree on f1b0663f1, then on b1f044fc1 (which changed
core scripts only, i18n.js and syncfiles.js, so internal/gui and the GUI
files were run again there):
- mica: gofmt -l (nothing), go vet (darwin), GOOS=linux go vet -tags nogui,
GOOS=windows go vet for internal/gateway, internal/usage, internal/gui: ok.
- mica: go test -timeout 45m -count=1 ./internal/gateway ./internal/usage
./internal/gui: ok (916s, 64s, 161s).
- mote: node --test purpose-filter, routing-purpose-state, usage-big-write,
usage-ledger-mcp, usage-ledger-search, i18n-keys (Chromium and WebKit):
74 of 74 pass.
- On b1f044fc1, the pushed base: mica go test -timeout 45m -count=1
./internal/gui ok (147s); mote the same six GUI files, 74 of 74 pass.
- Before the rebase, at ae94571d7, the same packages on mote were ok
except TestCoreScriptBudget, which this commit's budget line answers.
Broken by hand:
- aUsage.usage never setting advised: TestAdvisorIterationsRead red
("stream=false: advisor calls <nil>, want one"), TestAdvisorCallHasItsOwnRow
red in both subtests ("advisor rows: []").
- passthrough without advisedAs: TestAdvisorCallHasItsOwnRow red in both
subtests, the row named claude-opus-5-5 and not magpie's claude-opus-5.5.
Not tried: a real Anthropic reply with an advisor call (no account with the
advisor beta at hand); Bedrock and Vertex passthrough with an advisor
(they share the sniffer, not run); the Usage page with an advisor row in a
real browser session beyond the GUI files above.
Reported by Refeccd on Discord.