feat(web): every inference on Luke's key is counted on the account's meter, a coding agent's and every title included (one runtime 6/n)
Merged
DA
6d ago+172+172+012345678901234567890123456789-76-76-01234567890123456789
One-agent-runtime migration, PR 6 (docs/proposals/one-agent-runtime.md §5, Decision 6: "Meter every inference on Luke's key, coders included").
What
Only the planning model and its workers counted the account's daily meter (spendHostedMeter). A coding agent or its worker running on Luke's key wasn't counted, and neither was any generated title.
server/hosted/agent-runtime/meter.ts(new):MeterSeams,meteredModel(moved unchanged frombrain-host/model.ts), andaccountMeter(spend, userId).- Luke's key carries the meter.
ProviderKey.meteris set only on Luke's own key (coder-host/account-keys.ts).modelOnKeyputs the meter in front of a model on Luke's key, and in front of nothing on the account's own key. Every step on Luke's key is counted, whoever asked:- the planning model and its workers (
brainModelSelectionhands its meter in with the key instead of wrapping afterwards); - a coding agent and its workers, which were never counted before.
- the planning model and its workers (
- Titles.
titleModel(keys, meter)counts a title on Luke's Anthropic key. Both hosts'titleModelseam now takes the account (titleModel(userId)), so a coding agent's title, a delegated worker's title and a planning worker's title are each counted for the account they name. - BYOK steps are never counted: the account pays for them.
The count still enforces nothing. It never refuses, and a failed count is reported by its kind and the inference runs anyway (meter.ts header).
Tests
tests/coder-host-account-keys.test.ts, against providers faked at their fetch over a real dialect:- New: a step on Luke's key counts the account's meter once, even one the provider refuses, and a step on the account's own key counts nothing.
- New: a title generated on Luke's key counts the account's meter once.
tests/hosted-brain-host-model.test.ts: the meter's own tests (one count per inference, a failed count reported by kind) now import it fromagent-runtime/meter.- The whole web suite passes (153 files, 1,319 tests). The offline brain and coder evals pass against a local Postgres. Lint and repository checks pass.
This PR touches neither the Mac app nor the renderer.
🤖 Generated with Claude Code