aiworkhub_task_cost_ledger
READ-ONLY: bounded cost summary, with opt-in detailed dimensions.
Instructions
READ-ONLY: bounded cost summary, with opt-in detailed dimensions.
Default mode retains cost/cache truth plus provider, model and day
aggregates, and stays bounded as usage history grows. by_model,
cost_per_accepted_outcome.routes and model_outcomes.models
each return at most _COST_LEDGER_SUMMARY_TOP_N rows. by_day
is bounded as two independent groups -- up to
_COST_LEDGER_SUMMARY_TOP_N most-recent dated buckets beside up to
_COST_LEDGER_SUMMARY_TOP_N undated ones -- so its exact ceiling is
2 * _COST_LEDGER_SUMMARY_TOP_N rows, not N; undated spend is
retained rather than made to compete with real days for one shared
bound. Every bounded dimension carries explicit total_count/
returned_count/truncated/ranked_by metadata under
summary_row_bounds, so no row is dropped silently. The two
model-keyed dimensions rank by observed dollars rather than tokens; a
bucket whose provider reported no price ranks on its activity instead
of being cut as though it were free, and a partially priced bucket
ranks in both orders so one cheap priced record cannot hide the
magnitude whose dollars are still unknown. Per-runner and per-topic
maps are available with full=true; task rows remain independently
opt-in through include_tasks.
Kept rows are also narrower than full=true. Each kept model's
cost_per_accepted_outcome.routes adapter folds its family/risk
partitions into one total row, re-derived from summed counters so an
UNKNOWN partition keeps it UNKNOWN; the fold is receipted under
summary_row_bounds. by_day rows keep records,
total_tokens, cost_usd, cost_unknown_records and
cache_hit_ratio. full=true returns both exactly as built.
The repository binding is what makes those aggregates answerable.
build_cost_ledger reads canonical usage events only when it is given a
root; without one it parses the human-readable usage report, whose lines
carry no model, provider or timestamp, so every dimension this docstring
promises collapsed to unknown. Measured 2026-09-02 on this repository:
unbound 590 rows / 1 model / 1 provider / 1 day / 0 usage-observed / 0
cache-observed / 0 routes; bound 3,509 rows / 28 models / 8 providers / 36
days / 2,267 usage-observed / 1,869 cache-observed / 13 routes. Every
other caller (dashboard, manager tools, evidence instruments) already
passed a root; this tool -- the manager's own cost surface -- did not, so
routing by cost and difficulty had no measurement to steer by
(NF-2026-00542).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| full | No | ||
| topic | No | ||
| runner | No | ||
| status | No | ||
| include_tasks | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||