Build a test set from real cases, pick graders, agree thresholds, add red-team cases and decide in a go/no-go meeting: a practical launch path.
To test an AI agent before launch, collect real cases from the workflow it will run, write down the correct outcome for each, grade its answers and actions with a mix of automatic checks and human review, and compare the results with thresholds the business agreed before testing began. Add deliberate attack cases, run everything more than once because agents do not answer the same way twice, and make the launch decision in a short meeting with the evidence on the table.
Testing an agent differs from testing ordinary software in two ways. The output varies from run to run, so one pass proves little. And the failures are often plausible: a confident answer with the wrong date, a correct refund on the wrong order. A good test plan is built to catch exactly those.
Build the test set from real cases, not invented ones
The test set is the most valuable thing you will build, worth more than the prompt. Draw it from the work the agent will do: past support tickets, emails, documents and orders, with the notes staff wrote when they handled them. Invented examples tend to be cleaner and easier than reality.
- **Cover the common cases** in roughly the proportions they occur, so the overall score means something.
- **Add the edge cases staff remember:** the duplicate order, the customer with two accounts, the invoice in two currencies, the message that asks two questions at once.
- **Include cases the agent should refuse or escalate,** and count them as passes only when it does. An agent that tries to answer everything is a risk, not a feature.
- **Write the expected outcome for each case:** the correct answer, the tool calls that should happen and the ones that must not.
- **Cover every language and channel** you will launch in. A request written in Gulf Arabic is a different test from the same request in English.
- **Mask personal data** before cases enter the test set, and control who can read it.
Start with a few dozen cases per task and grow the set every week. Every bug found in testing or in production becomes a new case, so the same mistake cannot return unnoticed.
Choose a grader for each kind of check
A grader decides whether an output passes. Use the simplest grader that measures what matters, and combine them.
| Grader | Good for | Watch out for |
|---|---|---|
| Rule-based checks | Required fields, formats, forbidden content, the right tool called with the right arguments | They pass answers that are well formed but wrong |
| Comparison with a reference | Facts with one right answer: an order status, a date, a policy limit | Correct answers worded differently can fail an exact match |
| A model grading against a rubric | Tone, completeness, whether the answer is supported by the retrieved sources | The grading model makes its own mistakes; compare it with human grades before relying on it |
| Human review | Judgement, tone in Arabic and English, anything new or high-risk | Slow and inconsistent unless reviewers share a written rubric |
For an agent that takes actions, grade the actions as well as the words. Check the end state: was the right record changed, and nothing else? An agent can write a perfect reply while calling the wrong tool. The wider method is described under [LLM evaluation](/glossary/llm-evaluation).
Because outputs vary, run every case several times and look at consistency as well as the average. For an action that matters, the question is not whether it passed once but whether it passes every time. A case that fails one run in five will fail in production, regularly.
Agree the thresholds before you see the results
Set pass thresholds with the business owner before testing starts, so the results cannot move the goalposts. Set them per category, not for the whole set:
- **Critical failures:** data shown to the wrong customer, a refund above the limit, an action taken without the required approval. The threshold is zero. One failure blocks launch until it is fixed and retested.
- **Accuracy on common cases:** compare it with how people perform the same task today, measured on the same cases. The agent does not need to be perfect, but it must match the process it changes or have a person checking its work. The baseline also feeds [measuring the return on AI automation](/blog/measuring-ai-automation-roi).
- **Correct escalation:** cases that should reach a person and did. A missed escalation is usually worse than an unnecessary one.
- **Tone and language:** rated by native speakers against the rubric.
- **Cost and speed:** time and model cost per case, within what the workflow can carry.
Red-team the agent before someone else does
Red-team cases are deliberate attempts to make the agent misbehave. Write them for your agent's tools and data rather than copying a generic list. [AI red teaming](/glossary/ai-red-teaming) explains the practice in general.
- **Injection hidden in content:** an email or PDF that tells the agent to ignore its rules, forward data or change a bank account, written in both languages. See [prompt injection](/glossary/prompt-injection).
- **Requests for other people's data:** 'what did my colleague order?', or a guessed order number.
- **Pressure and false authority:** a message claiming to come from a manager, the bank or the police, demanding urgent action.
- **Policy edges:** a return one day past the deadline, a discount stacked on another discount.
- **Distress and abuse:** an angry customer, a threat, a message suggesting someone is at risk. The agent should stay calm and hand over to a person.
- **Confusing input:** a pasted error log, a voice note transcribed with errors, a message mixing Arabic and English.
Each red-team case joins the regression set once it is fixed. The controls these cases probe are listed in our [security checklist for AI agents](/blog/securing-ai-agents-checklist).
Test the whole system, then run a small pilot
Offline scores are necessary but not enough. Before a full launch:
Each stage turns up cases nobody thought of. Add them to the test set before moving on.
The go/no-go meeting
Keep it short and evidence-led. The business owner of the workflow decides; engineering, security, operations and the people who will handle escalations attend. Put on the table:
- results per category against the agreed thresholds, with every critical failure and its fix;
- a handful of real failures read aloud, not just scores;
- open risks, who accepted them and until when;
- the approval rules and limits that will apply at launch;
- [monitoring](/services/ai-automation/ai-monitoring), alerts and who is on call for the first weeks;
- the rollback plan and a kill switch that has been tried.
Record the decision and its conditions, such as launching in English first and in Arabic after another round of native review. A no-go backed by evidence is a good outcome: it costs far less than a public failure.
Keep testing after launch
Treat the test set as a regression suite. Run it before every change to the prompt, the model version, the tools or the documents the agent retrieves, and block the change if a critical case fails. Providers update their models and your documents change, and either can shift behaviour without a line of your code changing. Our [AI agent testing](/services/ai-automation/ai-agent-testing) work is organised the same way: the test set belongs to you and grows with the product.