How to Test AI Agents Before and After Deployment

How to Test AI Agents Before and After Deployment

Learn how to test AI agents before and after deployment, check access controls and turn production failures into tests you can run before each update.

Listen to this article

0:00 —

Press play to start listening

A customer support agent can look ready in a demo when the order number is valid and the lookup works. In production, customers will mistype order numbers, the order system will sometimes time out, and some requests will concern orders the customer isn’t authorised to see. Those are the cases I’d test before giving an agent access to live customer data.

Define what counts as a pass

Start with a task the agent will actually handle. For an order status request, a pass means the agent checks that the customer is authorised, looks up the right order and reports the status returned by the order system. If the lookup fails, the agent should explain that it couldn’t confirm the status or hand the request to a person. Guessing a delivery date counts as a failure, even if the reply sounds convincing.

The wording can vary as long as the response is accurate and useful. Other requirements need a firm pass or fail rule. If the agent discloses another customer’s order details, that should block release even if the overall completion rate improves. Track completion rate, response time and cost per request separately so you can see whether a change improves one measure at the expense of another.

Test the answer and the actions behind it

Build a small test set around the requests the agent is expected to handle. For an order status agent, I’d start with these three cases:

Test caseExpected behaviour
A customer asks about their own orderVerify access, check the order system and report the status it returns.
A customer enters someone else’s order numberRefuse to disclose the order details or confirm that the order exists.
The order system times outExplain that the status couldn’t be confirmed or hand off the request without inventing a delivery date.

I’d record how the current version performs on these cases before changing it. That gives the team a baseline for comparing later versions. Check the final reply and the actions the agent took: which tool it called, whether the tool enforced account permissions and how the agent responded to an error. Automated checks can verify those steps. A person reviewing the reply can judge whether it was clear and gave the customer a useful next step.

Turn production failures into tests

When a customer reports a bad answer, the reply alone may not explain what happened. Log which tools the agent called, their error codes and response times, and whether the request went to a human. Use a request ID to connect feedback to the relevant trace, and leave secrets and unnecessary customer details out of the logs.

Suppose a customer says the agent promised delivery on Friday, but the trace shows the order lookup timed out. Turn that incident into a test using fictional order details. In the test, the lookup should time out again, and the next version should say it couldn’t verify the date or send the request to a support worker.

Release changes in small steps

A failure in production tells you where to look. If the order service times out frequently, investigate the service or its integration. If the agent invents a date after receiving a timeout, fix how it handles that error. I’d address failures based on how often they happen and how much harm they can cause, with privacy and permission failures taking priority.

Change one thing at a time where practical, then run the same tests against the current and proposed versions. Check that the fix works and that routine order lookups still return accurate answers. If the new version passes, release it to a small group first. Decide in advance when to roll back, such as if incorrect replies exceed the team’s agreed limit or the agent discloses information to an unauthorised customer.

Before giving an agent more responsibility, check that it can handle the work it already has, including the requests it needs to refuse or hand off. When a new failure appears in production, add it to the test set. The next release should pass that test without breaking the tasks the agent already handles well.

Related Posts