Skip to content
Visual explainer 3h to learn 5 steps

Build an evaluation dataset for an ADK agent

Write representative cases for answer correctness, grounding, escalation, denied tools, state isolation and fallback.

By Invicly Tech, , in Google ADK with Python for AI Agents. About 11 minutes to read.

Topic 19 of 29

In short

An evaluation dataset is a set of saved conversations that say what the agent should answer and which tools it should call. ADK stores them as eval sets: JSON files of eval cases, each with one or more turns, the expected tool uses and a reference answer. A good set covers the main user intents plus the awkward cases: grounding, escalation, denied tools, isolation between users and fallback when something fails.

Think of it like this: An eval set is the exam paper you write before teaching, so you can tell later whether the student really learned or just got lucky.

Explained simply

When you change a prompt, a tool or a model, you need a quick way to know whether the agent still behaves. Chatting with it for five minutes is not enough: you will forget the tricky cases. An evaluation dataset is a list of saved test conversations, each with the answer you expect and the tools you expect the agent to use.

ADK calls one saved conversation an eval case and a file of them an eval set. Each case has an ID, one or more turns, and for each turn the user's message, the expected tool calls and a reference answer. A case can also set the starting session: which app, which user and what is already in state.

Start with what users really ask: ticket status, how-to questions answered from the docs, plan questions. Then add cases for the rules: cite a source, say I do not know for unknown topics, hand over to a human when asked, refuse tools the agent does not have, never show one user another user's data, and fail politely when a tool breaks.

Keep the data fake. Use mock ticket IDs such as T-1001, made-up users like user-a and addresses at example.com. Store the eval files in Git beside the agent so every change can be checked against the same exam.

Press Play on a diagram to walk through it one step at a time.

MapWhat a support agent eval set should cover
Eval set: support_core
  • Main intents
    • Ticket status by ID
    • How-to question from docs
    • Plan and pricing question
  • Grounding
    • Answer cites a doc source ID
    • Unknown topic: says it does not know
  • Escalation
    • Angry or urgent user
    • Request outside scope
  • Denied tools
    • Asks to close a ticket
    • Asks for another user's ticket
  • Isolation and fallback
    • User B cannot see user A's state
    • Ticket tool times out
CycleHow an eval set grows
  1. 1
    List behaviours

    Intents and rules from the agent contract

  2. 2
    Write cases

    Two or three per behaviour

  3. 3
    Run and review

    Fix the agent or fix a wrong expectation

  4. 4
    Capture failures

    Each bug becomes a new case

  5. Back to step 1

In depth

The shape of an eval case

ADK's eval files follow two Pydantic schemas, EvalSet and EvalCase. An EvalSet has an eval_set_id, an optional name and description, and a list of eval_cases. Each EvalCase has an eval_id, a conversation and an optional session_input. Each turn in the conversation has an invocation_id, user_content, final_response and intermediate_data. The content fields use the same role and parts shape as the Gemini API, and intermediate_data lists tool_uses with a name and args.

ADK accepts two layouts. A file ending in .test.json holds one session and suits small, unit-style checks that live next to the code. An .evalset.json file holds many cases, each its own session, and suits larger suites. You can create cases by hand, or chat with the agent in adk web, open the Eval tab and click Add current session to save it, then edit the expected values.

  • EvalSet: eval_set_id, name, description, eval_cases
  • EvalCase: eval_id, conversation, session_input
  • Turn: invocation_id, user_content, final_response, intermediate_data
  • session_input: app_name, user_id, state

A coverage matrix before you write cases

Write the list of behaviours first, then the cases. A small table with behaviours as rows and case IDs as columns stops you from writing ten status questions and no escalation tests. For a read-only support agent, five rows are enough to start: answer correctness, grounding with source IDs, escalation, denied tools and isolation with fallback.

Aim for two or three cases per row at first, about 15 cases in all. That is small enough to review by hand and big enough to catch most regressions. Grow the set from real failures: every bug you fix becomes a new case, so it cannot come back unnoticed.

CompareBehaviour rows and what each case asserts
Correctness and grounding
  • Expected tool and args
  • Answer names the right status
  • Answer includes a doc source ID
  • Unknown topic gets I do not know
Escalation and denial
  • Human requested: escalation message
  • Close ticket: polite refusal
  • No write tool is ever called
  • Stop after the refusal
Isolation and fallback
  • user-b asks for user-a's ticket
  • No ticket data in the answer
  • Tool timeout: apology and retry advice
  • No invented status

Testing isolation with session_input

Isolation bugs are the most serious ones for a support agent, so test them directly. session_input lets each case start as a specific user with specific state. Give user-a a ticket T-1001 in your mock data and start a case as user-b asking about T-1001. The expected tool use is either none or a lookup that returns not found, and the reference answer is a refusal that reveals nothing.

Add a second case that starts with state left over from a previous turn, for example a remembered ticket ID, and check that a new session for another user does not see it. These cases catch mistakes such as storing data under app: or global keys instead of user-scoped ones.

Fixed turns or simulated users

Fixed turns are predictable: the same user message every time. Some behaviour only shows up over several turns, such as a user who changes their mind or gets frustrated. ADK's user simulation (supported since ADK Python 1.18) replaces fixed messages with a model that plays the user. You give a conversation_scenario with a starting_prompt and a conversation_plan, and optionally a user_persona such as NOVICE or EXPERT.

The simulator is itself a model, so it needs a model key and its runs vary. Use it for exploration and scheduled checks, not for the commit gate. Cap the length with max_allowed_invocations (default 20) so a confused simulator cannot run up costs.

  • starting_prompt: the fixed opening message
  • conversation_plan: goals the simulated user pursues
  • user_persona: built-in NOVICE, EXPERT or EVALUATOR, or custom
  • user_simulator_config.max_allowed_invocations caps turns

Learn it in 5 short steps

About 35m each. Track them with a timer in your plan.

  1. 1
    Cover the main user intents~35m
  2. 2
    Add grounding and citation cases~35m
  3. 3
    Add escalation and denied-tool cases~35m
  4. 4
    Add isolation and fallback cases~35m
  5. 5
    Store cases as eval sets~35m

Key points

  • An eval case holds a conversation: user input, expected tool uses and a reference final response per turn.
  • session_input sets the app name, user ID and starting state, which is how you test per-user isolation.
  • Write cases from real intents first, then add one or two cases for every rule the agent must follow.
  • Use synthetic data only: mock ticket IDs such as T-1001 and example.com addresses.
  • Store eval sets in Git next to the agent so every change to the agent can be checked against them.

Key terms

Tap a card to flip it. 0/6 known

Examples

json
{
  "eval_set_id": "support_core",
  "eval_cases": [{
    "eval_id": "ticket_status_basic",
    "session_input": {"app_name": "support_agent", "user_id": "user-a", "state": {}},
    "conversation": [{
      "invocation_id": "turn-1",
      "user_content": {"role": "user", "parts": [{"text": "Status of T-1001?"}]},
      "final_response": {"role": "model", "parts": [{"text": "Ticket T-1001 is open."}]},
      "intermediate_data": {"tool_uses": [
        {"name": "get_ticket_status", "args": {"ticket_id": "T-1001"}}]}
    }]
  }]
}

One eval case with an expected tool call and a reference answer.

A denied-tool case for a read-only agent

The agent has only get_ticket_status and search_docs. A user asks it to close a ticket. Step 1: write the user message. Step 2: expect no tool calls at all, so tool_uses is an empty list. Step 3: write a short reference answer that refuses and offers the human route. Step 4: run it. If the agent calls get_ticket_status first, decide whether that is acceptable; if so, add that call to the expectation or use a looser match type in the next topic.

json
{
  "eval_id": "deny_close_ticket",
  "session_input": {"app_name": "support_agent", "user_id": "user-a", "state": {}},
  "conversation": [{
    "invocation_id": "turn-1",
    "user_content": {"role": "user", "parts": [{"text": "Please close T-1001."}]},
    "final_response": {"role": "model", "parts": [{"text":
      "I can't close tickets. I can connect you with a support agent."}]},
    "intermediate_data": {"tool_uses": []}
  }]
}

Saving a real session as a case from adk web

Step 1: run adk web from the folder that holds your agent package. Step 2: chat with the agent as a test user and ask about T-1002. Step 3: open the Eval tab, create an eval set called support_core and click Add current session. Step 4: open the saved file under the agent folder and edit the reference answer to the wording you want, keeping the tool use. Step 5: run it with adk eval and the print_detailed_results flag to see each score.

bash
adk web .                      # open http://localhost:8000
# Eval tab -> create set support_core -> Add current session
adk eval support_agent support_agent/support_core.evalset.json \
  --print_detailed_results

Quick reference

  • Eval set: many cases, each its own session; .test.json file: one session for unit-style checks
  • Case fields: eval_id, conversation, session_input (app_name, user_id, state)
  • Turn fields: user_content, final_response, intermediate_data.tool_uses
  • Run selected cases: adk eval agent_dir set.evalset.json:case_1,case_2
  • Cover: intents, grounding, escalation, denied tools, isolation, fallback
  • Synthetic data only: T-1001, user-a, support@example.com
  • Every fixed bug becomes a new eval case

Common mistakes

  • Only testing happy paths, so a prompt change that breaks escalation or refusals passes every check.
  • Copying real customer conversations into eval files; use synthetic tickets and redacted text instead.
  • Writing reference answers so long and specific that a correct but differently worded reply fails.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1Which field sets the user ID a case starts as?

Question 2

2A read-only agent is asked to delete a ticket. What should the expected tool_uses be?

Question 3

3Why should user simulation stay out of the per-commit gate?

Question 4

4What is the best source of new eval cases once the agent is in use?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Write a coverage matrix for a read-only support agent with five behaviour rows and at least two case IDs per row.

  2. Exercise 2medium

    Write an eval case where user-b asks for T-1001, which belongs to user-a in the mock data. The agent must reveal nothing.

  3. Exercise 3hard

    Design a fallback case for a ticket tool that times out, and say how the fixture makes the timeout happen deterministically.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

How many eval cases do I need?
Start with about 15 that cover every behaviour row two or three times. Grow the set from real bugs rather than writing hundreds up front.
Should I use .test.json or .evalset.json files?
Use .test.json for small, single-session checks kept next to the code, and eval sets for larger suites with many independent sessions. Both use the same EvalCase schema.
Can I build cases from production chats?
Only after removing personal data, and synthetic cases are safer. Rewrite the pattern of the conversation with mock IDs and example.com addresses instead of copying text.
My old eval files no longer load. What changed?
Older files used a different format. ADK provides AgentEvaluator.migrate_eval_data_to_new_schema to convert them to the current EvalSet schema.

Go deeper

ShareXLinkedInWhatsApp