How to test an AI agent before it goes live
An agent that works in a demo has passed one test. Here is the set it needs to pass before a business relies on it.
Test an agent the way you would assess a new hire: give it real work with known right answers, check the result and how it was reached, and confirm it refuses what it must never do. Run every case several times, because the same request can come out differently on each run. Agree the pass mark before anyone sees a score, and repeat the whole set on every change.
Why ordinary software testing is not enough
Traditional software is tested by checking that the same input gives the same output. An agent does not behave that way: the same request can take a different route each time and still be right, or look right and be wrong. Testing it takes a different kit.
It helps to borrow the vocabulary from Anthropic's engineering guide to agent evaluations, published in January 2026. A task is one test with a defined input and a definition of success. A trial is one attempt at it. The transcript is the full record of what the agent did, and the outcome is the state of the world afterwards. An agent can say it has booked the flight. The outcome is whether a booking exists in the system.
Build the test set from real work
Collect real examples of the task: the actual emails, invoices or tickets the agent will meet, with the outcome a competent person would produce. Fifty carefully chosen cases teach you more than five hundred invented ones. Include the awkward ones on purpose: the incomplete form, the customer who changes their mind, the document in the wrong format.
You do not need a large set to begin. The same guide suggests that 20 to 50 simple tasks drawn from real failures is a good start, because early changes to an agent have effects large enough for a small set to show. For each case, write down what a correct result looks like, clearly enough that two people marking the same run would agree.
Anthropic's documentation on building evaluations lists the kinds of edge case worth adding on purpose:
- Input that has nothing to do with the task, or is missing altogether.
- Input that is far longer than usual.
- A poor or harmful request that the agent should decline.
- A case so ambiguous that sensible people would disagree. Decide in advance what the agent should do with it, which is usually to ask.
Score the outcome, then the route
First ask whether the final result was correct. Then look at how the agent got there: which tools it called, in what order, and what it wrote. A right answer reached by a wrong route is a failure waiting for a different input.
Be careful how you check the route. Insisting on one exact sequence of steps makes tests brittle, because a capable agent often finds a valid path nobody wrote down, and Anthropic's guide advises marking what the agent produced in preference to the path it took. So mark the outcome first. Then check the route only for things that are rules in your business: a required check that was skipped, a tool used outside its scope, a record opened that the task did not need.
Choose how each case is marked
There are three ways to mark a run, and most test sets use all of them.
| Marked by | Good for | Weakness |
|---|---|---|
| Code | Facts that can be checked exactly: the right amount, the right record updated, a forbidden tool never called | Fails valid answers that are worded or ordered differently |
| A second model | Open-ended output, such as tone, completeness or whether a reply answers the question | Costs more, varies between runs and needs checking against human marks |
| A person | Setting the standard, and settling cases the other two disagree on | Slow and expensive, so it cannot run on every change |
Automate as much as you can, so the set is cheap enough to run often. Where a model does the marking, Anthropic's documentation recommends using a different model from the one that produced the answer. And read the transcripts. A score means little until someone has checked that the failures are real mistakes and not a marker rejecting a correct answer.
Run every case more than once
One pass proves little. Anthropic's guide gives the arithmetic: an agent that succeeds 75% of the time on a single attempt will succeed three times in a row only about 42% of the time. For an internal tool where a person can retry, one success in a few attempts may be acceptable. For an agent that talks to customers or moves money, the number that matters is how often it gets the case right every time.
Test what it must never do
Write cases for the actions that are not allowed: paying an unapproved invoice, emailing a customer without review, reading a record outside its scope. These tests should fail loudly. They are the ones that protect you when the model or the prompt changes.
Include hostile input. OWASP's guidance on prompt injection recommends regular adversarial testing that treats the model as an untrusted user. We cover the defences in Prompt injection: the security problem every agent has.
Decide the pass mark before you look
Agree in advance what is good enough, and what happens to the cases the agent is unsure about. A system that hands five in a hundred to a person, with the context attached, is often more useful than one that guesses at all hundred.
Make the criteria specific and measurable. "Handles invoices well" cannot be tested. A target such as "extracts the correct total on at least 95 of 100 test invoices, and never approves one without a purchase order" can. Where the unsure cases go is a design decision of its own, covered in Human in the loop: deciding where an agent must stop and ask.
Run the set on every change
A new model version, an edited prompt or an extra tool can each quietly change behaviour. Keep the test set in the same place as the code and run it before anything ships. If the score drops, the change does not go out.
It helps to keep two sets. One holds the hard cases the agent cannot yet do. The other holds everything it already does correctly, and that one should stay close to a full pass on every run. Open-source tools exist for running both: Inspect, an evaluation framework created by the UK AI Security Institute, and promptfoo, a command-line tool for evaluating and red-teaming applications built on language models. Both repositories showed an MIT licence when we checked on 16 November 2026. Licences change, so read the licence yourself before building on either.
Keep testing after launch
Sample live runs every week and add the surprising ones to the test set. The set should grow with the business, because the work the agent meets will.
The NIST AI Risk Management Framework, a voluntary framework published in January 2023, notes that risks measured in a controlled setting can differ from those that appear in real use. Among its outcomes are that a system is shown to be valid and reliable before it is deployed, and that its behaviour is monitored once it is in production. A pre-launch test tells you the agent was ready on the day. Monitoring tells you it still is.
Common questions
Who should write the test cases?
The people who do the work today. They know what a correct result looks like and where the awkward cases hide. Engineers turn those examples into automated checks, but the judgement about right and wrong should come from the business.
Can a model mark another model's work?
Yes, for output that code cannot check, such as tone or completeness. Anthropic's guide notes that model-based marking needs calibrating against human judgement, so have a person mark a sample and compare.
What should we ask a supplier to show us?
Ask for the test set, the pass mark agreed in advance, the results across repeated runs, and the cases covering forbidden actions. Then ask what happens when the model version changes. If you would like a second opinion on a test plan, get in touch.