Skip to content

Commit 7e15976

Browse files
authored
feat: Add Conformance evaluation docs (#1813)
* Update index.md 1. Updated the evaluation page, added the 4th evaluation "adk conformance", 2. removed numbering in headers as suggested, 3. improved the "notes" and "warnings" that had an incorrect formatting. * Update index.md * Update index.md worked on all your comments * Update index.md
1 parent 3267035 commit 7e15976

1 file changed

Lines changed: 128 additions & 22 deletions

File tree

docs/evaluate/index.md

Lines changed: 128 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Why Evaluate Agents
1+
# Why evaluate agents
22

33
<div class="language-support-tag">
44
<span class="lst-supported">Supported in ADK</span><span class="lst-python">Python</span>
@@ -12,7 +12,7 @@ This may seem like a lot of extra work to set up, but the investment of automati
1212

1313
![intro_components.png](../assets/evaluate_agent.png)
1414

15-
## Preparing for Agent Evaluations
15+
## Prepare for agent evaluations
1616

1717
Before automating agent evaluations, define clear objectives and success criteria:
1818

@@ -22,16 +22,16 @@ Before automating agent evaluations, define clear objectives and success criteri
2222

2323
These considerations will guide the creation of evaluation scenarios and enable effective monitoring of agent behavior in real-world deployments.
2424

25-
## What to Evaluate?
25+
## What to evaluate?
2626

2727
To bridge the gap between a proof-of-concept and a production-ready AI agent, a robust and automated evaluation framework is essential. Unlike evaluating generative models, where the focus is primarily on the final output, agent evaluation requires a deeper understanding of the decision-making process. Agent evaluation can be broken down into two components:
2828

29-
1. **Evaluating Trajectory and Tool Use:** Analyzing the steps an agent takes to reach a solution, including its choice of tools, strategies, and the efficiency of its approach.
30-
2. **Evaluating the Final Response:** Assessing the quality, relevance, and correctness of the agent's final output.
29+
1. **Evaluate Trajectory and Tool Use:** Analyzing the steps an agent takes to reach a solution, including its choice of tools, strategies, and the efficiency of its approach.
30+
2. **Evaluate the Final Response:** Assessing the quality, relevance, and correctness of the agent's final output.
3131

3232
The trajectory is just a list of steps the agent took before it returned to the user. We can compare that against the list of steps we expect the agent to have taken.
3333

34-
### Evaluating trajectory and tool use
34+
### Evaluate trajectory and tool use
3535

3636
Before responding to a user, an agent typically performs a series of actions, which we refer to as a 'trajectory.' It might compare the user input with session history to disambiguate a term, or lookup a policy document, search a knowledge base or invoke an API to save a ticket. We call this a ‘trajectory’ of actions. Evaluating an agent's performance requires comparing its actual trajectory to an expected, or ideal, one. This comparison can reveal errors and inefficiencies in the agent's process. The expected trajectory represents the ground truth \-- the list of steps we anticipate the agent should take.
3737

@@ -45,11 +45,11 @@ actual_steps = ["determine_intent", "use_tool", "review_results", "report_genera
4545

4646
ADK provides both groundtruth based and rubric based tool use evaluation metrics. To select the appropriate metric for your agent's specific requirements and goals, please refer to our [recommendations](#recommendations-on-criteria).
4747

48-
## How Evaluation works with the ADK
48+
## How evaluation works with ADK
4949

50-
The ADK offers two methods for evaluating agent performance against predefined datasets and evaluation criteria. While conceptually similar, they differ in the amount of data they can process, which typically dictates the appropriate use case for each.
50+
ADK offers two methods for evaluating agent performance against predefined datasets and evaluation criteria. While conceptually similar, they differ in the amount of data they can process, which typically dictates the appropriate use case for each.
5151

52-
### First approach: Using a test file
52+
### Evaluate with test files
5353

5454
This approach involves creating individual test files, each representing a single, simple agent-model interaction (a session). It's most effective during active agent development, serving as a form of unit testing. These tests are designed for rapid execution and should focus on simple session complexity. Each test file contains a single session, which may consist of multiple turns. A turn represents a single interaction between the user and the agent. Each turn includes
5555

@@ -70,7 +70,8 @@ You can give the file any name for example `evaluation.test.json`. The framework
7070
[Eval Case](https://github.com/google/adk-python/blob/main/src/google/adk/evaluation/eval_case.py).
7171
Here is a test file with a few examples:
7272

73-
*(Note: Comments are included for explanatory purposes and should be removed for the JSON to be valid.)*
73+
!!! note
74+
Comments are included for explanatory purposes and should be removed for the JSON to be valid.
7475

7576
```json
7677
# Do note that some fields are removed for sake of making this doc readable.
@@ -129,7 +130,8 @@ Test files can be organized into folders. Optionally, a folder can also include
129130

130131
#### How to migrate test files not backed by the Pydantic schema?
131132

132-
NOTE: If your test files don't adhere to [EvalSet](https://github.com/google/adk-python/blob/main/src/google/adk/evaluation/eval_set.py) schema file, then this section is relevant to you.
133+
!!! note
134+
If your test files don't adhere to [EvalSet](https://github.com/google/adk-python/blob/main/src/google/adk/evaluation/eval_set.py) schema file, then this section is relevant to you.
133135

134136
Please use `AgentEvaluator.migrate_eval_data_to_new_schema` to migrate your
135137
existing `*.test.json` files to the Pydantic backed schema.
@@ -139,7 +141,7 @@ file, and generates a single output json file with data serialized in the new
139141
format. Given that the new schema is more cohesive, both the old test data file
140142
and initial session file can be ignored (or removed.)
141143

142-
### Second approach: Using An Evalset File
144+
### Evaluate with an Evalset File
143145

144146
The evalset approach utilizes a dedicated dataset called an "evalset" for evaluating agent-model interactions. Similar to a test file, the evalset contains example interactions. However, an evalset can contain multiple, potentially lengthy sessions, making it ideal for simulating complex, multi-turn conversations. Due to its ability to represent complex sessions, the evalset is well-suited for integration tests. These tests are typically run less frequently than unit tests due to their more extensive nature.
145147

@@ -153,7 +155,8 @@ Creating evalsets manually can be complex, therefore UI tools are provided to he
153155
This evalset evaluation method requires the use of a paid service,
154156
[Vertex Gen AI Evaluation Service API](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/evaluation).
155157

156-
*(Note: Comments are included for explanatory purposes and should be removed for the JSON to be valid.)*
158+
!!! note
159+
Comments are included for explanatory purposes and should be removed for the JSON to be valid.
157160

158161
```json
159162
# Do note that some fields are removed for sake of making this doc readable.
@@ -291,7 +294,8 @@ Creating evalsets manually can be complex, therefore UI tools are provided to he
291294

292295
#### How to migrate eval set files not backed by the Pydantic schema?
293296

294-
NOTE: If your eval set files don't adhere to [EvalSet](https://github.com/google/adk-python/blob/main/src/google/adk/evaluation/eval_set.py) schema file, then this section is relevant to you.
297+
!!! note
298+
If your eval set files don't adhere to [EvalSet](https://github.com/google/adk-python/blob/main/src/google/adk/evaluation/eval_set.py) schema file, then this section is relevant to you.
295299

296300
Based on who is maintaining the eval set data, there are two routes:
297301

@@ -302,6 +306,69 @@ Based on who is maintaining the eval set data, there are two routes:
302306
migration tool is in the works, until then the ADK eval CLI command will
303307
continue to support data in the old format.
304308

309+
### Evaluate with conformance testing
310+
311+
`adk conformance test` command verifies that your AI agents behave consistently over time. It ensures that updates to your codebase or models don't introduce regressions by validating current agent outputs against baseline data.
312+
313+
#### Prerequisites and setup
314+
315+
Before the `adk conformance` command can execute meaningful regression testing, you must establish an optimal "golden baseline." Conformance testing operates by comparing live agent behavior against these previously recorded, verified interactions.
316+
317+
Follow this workflow to prepare your environment:
318+
##### Create the Test Directory Hierarchy
319+
320+
Conformance tests rely on a strict file layout to automatically discover and map test cases.
321+
Initialize your testing directory using the following structure:
322+
323+
```
324+
tests
325+
└── category_name/
326+
└── test_case_name/
327+
├── spec.yaml # Test case specification
328+
├── generated-recordings.yaml # Baseline recorded interactions
329+
└── generated-session.yaml # Baseline session data
330+
331+
```
332+
333+
!!! note
334+
If your agent uses Server-Sent Events (SSE), the testing framework will additionally look for `generated-recordings-sse.yaml` and `generated-session-sse.yaml` within the same folder.
335+
336+
##### Define the test specification (spec.yaml)
337+
338+
In your target test folder, create a `spec.yaml` file. This file outlines the initial conditions, configurations, and user prompts that the agent will execute during the baseline recording and subsequent conformance runs. Ensure your file matches the following basic schema, this is an example only:
339+
340+
```
341+
# Example spec.yaml for a Weather Agent name: "current_weather_check" description:
342+
"Verifies the agent correctly identifies location and calls the weather tool."
343+
user_prompts: - "What's the temperature in San Francisco right now?" expected_tools:
344+
- "get_weather_api"
345+
```
346+
347+
#### Automate the baseline
348+
349+
Because the background data (like LLM requests and tool calls) is complex, you shouldn't try to write or save the baseline files manually. Instead, let ADK generate them for you.
350+
351+
1. Start your ADK web server with the recording plugin turned on:
352+
353+
```shell
354+
adk web -v --extra_plugins=google.adk.cli.plugins.recordings_plugin.RecordingsPlugin /path/to/agents
355+
```
356+
357+
2. Next, open a new terminal window and tell ADK to create the baseline files based on your spec.yaml:
358+
359+
```shell
360+
adk conformance create tests/category/test_name
361+
```
362+
363+
This automatically runs the scenario, records all the interactions, and saves the generated-recordings.yaml and generated-session.yaml files exactly where they need to be.
364+
365+
Once these baseline files are locked in, your setup is complete, and the directory is ready to be targeted by `adk conformance` in either **Replay** or **Live** mode.
366+
367+
#### How it works
368+
369+
* **Replay Mode (Default):** The tool runs your agent and compares its live LLM requests, responses, and tool calls directly against your previously recorded interactions to catch unexpected deviations.
370+
* **Live Mode:** Runs evaluation-based verification against active environments *(Note: This mode is a work in progress)*.
371+
305372
### Evaluation Criteria
306373

307374
ADK provides several built-in criteria for evaluating agent performance, ranging
@@ -398,15 +465,16 @@ generated by an AI model.
398465
For details on how to set up an eval with user simulation, see
399466
[User Simulation](./user-sim.md).
400467

401-
## How to run Evaluation with the ADK
468+
## How to run Evaluation with ADK
402469

403470
As a developer, you can evaluate your agents using the ADK in the following ways:
404471

405-
1. **Web-based UI (**`adk web`**):** Evaluate agents interactively through a web-based interface.
406-
2. **Programmatically (**`pytest`**)**: Integrate evaluation into your testing pipeline using `pytest` and test files.
407-
3. **Command Line Interface (**`adk eval`**):** Run evaluations on an existing evaluation set file directly from the command line.
472+
- **Web-based UI (**`adk web`**):** Evaluate agents interactively through a web-based interface.
473+
- **Programmatically (**`pytest`**)**: Integrate evaluation into your testing pipeline using `pytest` and test files.
474+
- **Command Line Interface (**`adk eval`**):** Run evaluations on an existing evaluation set file directly from the command line.
475+
- **Conformance Testing** (**`adk conformance`**):** Execute automated tests against your baseline files to detect unexpected deviations or regressions.
408476

409-
### 1\. `adk web` \- Run Evaluations via the Web UI
477+
### Run Evaluations via the Web UI
410478

411479
The web UI provides an interactive way to evaluate agents, generate evaluation datasets, and inspect agent behavior in detail.
412480

@@ -447,7 +515,7 @@ After the run completes, you can analyze the results:
447515

448516
### Debugging with the Trace View
449517

450-
The ADK web UI includes a powerful **Trace** tab for debugging agent behavior. This feature is available for any agent session, not just during evaluation.
518+
ADK web UI includes a powerful **Trace** tab for debugging agent behavior. This feature is available for any agent session, not just during evaluation.
451519

452520
The **Trace** tab provides a detailed and interactive way to inspect your agent's execution flow. Traces are automatically grouped by user message, making it easy to follow the chain of events.
453521

@@ -465,7 +533,7 @@ Each trace row is interactive:
465533

466534
Blue rows in the trace view indicate that an event was generated from that interaction. Clicking on these blue rows will open the bottom event detail panel, providing deeper insights into the agent's execution flow.
467535

468-
### 2\. `pytest` \- Run Tests Programmatically
536+
### Run Tests Programmatically
469537

470538
You can also use **`pytest`** to run test files as part of your integration tests.
471539

@@ -494,7 +562,7 @@ async def test_with_single_test_file():
494562

495563
This approach allows you to integrate agent evaluations into your CI/CD pipelines or larger test suites. If you want to specify the initial session state for your tests, you can do that by storing the session details in a file and passing that to `AgentEvaluator.evaluate` method.
496564

497-
### 3\. `adk eval` \- Run Evaluations via the CLI
565+
### Run Evaluations via the CLI
498566

499567
You can also run evaluation of an eval set file through the command line interface (CLI). This runs the same evaluation that runs on the UI, but it helps with automation, i.e. you can add this command as a part of your regular build generation and verification process.
500568

@@ -524,3 +592,41 @@ Here are the details for each command line argument:
524592
`This will only run eval_1, eval_2 and eval_3 from sample_eval_set_file.json`
525593
* `CONFIG_FILE_PATH`: The path to the config file.
526594
* `PRINT_DETAILED_RESULTS`: Prints detailed results on the console.
595+
596+
### Run conformance tests
597+
598+
You can run all your tests at once, run specific ones, or create a summary report.
599+
600+
#### Run All Tests
601+
602+
If you don't type a specific folder path, the tool automatically looks for a tests/ folder in your workspace and runs everything inside it:
603+
604+
```
605+
adk conformance test
606+
```
607+
608+
#### Run Specific Test Groups or Individual Cases
609+
610+
Pass one or more folder paths to narrow down which tests execute:
611+
612+
```
613+
614+
# Test an entire category of tests
615+
adk conformance test tests/core
616+
617+
# Test one specific case
618+
adk conformance test tests/core/description_001
619+
620+
```
621+
622+
#### Generate Markdown Test Reports
623+
624+
Add the `--generate_report` flag to produce a clean test summary report. You can optionally specify where to save it using the `--report_dir parameter`:
625+
626+
```
627+
# Save the report in a specific folder
628+
adk conformance test --generate_report --report_dir=reports
629+
```
630+
631+
#### Automating with CI/CD
632+
Because adk conformance test is a command-line tool that fails if things don't match, it is highly useful for CI/CD pipelines. You can set it up to run automatically whenever someone opens a pull request, blocking any code from merging if it changes the agent's expected behavior.

0 commit comments

Comments
 (0)