Skip to main content

How to Test AI Agents With Evals

You cannot unit-test an AI agent, its output is non-deterministic and open-ended. You eval it: golden dataset, LLM-as-judge scoring, and a deploy gate that blocks regressions. Here is how to set it up.

Insights
8m read
#AIAgents#Evals#AIEngineering#LLM#Testing
How to Test AI Agents With Evals - Featured blog post image
Mahmoud Zalt

1:1 Mentor

Are you a software engineer moving into AI?

Let's have a call. I'll help you modernize your skills and learn the tools, systems, and architecture behind reliable AI products. One session or ongoing.

Writing livev0.1 · 2026 Edition

The Vibecoder's Handbook, from idea to production

Everything you need to know about shipping software with AI, from the App idea to production.

What it covers

  • 1PlanStructure your idea into a clear specification
  • 2Set UpPrepare your environment and tools
  • 3AutomateSetup your AI agents operating system
  • 4ArchitectLay out a modular codebase for your AI
  • 5BuildImplement the application in working slices
  • 6DebugDiagnose and fix what the agent breaks
  • 7TestProve it works, and keep it working
  • 8HardenMake it a solid, complete product
  • 9SecureProtect your app, data, and users
  • 10ProtectHandle user data responsibly and legally
  • 11ShipDeploy to production on real infrastructure
  • 12OperateRun and maintain it in production
  • 13ScaleGrow it to handle real traffic and data
Start Reading Free

93 chapters

How to Test an AI Agent With Evals

You test an AI agent with evals: a repeatable suite that runs the agent against a fixed set of inputs and scores each output against what you expected. The setup has four parts. First, build a golden dataset of real inputs paired with expected outputs or pass conditions. Second, run the agent over that dataset. Third, score each result, using exact match where the answer is deterministic, and an LLM-as-judge (a second model grading the output against a rubric) where the answer is open-ended. Fourth, gate your deploys on the score so no prompt, model, or tool change ships without passing. Traditional unit tests assume the same input gives the same output; a model does not, so evals measure quality as a distribution, not a single pass or fail.

I'm Mahmoud Zalt, an AI systems architect. Through Sista AI I help teams put evals and guardrails around agents before they reach users, and this is the setup I put in place first.

Why Agents Need Evals, Not Just Unit Tests

A unit test asserts that a function returns exactly what you expect. That model breaks with agents for two reasons. The output is non-deterministic: run the same prompt twice and the wording changes, so a string-equality assertion is useless. And the output is open-ended: 'summarize this ticket' has no single correct answer, only better and worse ones. Evals handle both by scoring quality across many examples and tracking how that quality moves over time. The practical payoff is regression detection. Model providers update models, you tweak a prompt, someone changes a chunking parameter, and any of those can quietly degrade behavior on inputs you were not looking at. An eval suite catches the regression before your users do, which is the entire point of testing.

Building the Eval Suite Step by Step

Here is the sequence I use to stand up evals on an agent that has none:

  1. Collect a golden dataset. Pull twenty to a hundred real inputs, ideally from actual usage or support tickets, and label each with an expected output or a clear pass condition. Cover your common cases and your known edge cases.
  2. Pick a scoring method per case. Use exact or structural match for deterministic outputs (a JSON field, a classification label), and LLM-as-judge with a written rubric for open-ended ones. For retrieval-heavy agents, also score whether the retrieved context actually contained the answer.
  3. Write the judge rubric carefully. A vague rubric gives noisy scores. Spell out what a good answer must contain and what disqualifies it, and prefer a small scale (pass or fail, or one to five) over false precision.
  4. Run and baseline. Run the suite, record the score, and treat that number as the line no change is allowed to cross downward without a decision.
  5. Gate deploys. Wire the suite into CI so a prompt, model, or tool change runs the evals and blocks on a regression.

Start small. A tight fifty-example suite that runs on every change beats a thousand-example suite that runs once and rots.

What to Measure, and the Traps to Avoid

Measure the dimensions that map to how your agent actually fails. Common ones: task success (did it accomplish the goal), factual grounding (is every claim supported by retrieved context), format correctness (valid structured output), tool-use accuracy (did it pick and call the right tool), and safety (did it refuse what it should refuse). For retrieval specifically, separate retrieval quality from answer quality, because an agent can answer correctly on lucky retrieval, or retrieve perfectly and still answer poorly, and you want to know which one broke.

Frequently Asked Questions

What is an eval in AI agents?

An eval is an automated test that runs an agent against a fixed dataset of inputs and scores each output against an expected result or rubric. Because model outputs vary, evals measure quality across many examples rather than asserting a single exact answer like a unit test.

What is LLM-as-judge?

LLM-as-judge uses a second model to grade an agent's output against a written rubric. It scales evaluation of open-ended answers that have no single correct string. It works well when the rubric is specific, but you should spot-check its scores by hand because judges can carry biases.

How many examples does a good eval set need?

Start with twenty to a hundred well-chosen examples covering common and edge cases. Quality and coverage matter far more than volume. A small suite that runs on every change catches more regressions than a large one that runs rarely.

Can I test agents with normal unit tests?

Unit tests still cover the deterministic parts, your tool functions, schema validation, and parsing. But the model's own behavior is non-deterministic and open-ended, so it needs evals. Use both: unit tests for the plumbing, evals for the model's output quality.

Set Up Evals on Your Own Agent

Evals are the difference between shipping agent changes on faith and shipping them on evidence. Once a suite gates your deploys, you can upgrade models, rewrite prompts, and refactor retrieval without holding your breath, because a regression shows up as a failing score instead of an angry user.

If you want to build an eval harness on your real agent rather than a sample, that is one of the things we do in my hands-on AI Agents for Engineers masterclass. It is private, one-on-one or with your own team, covering agent architecture, tools and function calling, memory and retrieval, orchestration, and evals and guardrails. It starts at $120 for a single private technical session, $420 for a four-session Engineering track, or $780 for a private team workshop.

Learn evals in the AI Agents for Engineers masterclass

Thanks for reading! I hope this was useful. If you have questions or thoughts, feel free to reach out.

Content Creation Process: This article was generated via a semi-automated workflow using AI tools. I prepared the strategic framework, including specific prompts and data sources. From there, the automation system conducted the research, analysis, and writing. The content passed through automated verification steps before being finalized and published without manual intervention.

Mahmoud Zalt

About the Author

I’m Zalt, a technologist with 16+ years of experience, passionate about designing and building AI systems that move us closer to a world where machines handle everything and humans reclaim wonder.

Let's connect if you're working on interesting AI projects, looking for technical advice or want to discuss anything.

Support this content

Share this article

Stay in touch

An occasional note when I build or write something new. Leave anytime.

Hire AI Employees

Hire AI Employees that work 24/7. No code.