BeginnerCoder

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.

Want it another way?
Task

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.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.

Keep going with AI Agents Foundations

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.