Cost Per Issue
How the live cost-per-issue dashboard number is produced, and the dormant per-issue rollup module.
Partially implemented. The dashboard cost metrics (average cost per issue, cost per station, cost trend) are live and read from factory_metrics. A richer per-issue rollup module (token cost + flat compute cost per issue) is coded and tested but dormant - it has no API route, no cron, and no production caller. There is no per-issue drill-down API today.
The Cost Per Issue metric tracks what it costs to move work items through your SDLC workflow. The Factory dashboard uses it for cost trends, cost per station, and cost efficiency ratios.
How the live number is produced
Costs enter the system on factory events: when a session completes, the emitted factory_events row carries costUsd (and token counts) in its payload. The metrics pipeline processes each event at ingest time and upserts additive factory_metrics rows:
- Event ingest -
processEventForMetricsruns for every factory event. - Cost upsert - if the event carries
costUsd > 0, the pipeline adds it to thecost_per_issuemetric for that station, in both hourly and daily buckets (provider + token counts land in the bucket metadata). - Read path - the dashboard's Cost panel calls
GET /api/factory/metrics?metricType=cost, which aggregates those buckets viagetCostMetrics.
There is no hourly cron: aggregation happens on ingest, plus an operator-triggered re-aggregation endpoint (POST /api/factory/aggregate) that rebuilds buckets from the raw event log.
Reading cost data
Dashboard view
The Factory dashboard's cost panel shows:
- Average cost per issue - mean of the
cost_per_issuemetric buckets in the window - Cost per station - summed cost grouped by station (development, qa, …)
- Cost trend - daily cost series
- Human vs agent activity split - the ratio of human-actor to agent-actor factory events (an event-count ratio, not a dollar figure)
API access
curl -H "Authorization: Bearer $RENSEI_API_KEY" \
"https://app.rensei.ai/api/factory/metrics?metricType=cost&timeRange=30d"Response shape (CostMetrics):
{
"avgCostPerIssue": 1.23,
"costPerStation": [
{ "station": "development", "cost": 0.62 },
{ "station": "qa", "cost": 0.38 }
],
"costTrend": [
{ "date": "2026-05-03", "cost": 1.18 },
{ "date": "2026-05-04", "cost": 1.25 }
],
"humanTimePct": 12.5,
"agentTimePct": 87.5
}There is no GET /api/factory/cost-per-issue endpoint and no per-issue / per-session cost drill-down API. Cost is attributed per station bucket, not per individual issue, on the live path.
What counts toward cost
Today the only cost source is what session completion events report as costUsd - in practice, LLM token cost computed from the model pricing catalog. Sandbox execution dollars and human review time are not costed:
- Sandbox provider charges (e2b, Modal, …) are not metered into
costUsd. - Human review sessions carry no hourly rate; humans only influence the event-count activity split above.
If model pricing is missing from the catalog for a provider, its sessions contribute 0 - check the Model Catalog before trusting cost figures.
The dormant per-issue rollup module
A second, more precise implementation exists in platform/src/lib/factory/cost-per-issue.ts (+ cost-per-issue-job.ts): a per-issue rollup with a two-leg cost model -
- Token leg - input/output tokens × catalog pricing
- Compute leg - session wall-clock hours × a flat
COMPUTE_HOURLY_RATE_USD($0.08/hr, the amortised per-hour cost of one managed runner slot)
It is coded and unit-tested but not wired: no route exposes getCostPerIssue, no cron runs the recompute job, and its cost_per_issue table has no production rows. Treat it as infrastructure that may be promoted - or removed - rather than a feature you can call.
Cost optimization strategies
- Route simple tasks to cheaper models - Haiku vs Sonnet via routing profiles
- Improve specification clarity - fewer agent loops and rework sessions per issue
- Watch the trend line - a rising per-issue trend usually means more rework or a more expensive model mix
Next Steps
- To configure model pricing, see Model Catalog & Routing
- To set cost caps and budgets, see Cost and Caps
- To understand cost trends, see Cost Breakdown
- To calculate cost efficiency (yield/cost), see Agentic DORA