AI systemsTechnical article

Why your AI agent works in the demo and fails in production

A 2024 benchmark from Sierra ran the same customer-service tasks again and again. An agent that solved about 61% of them on one try solved under a quarter of them on all eight tries. Here is why a demo hides that, and what to fix before launch.

In short

  • A demo is one run of a task someone chose. Production runs every task many times, and an agent that is right once is often not right every time.
  • A run is only right if every step is, so small error rates multiply: 95% a step over ten steps is about 60% end to end.
  • A retry can repeat an action, wide permissions make a wrong action costly, and every extra step re-sends the whole conversation, so long runs cost more than the step count suggests.
  • The fixes are ordinary engineering: test each case many times, put a key on every action, hand the agent narrow tools, ask a person to approve big actions and cap the steps.

A demo is a sample of one

In a demo, someone picks a task, runs the agent once and it works. The audience sees one run of one task, chosen by a person who already knows it will go well. Production is the opposite. Every customer brings their own task, the same kinds of task come back all day, and nobody picks the easy ones.

The clearest measurement I know of is Sierra's tau-bench, published in June 2024. It puts an agent in a simulated shop with a simulated customer and a set of tools, gives it ordinary jobs such as changing or returning an order, and then checks the database to see whether the right thing happened. Its new measure, pass^k, is the chance that all k tries at the same task come out right. A gpt-4o agent using function calling got about 61% of the retail tasks right on one try. Asked to get a task right on all eight tries, it managed under 25%.

Figure 1The same 20 tasks, run again and again
Runs of the same task12345678all 81234567891011121314151617181920Right on one run13 / 20 tasksRight on every one of the first 8 runs5 / 20 tasks65% on one run, 25% on all 8

Swipe sideways to see the whole figure

The tasks and the runs are made up and drawn from a fixed seed, shaped like the tau-bench result: some tasks nearly always work, some rarely do. Green is a run that came out right, red one that did not.

Slide the figure from 1 run to 8. The 20 tasks are made up, but they are shaped like the benchmark: a few the agent nearly always gets right, a few it rarely does and many in between. On the first run 13 of the 20 look fine. Ask for all eight runs to be right and 5 are left. If every run were an independent 61% coin flip, eight in a row would happen about 2% of the time (0.61 to the power of 8 is 0.019). The real figure is higher because some tasks are easy, and the average success rate hides which ones.

Surveys show the same gap in business terms. Camunda's research with Coleman Parkes among 1,150 senior IT leaders (September to October 2025) reported that 71% say they use AI agents, while only 11% of agentic use cases reached production in the last year. It is a vendor-commissioned survey of what people say about themselves, so read it as a hint.

Every step has to work

An agent that issues a refund does not make one decision. It reads the message, finds the order, checks the policy, calls a tool, reads what came back and writes a reply. The run is only right if every step was right. Anthropic's guide to building agents, published in December 2024, says the autonomous nature of agents "means higher costs, and the potential for compounding errors."

The arithmetic is multiplication. If each step is right 95% of the time, ten steps in a row are all right 0.95 to the power of 10 of the time, which is 0.60. Of 100 runs, about 60 get through.

Figure 2One hundred runs, step by step
0.95 ^ 10 = 0.6060 of every 100 runs get through all 10 steps without a wrong one.half1952903864815776747708669631060stepleft

Swipe sideways to see the whole figure

Each column is the same 100 runs. Green is the share still on track after that step, red the share that has already gone wrong. Simplified: it treats every step as an independent chance, and a real agent can sometimes notice a mistake and recover.

Set the steps to 20 and leave each step at 95%: 36 of 100 runs finish (0.95 to the power of 20 is 0.36). Raise each step to 99% and ten steps leave 90 of 100, twenty leave 82. The model is simple on purpose. Real steps are not independent, and an agent can sometimes notice its own mistake, which is why checks between steps help.

A retry can do the job twice

Tools fail in an awkward way. Sometimes the call worked and only the reply was lost. The agent sees a timeout and cannot tell the two cases apart, so it tries again. For a read that is harmless. For a refund, a booking or an email, the action runs twice.

Figure 3A refund, a lost reply and a retry
Agentcalls the toolRefund APIdoes the workLedgermoney paid out-$40-$40reply receivedreply lostdonerefund paidThe reply goes back. Two refunds, $80 paid, in the ledgerCustomer owed $40, customer paid $80.

Swipe sideways to see the whole figure

Retry
The amounts and the key are made up for the picture. The lost reply is what makes a retry risky: a request that failed and a request that worked but lost its answer look the same to the caller.

Switch the figure between the two policies. With a plain retry the ledger ends with two refunds and the customer is paid $80 instead of $40. With an idempotency key, a unique code the caller sends with the request, the API recognises the repeat and returns the saved reply. Stripe's API documentation describes this as a way to retry "without accidentally performing the same operation twice." The agent loop is another caller that retries, so it needs the same protection. Make the key once per intended action, from the order and the reason for example, and not once per attempt, or every retry will look like a new request.

The agent can do more than the job needs

The agent will be wrong sometimes. It misreads an order, gets a vague message, or treats a line in a pasted email as an instruction. What matters then is what it is allowed to do. OWASP's list of risks for language-model applications calls the problem excessive agency: damaging actions taken in response to unexpected, ambiguous or manipulated model output, whatever caused the model to misbehave. It traces it to excessive functionality, excessive permissions and excessive autonomy.

Figure 4What the agent is allowed to do
Proposed by the agentWhat happensRefund $20the customer askedDone: inside the limitRefund $45the customer askedDone: inside the limitRefund $380the model misread an orderWaits for a personDelete a customer accountan unclear messageRefused: no such toolExport every customer emaila line hidden in a pasted emailRefused: no such toolDone without anyone looking2 of 5 actionsRefund tool, limit $50. No delete tool, no export tool.

Swipe sideways to see the whole figure

Access
Five proposed actions, the reasons and the amounts are made up. The refund limit is arbitrary; the right one depends on what a mistake costs you. With narrow tools the limit is enforced by the tool itself, so the model cannot talk its way past it.

With broad access, all five proposals go through, including deleting an account and exporting every customer email. Switch to narrow tools and the agent has a refund tool and nothing else. At the default limit of $50 the $20 and $45 refunds go through, the $380 refund waits for a person, and the two dangerous actions have no tool to call. OWASP's advice says the same in other words: keep the tools and their permissions to the minimum, ask a person to approve high-impact actions, and check authorization in the system being called, since the model should not decide what it may do.

A long run costs more than it looks

A model has no memory between calls. Anthropic's documentation describes its Messages API as supporting "stateless multi-turn conversations": you send the earlier turns with every request. An agent loop does that on every step, so the model re-reads the instructions, the tool descriptions and everything that happened so far, each time.

Say the fixed prompt is 3,000 tokens and each step adds 1,000, a tool result and the model's note. Step 1 sends 3,000 tokens and step 10 sends 12,000. Ten steps send 75,000 in total (10 times 3,000 plus 1,000 times 45) and twenty steps send 250,000 (20 times 3,000 plus 1,000 times 190).

Figure 5Every step sends the conversation again
10 steps send 75,000 input tokensStep 1 sends 3,000. Step 10 sends 12,000.12345678910fixed prompt: instructions and tool descriptionseverything said so far, which keeps growing20 steps would send 250,000: 3.3 times as many.

Swipe sideways to see the whole figure

The 3,000-token fixed prompt and the tokens added per step are made up for the picture, and the effect is real: the model has no memory between calls, so each call carries everything said so far. Prompt caching lowers the price of the repeated part, not its size.

Drag the steps and the tokens added per step. Twice the steps cost 3.3 times the input here (250,000 against 75,000), because every extra step also carries all the earlier ones. Prompt caching lowers the price of the repeated part, so check what your provider charges for it, but it does not shorten what the model has to read. A limit on steps is the cheapest protection, and Anthropic's guide says it is common to include stopping conditions such as a maximum number of iterations.

Patterns that hold up

Start by asking whether the steps are always the same. If they are, a plain script or a fixed workflow has none of these problems, and Anthropic's own advice is to find the simplest solution possible and add complexity only when needed. If the input really is messy, these habits help.

Run every important case many times

Keep a set of real requests with the outcome you expect, and run each one at least eight times before a release. Score the end state, as tau-bench does, by checking the records themselves, because the wording of a reply proves little. A case that passes five times out of eight is a finding, whatever the average says. Anthropic recommends extensive testing in sandboxed environments along with appropriate guardrails.

Give every action a key and every loop a limit

async function runAgent(task, { maxSteps = 8 } = {}) {
  const messages = [task.message];
  for (let step = 0; step < maxSteps; step++) {
    const move = await model.next(messages);
    if (move.type === "reply") return move.text;

    // one key per intended action, not per attempt
    const key = [task.id, move.tool, hash(move.args)].join(":");
    const result = await callTool(move, { idempotencyKey: key });
    messages.push(move, result);
  }
  return handToPerson(task); // out of steps: stop and hand over
}

Hand over narrow tools

Give the agent a tool for one job, such as issue_refund(order_id, amount), and no general database login or shell. Put the limit inside the tool and not only in the prompt, so a confused or manipulated model cannot talk its way past it. Anything above the limit goes into a queue for a person.

Keep a record of every step

Store each prompt, tool call and result under a run id. When a customer says the agent did something odd, you need to replay that run, and nobody can do that from memory.

How this looked in a real product

Oh Crap! Chat is a paid AI coach we built with Prologue Partnerships. It answers questions from one author's material, so it has fewer ways to go wrong than an agent that acts on records, but the same limits are in it. The API has one time limit for the first words and another for the whole answer, and it retries with a growing delay when the model is busy. Access is checked before any model call, so an expired pass never spends tokens. The model only sees passages pulled from the author's material, which keeps answers inside the book. A dashboard shows AI usage and an estimated daily cost next to revenue. The case study has the full picture.

Questions to answer before launch

  1. If you run your ten most common requests eight times each, how many come out right every time?
  2. How many steps can one run take, and what happens when it reaches the limit?
  3. If a tool call times out, can the same action run twice?
  4. What is the worst thing the agent can do with the access it has today, and who approves it?
  5. Is the limit on each action inside the tool, or only written in the prompt?
  6. Do you know what a 20-step run costs, and can you replay yesterday's odd run from your logs?

Sources

  1. Yao, Shinn, Razavi and Narasimhan (Sierra), τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains (arXiv, June 2024)
  2. Anthropic, Building effective agents (19 December 2024)
  3. Stripe API reference, Idempotent requests
  4. OWASP GenAI Security Project, LLM06:2025 Excessive Agency
  5. Anthropic API reference, Messages
  6. Camunda, Three Quarters of Organizations Admit Gap Between Agentic AI Vision and Reality (press release, 14 January 2026)

The animated figures are simplified illustrations that use the numbers stated in the text. Where a figure is modelled on a real incident, the sources above are the full accounts.

The service behind this articleAI Systems, Agents, and Workflow AutomationRelated case studyPrologue Partnerships: an author's book, turned into a paid AI coach
Aslam Sarfraz profile photo

Aslam Sarfraz

AI, DevOps and full-stack engineer

More articles

AI systems · 10 min read

How AI backends handle millions of requests without falling over

A chat answer keeps a GPU, a block of memory and a connection busy for many seconds. What that does to a backend, how serving systems cope, and what a startup should copy.

Full-stack engineering · 8 min read

Why startup backends break at the first big traffic spike

Ticketmaster took 3.5 billion requests in one sale and Segment merged more than 140 services into one. The failures behind spikes are rarely exotic, and each one has arithmetic you can do before launch.

DevOps and reliability · 8 min read

How one config change takes down production, and how to contain yours

CrowdStrike, Google Cloud, AWS and Cloudflare each had a major outage between July 2024 and November 2025, and none began with an attack. What happened, what it teaches and what to put in place.

LinkedIn outreach · 7 min read

Designing a LinkedIn outreach pipeline: a fixed capacity and an unseen limit

Outreach is a pipeline with a fixed capacity, a limit nobody publishes and very small samples. The planning numbers I use and the engineering behind them.