{# R7 · ANALYTICS center view (live) — usage & cost (CTO item 8 rework). The SUBSTANCE is the usage + estimated-cost breakdowns, computed for the SELECTED PROJECT from its agents × each agent's effective model × token usage × the providers pricing catalog (built in main._analytics_usage_cost): 1. Total usage BY MODEL (bar + table) 2. Usage BY MODEL × PROVIDER (provider totals + their model rows) 3. MODEL USAGE PER AGENT (agent · model · token usage table) 4. est. API COST BY AGENT (tokens × model price/Mtok; 'n/a' unpriced) 5. est. API COST BY PROJECT (Σ per-agent est. cost) A slim headline KPI row (events/24h, active tasks, decisions, recent tokens) is kept above the breakdowns. COST NOTE: the CTO is on SUBSCRIPTIONS now, so every cost here is the counterfactual "what it WOULD cost on metered API tokens" (priced from providers.py per-Mtok), NOT a real charge. Real cost arrives with metered per-call telemetry. Token usage is best-effort from /history `token_count` frames (server-capped window) — agents with no frames show "n/a" and are NOT zero-filled. TODO(usage-telemetry) noted in the footnote. Context (built in main._analytics_view / _analytics_usage_cost): headline KPIs : an_events_24h, an_active_tasks, an_pending_handoffs, an_recent_decisions (+ an_window_days), an_decisions_total, an_handoffs_total, an_lessons_total, an_tokens usage/cost : an_usage = { rows[], agent_count, agents_with_usage, total_tokens(_h), by_model_bars[], by_model_table[], model_count, by_provider[], by_provider_bars[], provider_count, cost_rows[], project_cost(_h), priced_agent_count } an_catalog_priced : did the providers catalog load (pricing available) #} {% macro stat(label, value, unit="", na_note="n/a") -%}
No usage recorded yet for this project — the breakdown fills in once agent runs write to the usage store.
{% endif %} {%- endmacro %} {% if selected %}| Model | Provider | Tokens |
|---|---|---|
{{ r.model }} |
{{ r.provider }} | {{ r.tokens_h }} |
{{ m.model }}{{ m.tokens_h }}| Agent | Model | Provider | Tokens | in · out / Mtok |
|---|---|---|---|---|
| {{ r.display }} |
{% if r.model_known %}{{ r.model }}
{% else %}no model configured{% endif %}
|
{{ r.provider or "—" }} | {% if r.tokens is not none %}{{ r.tokens_h }}{% else %}n/a{% endif %} | {% if r.priced %}{{ r.price_in_h }} · {{ r.price_out_h }}{% else %}—{% endif %} |
No agents resolved for this project.
{% endif %}| Agent | Model | Tokens | Est. cost |
|---|---|---|---|
| {{ r.display }} |
{% if r.model_known %}{{ r.model }}
{% else %}—{% endif %}
|
{% if r.tokens is not none %}{{ r.tokens_h }}{% else %}n/a{% endif %} | {% if r.cost is not none %}{{ r.cost_h }} {% else %}n/a{% endif %} |
| Project total · est. | {{ an_usage.project_cost_h }} | ||
No agents to cost for this project.
{% endif %}usage_events) — the separate operational store, NOT Cortex
(E007 data separation: Cortex stays agent memory + coordination). Each run records its resolved model · provider · token in/out,
and an estimated cost (the harness's reported cost, else the run's tokens priced at the model's per-Mtok rate from the
Providers & Models catalog — {{ "loaded" if an_catalog_priced else "unavailable — pricing n/a" }}).
Cost is an estimate of metered API spend — the team is on subscriptions, so nothing here is billed; it becomes real on metered API tokens.
Where a project / agent has no recorded runs, usage and cost show n/a (never fabricated).
{# TODO(usage-telemetry): per-harness routing (codex turn.completed.usage etc.) lands token capture for the non-claude lanes; the App-DB schema already carries provider/model/tokens/cost for them. #}
Select a project to view its usage & cost analytics.