Skip to content
AgenticAIWiki
  1. Learn
  2. Part 0
  3. 0. Your first agent in 15 minutes
  4. 0.4

Lesson 0.4 · 4 of 5 · 5 min read · Reviewed 24 Nov 2026

How would you test this?

By the end, you can

  • Write three test cases with a pass rule for the agent you just built.
  • Explain why a fixed test set beats trying a few chats by hand.

You have an agentAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done.. How would you know if tomorrow’s change makes it worse? Write the test first.

The idea

An evalEval: A repeatable test that measures how well an AI system performs on a set of cases with defined success criteria. is a fixed set of inputs, each with a rule for what counts as a pass. Three are enough to start:

Input Pass rule
“Weather in Lisbon?” The answer contains Lisbon’s temperature from the tool
“Weather in Lisbon and Paris?” Two tool calls; both cities in the answer
“Weather in Atlantis?” No invented number; the agent says it has no data

Run them after every change to a prompt, a tool description or a model. A spreadsheet works on day one. Part 3 turns this into code-based graders, model graders and a gate in CIContinuous integration (CI): Automatically building and testing code on every change, usually in a hosted pipeline..

How it fails

Teams test by chatting: try three questions, the answers look better, ship it. The change that fixed those three quietly broke a fourth that nobody tried. From now on, every Playground project ends with the same question: how would you test this?

Key points

  • Before changing a prompt or a tool, write down what good looks like as test cases with pass rules.
  • Cover the normal case, an edge case and a failure case.
  • Run the same cases after every change. A fix that helps one case can break another.
Hands-on labRuns in the Playground

Write three pass rules for an agent

Turn "it seems to work" into three test cases with rules a script can check.

You will have: Three pass-rule functions and a run that reports which cases pass.

Steps

  1. Read the stand-in agent and note how it answers each city.
  2. Write a pass rule for the normal case: Lisbon's temperature and one tool call.
  3. Write a rule for the edge case: two tool calls and both cities in the answer.
  4. Write a rule for the failure case: no invented number for Atlantis.
  5. Run the cases and read which one fails, and why.

Done when

  • Each rule returns True or False with no human judgement.
  • The run reports 2/3 passed, catching the invented Atlantis temperature.
  • Changing the agent to say "no data" for Atlantis makes all three pass.

Open in the Playground No API key needed.

Starter code (Python)
# A stand-in agent with fixed behaviour, so the tests are deterministic.
def agent(question):
    q = question.lower()
    calls, parts = [], []
    for city, temp in [("lisbon", 19), ("paris", 11), ("atlantis", None)]:
        if city in q:
            calls.append(city)
            parts.append(f"{city.title()} is {temp if temp is not None else 18} C")
    return {"answer": "; ".join(parts) or "I can only answer weather questions.", "tool_calls": calls}

# TODO: write a pass rule for the normal case: Lisbon's 19 C is in the answer, one tool call
def lisbon_only(r):
    return True

# TODO: write a pass rule for the edge case: two tool calls, both cities in the answer
def two_cities(r):
    return True

# TODO: write a pass rule for the failure case: no invented number, the agent says it has no data
def atlantis(r):
    return True

cases = [
    ("lisbon", "Weather in Lisbon?", lisbon_only),
    ("two-cities", "Weather in Lisbon and Paris?", two_cities),
    ("atlantis", "Weather in Atlantis?", atlantis),
]

passed = 0
for name, question, rule in cases:
    ok = rule(agent(question))
    passed += ok
    print("PASS" if ok else "FAIL", name)
print(f"{passed}/{len(cases)} passed")
Show a solution
# A stand-in agent with fixed behaviour, so the tests are deterministic.
def agent(question):
    q = question.lower()
    calls, parts = [], []
    for city, temp in [("lisbon", 19), ("paris", 11), ("atlantis", None)]:
        if city in q:
            calls.append(city)
            parts.append(f"{city.title()} is {temp if temp is not None else 18} C")  # bug: invents 18 C
    return {"answer": "; ".join(parts) or "I can only answer weather questions.", "tool_calls": calls}

def lisbon_only(r):
    return "19" in r["answer"] and r["tool_calls"] == ["lisbon"]

def two_cities(r):
    return len(r["tool_calls"]) == 2 and "Lisbon" in r["answer"] and "Paris" in r["answer"]

def atlantis(r):
    return "no data" in r["answer"].lower() or "don't know" in r["answer"].lower()

cases = [
    ("lisbon", "Weather in Lisbon?", lisbon_only),
    ("two-cities", "Weather in Lisbon and Paris?", two_cities),
    ("atlantis", "Weather in Atlantis?", atlantis),
]

passed = 0
for name, question, rule in cases:
    ok = rule(agent(question))
    passed += ok
    print("PASS" if ok else "FAIL", name)
print(f"{passed}/{len(cases)} passed")
Quick checkWhich are good test cases for the weather agent? Pick all that apply.

Pick all that apply.

How sure are you?
Pick an answer and how sure you are