AI coding

What an Acceptance Check Costs in Command Time and Tokens

Antonio Evans8 min read

A split dashboard: on the left, a stopwatch over a command line; on the right, a token counter.
Key points

Key points

  1. 1An acceptance check costs command time (wall clock seconds for the check process) plus tokens (the model calls needed to read output and decide pass or fail).
  2. 2Measure both costs per check, multiply by checks per task, and set a per-task ceiling before the agent starts editing.
  3. 3Budget the check loop at no more than the task's edit loop; a check that blows its limit is a signal to narrow the check, not to raise the ceiling.
  4. 4Instrument the loop with timestamps and per-call usage fields so cost attribution happens per step, not per month.

Why the check loop, not the edit loop, sets your bill

Coding agents spend much of their money verifying work, not writing it. Anthropic's documented workflow for Claude Code is Explore, Plan, Implement, Commit, and its guidance is blunt: give the agent "a check it can run: tests, a build, a screenshot to compare," because without verification the agent stops when work merely looks done (Anthropic's best practices, as summarized by SSOJet). That check is the mechanism that makes autonomy safe, and it is also the meter that keeps running.

The cost has two currencies and they behave differently. Command time is cheap per second but serial: a browser test that takes 90 seconds blocks the agent for 90 seconds, and the agent cannot think while it waits. Tokens are cheap per call but compound: every retry re-sends context, and output tokens cost roughly four times input tokens across major providers, with the median output-to-input price ratio near 4x and premium reasoning models reaching 8x (Glean's token efficiency metrics). An agent that reruns a check six times pays six times for the tokens that interpret the output, even if the check itself passes on the first run.

Agents amplify this because they consume far more tokens than chat interfaces: a Gartner estimate cited in industry monitoring guidance puts agent consumption at 5 to 30 times that of traditional chatbots (Mintive's agent monitoring guide). The same guide notes that Uber exhausted its annual Claude Code budget by spring, a concrete case of agentic coding costs outrunning forecasts (Business Insider via Mintive). The lesson is not that agents are too expensive; it is that nobody measured the check loop before it ran.

The two currencies, defined precisely

Command time is the wall clock from process start to exit for everything the check executes: test runner, build, linter, browser automation, container startup. Measure it at the boundary, not inside the agent, so retries and setup count. DORA's test automation guidance is a useful benchmark: developers should get automated feedback in under ten minutes locally and from CI (DORA's test automation capability). Anything longer than that inside an agent loop is a cost problem before it is a quality problem.

Tokens are the model calls needed to interpret the check and decide. A clean pass usually needs one small call: feed the exit code and a summary, get a classification. A failure needs more: the agent reads the error, reasons about it, edits, and rechecks. Token accounting should follow the provider's own usage fields, which include prompt and completion counts plus cached-token and reasoning-token details (Braintrust's token tracking guide). For portability across providers, the OpenTelemetry GenAI conventions define attributes such as gen_ai.usage.input_tokens and gen_ai.usage.output_tokens, so you can compare engines without rewriting dashboards (Braintrust).

The trap is that aggregate totals hide the cause. Braintrust separates three views: per-call prompt and completion tokens, context window utilization per request, and per-step tokens inside agent traces. Prompt bloat, context overflow, and runaway agent loops each raise totals but need different fixes (Braintrust). For an acceptance check, the third view matters most: the expensive step usually sits deep in the loop, not at the top.

Instrumenting one check to log both currencies

You do not need a full observability stack to start. Wrap the check in a small runner that records start time, exit code, output size, and the token usage of any model call made to interpret the result. Here is a minimal Python sketch that works with any OpenAI-compatible endpoint:

import time, subprocess, json

def run_check(cmd, interpret):
    t0 = time.monotonic()
    proc = subprocess.run(cmd, shell=True, capture_output=True, text=True)
    elapsed = time.monotonic() - t0
    verdict, usage = interpret(proc.returncode, proc.stdout[-4000:], proc.stderr[-4000:])
    return {
        "command": cmd,
        "exit_code": proc.returncode,
        "command_seconds": round(elapsed, 2),
        "output_chars": len(proc.stdout) + len(proc.stderr),
        "verdict": verdict,
        "tokens_in": usage.get("prompt_tokens", 0),
        "tokens_out": usage.get("completion_tokens", 0),
        "tokens_cached": usage.get("cached_tokens", 0),
    }

Two implementation notes. First, truncate output before sending it to the model; a failing test suite can emit megabytes, and output tokens are the expensive kind. Second, include cached-token counts, because caching stable prefixes is the cheapest optimization available and cache-read tokens are roughly 90 percent cheaper than fresh input (Glean). Log each record as one JSON line, then aggregate per check name. That gives you the exact two numbers the budget needs.

If you would rather not build the routing and metering yourself, one option is Quanta Inference, which puts text, image, video, audio, and embedding models behind a single OpenAI-compatible key with prepaid, dollar-denominated pricing, so the token side of the ledger is one number to track.

A worked example with numbers

Take a mid-sized feature: add discount stacking to a checkout flow. The ticket says a 20 percent loyalty discount stacks with promotional discounts to a maximum of 35 percent, which is exactly the kind of requirement that converts cleanly into acceptance tests (VirtusLab's maturity matrix). Assume four acceptance checks: unit tests for the pricing rules, an API contract test, a browser test for the checkout page, and a linter.

CheckCommand time per runRuns per taskCommand totalTokens per run (in + out)Token total
Pricing unit tests8 s648 s900 + 1206,120
API contract test35 s4140 s1,400 + 1506,200
Browser checkout test90 s3270 s2,200 + 2007,200
Linter4 s624 s500 + 403,240
Total482 s (8 min)22,760

The numbers are illustrative but the method is not: every cell comes from a logged record like the one above, and the run counts come from your trace, not from a guess. Read the table the way a budget analyst would. The browser test consumes 56 percent of command time from three runs, so its cost is dominated by wall clock, and the fix is to run it once on the final diff rather than after every edit. The API contract test consumes 27 percent of tokens from four runs, so its cost is dominated by re-reading its output, and the fix is to assert on a compact JSON diff instead of dumping the whole response.

Now compare with the edit loop. Suppose the agent makes nine edits across the task at roughly 6,000 input and 800 output tokens each (context plus the edit), about 61,000 tokens. The check loop at 22,760 tokens spends roughly 37 percent of the edit loop's tokens, comfortably inside the rule of thumb that checks should not exceed edits. If instead the browser test ran after all nine edits and re-read full page HTML each time, its token line would roughly triple and the check loop would overtake the edit loop. That is the crossover point where you change the check, not the budget.

The acceptance-test literature supports investing here: in an industrial case study, 60 percent of LLM-generated acceptance test cases were usable as generated, 8 percent needed minor fixes, and 24 percent needed regeneration with more input (the arXiv case study). Translation for budgeting: expect roughly one in three checks to cost a second interpretation round, and size the per-task ceiling to absorb that without letting a degenerate check run unbounded.

Setting per-task ceilings that do not block real work

A per-task ceiling is two numbers, not one: a command-time cap and a token cap. Set them from the task's edit loop, measured on your own traces. A practical procedure:

  1. Run ten representative tasks with instrumentation on, and record edit-loop command time and tokens per task.
  2. Set the check ceiling at 100 percent of the median edit-loop cost, with a hard stop at 150 percent.
  3. Allocate the ceiling across checks in proportion to their historical share, but cap any single check at 40 percent of the total.
  4. On breach, do not raise the ceiling. Shrink the check: reduce scope, compress output, or move it to a final-only gate.
  5. Review breaches weekly; a check that hits its cap repeatedly is a design signal.

Step 4 is the decision rule that matters. Raising a ceiling hides a check that is too broad, and broad checks are exactly what agents over-run. Anthropic's documented workflow separates exploration and planning from implementation, which is the same principle applied to checks: run the narrow, fast checks constantly and the broad ones once (SSOJet on Anthropic's guidance). Spec-driven practice points the same way: a good spec covers just enough nuance to guide the agent without overwhelming it, and large tasks should be broken into smaller ones rather than crammed into one prompt (Addy Osmani's spec guide).

A compact policy table keeps the rule enforceable in code:

SignalThresholdAction
Single check command timeOver 40 percent of task command capNarrow scope or final-only gate
Single check tokensOver 40 percent of task token capCompress output, summarize before sending
Check loop totalExceeds edit loop totalStop task, review check design
Repeated identical failuresThree runs, same errorHalt, escalate to human with the trace

The last row deserves emphasis. A retry loop that produces the same error is burning both currencies for no information, and per-step trace visibility is the only reliable way to catch it, since the expensive span usually sits deep inside the run (Braintrust).

Where teams overspend, and the decision rules that stop it

Three patterns account for most check-loop overspend. First, interpretation by a frontier model for trivial verdicts: a passing exit code needs no reasoning, so route classification to a small model. OpenAI's own agent guidance recommends building with the most capable model to establish a baseline, then swapping in smaller models where accuracy holds, optimizing cost and latency only after accuracy targets are met (OpenAI's practical guide to agents). Second, undersized output hygiene: piping raw logs into the prompt is prompt bloat, one of the three named drivers of token spikes (Braintrust). Third, no per-step attribution: without it you cannot tell a retrieval fault from a retry loop, and per-agent cost attribution is precisely what surfaces those faults (Mintive).

A fourth pattern is architectural. The OpenDev terminal-agent paper describes workload-specialized model routing and adaptive context compaction, both of which cut the cost of every step that re-reads the conversation, and both are deliberate engineering choices rather than defaults (the OpenDev paper). The decision rule that ties it together: treat the check loop as a fixed budget attached to the task, sized from measured edit-loop cost, and treat any breach as evidence about check design. Checks that pass cleanly on the first run cost almost nothing to interpret; checks that fail repeatedly are the expensive ones, and they are also the ones most likely to be too broad to be useful.

For teams that want the loop staffed rather than hand-tuned, Quanta Experts runs each expert against your context and returns finished deliverables, which pairs naturally with a check budget set at the task level rather than the tool level.

FAQ

FAQ

What exactly counts as command time in an acceptance check?

Command time is the wall clock from process start to exit for everything the check runs: test runner, build step, browser automation, container startup, teardown. Measure it outside the agent so retries and setup are included. If a single check exceeds about ten minutes, it is already past the feedback threshold DORA recommends for automated tests (DORA).

Should I count tokens for every check, even ones that pass?

Yes, but the passes are cheap. A clean pass can be classified from the exit code and a short summary in one small call, while a failure needs the error output, reasoning, and often a second round. Since roughly one in three generated checks needs a fix or regeneration (arXiv case study), budget for the passes and let the failures draw from the same per-task cap.

Why is the edit loop the right yardstick for the check budget?

Because it scales with task size and reflects what the task is actually worth. A task with nine edits at moderate token cost has a measurable cost, and checks that cost more than the work they verify are out of proportion. Measuring both on your own traces gives a ratio you can defend, rather than a number copied from someone else's setup.

What should I do when a check hits its token cap?

Narrow the check, do not raise the cap. Reduce what the check asserts, compress or summarize output before sending it to the model, or move the check to a final-only gate that runs once after the last edit. A repeated breach usually means the check is trying to verify too much at once, and the fix is scoping, not more budget.

How do I track per-step cost across different model providers?

Use each provider's usage fields for prompt, completion, and cached tokens, and emit them under the OpenTelemetry GenAI attribute names so dashboards stay comparable across engines (Braintrust). Route all calls through one gateway if you want a single ledger; an OpenAI-compatible aggregator such as Quanta Inference reduces the per-provider bookkeeping.

Sources

Sources

  1. 25 Best Prompts for AI Coding Agents - SSOJet
  2. Key metrics for evaluating token efficiency in AI systems
  3. AI Agent Monitoring: How to Track Token Usage, Costs, and ...
  4. Capabilities: Test automation
  5. How to track LLM token usage (2026): Prompt, completion ...
  6. Acceptance tests from tickets (Autonomous Requirements)
  7. Acceptance Test Generation with Large Language Models
  8. How to write a good spec for AI agents
  9. A Practical Guide to Building AI Agents - OpenAI
  10. Building AI Coding Agents for the Terminal - arXiv
About the author

About the author

Antonio Evans
Antonio Evans

Antonio Evans is the founder of Quanta Intelligence and a fractional CTO who builds HIPAA-ready AI systems for health and life-science companies. Before that he was technical co-founder of FriendsEAT for twenty years, CEO of Socialdraft, and a data engineer at IBM. Antonio lives with his dog Santino in Lisbon, Portugal.

All articles