Fifty tests, fifty green checks, and a release note that says the support agent is ready. Three days later a customer with an order split across two shipments asks for a refund on the second box, and the agent politely refuses. Someone opens the system prompt, adds a sentence about split shipments, checks that one conversation, and ships again. The next week a different customer gets the wrong return window, and the cycle starts over.
Nothing in that story is a testing failure in the usual sense. The tests did exactly what they were written to do. The real failure is quieter: the team has no way to learn from what broke, so every fix starts from zero and every release is a fresh gamble.
What follows covers why AI agent testing that passes in CI can still ship bugs to users, why fixing those bugs one prompt edit at a time makes the agent harder to trust, and how an evaluation loop turns each production failure into a permanent regression case. The split-shipment refund comes back at the end, handled both ways.
Why passing tests doesn't mean your AI agent works
An AI agent passes its tests and still fails users because a test suite is a small, fixed sample of the inputs the team imagined, while users bring an open-ended stream of inputs nobody wrote down. A green run proves the agent handled those cases once. It says little about the cases that matter next week.
Four gaps explain most of the distance between the CI report and the support queue.
Limited coverage. A suite of 50 hand-written cases describes the scenarios the team thought of during the sprint. Real customers combine intents in one message, paste half an order number, switch language mid-conversation, or ask about a policy exception that exists only in a PDF on the help center. Your suite covers your imagination, and your users are more creative.
Missing edge cases. Agents fail at the seams: a tool call that times out halfway through a conversation, an account with missing fields, a refund that touches two systems. These are hard to think up in advance and easy to meet in production.
Unpredictable model behavior. The same input can produce a different output on a second run. A single pass is one sample, not a guarantee. Sierra's tau-bench study (2024) measured this directly with a metric called pass^k, the chance an agent succeeds on all k repeated attempts of the same task, and found that even strong function-calling agents were far less consistent across repeated trials than a single run suggested. One green check per test case hides that variance completely.
The gap between test inputs and real inputs. Test prompts tend to be short, clean, and written by engineers who know what the agent is for. Production conversations are long, messy, and full of context the agent has to carry across turns. OpenAI's evaluation best-practices guide lists "creating eval datasets that don't faithfully reproduce production traffic patterns" as an anti-pattern for exactly this reason.
Model evaluation is not system evaluation
Most failures users report are not failures of the model alone. Your agent is a system: a prompt, a model, retrieval over your documents, tool definitions, business rules, and the code that glues them together. A test that checks whether the model gives a sensible answer to a sensible question misses most of that surface. When a refund goes wrong, the cause might sit in the retrieved policy text, in a tool schema, or in a missing business rule, and a prompt-level test will not see any of them.
The manual prompt-engineering trap
Here is the workflow many teams fall into once real users arrive:
- A ticket comes in describing a wrong answer.
- An engineer reproduces it, usually after a few tries, because the behavior is not deterministic.
- They edit the system prompt to handle that case.
- They check the one conversation that failed. It works now.
- They ship.
Each step is reasonable. Together they form a trap, and it closes slowly enough that nobody notices. A prompt is shared state: every instruction you add changes how the agent reads every other request. The sentence that fixes split-shipment refunds can make the agent more generous with a different order type, and nothing in the workflow above would notice. The fix is verified against one case, and the side effects are verified against none.
OpenAI's guide has a blunt name for this pattern: "vibe-based evals," meaning "it seems like it's working" as the evaluation strategy. Without a regression set, the team cannot answer the most basic quality question a CTO or product owner will ask: is this version better than the last one?
You can usually spot the trap from a few symptoms:
- The same bug gets reopened after an unrelated change.
- The system prompt has grown into a long list of special-case rules, each added for one ticket.
- Nobody can say whether the current version is better or worse than the one from two months ago.
- Whether a fix "worked" depends on who tested it last and which examples they tried.
- Senior engineers spend their week reproducing non-deterministic failures by hand.
Prompt engineering vs evals
Prompt engineering is a way to change the agent's behavior. Evals are the way to know whether the change helped. The two work together. What causes the damage is changing behavior without measuring it. A prompt edit backed by an eval run is engineering. A prompt edit backed by one spot check is a guess.
Evals as the fix: what to build
An eval, in the sense that matters here, is a repeatable test of your agent's behavior on a representative set of inputs, scored automatically or semi-automatically, so you can compare one version against another. For a product team, LLM evaluation comes down to four practical pieces (academic benchmarks barely figure).
A golden dataset that looks like production
The golden dataset is the set of conversations your agent must handle correctly. Start it from real traffic, anonymized, rather than from what engineers imagine users say. Include the failures you have already seen, the boring common requests, and the awkward edge cases. OpenAI's guide puts the habit simply: log everything as you develop, so you can mine your logs for good eval cases.
Each case needs a definition of success. Sometimes that is an expected answer. More often for agents it is a set of criteria: the correct policy was cited, the right tool was called with the right arguments, the agent asked for missing information instead of guessing. The dataset grows over time, and that growth is the point.
If you want detail on writing assertions for outputs that vary from run to run, our guide on how to test AI features when outputs are non-deterministic covers that layer.
Score correctness and task completion separately
An agent can say the right thing and still fail the job. It can describe the refund policy accurately and never issue the refund. It can call the right tool with a wrong order ID. Score at least two things for each case:
- Correctness: is what the agent said true and consistent with your policies and data?
- Task completion: did the agent actually do what the user needed, with the right actions in the right order?
Many teams use an LLM-as-a-judge to grade open-ended answers at scale. That works when the judge is calibrated against human review on a sample of cases (an uncalibrated judge tends to drift without anyone noticing). OpenAI's guide recommends using human feedback to calibrate automated scoring for exactly this reason. A judge nobody has checked is just another unverified model.
Find failure patterns, not single failures
One failed case tells you what broke. Twenty failed cases sorted into groups tell you why. GitHub's engineering team, writing about how they evaluate LLM systems before production, describes reviewing failures and asking of each one: "Did this failure come from the model, prompt, input, pipeline, dataset, or label?" That single question turns "the agent is flaky" into a list of concrete engineering tasks.
Patterns change the fix. If most refund failures trace back to retrieval pulling an outdated policy page, another prompt sentence will not help. The fix belongs in the index, and only a pattern would have told you so.
Track quality across versions
Every release candidate runs the same eval set and produces a scorecard: overall pass rate, pass rate per failure category, and any case that passed before and fails now. Compare prompt versions, model versions, and retrieval changes side by side. A regression shows up in the scorecard before it shows up in a ticket, and an improvement shows up as a number instead of a feeling.
The continuous improvement loop for AI agent reliability
Evals on their own are a measurement. AI agent reliability comes from wiring that measurement into a loop that runs every time something goes wrong. The loop has seven steps.
- Capture the production failure. A ticket, a thumbs-down, an escalation to a human, or an alert from monitoring. Record the full conversation and every tool call along with the final answer.
- Classify the failure. Put it into a category from a small, agreed taxonomy: retrieval miss, wrong tool or wrong arguments, policy violation, made-up fact, misread intent, missing business rule. Microsoft Research's AgentRx work shows this is tractable for agents: the team released a benchmark of 115 manually annotated failed agent trajectories with a nine-category failure taxonomy, built to find the first step where a run became unrecoverable.
- Add new eval cases. Turn the failing conversation, plus a few close variations, into cases in the golden dataset. This is the step that makes the fix permanent. The failure is now something the agent is tested against on every future change.
- Fix the root cause. Use the classification to choose the layer. Sometimes it is the prompt. Often it is retrieval, a tool schema, a guardrail, or a product rule that was never written down.
- Run automated regression evals. Every change runs the full eval set. A drop on any case that used to pass blocks the release until someone looks at it. On a two-week release cadence, that run belongs in the same CI job as the unit tests, so it costs minutes per merge instead of a separate review meeting.
- Deploy in a controlled way. Roll the change out to a share of traffic first, behind a flag or a staged rollout, so a surprise affects a few conversations instead of all of them.
- Monitor, and feed the next failure back to step 1. Production monitoring finds the cases your eval set does not have yet.
Two of those steps deserve a pointer. For step 4, smaller narrow checks can help, as covered in our piece on how small decision models make AI products more reliable . For step 7, see what to monitor when your AI feature reaches production for what to watch once the agent is live.
The whole idea fits in one sentence: every failure gets fixed once, because it becomes a test that runs forever.
The loop also changes who owns quality. Product owners help define what "correct" and "complete" mean for each category. Engineers own the fix and the eval cases. The release decision rests on a scorecard both sides can read.
An illustrative example: one support agent, two ways to fix it
Back to the support agent from the opening. The scenario below is hypothetical. It describes a common pattern, not a specific client or measured result.
A team runs an AI support agent for an online retailer. It passes all 50 of its existing tests. After launch, two kinds of complaints arrive. The agent refuses valid refunds when an order was split into two shipments, and it quotes the wrong return window to customers in one region.
Patching the prompt
An engineer adds a paragraph to the system prompt explaining split shipments and a line about the regional return window. They test the two reported conversations. Both pass. The release goes out.
A week later, support notices the agent approving refunds for a different order type that should go to a human. The new paragraph about split shipments made the agent more permissive in general, and no test covered that path. Two weeks after that, someone tidies the prompt for an unrelated feature, the regional line gets reworded, and the wrong return window comes back. Nobody can say whether the agent is better overall than it was at launch. The suite still shows 50 of 50, which is exactly the problem.
Running the loop
The same two complaints arrive. This time each one is captured with its full conversation and classified. The split-shipment refusal is a reasoning failure over multi-item orders. The wrong return window is a retrieval failure: the agent pulled an outdated policy page.
The team adds both conversations to the golden dataset, plus a handful of variations: three-shipment orders, partial refunds, the same policy question asked in the other regions. The suite now has more than 50 cases, and the new ones fail on the current version, which confirms they capture the bug.
The return-window fix goes into retrieval: the outdated page comes out of the index, and the prompt stays as it was. The split-shipment fix does touch the prompt, and the regression run catches the side effect immediately: the over-permissive refund cases fail before release. The engineer tightens the instruction, the full set passes, and the change goes out to a share of traffic first.
When someone edits the prompt next month, the return-window and split-shipment cases run again automatically. If either breaks, the release stops. The known failures cannot come back quietly, and the scorecard shows the improvement as a change between versions that anyone in the release review can read.
What changes for the business
For a CTO or product owner, the loop matters most in the release review, because it changes what you can answer there.
Fewer recurring bugs. A failure that has become an eval case cannot return unnoticed. The support queue stops filling with tickets the team has already "fixed."
Faster diagnosis. Classified failures point to the right layer. Engineers stop spending days reproducing a non-deterministic bug. The failing conversation is already in the dataset, and the category tells them where to look.
Measurable reliability. You get a version-over-version number per failure category. When leadership asks whether the agent is getting better, the answer is a scorecard, not an anecdote: one pass rate per failure category, compared release over release.
Lower long-term maintenance. The system prompt stops accumulating special-case rules, because many fixes land in retrieval, tools, or business logic where they belong. That keeps the agent easier to change later, which matters as much as how well it works today.
A large platform on day one is optional. The habit that matters is treating every reported bug as data instead of a one-off.
Where to start next week
You do not need a perfect eval platform to begin. A shared spreadsheet of real conversations and a script that replays them through the agent is enough tooling for the first month. Three steps get the loop moving:
- Seed the dataset from real failures. Pull the last 30 to 50 tickets about wrong or odd agent behavior, anonymize them, and write a success criterion for each. That is your first golden dataset.
- Agree on a short failure taxonomy. Five to eight categories are enough to start. Tag every new failure as it arrives.
- Make the eval run block merges. Connect the eval set to CI so any change that breaks a previously passing case cannot ship without someone looking at it.
From there, add controlled rollouts and production monitoring, and let the dataset grow with every failure your users find. Prompts are still part of the work, but as our post on why AI agents need runbooks, not just prompts argues, they are only one of the levers.
Aim past the better prompt. Build a system where every failure your users find makes the agent permanently better.
Is your AI agent passing tests but still failing users? A structured evaluation and improvement process can help turn an unpredictable prototype into a more reliable production system. Book a free 30-min readiness call and get an AI Readiness Snapshot of where your agent's quality process stands today.