Lesson 23 — Evaluating an agent with test cases
How do you know it works?
An eval (evaluation) is a list of test cases: an input and what a good answer must contain. You run the agent on every case and count the passes. This gives you a score like 4/5.
Real model answers vary in wording, so evals usually check that the answer contains the key fact ("Paris" in answer) rather than matching it word for word.
Run the evals every time you change a prompt, a tool or the model. If the score drops, you broke something.
Watch out: when a case fails, fix the agent — not the test. The Tokyo case below fails on purpose: it shows you what to improve next.
Why it matters: without evals, "it seems to work" is a guess. With evals, it is a number you can track.
Fill in the check: ok is True when the expected text appears inside answer, and passed grows by 1 for every passing case.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based AI Agents Foundations courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for AI Agents Foundations books — check the publication year so the examples match current versions.
Search Amazon →