feat(agents): per-model rate table + per-delta cost accumulation #1003
No reviewers
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks!1003
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "code-lead/953"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Charge each
usage_deltaagainst a per-(provider, modelId)rate table and accumulate USD ontorecord.cost_usdso cursor runs stop reporting$0and provider switches bill correctly.Agent.listModelsSKUs (composer-2, gpt-5.5), and Bedrock-routed Anthropic SKUs; unverified rows carry// TODO(#953)commentsservice_config.model_rates_json(migration0012); cache invalidator hooked into the webhook-config reloader so an edit lands without a restartusage_deltawith the run model;event-log.tslooks up the rate at delta time (not terminal time) — runtime overrides do not retroactively re-price; SDK-reportedtotal_cost_usdis preserved on the result row assdk_cost_usdfor diagnostics(provider, model)→ onecost_unknown_modelsystem event per task +record.cost_unknown_model: true; SSEusage_deltaenvelope carriestotal_cost_usd+cost_unknown_modelso the live chip ticks without a refetch<TokenMeter>renders a 3-sig-figs cost chip in bothcompactandfullvariants; unknown-model runs render?with a tooltip pointing atservice_config.model_rates_jsonTest plan
just qaclean — 3473 server tests pass (14 new inmodel-rates.test.ts, 4 new inevent-log-delta.test.ts)record.cost_usdto 9 decimalsCloses #953
Rate table, delta accumulation, override layer, cache invalidation, SSE tick, and frontend chip all correct. Tests cover seed coverage, hand-computed cost, unknown-model dedup, and the non-retroactive mid-run override AC.
Nit:
fmtCostUsd(0.043)→"$0.0430"(trailing zero fromtoPrecision(3)); the PR description shows$0.043. Technically correct per 3-sig-figs spec, but cosmetically odd — worth stripping trailing zeros before shipping to users.