An AI agent can give a smooth, correct-sounding reply and still file the wrong ticket, charge a card twice or waste the budget on retries. Reading the chat log will never catch that, because the damage happens in other systems, through actions the log does not show. And a release that fails one time in twenty will pass a ten-run spot check about 60% of the time.

Fluent answers can still fail production

A proper set of release tests (a regression suite) has to check everything the agent does. That means the answer, the order of its decisions, every tool it calls, what it changed in other systems, how long it took and what it cost. Reading the chat log, still the default check in many teams, sees only one of those six things.

The answer alone can be costly enough. A company that deploys an agent owns what the agent tells customers, in the same way it owns what a clerk says at a counter, so a confident wrong statement about a refund rule is a promise somebody may hold it to. An agent with write access adds a second layer of liability, because its mistakes land in databases rather than in chat windows.

Regression testing treats a release as a promise about behaviour. It does more than compare questions with replies. It asks whether the agent finished the task, used only the tools it may use, and used them correctly. It checks that the agent did nothing forbidden, stayed within limits and can be stopped safely. A small runnable suite built around those questions does more than a folder of subjective “good answer” examples.

The suite need not mirror all traffic. Cover expensive mistakes, high-volume workflows, known failures and the decisions the change touches. Its job is to block customer incidents; general cleverness can be measured somewhere else.

A release contract beats transcript review

Define each case with a scenario, an initial state, the available tools and a pass/fail rubric. Expected text can be part of the rubric, but rarely all of it. A support agent replacing a damaged order might need to verify eligibility, create exactly one replacement request, explain the next step and avoid an unsupported refund.

Record separate expected outcomes:

  • Task result: the requested business outcome exists and meets its constraints.
  • Tool trace: required calls have valid arguments, forbidden calls never occur, and ordering respects dependencies.
  • External state: the expected record exists, with no duplicate or stray records beside it.
  • Response quality: the user receives an accurate, policy-compliant explanation that matches the action taken.
  • Resource envelope: latency, model use and paid tool activity stay within the agreed budget.

A final answer is not proof of completion. An agent may claim a case was updated after a failed tool call, or update it correctly while telling the user the wrong resolution. Both are failures, and they need different fixes.

Make rubrics checkable by the runner. “Helpful and accurate” helps reviewers but cannot gate a release. Observable checks can: required fields present, a named API method called once, no forbidden method, a response containing the approved disposition. Where language judgement is unavoidable, use a bounded evaluator rubric with explicit failure labels, and keep every failure for human review.

One passing run is weak evidence

Agent behaviour is partly random, even with the same workflow, tools and input. Model settings and updates, search results, slow services and retries can all change what it does. One success proves that success was possible, not that the release is dependable at the exposure it is about to get.

The arithmetic is unforgiving. If a release truly fails 5% of the time, the chance that ten independent runs all pass is 0.95 to the power of 10, about 0.60. To give yourself a 95% chance of seeing at least one failure, you need ln(0.05) / ln(0.95), roughly 59 runs. Turn it around with the statistician’s “rule of three”. If you see zero failures in n runs, you can only be 95% sure the real failure rate is below about 3/n. So 30 clean runs still allow a failure rate of up to 10%. For a read-only agent that may be fine. For one that cancels orders, it is not.

So repeat every nondeterministic scenario and store every trace, not just aggregate scores. Fix the number of repetitions before the run, scaled to how risky the action is, and specify two things in advance: the success requirement, and the failure patterns that block a release on their own. One prohibited side effect can be a hard failure even if every other repetition succeeds.

Task Success Rate = successful task runs / attempted task runs

This rate needs a companion measure. Nine correct outcomes and one duplicate cancellation are not “90% good” when duplication is unacceptable. Count hard failures separately from recoverable ones, and inspect clusters by input type, tool, model route or retry branch.

Repeated runs also show when test data gives false confidence. If search always returns the same saved results and the fake API never times out, you are testing one narrow path. Keep a stable baseline, then add controlled variants: missing records, ambiguous identifiers, delayed tool responses, malformed results, duplicate user requests. Each variant reproduces a condition production is known to produce, and the question is whether the agent stays inside its authority when it meets one. Random chaos testing answers a different question.

Tool traces reveal the hidden failure

An agent that uses tools is really a system that carries out transactions, with chat on top. Check the record of its actions (its trace) as closely as its reply: why it made each call, what it sent, the order, how it handled the result and what it changed. Tool names alone are not enough; create_case with the wrong account ID is not a near miss.

The OWASP Top 10 for LLM Applications 2025 lists this risk as LLM06, excessive agency: an agent granted more functions, permissions or autonomy than its task needs. A trace check is how you prove the grant was used narrowly. For every state-changing action, assert that it was allowed for the task, its preconditions were met, its parameters came from validated data, it happened the permitted number of times, and the resulting state matches the claimed outcome. Record correlation IDs so a failed test can be traced into downstream logs.

Test separately that repeating an action does no harm (idempotency). Agents retry after timeouts, but a timeout does not prove the other service missed the request. Simulate an unclear response and require one of three behaviours. The agent sends a unique key so the service can spot a repeat, checks the current state before retrying, or passes the case to a person. Blindly retrying a write creates duplicate orders, duplicate emails or conflicting account updates.

Check side effects where you can see the real result. Fake services (mocks) test every path reliably, but they cannot prove that data lands in the right fields or that duplicates are caught in the real system. Use sandbox accounts or separate test environments for full end-to-end checks. For irreversible actions, test the authorisation boundary and the handoff path instead of performing the action.

Score outcomes, traces and spend separately

A compact scorecard ties the release discussion to observable behaviour and stops cost or safety regressions from hiding inside a blended score.

Measure Calculation Release question
Task Success Rate successful runs / attempted runs Did it complete the intended work?
Trace Compliance Rate compliant traces / attempted traces Did it respect tool and policy constraints?
Side-Effect Error Rate runs with invalid state changes / attempted runs Did it cause forbidden or duplicate changes?
Cost per Successful Task total model and tool cost / successful runs Is it affordable at expected volume?
Tail Latency chosen high-percentile completion time Will slow paths breach the user experience or a worker timeout?

Compare a candidate with a versioned baseline using the same test set, tool configuration and evaluation window. Lower cost is not a win if success falls, and higher success deserves suspicion if a more expensive fallback model quietly handled every case.

An illustrative comparison shows why the cost line matters. The baseline costs $0.05 per run and succeeds in 90 of 100 runs: $5.00 / 90, about $0.056 per successful task. The candidate routes hard cases to a larger model, costs $0.12 per run and succeeds in 96 of 100: $12.00 / 96, or $0.125. Success rose six points; cost per success rose 2.25 times. At 50,000 successful tasks a month that is roughly $2,800 against $6,250. Ship the candidate only if the six extra successes per hundred are worth about $3,450 a month to the business, for example in avoided support tickets, and say so in the release note.

Cost gates should count model tokens, external tool charges, retrieval requests and retries. Four search-endpoint calls before an answer can pass every quality check while hurting unit economics; OWASP files the extreme case as LLM10, unbounded consumption. When tasks vary in difficulty, compare groups instead of one average. A small group of long, failed runs hides easily among many easy requests.

Do not treat evaluator scores as ground truth. Zheng et al.’s NeurIPS 2023 study “Judging LLM-as-a-Judge” found that strong model judges agreed with human preferences more than 80% of the time, and also documented position, verbosity and self-preference biases. A grader that favours longer, more confident answers will reward exactly the agent that talks its way past a failed tool call. Use AI graders for clear, repeatable criteria. Check where they disagree with humans. And for actions with real consequences, keep fixed, rule-based checks.

Risk changes the test shape

A read-only internal research agent can start with representative prompts, citation checks and budget limits. A customer-facing agent with account access needs stronger identity, permission and trace checks. An agent writing to operational systems needs state verification, idempotency scenarios and an immediate kill switch. Strictness should track the agent’s authority more closely than its traffic.

Teams that skip all of this usually do it for cost reasons, and the question is fair. Building fixtures, sandboxes and trace assertions takes engineering weeks, while a reviewer sampling 50 production conversations a week catches the failures users actually hit. For a read-only agent whose worst mistake costs a user a few minutes, the cheaper route is right: sampled review plus spend alerts is the proportionate control. The calculation flips the moment the agent can write to a system of record or spend money, because by the time a sampled review finds a duplicate refund, the refund has been paid. A workable rule: any tool that changes state gets trace-level gates before release; everything read-only can start with sampled review and graduate later.

Maturity changes which regressions are useful. Early failures tend to come from missing instructions, badly described tools and gaps in logging. Later ones come from changes in which model handles a request, tools changing version, changes to the documents the agent searches, updates from the model provider and backup paths interfering with each other. A suite frozen after launch becomes a museum of old bugs.

Incidents and near misses are the best test sources. Convert each into a minimised scenario with sanitised data, define the expected trace and final state, and keep it in the regression set. The suite then remembers concrete failures without turning every release review into forensics.

Rollback must be tested before release day

A passing suite lowers risk without removing it. Production has inputs, timing conditions and dependency failures that no pre-release set fully reproduces. Releases need controls that can undo them: saved versions of prompts and tool descriptions, on/off switches for features, control over which users get the new version, audit logs and a named owner who can switch the feature off.

Set measurable rollback criteria before expanding traffic: a single prohibited tool action, the task-success rate held below its floor for an agreed window (say, three points under baseline for an hour), cost per successful task above an agreed ceiling, or a trace indicating a permission bypass. Define who decides, which switch they use and whether in-flight work may finish. “We can roll back quickly” is not a control until someone has done it.

Where you can, release to a small slice first (a canary): one customer, one workflow or a share of traffic. Even 1% or 5% of traffic is enough to see tool errors and rule breaks within hours. Watch leading signals such as those, plus lagging ones such as customer corrections and downstream reconciliation failures. If a write cannot be safely reversed, use shadow evaluation or human approval until the evidence supports broader authority.

The durable suite stays small and opinionated

The strongest production suite looks nothing like a leaderboard. It is a short set that encodes non-negotiable behaviour: tasks the agent must complete, actions it must never take, resource limits it must respect, and the conditions under which it stops.

Keep every case runnable, version fixtures and rubrics, save traces from every run, and treat failures as engineering evidence. An agent is ready for wider exposure when its gate can catch each of these: a bad answer, a bad tool call, a wrong state change, an expensive detour and a rollback path that fails. Of the five, the broken rollback is the one a pre-release suite is least likely to exercise, because nothing in normal traffic triggers it. Unless someone schedules the drill, the first real test is the incident itself.