Add session cost reports, live TUI visibility, and cache economics
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 152
- Forks
- 16
- Avg merge
- 14h 48m
- Merged PRs (30d)
- 536
Description
Parent
Part of #610. Depends on enriched pricing and complete LLM-call attribution.
User outcome
An operator can obtain a trustworthy, machine-readable cost summary for a session and see the same essential information live in mecatui without needing a separate analytics product.
Scope
Cost-summary query
Expose a session-scoped report containing:
- total estimated cost and currency;
- pricing coverage percentage and explicitly unpriced usage;
- estimate/price provenance and price-card freshness;
- breakdown by functional label;
- breakdown by requested/resolved/served model where meaningful;
- successful, failed, retry, and fallback spend;
- ordinary input, output, reasoning, cache-read, and cache-write usage/cost;
- top deterministic cost contributors.
Provide a stable machine-readable representation suitable for scripts and later external dashboards. Aggregation must be reconstructable from durable usage observations rather than an in-memory-only counter.
Basic cache economics
Report only the initial high-value indicators:
- cache hit rate;
- cache-read cost;
- cache-write cost;
- estimated uncached input baseline;
- estimated net cache savings.
The calculation must document provider-normalized semantics, price provenance, partial coverage, and where an uncached baseline is only an estimate. It must not double-count cache tokens already included in inclusive input totals.
Minimal TUI surface
Add a compact session-cost view/live meter showing:
- current estimated session cost;
- last-call increment when known;
- pricing coverage/unpriced warning;
- top function/model contributors;
- cache hit rate and estimated savings.
A table or expandable pane is sufficient; charts and historical trends are not required.
Acceptance criteria
- A completed or active session has an obtainable machine-readable cost report reconstructed from durable observations.
- The report totals reconcile with the underlying observed calls and do not double-count delegation.
- Unknown pricing is visible in both amount coverage and token/call counts; totals never imply 100% coverage when usage is unpriced.
- Every displayed amount is labeled estimated and includes its price provenance/freshness.
- Failed/retried spend and requested-versus-served model attribution are inspectable.
- Cache economics handle inclusive input/cache subsets correctly and expose the formula through tests/docs.
- The TUI updates after completed model calls and degrades cleanly when no pricing or usage exists.
- Cost-report content contains no prompts, tool payloads, credentials, or sensitive provider configuration.
- User-facing documentation explains list-price estimates, coverage, cache-savings assumptions, and limitations.
- Tests are offline and include mixed priced/unpriced, cache, retry, fallback, and nested-delegation fixtures.
Out of scope
- Organization/repository historical dashboards.
- Detailed cache-miss root-cause diagnosis.
- Cost forecasts.
- Billing exports or invoice reconciliation.
- Cost per PR or business outcome.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing parent issue #610 and tracing the durable usage observations that can support a session-scoped report. Then examine the mecatui session view and existing offline test structure. Done means reconcilable machine-readable totals, documented cache and pricing assumptions, safe TUI updates, and coverage for the listed mixed-usage scenarios.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend, cli, data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100