Skip to content
Unsnag

Cost control

Unsnag spends money in one place: model calls on your OpenRouter key. Docker, your machine and CI minutes aside, everything else is free: validate, scenarios, report, reports, diff and schema never call a model.

What costs money

What calls modelsCapped by
A Runthe Agent, through the Run's model relaybudget.run per Run ($1), and budget.report per Report ($50)
The Jurythree models per judge Check, per Run and in verifybudget.report
The analysisone merge call, then the explainer for each Findingbudget.analysis per Report ($5)
Draftingthe drafter, and the Jury in its verifybudget.draft per unsnag draft ($5)

Verify runs your Reference Solutions, not an Agent, so it costs nothing unless a Scenario has judge Checks. A pass is cached, so an unchanged Scenario is never verified twice.

Set the budgets in budget, all in US dollars:

unsnag/benchmark.yaml
budget: { run: 0.5, report: 20, analysis: 2, draft: 3 }

The Run budget

Every model call an Agent makes goes through a relay that holds your key, and the relay adds up what OpenRouter reports each call cost. When a Run reaches budget.run, the relay refuses further calls and the Run stops: it fails with the reason budget, or errors if the Agent hadn't called your CLI yet. A Scenario that needs more sets its own budget. The Run records its cost, tokens, turns and the provider that served it.

The Report budget and the estimate

Before any Run starts, unsnag run prints its plan's cost on stderr:

estimate $3.12, at most $75.00, Report budget $50.00, overshot by up to 8 × $1.00 (8 Runs at once)
  • The estimate prices each Cell's Runs from the mean cost per Run of that Scenario's earlier Runs with the same Agent in unsnag/reports/: first the Runs of the Scenario as it is now (its goal, Checks and setup unchanged), else the Runs of its earlier versions, else that Agent's mean over every Scenario, else the model's OpenRouter prices for a typical Run (80,000 input tokens, 60,000 of them cached, and 1,000 output tokens). So a first Report gets an estimate too, a new Scenario is priced like its Agents' average until it has Runs of its own, and a Scenario made harder is priced from its new Runs once it has some. report.json's cost.cells records what each Cell was priced from: scenario, scenario_id (earlier versions), agent, prices or none.
  • The hard ceiling is every Run spending its whole Run budget, plus $0.05 for the Jury per judge Check per Run: the most the Report could cost.
  • The Report budget: when the estimate is over it, run refuses to start (over_budget), saying by how much. While the Report runs, no further Run starts once the Report has spent its budget (verify, the Runs and the Jury), and the Report ends incomplete, which exits 1. The budget is checked only as each Run starts, so the Runs already under way can take the spend past it by up to concurrency × budget.run, as the line says.

--budget <USD> sets the Report budget for one Report, and --budget none lifts it.

The analysis budget

When the Runs finish, one model call merges and labels the Findings' groups, then the explainer Agent writes each Finding's explanation and fix, in rank order. They share budget.analysis: each explainer may spend what is left, and none starts once it is spent; Findings left out keep their numbers and rank and are labelled unexplained: budget. budget: { analysis: 0 } turns this stage off entirely. Its spend is in llm_stage.spent, apart from the Report's cost.

Spending less

  • Fewer Runs per Cell. unsnag run --runs 1 for a quick look. Keep runs at 5 (or more) for Reports you compare: with fewer Runs, only large drops are detectable, and each row of the comparison says the smallest drop it could have detected.
  • Fewer Cells. --scenario, --tag, --agent and --context each narrow the Report to what you're working on. A partial Report is labelled as such and compares only the Cells it ran.
  • Rerun only what failed. unsnag run --failed <report> reruns the Cells that had a failing Run.
  • Check one fix. Each Finding's verify command reruns only the Scenarios and Agents it hit.
  • Cheaper models. agents, jury and explainer each take any OpenRouter model id. The defaults are capable models from three vendors; a cheap model makes cheaper Runs, but its struggles may not be your users' Agents' struggles.
  • Shorter Runs. A lower timeout or budget.run stops Agents that wander.

concurrency changes how fast a Report finishes, not what it costs (beyond how far the Report budget can be overshot). By default it is the machine's cores, capped by its available memory at about 1 GB per Run, and 1 with external: true; the Report records it as concurrency.

Where the money went

unsnag report --json has the Report's cost: estimate (with cells, each Cell's price per Run and what it came from), ceiling, budget, overshoot (how far the Report budget can be overshot), verify and actual (verify, every Run and every Jury vote). Each Run's run.json has its cost and jury_cost, and llm_stage.spent is the analysis.