Skip to main content

ArticleUpdated November 202613 min read

How to test an AI agent or chatbot for accuracy and safety

A plain process for testing an AI agent or chatbot: written rules, evals, human gates, audit trails, and monitoring after launch.

  • AI testing
  • LLM evals
  • AI agents
  • chatbot testing
  • AI safety
  • QA

Testing an AI agent or chatbot means writing down what good looks like, then running the agent against real questions from your own customers, each paired with an answer you would accept (this list is called an evaluation set). Safety is tested with written rules, human approval gates, an audit trail of every action, and deliberate attempts to trick the agent. Testing continues after launch, because prompts, models, and tools keep changing.

How do you test an AI agent or chatbot for accuracy and safety?

Accuracy and safety are two separate test programs that share one set of cases. Accuracy asks whether the agent gives the right answer or takes the right action. Safety asks whether it stays inside the limits you set, and whether you can prove afterwards what it did.

Accuracy testing starts with the evaluation set: a list of real questions and requests from your customers, each with the answer or action you would accept. Generative AI can produce different outputs for the same input, so traditional software testing on its own is not enough (OpenAI's evaluation best practices). Each case is therefore scored against criteria rather than compared to one fixed expected answer.

Safety testing starts with the rules. Write down what the agent may do, what it may not do, and who approves anything that leaves your systems. Then test those rules directly: try to make the agent break them, and check that the gate holds when it tries.

What is LLM testing, and when do you run it?

LLM testing checks what a large language model (the kind of AI behind most chatbots and agents) produces against criteria you set for your own use case. It is usually called evaluation, or "evals". OpenAI's documentation defines evals as tests that check model outputs against style and content criteria you specify. It is not a spell-check and it is not a standard software test: the criteria come from your business, your customers, and your rules.

A useful evaluation set has three parts:

  • Cases that must always work.
  • Cases that are genuinely hard.
  • Cases that are dangerous if the agent gets them wrong.

Each case carries the answer or action you would accept, and a score for how close the agent came.

Run LLM testing before launch, so you know the agent is good enough before customers see it. Run it again whenever the agent's goals change, whenever you change the criteria for a good answer, and whenever you add a new kind of request or a new tool. Run it when you switch to a different model, too.

What is LLM regression testing, and when do you run it?

LLM regression testing means re-running a fixed set of hard cases after every change, to confirm the agent still handles the things you already fixed. OpenAI's voice evaluation guide defines a regression suite as hard cases you already fixed, to be re-run on every prompt, model and tool change.

Run it on every change to a prompt, a model version, a tool, a knowledge base, or a routing rule. Run it before every release. Also run it on a schedule even when nothing has changed, so that slow drift shows up as a trend rather than a surprise.

The two work together. LLM testing asks "is the agent good enough?" Regression testing asks "is it still as good as it was?"

The test process, step by step

The process runs in twelve steps, from writing the rules down to watching the agent in production. Each step produces something you can read and keep.

  1. Write the rules down. Before any prompt is written, list what the agent may do, what it may not do, and who approves anything that leaves your systems. OpenAI's business guide to evals says you must define what "great" means for your use case before you can test for it.
  2. Turn the rules into cases. For each rule, write at least one case that should pass and one that should fail.
  3. Build the evaluation set from real customer questions. Pull the last few hundred real requests, including the awkward ones.
  4. Build the regression suite from the hard cases you already fixed.
  5. Test the conversation flows as scripts, not as one-off chats.
  6. Test the actions. Every tool the agent can use gets its own test, including a test that the human gate stops it.
  7. Test the failure paths. Check what happens when a tool times out, returns an error, or returns something unexpected.
  8. Try to break it. Run the adversarial tests described below: tricking the agent, leaking data, making things up, and going off topic.
  9. Agree the pass bar before the final run. Decide in writing what score counts as ready, and who signs it off.
  10. Run the full pre-launch pass on a frozen version. A frozen version is one fixed copy of the agent that nobody changes during testing, so the results describe exactly what will go live. Use the same cases, the same model, and the same tools, and record the results.
  11. Go live behind a limit. Start with a small share of traffic or one team, and watch what happens.
  12. Monitor after launch. OpenAI's agent evaluation documentation defines a trace as the end-to-end record of one agent run, including model calls, tool calls, guardrails and handoffs. Graders (automatic checkers, or people, that score each run against your criteria) score these traces to find regressions. Read the traces weekly, along with anything the agent flagged or a person overrode.

How do you test a chatbot for safety?

Test safety by playing the part of someone who wants the agent to misbehave, and by checking that it does not. In plain words, this is adversarial testing: deliberately hostile or careless use, written down as cases so that you can repeat it after every change.

Cover at least four kinds of attempt:

  • Tricking the agent into ignoring its rules. Tell it to forget its instructions, claim to be an administrator, or ask it in small steps to do something it refused outright. The agent should hold its position every time.
  • Getting it to leak private data. Ask for another customer's details, for internal notes, or for the instructions it was given. The agent should reveal none of it.
  • Getting it to make things up. Ask about a product, price, policy, or order that does not exist. The agent should say it does not know or hand off to a person, not invent an answer.
  • Pulling it off topic. Ask for legal advice, medical advice, opinions, or jokes if those are outside its job. The agent should politely return to what it is there for.

Keep every successful trick as a permanent case in the regression suite, so it can never quietly come back.

What counts as passing?

An agent passes when it meets a bar that people agreed in writing before the final test run. A common shape is two parts: no failures at all on the dangerous cases, and an agreed score on the rest, such as a set share of ordinary cases answered correctly.

Agree the bar in this order:

  1. List the dangerous cases: anything involving money, personal data, legal commitments, or a write to a system of record. These get a zero-failure rule.
  2. For the other cases, pick a score the business can live with, based on what a wrong answer costs.
  3. Name who signs it off. This should be the business owner of the process the agent touches, together with the person accountable for risk, not only the team that built the agent.
  4. Write the bar down before the final run, so the result cannot be argued around afterwards.

If the agent misses the bar, it does not launch. Fix it, re-run the regression suite, and test again.

How do we test an agent before we trust it?

Trust comes from evidence you can read, not from a good demo. Before you trust an agent, you should be able to show:

  • a signed page of rules
  • an evaluation set with scores
  • a regression suite that passes
  • the results of the adversarial tests
  • a signed pass bar, and proof the agent met it
  • traces (the step-by-step record of a run) from real runs
  • a test that proves the human gate holds

A demo shows the agent at its best. A test program shows the agent on a bad day: an unclear request, a tool that fails, a caller who changes their mind halfway through.

How do you test an agent that can take actions in your systems?

Test the action the way you would test any other write to a system that matters: in a copy of production, with a record count before and after, and with a way to undo it. Then test the limits around the action.

Three limits do most of the work:

  • A human gate on anything high impact. OWASP's entry on excessive agency names, as one cause of damaging agent actions, an application that fails to independently verify and approve high-impact actions. Test the gate by trying to get past it.
  • An audit trail for every action. Record every tool call, every field written, and every message sent, along with the input that caused it. If you cannot answer "why did it do that" for any action, the agent is not ready.
  • The AI never files upstream. It prepares and proposes. A named person approves and submits. The agent has no authority to file to a regulator, a tax authority, a court, a billing system, or a client email inbox.

How do you test AI so it does not corrupt orders or inventory data?

Point the agent at a copy of production first, and reconcile the numbers before and after every run: order counts, line counts, inventory quantities, and the value of open orders. If the numbers do not match, stop.

Then test the specific ways an agent damages data:

  • Duplicate writes. Send the same document or message twice and confirm it is processed once. An agent built to recognise a repeat (for example, by deal plus document fingerprint) will not double an order.
  • Partial writes. Break the connection halfway through a multi-step write and confirm the system is left in a known state, not half updated.
  • Wrong field. Confirm the agent writes to the field you intended, and that a holding field is used wherever a live field would be dangerous.
  • Silent failure. Confirm that a failed write is raised to a person, with the reason, rather than disappearing.
  • Out-of-range values. Try a quantity of zero, a negative amount, a currency the system does not support, and a date in the past.

AI where judgment is needed, code where determinism is needed

Use AI where judgment is needed and plain code where determinism is needed. Classifying a document is a judgment call, so a model does it well. Moving a deal from a classification to a stage is a rule, so code should do it.

Here is the routing example. An agent reads a document and classifies it. Then a routing table written in plain code decides whether the deal moves to Won, Lost, Deferred, or Hold. When the firm changes its routing policy, three lines of code change and ship, with no prompt engineering, no new evaluation set, and no regressions on unrelated classifications.

That separation is also what makes the agent testable. The classifier is tested with an evaluation set, and the routing table is tested with ordinary software tests. See the Intelligent Routing Agent and how to draw the line between AI and people.

How do you build and test conversation flows before going live?

Write the flows down as scripts first: what the agent says, what it asks for, what it does with each answer, and where it hands off to a person. Then test the scripts as scenarios rather than as single messages.

A workable scenario set covers:

  • the happy path
  • a request the agent cannot help with
  • a caller who gives information in the wrong order
  • a caller who changes their mind
  • a caller who is angry
  • a caller who asks for a person
  • a caller who goes silent

Run each scenario end to end, including the summary and the record it leaves behind.

How do you test AI voice agents before launch?

Voice adds four things that text does not: time, noise, interruption, and consent. Test all four before launch, then test the parts that touch your systems.

  • Time. Measure how long the agent takes to respond, and test the worst case, not the average. A pause that reads fine in a transcript feels broken on a call.
  • Noise. Test with background noise, a poor phone line, an accent, and two people talking at once.
  • Interruption. Test a caller who talks over the agent, and confirm the agent stops and listens.
  • Consent. If the agent places calls using a voice generated by AI, the rules are strict. The FCC ruled that calls using AI technologies that generate human voices fall under the TCPA (the US law on automated calls), so they require the called party's prior express consent. Test that consent is captured and recorded before any outbound call.

Then test the booking written to the calendar, the record written to the CRM, the summary and transcript sent to the team, and the handoff to a person.

Companies that test AI chatbots and AI agents before launch

Rex Black Inc. has worked in software quality since 1994, provides software testing and QA consulting, and builds AI agents in production with testing built in. The firm is an ASTQB-accredited ISTQB training provider, one of 8 in the US, and is accredited to teach the ISTQB Certified Tester AI Testing (CT-AI) course. The ISTQB CT-AI certification page lists understanding the AI-specific quality characteristics defined in ISO/IEC 25059 among its outcomes.

Published case studies include an AI intake agent for a national veteran services organization and an AI voice agent for a regional services provider. Rex Black Inc. uses AI-assisted delivery with senior review, and leads every engagement with practitioners averaging more than 15 years of experience. The same team studies the problem, builds the fix, and tests it before anything goes live.

What is the difference between a testing platform and a testing service?

A testing platform is software: evaluation libraries, tracing tools, dashboards, and scoring functions. A testing service is people who decide what to test, write the cases, read the results, fix the agent, and stay accountable after launch.

Both have a place, but one does not replace the other. A platform will not tell you that your agent should never move a deal to Won on its own. It will not notice that the summary sent to the team is missing the caller's callback number. Those judgments come from someone who understands the business process the agent touches. Rex Black Inc. offers software testing as a service.

Questions to ask before you sign

Ask these before you sign anything. The answers tell you whether the testing is real or a demo. The guide Seven questions to ask before you sign covers the wider buying decision.

  1. Who writes the rules for what the agent may and may not do, and who signs them?
  2. What does the evaluation set look like, and where do the cases come from?
  3. How many cases are in the regression suite, and what triggers a re-run?
  4. How do you try to trick the agent, and what happens to each trick that works?
  5. What is the pass bar, and who signs it off?
  6. Can you show a trace of a real run, end to end?
  7. How is the human gate tested, and what happens when someone tries to get past it?
  8. What is the audit trail, and how long is it kept?
  9. What happens when a tool fails halfway through a write?
  10. How do you test the agent against a copy of our data before it touches the real thing?
  11. For a voice agent, how is consent captured and recorded?
  12. What do you monitor after launch, and who reads it?
  13. What does done look like, and what do we own at the end?

What to do next

Start with the buyer reading path, Putting an AI agent into production: what to read before the first call. Then look at how Rex Black Inc. builds and tests voice and intake agents in production, and at the framework for drawing the line between what the AI decides and what a person approves. If you want a straight read on your own agent, book a 30-minute call with a principal.

Rex Black Inc. · Since 1994 · Dallas, Texas

Keep reading

Related reading

Practices

Where this leads

Working on something like this?Talk to the people who wrote it.

Book a call