Your pricing page quotes dollars per million tokens. Your finance partner wants to know what it costs the agent to resolve one support ticket, compared with today. Nothing on the pricing page converts one into the other.
My argument is that an agent's cost per task depends on its structure more than on its token price. Five things set the bill: steps per task, context growth across those steps, tool-call fan-out, retry rate and model routing. Work out the cost of one ticket and you can see why a cheaper model is a weaker lever than it first looks. A lower token price reduces only the token part of the cost. It does nothing about the human who picks up an escalated ticket, or the failed run you paid for before it was abandoned, and in a support workflow those failure costs can be the bigger share. Step caps, capped history and retry limits work on the multipliers instead. You can model all of this before you build, and the design choices that keep it bounded are architectural ones. This piece turns the runaway-cost problem behind how a circuit breaker stops runaway agent spend into a planning model you can fill in before anyone commits to a build. It includes a sensitivity run over those levers, so you can see which ones move cost per successful task the most.
1. Cost per completed task is the number a business case needs
A price per token is an input price. A business case compares the agent with what the same outcome costs today, whether that's a support engineer's time, an outsourced queue or an existing script. So define the outcome first: one task is one ticket from intake to resolution or handoff, not one LLM call. An agent makes many calls per ticket, and a business case that prices one call is off by that factor before anything else goes wrong.
Failed and abandoned runs still cost money. Every ticket ends up resolved by the agent, by a person after a clean handoff, or by a person after the agent runs out of retries. Divide every route to resolution, failed attempts and human time included, by the number of tickets. That gives an all-in cost per resolved ticket you can set beside today's figure. Also track the share the agent resolves alone, which shows how much cost is still labour.
The running example, illustrative throughout, is an agent that triages a ticket, looks up the customer and order, searches a knowledge base, drafts a resolution, and then closes or escalates.
2. Where the money goes inside one agent run
The whole model fits in a few lines:
input(step) = stable prefix + history so far (+ running summary, if compacted)
cost(step) = input tokens × input price × cache multiplier
+ output tokens × output price
+ tool calls × fee per call
cost(attempt) = sum of cost(step) over one run
cost(ticket) = expected attempts × cost(attempt) × failure premium
+ P(clean handoff) × handoff cost
+ P(retries exhausted) × abandon costAll five drivers appear in it: steps set the number of terms, context growth lives in the history term, fan-out in the tool term, retries set the expected attempts, and routing sets the price.
Not every cost is a token. Anthropic's pricing page charges $10 per 1,000 web searches inside a Managed Agents session, and its worked example adds session runtime billed by the hour. Treat these as examples of line items: your tools may bill per call, per hour or through a separate contract, and the model needs a term for each.
Fan-out is charged twice: a call can carry its own fee, and its result is then re-sent as input on every later step.
3. Re-sending history is why input cost climbs with every step
A stateless model API sees only what you send it, so an agent loop re-sends the conversation on every call, and cumulative input grows roughly with the square of the step count.
A naive 20-step loop that adds 1,000 tokens per step accumulates 210,000 input tokens, not 20,000: 1,000 × (1 + 2 + … + 20).
This is the error a spreadsheet business case is most likely to contain: measure one step, multiply by the step count, and get a number that looks affordable.
Two kinds of lever act on that curve. Caching, covered next, changes the price of re-sent history. The others change how much gets re-sent: a capped window that keeps the last few steps plus a running summary, compaction that rewrites older turns as a short state record, and trimming tool results to the fields the agent needs. None is free. A summary costs a model call and is then re-sent on every step, all three throw information away, and a dropped detail shows up as a retry or a wrong answer rather than in the token count.
4. Prompt caching and the cost of re-sent history
The system prompt, tool definitions and policy text are identical on every step, and in a default loop each call is the previous call plus one new chunk at the end. Prompt caching bills a prefix the API has already seen at a discount, which is why it matters so much for agents.
The pricing works as multipliers on the base input price. A cache write costs 1.25x base input with a 5-minute TTL, or 2x with a 1-hour TTL. Reads cost 0.1x on many models and as little as 0.025x on some current models, so the 0.1x used below is conservative. Check Anthropic's pricing page and prompt caching documentation before you plug them in.
In an append-only loop, the history re-sent at step n is already in the cache from step n−1, so it is billed at the read rate and only the new chunk is billed as a write. The quadratic term remains, at a fraction of the base price. In the worked example below, no other token lever moves this curve as much.
The discount depends on the cached prefix staying exactly the same. The cache follows the order tools, system, messages, and a change at any level invalidates that level and everything after it, so a sliding window, a compaction pass or a timestamp near the top of the system prompt forces a rewrite at the write premium. The levers from the previous section don't simply add to caching: if you need compaction, do it in chunks, then go back to appending.
A write costs more than an uncached call, so caching pays only when the content is read again within its lifetime, which defaults to five minutes and is refreshed on each read. One ticket's steps run close together, so its history gets reused; sharing the stable prefix across tickets needs traffic dense enough to keep it warm.
Caching can also fail silently. If the prefix is shorter than the minimum cacheable length, nothing is cached, there is no error, and cache_creation_input_tokens comes back as 0. Log it and the read field on every pilot call.
5. Routing easy steps to a cheaper model, and proving it works
Not every step needs the strongest model. Classifying a ticket or extracting an order number is different work from diagnosing an ambiguous fault, so routing gives each step type its own price term.
Research suggests routing can hold quality: RouteLLM reports 95% of frontier quality while routing 85% of queries to cheaper models, with cost reductions of 45–85% depending on workload. I'd treat those figures as a ceiling for agents: routing steps mid-run lets an early mistake carry forward, and a queue full of ambiguous faults won't reach the top of that range.
Routing also interacts with caching. Caches are tied to one model, so a router that switches models step by step keeps two caches and, on every switch, writes again whatever was added since that model's last call. Routing by phase pays one handover write: triage and extraction on the cheap model, the rest of the ticket on the strong one.
So you need an eval before you trust a router: real tickets, success judged per ticket type, and a comparison on cost per resolved ticket. Without it, routing just moves cost into retries and escalations.
6. Single loop, graph workflow or multi-agent: the architecture multiplier
Architecture sets the multiplier on everything above. Anthropic reports that agents typically use about 4x more tokens than chat interactions, and multi-agent systems about 15x more than chats.
My reading of why: each subagent carries its own context and prefix, coordination adds calls, and an orchestrator reasons again over whatever comes back. Anthropic suggests subagents store outputs externally and pass back lightweight references, which targets the last of those.
The shapes compared in AI agent architecture patterns differ in how easy they are to model. A graph workflow with fixed nodes bounds the step count, so its costs vary far less; an open loop has a variable step count, so you model it as a median and a tail; multi-agent multiplies both context and fan-out.
In Building effective agents, Anthropic recommends the simplest solution possible and notes that agentic systems often trade latency and cost for better task performance; for well-defined tasks, workflows suit. A lot of ticket handling is well defined.
For a support ticket agent, I would start with a graph workflow and add an open loop only where a step needs one, because predictability is what a business case needs most.
| Cost driver | What multiplies it | Design lever that bounds it |
|---|---|---|
| Steps per task | Open-ended loops, vague stopping criteria, verbose outputs | Step cap; fixed workflow nodes for known paths; output length limits |
| Context growth | Full history re-sent every step at full price | Append-only prompt caching; chunked compaction; external storage with references |
| Tool fan-out | Many calls per step, large raw results re-sent as history | Tool-call cap; trim results before they enter history |
| Retries and failures | Weak model on hard steps, lossy summaries, no retry limit | Retry limit; circuit breaker that hands off early |
| Model routing | One strong model for every step, or a router that switches models and loses the cache | Route by step type or phase, backed by an eval |
7. Pricing one support ticket end to end
The model is a planning sketch that uses only the standard library. Caching uses the multipliers from the caching section at the 5-minute write rate.
Every other input is a placeholder, and that includes the tool fee. The ticket's tools are a customer lookup, an order lookup and a knowledge-base search. All three are internal, so the cent charged per call stands in for whatever those calls cost you to run. It is not a vendor price. Internal lookups may cost close to nothing per call, so any result that depends on tool fees, such as their share of an attempt, holds only for that input. If some of your tool calls are web searches inside a Managed Agents session, price them as a separate line item at $10 per 1,000 searches.
Three assumptions shape the results. History stays cached only while each call extends the same model's previous call, so a history cap or per-step switching keeps only the stable prefix cached. A failed attempt costs fail_cost_ratio times a normal one, because failed runs often run until a cap stops them. And every attempt has the same odds; a production model would use per-step-type terms and measured distributions.
from dataclasses import dataclass, replace
@dataclass(frozen=True)
class Run:
"""One agent attempt on one ticket. Every default is an illustrative input."""
steps: int = 12
prefix_tokens: int = 5_000 # system prompt, tool definitions, policy
tokens_added_per_step: int = 1_500 # last output plus tool result
output_tokens_per_step: int = 400
tool_calls_per_step: int = 1
tool_cost_per_call: float = 0.01
price_in: float = 2.00 # $ per million tokens, strong model
price_out: float = 10.00
cheap_in: float = 0.40 # $ per million tokens, cheap model
cheap_out: float = 2.00
caching: bool = True
write_mult: float = 1.25 # 5-minute cache write
read_mult: float = 0.10
history_cap: int | None = None # keep only the last N chunks word for word
summary_tokens: int = 600 # running summary once the cap bites
compaction_out: int = 300 # output spent keeping the summary current
cheap_first: int = 0 # phase routing: first N steps on cheap model
cheap_share: float = 0.0 # per-step switching: share on cheap model
@dataclass(frozen=True)
class Outcomes:
p_resolve: float = 0.75 # attempt resolves the ticket
p_handoff: float = 0.05 # attempt hands off cleanly; the rest fail
fail_cost_ratio: float = 1.5 # assumption: failed attempts run longer
max_attempts: int = 2
handoff_cost: float = 6.00 # human time after a clean handoff
abandon_cost: float = 9.00 # human time starting from scratch
def step_prices(r: Run, i: int) -> tuple[float, float]:
if r.cheap_share: # switching every step: blend the two prices
s = r.cheap_share
return ((1 - s) * r.price_in + s * r.cheap_in,
(1 - s) * r.price_out + s * r.cheap_out)
if i < r.cheap_first:
return r.cheap_in, r.cheap_out
return r.price_in, r.price_out
def attempt_cost(r: Run) -> float:
# History stays cached only if each call extends that model's previous call.
append_only = r.caching and r.history_cap is None and not r.cheap_share
total = 0.0
for i in range(r.steps): # step i carries i chunks of history
kept = i if r.history_cap is None else min(i, r.history_cap)
history = kept * r.tokens_added_per_step
out = r.output_tokens_per_step
if kept < i: # older chunks folded into a running summary
history += r.summary_tokens
out += r.compaction_out
# A model's first call writes its cache; switching writes the prefix twice.
fresh = i in (0, r.cheap_first) or (r.cheap_share > 0 and i == 1)
if append_only and not fresh: # read last prompt, write the new chunk
new = r.tokens_added_per_step
billed_in = (r.prefix_tokens + history - new) * r.read_mult + new * r.write_mult
elif append_only: # empty cache on this model: write the whole prompt
billed_in = (r.prefix_tokens + history) * r.write_mult
elif r.caching: # only the prefix is cached; history at full price
billed_in = r.prefix_tokens * (r.write_mult if fresh else r.read_mult) + history
else:
billed_in = r.prefix_tokens + history
p_in, p_out = step_prices(r, i)
total += (billed_in * p_in + out * p_out) / 1e6
return total + r.steps * r.tool_calls_per_step * r.tool_cost_per_call
def cost_per_ticket(attempt: float, o: Outcomes) -> tuple[float, float]:
p_fail = 1 - o.p_resolve - o.p_handoff
attempts = sum(p_fail ** j for j in range(o.max_attempts)) # expected attempts
agent = attempts * attempt * ((1 - p_fail) + p_fail * o.fail_cost_ratio)
human = attempts * o.p_handoff * o.handoff_cost + p_fail ** o.max_attempts * o.abandon_cost
return agent + human, attempts * o.p_resolve # all-in cost, share agent resolvesThe sensitivity run changes one input at a time from the cached baseline.
base, odds = Run(), Outcomes()
scenarios = [
("baseline (append-only cache)", base, odds),
("no prompt caching", replace(base, caching=False), odds),
("history cap 4", replace(base, history_cap=4), odds),
("phase routing: first 6 steps cheap", replace(base, cheap_first=6), odds),
("per-step switching, 50% cheap", replace(base, cheap_share=0.5), odds),
("per-step switching, 50% cheap, no caching",
replace(base, cheap_share=0.5, caching=False), odds),
("18 steps instead of 12", replace(base, steps=18), odds),
("tool fee $0.02 per call", replace(base, tool_cost_per_call=0.02), odds),
("resolve 65%, fail 30%", base, replace(odds, p_resolve=0.65)),
("3 attempts instead of 2", base, replace(odds, max_attempts=3)),
]
for name, run, o in scenarios:
attempt = attempt_cost(run)
per_ticket, by_agent = cost_per_ticket(attempt, o)
print(f"attempt ${attempt:.3f} per ticket ${per_ticket:.3f} "
f"agent resolves {by_agent:.1%} {name}")Output for these inputs:
attempt $0.249 per ticket $1.049 agent resolves 90.0% baseline (append-only cache)
attempt $0.486 per ticket $1.362 agent resolves 90.0% no prompt caching
attempt $0.335 per ticket $1.162 agent resolves 90.0% history cap 4
attempt $0.227 per ticket $1.020 agent resolves 90.0% phase routing: first 6 steps cheap
attempt $0.289 per ticket $1.101 agent resolves 90.0% per-step switching, 50% cheap
attempt $0.340 per ticket $1.168 agent resolves 90.0% per-step switching, 50% cheap, no caching
attempt $0.386 per ticket $1.230 agent resolves 90.0% 18 steps instead of 12
attempt $0.369 per ticket $1.207 agent resolves 90.0% tool fee $0.02 per call
attempt $0.249 per ticket $1.573 agent resolves 84.5% resolve 65%, fail 30%
attempt $0.249 per ticket $0.784 agent resolves 93.0% 3 attempts instead of 2Prompt caching is the biggest token lever in this run: turning it off adds more per ticket than running 18 steps instead of 12 does. The model assumes every read hits the cache, so treat that saving as an upper bound and measure the real hit rate.
Routing pays only when it keeps the cache. Phase routing is the cheapest of the caching and routing configurations: the handover costs one full cache write on the strong model, and every other step still reads history at the read rate. Per-step switching at the same share costs more than not routing at all, but the code drops history caching for it entirely; per-model caches would cost less, so read it as a worst case. The history cap also loses on a run this short. The levers interact, so a business case that adds up each lever's savings separately overstates them.
Tool fees are almost half of the baseline attempt, which makes every token lever look smaller. Doubling the fee costs almost as much as the extra steps do, and no token lever touches it.
A lower resolve rate moves the per-ticket number more than any token lever, almost entirely through human time. A third attempt pulls it down by almost as much as caching saves, because an extra attempt costs far less than an abandoned ticket, assuming retries have the same odds as first attempts. Measure later-attempt resolve rates before you raise the limit.
8. What the model cannot tell you
Tokens often buy quality. In Anthropic's BrowseComp analysis, token usage alone explained 80% of performance variance on a research task. The risk carries over to tickets: squeeze tokens too hard and the success rate can fall, so the per-ticket figure rises even as each attempt gets cheaper.
Averages hide tails: a few runaway tickets can dominate the bill, so run the model at the median and at the worst case you'll accept. Inputs drift too, from cache terms to prompt edits that silently break the cache, so re-run the model when they move.
The approach doesn't fit everywhere. At very low volume, engineering effort dominates and token cost is noise. For tasks without a clear success criterion there is no resolved outcome to divide by, so the model has nothing to measure.
9. Budgets in code are what make the estimate hold
Anthropic is direct that agent autonomy brings higher costs and the potential for compounding errors, and it recommends sandbox testing and guardrails. A cost model without enforcement is a hope.
The controls matter as much for what trips them as for what they bound:
- Step cap. It trips when a loop isn't converging. The ticket goes to the human queue with its history, and in the model it counts as abandoned.
- Dollar budget per task. It trips on long contexts, oversized tool results or a run stuck on the expensive model. Set it in dollars, because a token budget doesn't cover tool fees or the price gap between routed models.
- Tool-call cap. It trips on search loops; tell the model no more searches are available and ask it to answer or hand off.
- Circuit breaker. It works across runs: when a tool keeps failing, it routes tickets straight to people, turning an unbounded retry term into a bounded handoff cost.
The dollar budget depends on reserving enough before each call. Here is the core check as a sketch, not production code:
def reserve_usd(est_input_tokens, max_output_tokens,
price_in_per_m, price_out_per_m, write_mult=2.0):
# Most one call can cost, provided est_input_tokens is an overestimate:
# all input billed as a cache write at the highest multiplier in use,
# all output at the max_tokens limit sent with the request.
return (est_input_tokens * price_in_per_m * write_mult
+ max_output_tokens * price_out_per_m) / 1e6
# Before each call, with that step's own model prices:
# if spent_usd + reserve_usd(...) > max_usd: hand the ticket to a person
# After each call, add the actual cost priced from reported usage,
# including cache read and write tokens.The reservation bounds spend only if its inputs are conservative. A cache write costs up to 2x base input with a 1-hour TTL, so price input at the highest write multiplier you use, count tokens with a margin, send the same output cap to the API, and add the worst-case tool fees for the call.
Set the limits from the pilot's worst acceptable ticket, not its average, or legitimate hard tickets get pushed into escalation. Log actual input, output and cache tokens per task, and compare the estimate with the bill every month.
10. Fill the model with ten real tickets before you commit
Run a ten-task pilot on real tickets, not hand-picked easy ones. For each, record steps, tokens per step, tool calls, cache creation and read tokens, and how it ended. Ten tickets isn't a statistically meaningful sample, but it replaces guesses with measured orders of magnitude. Put those numbers into the model at the median and at the worst ticket.
Then compare the result with today's cost per ticket, as one input alongside quality, risk and the effort of running the system. It is not an ROI promise.
Whatever the result, put a per-task budget in code from day one. That way the architecture enforces the number in your business case, and you aren't counting on the price per token staying low.






