What you get from measuring token spend per span
Token costs for agents do not behave like token costs for chat. Agentic tasks consume roughly 1,000 times more tokens than code reasoning or code chat, and input tokens, not output tokens, drive the majority of that spend. This matters for instrumentation: if you measure only output tokens, you are watching the wrong signal.
The goal of span-level measurement is to attach a cost figure to each discrete unit of agent work, a tool call, a retrieval step, a planning loop, so you can answer two questions: what does a normal run of this task cost, and when has a run crossed outside that range? Without per-span figures, you have a monthly bill but no way to connect it to behavior.
Prefactor records token counts at the span level as part of its trace instrumentation, which means cost attribution follows the same structure as quality and risk scoring. If a span is already the unit you use for behavioral validation, making it the unit for cost accounting requires no additional tagging work.
What computer-use agents actually spend
Desktop and computer-use agents illustrate why token volume surprised teams that estimated from simpler workflows. Open Cowork, an open-source desktop agent project with a built-in telemetry dashboard, shows that a single "organize downloads" task fires 15 to 20 model calls. Each call carries a screenshot or DOM snapshot as context, and those inputs are large.
Anthropic's Claude Cowork data from July 2026 reinforces this: across 1.2 million anonymized sessions from more than 600,000 organizations, over 90 percent of sessions involved non-software-development tasks. File management, form filling, and data entry tasks, exactly the kinds of work that require repeated screen captures, dominate real usage. The implication is that your cost baseline for a computer-use or autonomous background agent will look nothing like your baseline for a RAG retrieval agent, and treating them as the same category when budgeting will produce chronic underestimates.
One instrumentation approach that compounds this: structured locators instead of raw HTML. Research published in 2026 found that semantic locators reduce context window usage by 93 percent compared to passing raw HTML to the model, and that structured output formats such as JSON cut token consumption by roughly 67 percent against unstructured equivalents. These are not minor tuning decisions. They determine whether a task costs $0.04 or $0.60, and span-level measurement is what tells you which regime you are in.
Building cost baselines by agent type
A cost baseline is a distribution, not a number. For each agent type in production, you want the median cost per run, the 90th-percentile cost, and the conditions that predict which side of the median a given run lands on.
A Stevens Institute of Technology analysis from 2026 found that unconstrained agents spent $5 to $8 per task, while the same tasks with dynamic turn limits cost 24 percent less with comparable output quality. That 24 percent figure is worth naming precisely: it is the gap between a baseline with no upper bound and a baseline with a soft ceiling on planning iterations. The ceiling does not degrade quality in that study, but it is worth validating against your own tasks before applying it broadly.
To build these baselines in practice, group your spans by agent type and task category before you aggregate. A multi-agent orchestrator spawning sub-agents for research will have a cost profile that combines its own orchestration tokens with the tokens consumed by each child agent. If you roll those up without separating them, you lose the ability to identify which agent in the graph is the expensive one.
Prefactor's activity schemas give you a place to attach expected cost ranges alongside expected behavior, so a run that is within behavioral bounds but outside cost bounds still surfaces as an anomaly worth reviewing. This connects cost monitoring to behavioral validation rather than treating them as separate concerns.
Gartner research cited in 2026 found that organizations using structured agent governance and reuse patterns cut inference costs by up to 30 percent compared to ad hoc deployments. The mechanism behind that figure is reuse: when teams define shared retrieval steps and tool-call patterns once and instrument them as named spans, they stop paying for redundant context construction across every agent that does similar work.
Distinguishing normal variation from runaway behavior
Normal variation in token spend comes from input size, task complexity, and retrieval results that vary by query. Runaway behavior looks superficially similar but has a different cause: a planning loop that does not converge, a tool that returns unexpectedly large payloads, or a prompt that keeps expanding context without pruning earlier turns.
The practical separation between these two cases requires a baseline with enough history to set a meaningful upper bound. If you set your alert threshold at the 95th percentile of observed costs for a given task type, most normal variance stays below it. Runs that exceed it warrant a trace review, not necessarily an automatic shutdown, because the cause determines the right response.
Tokenless, a YC S26 startup, approaches this problem from the routing side: their dynamic model routing API switches between model backends turn-by-turn based on cost and performance requirements. For teams using LLM gateways or routers, this kind of dynamic dispatch can cap per-turn costs before a planning loop compounds them. The instrumentation requirement is the same either way: you need per-turn token counts, not just per-session totals, to know whether routing decisions are having the intended effect.
For internal ops agents and research analyst agents, the patterns that most reliably predict runaway spend are tool calls that retrieve full documents when summaries would do, and retry loops triggered by ambiguous tool outputs. Both show up clearly in span-level traces as abnormally high input token counts on a small number of spans within an otherwise normal run.
PwC's deployment of Claude Code and Claude Cowork across U.S. teams, with plans to train 30,000 professionals globally, represents the scale at which cost anomalies compound quickly. At that volume, a task pattern that costs 40 percent more than baseline because of an unconstrained retrieval step is not a curiosity; it is a budget line that needs an owner. Span-level attribution is what connects the anomaly to the specific agent, task type, and tool call responsible.
A practical monitoring setup combines three signals: cost per span compared to the baseline for that span type, total cost per run compared to the baseline for that task, and token count trends over time for tasks that run repeatedly. Drift in the third signal, costs creeping up over weeks without a change in task definition, often points to prompt or context accumulation problems that detecting agent quality decay monitoring will catch alongside cost monitoring.
Where to start
Pull span-level token counts for your highest-volume agent type and group them by task category. Calculate the median and 90th-percentile cost per run, then set a review threshold at 1.5 times the 90th percentile and examine the traces that exceed it over the next two weeks. That is enough to distinguish normal variation from structural inefficiency before you change anything else.
Start evaluating your agents or read through the docs to see how span instrumentation maps to cost and quality records in the same trace.
