Issue usage report¶
Starting 2026-10-21 we track what each issue uses: AI tokens, and GitHub Actions minutes. Until rig-events has a
live view of cost, scripts/cost/issue_usage.py reports it for one issue on demand. It is slice L10 of the cost
design and is read-only everywhere.
python3 -I scripts/cost/issue_usage.py dashecorp/rig-agent-runtime 807 # text
python3 -I scripts/cost/issue_usage.py dashecorp/rig-agent-runtime 807 --json # for other tools
python3 -I scripts/cost/issue_usage.py OWNER/REPO ISSUE --prices-ref <branch> # prices from an unmerged branch
It needs the standard library only, gh with read access to the issue's repo and to dashecorp/rig-events, and
the tailnet for rig-conductor (CONDUCTOR_URL points it elsewhere). Tests:
python3 -I -m unittest discover -s scripts/cost.
What each line counts¶
| Line | Basis | Source |
|---|---|---|
| GitHub Actions | calculated | The runs of the issue's closing PRs (their head branch) and of each merge commit, which covers deploys. Job by job (filter=all), each rounded up to the whole minute, at its runner's per-minute price. |
| Rig agents | as reported | rig-conductor's /api/costs/issue, per agent step. Dollars only until the conductor reports tokens per issue (slice L1e). |
| Codex | measured | ~/.codex/sessions: a run whose clone is the issue's repo on an issue-N branch, or whose brief names the repo and issue #N. OpenAI counts cached tokens inside input, so the report subtracts them. |
| Orchestrator | allocated | ~/.claude/projects: each API call counted once (by message id), while the issue was open. A call is shared equally among the issues and PRs its tool calls name, and a call that names none goes to the ones last named in that session. |
The run timing API is not used: on this account it reports total_ms: 0 for every job.
Prices¶
The script keeps no price table. It reads the price_events rows from rig-events' migrations (rig-events#17) and
prices each use at the rate in force on its day: the latest valid_from on or before it, and among rows with the
same valid_from, the latest recorded_at. A model id maps to a price key by the conductor's rule: the longest key
it starts with, followed by nothing, a release date (-YYYYMMDD or -YYYY-MM-DD) or a tag ([1m], @…).
- Usage before the first price event is priced at that first price, and the line says so.
- A model with no price events keeps its tokens but no cost, and the line says it is unpriced. It is never priced at another model's rates.
- Larger GitHub runners (
-N-cores) are not in the price events yet and show as unpriced minutes. Self-hosted minutes cost 0. - GitHub minutes are at list price. Minutes covered by the plan's included allowance cost nothing on the invoice, so this is what the work would cost, not what was billed.
Limits¶
- Local logs only. Codex and Claude Code logs are read from the machine that runs the script. Work done in another workspace or on another host is not counted, so run it where the work happened.
- Orchestrator figures are an allocation, not a measurement. A session that works on two issues at once without naming them splits its tokens by what its tool calls name.
- Rig agent figures recorded before 2026-10-21 overstate cost: Codex cached input was counted twice (rig-agent-runtime#808), and a streamed run was counted twice (rig-agent-runtime#805). Recorded events are not rewritten.