digiup

writing6 min read

What an AI Agent Actually Costs Per Task

Pilot invoices hide the real unit economics of AI agents. How to model cost per completed task, including retries, human review and failures, and the levers that cut it without gutting quality.

by Faisal Kurdi -- AI Solutions Architect

Cover for What an AI Agent Actually Costs Per Task

A pilot agent runs for six weeks, the invoice comes in at a few hundred dollars, and everyone relaxes. The model is cheap. The business case writes itself.

Then the agent goes to production, volume goes up fifty times, and finance asks a question nobody prepared for: what does one finished task actually cost?

Almost nobody can answer it. Not because the math is hard, but because the pilot measured the wrong thing.

The pilot bill is the wrong number

Pilots are designed to succeed. They run on clean inputs, a hand-picked set of cases, and a team that quietly fixes whatever the agent gets wrong. The invoice captures model spend, at low volume, on the happy path. It captures nothing else.

In production, three things change at once. Inputs get messy, so the agent takes more steps. Edge cases arrive, so it retries and hits dead ends. And the people who were absorbing failures for free go back to their real jobs, so every mistake now has a price.

The number that matters is not cost per call or cost per token. It is cost per completed task, with every line included.

What goes into cost per task

There are four lines, and the token bill is only one of them.

Model spend

An agent is a loop, not a call. It plans, calls a tool, reads the result, decides what to do next, and repeats. Each step usually re-sends the growing conversation history, so a ten-step task costs considerably more than ten single calls. Step ten carries everything from steps one through nine.

Retries compound this. A task that fails validation and restarts pays for the whole loop twice.

Tools and infrastructure

Document parsing, search, vector lookups, third-party APIs, logging and tracing. Each is small, but together they add up, and they are rarely in the pilot budget because they ran on someone’s test account.

Human review

Most production agents route some share of their work to a person: low-confidence cases, high-value transactions, anything that trips a guardrail. That person’s time is a cost per task, and it is usually the largest one.

Escaped errors

Some mistakes get past review: a misfiled invoice, a wrong answer to a customer, a record updated incorrectly. Each one costs something to find and fix, and occasionally far more than that. Multiply the rate by the average cleanup cost and you have a line most business cases leave out entirely.

A worked example

Take a common first agent: triaging inbound supplier emails, extracting invoice details, and posting them to the finance system. The numbers below are illustrative, not a quote.

  • Model spend: eight steps per task, averaging 12,000 input and 500 output tokens per step. At an assumed $5 per million input tokens and $15 per million output, that is about $0.54 per attempt. With 15% of tasks retrying, call it $0.62.
  • Tools and infrastructure: parsing, lookups and tracing add around $0.05.
  • Human review: 20% of tasks are flagged, each taking three minutes of a finance clerk’s time at $45 an hour. That averages $0.45 per task.
  • Escaped errors: 1% of tasks post something wrong that takes $60 of staff time to unwind. That averages $0.60.

The total is about $1.72 per completed task. Doing it by hand takes roughly six minutes, or $4.50.

The agent wins. But look at where the money goes. Model and infrastructure are under 40% of the real cost. Review and errors are the majority.

Why the obvious optimization backfires

Because the token bill is the most visible line, it is the first one teams attack. They swap in a cheaper model, cut the spend in half, and report a win.

Run that through the same example. Model spend drops by about $0.31. But suppose the cheaper model is slightly less reliable: the review rate climbs from 20% to 30%, and escaped errors go from 1% to 1.5%. Review now costs about $0.68 and errors $0.90.

The new total is about $1.94. You cut the model bill in half and made each task 13% more expensive.

This is not an argument against cheaper models. It is an argument against optimizing a line item instead of the task.

The levers that actually move the number

Stop re-sending everything

Growing context quietly multiplies model spend. Summarize earlier steps instead of replaying them, and trim tool outputs to the fields the agent actually needs. Keep stable instructions in a fixed prefix so the provider’s prompt caching can discount them. On long loops, this can cut model spend substantially without touching quality.

Route by difficulty, not by default

Steps inside a workflow are not equally hard. Classifying an email and extracting a date are jobs for a small, fast model. Deciding whether an unusual invoice should be paid is not. Send each step to the cheapest model that handles it reliably, and measure reliability per step, not per workflow.

Take the deterministic steps away from the agent

If a step can be a function, make it a function: date parsing, currency conversion, supplier lookups, schema validation. Every step the agent does not have to reason about costs almost nothing and never hallucinates.

Cap the loop

Set a step limit and a spend budget per task. An agent stuck in a retry cycle can burn forty steps on a case a person would resolve in a minute. Handing off to a human early is almost always cheaper than letting the loop run.

Spend review time where it pays

Reviewing every task is safe and expensive. Reviewing nothing is cheap until it isn’t. Use confidence thresholds to send only uncertain cases to people. Then sample-audit a small share of the confident ones to catch drift before it becomes an error rate.

Measure it like a product metric

None of this works if cost per task is a spreadsheet exercise done once for the business case. It has to be instrumented.

For every task, log four things: tokens by step, tool calls and retries, whether it went to review and what the reviewer changed, and whether anything was corrected downstream. It is the same tracing we argued for in AI Agents in Production, pointed at money instead of quality.

Then watch the distribution, not the average. In most agent workloads, a small tail of hard tasks eats a disproportionate share of spend. Find the 5% of cases consuming 30% of the budget, and route them to a person or a different path. That is often the single biggest saving available.

When the math says no

Sometimes the honest model shows the agent losing. That usually happens when the manual task is already fast, when errors are expensive and can’t be caught by sampling, or when volume is too low to cover the cost of building and monitoring the agent.

That is not a failure. It is the model doing its job before you have spent the budget. The better answer is often plain workflow automation with no agent in the loop, which is where most first automation projects should start anyway.

The question to ask before production

Before any agent goes live, ask for one number: cost per completed task, with review and escaped errors included, compared against the current way of doing the work.

If the team can produce it, you have a business case you can defend at the next budget review. If they can’t, you don’t have a business case yet. You have a demo, and demos are how projects end up in the pilot graveyard.

  • AI agents
  • AI engineering
  • unit economics
  • LLM costs
  • production AI

next

Have a request in mind?

Book 15 minutes and bring one idea, or write to info@digiup.io.