Why AI agents fail in production: same agent, two worlds

By Christophe Paka · Facts checked on 23 October 2026

On Friday the demo went well. The agent answered every question you typed. On Monday real users arrive. One run stalls. Another gives a calm, wrong answer. Builders sum it up in four words: it worked in testing.

So why do AI agents fail in production when the code did not change? An AI agent is a program where the model, not you, picks the next step. The model is the AI your code sends text to. You can leave it alone and the agent still breaks, because its world changed. The rewrite after the demo is often the real project.

The figure below puts both days side by side, row by row.

Two columns compare one agent at Friday's demo and Monday's production across five rows: the input, the dependencies, the knowledge, who is watching, and when it breaks. A box below reads: same code, same model, same prompt.
Figure 1.1: Same agent, two environments. Nothing about the model changed between Friday and Monday; everything around it did.
Use this diagram on your site

Free to share in your blog post, docs, course or slides, as long as the credit link stays. Paste the code below where the figure should go.

How to read this figure

  1. Read the two column headings. The left column, light grey, is the demo on Friday. The right column, shaded orange with a red outline, is production on Monday. Five rows run down the left edge. Read each row across: Friday first, then Monday.

  2. Compare the input row. On Friday the input is cases you picked yourself, phrased the way you phrase things. On Monday it is whatever a real user sends, including shapes you never tried. Your test cases were only a guess about real users.

  3. Read the dependencies row. A dependency is a service the agent calls through an API, a way for programs to send requests to a service. Friday has one quick API. Monday has timeouts, 429 errors and empty results. A timeout is when a program stops waiting for an answer. A 429 is the error a service sends when you call it too often. Fix this row first: a timeout on every call and a cap on retries.

  4. Read the knowledge and watcher rows. On Friday the facts are hardcoded, typed straight into the source file. On Monday the agent searches a corpus, a set of documents that keeps changing, and each edit needs a code deploy. On Friday you read every turn in the terminal. On Monday nobody watches until a complaint arrives three days later.

  5. See what happens when it breaks. On Friday you see the failure, shrug and run it again. On Monday it stalls silently with a plausible answer, or retries until the bill lands. The Monday column prints this row and the dependencies row in red. A spending limit, a cap on what the account may charge, ends that loop before your bank card does.

  6. Read the box at the bottom. The box under both columns reads: same code, same model, same prompt. Everything that changed sits outside the agent. That is why a smarter model fixes none of the five rows. See the production cliff for what fails next.

Key takeaways

  • Before you trust a demo, list what it chose for you: the inputs, the services, the data and the watcher.
  • Test with messy inputs from real users, not only the cases you wrote yourself.
  • Set three limits first: a cap on retries, a timeout on every call and a spending limit on the account.

Worked example: one real prototype, row by row

Three Google engineers wrote on the Google Developers blog about taking an internal agent from a prototype to real users. The prototype was one big Python script driving one huge prompt. The demo went well. Then they rebuilt all of it. Here is what they found, mapped to the rows of the figure.

  1. Dependencies: one API timeout, or one hallucination, stalled the whole process, and it failed silently. A hallucination is the model stating something false with full confidence.
  2. When it breaks: they knew something failed, but had no idea which part caused it.
  3. Knowledge: the agent knew only 12 case studies, typed into its source file, so each new case meant a code change.
  4. The bill: they warn that an agent which retries a prompt without strict limits can burn through a token budget in minutes. A token is the unit a model reads, writes and bills in, about a word or a piece of one.

Result: None of the four is a model problem. Each sits around the model: a slow service, a fixed file, no way to look inside, no limit on retries.

Questions readers ask

Why is everyone lying about AI agents?

Mostly nobody is lying. The demo is real, and so is the plateau after it. The 12-Factor Agents project heard the same story from at least 100 builders of online software: a fast start with a ready made agent library, a quality bar of 70 to 80 percent, then months spent taking the library apart, because 80 percent is not good enough for most features customers touch.

Why use an agent instead of just asking ChatGPT normally?

Use a chat when you want one answer and will do the work yourself. Use an agent when the job needs several actions, and you cannot know their order before you start. Ask ChatGPT how to process a refund and it writes a plan. An agent looks up the order, reads the policy, drafts the reply and stops.

What stops an unattended agent from looping or overspending?

Limits you set outside the model: a cap on retries, a timeout on each call and a spending limit, which caps what the account may charge. They end the run when the model does not. The book puts their cost at about an engineer's day. Nobody watches until a complaint arrives three days later, so the limits must be in place before the first real run.

Sources: Production-ready AI agents: 5 lessons from refactoring a monolith (Google Developers); Building effective agents (Anthropic); 12-Factor Agents (HumanLayer).

This figure is from AI Agents Made Crystal Clear, chapter 1.

The chapter builds the idea step by step, with recipes you can follow, a Try it to check yourself, and every source.

Get the book

All diagrams