# How to track LLM cost by agent step > Providers bill per call and agents fail per run. Carrying a trace id through every hop is what turns one into the other. Worked example inside. URL: https://getculpa.com/track-llm-cost-by-agent-step Last reviewed: 2026-08-03 Rates effective: 2026-07-02 ## Answer To track LLM cost by agent step you carry a trace identifier through every call the run makes, then sum the priced calls back to that identifier. Culpa, a local-first LLM cost, margin, and forecast ledger, prices each call from a versioned price book and attributes it to the step and the run that produced it, so a run total exists rather than a pile of calls. ## Why this happens Providers bill per call. Agents fail per run. That mismatch is the whole problem and it isn't solved by better dashboards. A single user request can become a planning call, four tool-selection calls, a retrieval summarisation and a final answer, each arriving at the provider as an unrelated request with its own usage block. Sum them by model and you learn what the month cost. Sum them by run and you learn which runs are worth having. The join between the two is an identifier you generate at the start of the run and pass down every hop, including the ones inside libraries you didn't write. Where that identifier gets dropped is where attribution stops, and it usually gets dropped at exactly the boundary you most want to measure: the tool call, the retry, the sub-agent. ## What this usually looks like - You know last month's total and can't say what one agent run costs on average. - A run that failed halfway still cost money and nothing records that it failed. - Costs look fine per call and the per-run figure nobody computes is the alarming one. - Retries are invisible, because a retried call looks like a first attempt. - Two runs of the same workflow cost very differently and nobody can say which step diverged. ## Common mistakes - Attributing by model instead of by run. Why it hurts: Model totals tell you about your rate card. Run totals tell you about your product. Do instead: Generate a run identifier at the entry point and carry it to every call underneath. - Letting the identifier stop at a library boundary. Why it hurts: Framework-issued calls are usually the expensive ones, and they're the ones that lose the tag. Do instead: Check a real trace and confirm every call carries the run id, including framework-issued ones. - Counting a failed run as free because it produced no answer. Why it hurts: It burned tokens up to the point it broke, and those tokens bought nothing at all. Do instead: Record the run outcome beside its cost, so failed spend is a number rather than a feeling. - Measuring step count and calling it cost. Why it hurts: Steps aren't equal. One retrieval summarisation can outweigh six routing calls. Do instead: Price each step from a rate book and rank steps by money rather than by frequency. ## Self-check - Pick one agent run and try to state its total cost without adding anything up by hand. - Follow a trace and count how many calls carry your run identifier against how many exist. - Find your most expensive single run last week, and say what made it expensive. - Compare the cost of runs that succeeded against runs that failed partway. ## Where the money sits in one agent run A modelled seven-call run on Claude Haiku 4.5 at real rates of $1.00 and $5.00 per million from the price book, effective 2026-07-02. The point is the spread across steps, not the total, because the spread is what per-call reporting hides. Token counts per step are modelled. 1 planning call, 2,000 in and 400 out = $0.0020 + $0.0020 = $0.0040 4 tool-selection calls, 1,500 in and 120 out each = 4 x ($0.0015 + $0.0006) = $0.0084 1 retrieval summarisation, 28,000 in and 900 out = $0.0280 + $0.0045 = $0.0325 1 final answer, 3,200 in and 700 out = $0.0032 + $0.0035 = $0.0067 run total = $0.0516, of which the single summarisation is $0.0325 One call out of seven carries 63% of the run. Ranked by call count that step looks ordinary, and ranked by money it's the entire optimisation. That inversion is why step-level attribution earns its implementation cost. ## Cost figures Every figure carries its confidence and its source. No figure on this page is provider-reported. - $0.0516, modelled cost of one seven-call agent run on Claude Haiku 4.5 [calculated] Source: Arithmetic shown in full on this page, using real rates of $1.00 and $5.00 per million from the price book effective 2026-07-02. The seven-step shape and every token count are modelled, not measured. The figure is on the page to show the spread across steps rather than to claim a typical run cost. - 63%, share of that modelled run carried by a single retrieval summarisation step [calculated] Source: $0.0325 of a $0.0516 run total = 63.0%, from the same modelled step shape and the same real rates. Reported as a share because the share is the transferable finding: one call in seven can dominate a run while looking ordinary in a call count. ## FAQ Q: How do I track LLM cost per agent step? A: Generate an identifier when the run starts, pass it to every call the run makes, and record it alongside the token counts. Price each call from a rate book, then group by the identifier for a run total and by step name for the breakdown within it. The hard part is coverage, not arithmetic. Q: Why can't I get this from my provider's dashboard? A: Because the provider never sees the relationship between your calls. Each request arrives independently, so a dashboard can group by key, model and time and nothing else. A run is a concept that only exists in your application, so the identifier has to come from there. Q: What usually breaks step attribution? A: A library boundary. Calls your own code makes carry the tag because you wrote the call. Calls a framework makes on your behalf, during tool selection, retries or sub-agents, are the ones that lose it, and those are usually the expensive ones. Q: Do failed runs need to be measured separately? A: Yes, and they rarely are. A run that broke halfway still burned every token it spent getting there, and those tokens bought nothing. Recording the outcome beside the cost turns wasted spend into a number you can act on. ## Sources - Anthropic pricing: https://platform.claude.com/docs/en/docs/about-claude/pricing Run the free Cost Leak Scan: https://app.getculpa.com/scan?source=pseo&slug=track-llm-cost-by-agent-step&cluster=attribution Machine-readable index of every guide: https://getculpa.com/api/pages Human-readable index of every guide: https://getculpa.com/guides Site overview: https://app.getculpa.com/llms.txt Privacy: Culpa runs on your infrastructure. Your prompts and responses never leave it. Culpa counts calls to run your plan, and it fails open, so if it ever breaks your app keeps running.