Blog post

The hidden bill of AI agents once real users arrive, and how to cut it

Author

Kirill Karakhainko

Category

Development

Date

Nov 23, 2026

In July 2025, Anthropic told Claude Code subscribers that weekly limits were coming, because some of them were running it "continuously in the background, 24/7," TechCrunch reported. It expected the limits to affect fewer than 5% of subscribers. Earlier that month, Cursor had explained a pricing change the same way: "New models can spend more tokens per request on longer-horizon tasks," and "the hardest requests cost an order of magnitude more than simple ones."

Both companies sell flat plans on top of expensive model usage, and both changed them once a minority of users and requests turned out to cost far more than the rest. If your AI feature has been live for a few months, you may be seeing a smaller version of this. The bill rises faster than users or revenue, and the pilot's estimate no longer explains it.

What gets billed

Agents spend more per task than chat, by design. In June 2025, Anthropic reported that in its data, agents "typically use about 4× more tokens than chat interactions," and "multi-agent systems use about 15× more tokens than chats." In August 2026, Gartner predicted that inference costs per agentic workflow will rise more than fivefold through 2028, with "falling model prices subsidizing more complex workflows."

Bar chart of tokens per task relative to a chat interaction, from Anthropic in June 2025: a chat uses 1×, a single agent about 4×, and a multi-agent system about 15×

Much of that comes from repetition. Claude Code's cost docs explain that it "sends your full conversation with every request, and each time Claude uses tools it sends another request carrying that batch of tool results." An agent that takes ten steps pays for its instructions and history ten times, at a discount if they're cached, and the history grows at every step. The model call is also only one line of the bill.

Line item

What makes it grow

Why the pilot missed it

Loops

More steps per task

Short, hand-picked cases

Long context

History resent every step

Few turns per session

Tool outputs

Whole records pasted in

Small test data

Retries and failures

Failed calls, invalid output

Someone reran by hand

Embeddings and search

Re-indexing, vector storage

Small document set

Logs and eval runs

Every trace stored and retested

Not set up yet

Review

Staff minutes per output

Done by the project team

Why pilot estimates run low

A pilot usually measures the average cost of a call. Production pays for the whole task, and the tasks vary widely. In March 2026, a developer asked on Hacker News how others forecast agent costs, because "a single user action can trigger anywhere from a few to dozens of LLM calls (tool use, retries, reasoning steps)."

Cost also gets less attention than it used to. In a survey of 1,340 practitioners run in late 2025 by LangChain, a vendor of agent tracing tools, 32% named quality as a top barrier to production, while cost was "less frequently cited as a concern than in previous years." Cheaper tokens lower the cost of a task only if the task stays the same size, and Gartner expects it to grow.

Part of the bill also lands on other budgets. The vector database sits on the cloud invoice, the tracing tool on a SaaS card, and review time in someone's working week. The AI line on the provider invoice can look reasonable while the feature as a whole loses money.

On a flat monthly seat, your heaviest users decide the margin, as Anthropic's round-the-clock subscribers showed.

Measure cost per good task

To see whether a feature pays for itself, track cost per successful task: everything the feature spent in a period, divided by the tasks that ended in a result the user kept. After listing retries, cache misses and hidden reasoning tokens, a developer on Hacker News put it this way in November 2026: "cost per successful task, sampled from real traffic, counting every failed attempt." Five steps get you the number.

  1. Give each user action a task ID, and attach it to every call it triggers.

  2. Log input, cache-write, cache-read, output and reasoning tokens per call.

  3. Record how each task ended, and decide up front which endings count.

  4. Add embeddings, vector storage, logs, eval runs and review minutes.

  5. Look at the spread, especially the costliest 5% of tasks and users.

To check where you stand, ask the team for last week's cost per successful task for each AI feature, and the traces of the five most expensive tasks. If that takes more than a day, start with the measurement.

Levers that cut the bill

Once you know which tasks cost the most, pick a lever. Run your quality checks before and after each change, since a cheaper agent that fails more often can cost more per successful task.

Lever

Best for

Watch for

Routing

Easy, frequent tasks

Silent mistakes, double calls

Prompt caching

Long, repeated instructions

Rarely reused prompts

Context trimming

Agents that read a lot

Lost facts, broken cache

Batch APIs

Work that can wait

Up to a day; some expire

Result caching

Repeated identical requests

Leaks across customers

Step caps

Every agent loop

Tasks that stop half done

Route by difficulty

Send each type of task to the cheapest model that passes your test cases for it, and move up to a larger model when an automatic check on the output fails, such as a schema check or a test. Count both calls in the cost of escalated tasks. In a July 2024 benchmark, the RouteLLM researchers reported "cost reductions of over 85% on MT Bench" against using GPT-4 alone, "while still achieving 95% of GPT-4's performance." On MMLU the saving was 45%. Your own mix of tasks will give a different number.

Keep the prefix stable

Providers charge far less for input they have processed recently, but only when the start of the request matches exactly. At Anthropic, a cache read costs a tenth of the base input price or less, depending on the model, while a cache write costs 1.25 times the base price for the default 5-minute lifetime, so a prefix that is rarely reused costs more. Changing the tool definitions "invalidates the entire cache." OpenAI caches automatically, with cached input "discounted up to 95%," and asks you to "preserve tool definitions, ordering, and schemas."

The developer of an open-source cache diagnostics tool listed the usual culprits on Hacker News in November 2026: "a tool list built from a set, a date in the system prompt, a missing cache_control marker." Put fixed instructions and tools first, in a fixed order, and dates, user data and the question last. On Anthropic, turn caching on with a cache_control marker. Both providers skip short prompts: under 1,024 tokens on OpenAI, and under 512 to 4,096 on Anthropic, depending on the model. Then send the same request twice and check the second response's usage data, cache_read_input_tokens on Anthropic or cached_tokens on OpenAI.

Trim what the agent reads

Give the agent the fields it needs instead of whole records, and summarise long tool output. Claude Code's docs give the example of a hook that filters a log for errors before the model sees it, "reducing context from tens of thousands of tokens to hundreds." Rewriting earlier messages breaks the prompt cache, so trim the newest tool output before it enters the history, and clear old results in large batches rather than at every step.

Batch what can wait

Anthropic and OpenAI both charge 50% less for asynchronous batches, with results within 24 hours, though requests that don't finish in time expire and must be resent. Anthropic says the batch and caching discounts can stack, and it keeps batch data for 29 days, so check retention first if the data is sensitive. Nightly enrichment, reports and eval runs rarely need an answer in seconds.

Cache results in your app

When users ask the same thing about the same data, store the answer yourself. Key it by the input, the data's version, the prompt and model version, and the customer or permission set that can see the data. Skip it for anything personal or fast-changing.

Cap steps and retries

Limit steps, retries and tokens per task in code, and hand the task to a person when a limit trips. In March 2026, a founder wrote on Hacker News that an agent with no budget cap looped overnight, calling outside APIs: "we woke up to a $600 bill and zero useful output." The author was promoting a product that sells the fix, so read it as an illustration. Our post on approvals, limits and undo covers caps per tool.

A four-step loop for AI feature costs: count every cost the feature causes, divide by tasks that succeeded, compare the result with a target set from what a task is worth, then pull one lever, cap steps and spend, and measure again

Set a unit-economics target

Start from what a task is worth: what the customer pays for it, its share of a seat price, or what the same work costs when a person does it.

Say a seat sells for $40 a month and an active user completes about 400 tasks. If AI costs should stay at or below 15% of revenue, the budget is $6 a seat, or 1.5 cents per successful task. A feature running at 4 cents a task needs a lever or a price change. One running at 1 cent has room for a stronger model where quality is weak. The same test applies to multi-agent designs, which Anthropic says need tasks "where the value of the task is high enough to pay for the increased performance."

Set the target per feature, and check heavy users separately, since they decide whether a flat price holds.

Then give each feature its own budget with the provider: a separate project on OpenAI, or a workspace on Anthropic, each with a monthly spend limit set above normal spend, and an alert below it where the provider offers one. When an OpenAI project hits its limit, every request fails with a 429 error until someone raises the limit or the month resets, so treat that error as a stop rather than a rate limit to retry, and show users a fallback. The rest is in our post on why AI pilots stall.

Monthly limits only trip after the money is spent. A daily alert on cost per successful task catches quieter problems, such as a prompt edit that breaks caching, weeks before the invoice does.

Tracing your bill

Our cost reviews start with your recent traffic, traced task by task, so each part of the bill is tied to a result. We then test routing, cache-friendly prompts, trimmed context and step limits against your own cases, and hand back a cost-per-task target with the tracking and caps to hold it.

Hybrid Intelligence