|
| 1 | +# Basic evaluation criteria |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Evaluates the shared home-automation agent with the two deterministic, |
| 6 | +reference-based criteria: |
| 7 | + |
| 8 | +- `tool_trajectory_avg_score`: does the agent call the right tools with the |
| 9 | + right args? Each expected tool call (name + args) is compared against what the |
| 10 | + agent actually did. |
| 11 | +- `response_match_score`: ROUGE-1 word overlap between the agent's final |
| 12 | + response and a reference answer. |
| 13 | + |
| 14 | +Both criteria are computed locally with no judge model, so this sample needs only |
| 15 | +a model credential for the agent's own inference (a Gemini API key or Vertex). |
| 16 | + |
| 17 | +## Sample Inputs |
| 18 | + |
| 19 | +The eval set (`home_automation.evalset.json`) contains two single-turn cases: |
| 20 | + |
| 21 | +- `Turn off device_2.` |
| 22 | +- `What is the temperature in the Living Room?` |
| 23 | + |
| 24 | +## How To |
| 25 | + |
| 26 | +Run the sample from the workspace root: |
| 27 | + |
| 28 | +```bash |
| 29 | +adk eval contributing/samples/evaluation/home_automation_agent \ |
| 30 | + contributing/samples/evaluation/basic_criteria/home_automation.evalset.json \ |
| 31 | + --config_file_path contributing/samples/evaluation/basic_criteria/eval_config.json \ |
| 32 | + --print_detailed_results |
| 33 | +``` |
| 34 | + |
| 35 | +`adk eval` takes the agent folder and the eval-set file as two separate |
| 36 | +arguments, so this folder holds only eval data (`home_automation.evalset.json`), |
| 37 | +the criteria config (`eval_config.json`), and this README, with no agent code. |
| 38 | + |
| 39 | +### `match_type` for tool trajectory |
| 40 | + |
| 41 | +`tool_trajectory_avg_score` has a `match_type` (set to `EXACT` here in |
| 42 | +`eval_config.json`) that controls how the expected and actual tool calls are |
| 43 | +compared: |
| 44 | + |
| 45 | +- `EXACT`: the actual tool calls must match the expected calls one-for-one, in |
| 46 | + the same order, with identical args. Use this when the trajectory is fully |
| 47 | + deterministic (as in this sample). |
| 48 | +- `IN_ORDER`: the expected calls must appear in the given order, but extra |
| 49 | + actual calls in between are tolerated. Useful when the agent may take |
| 50 | + additional, harmless steps. |
| 51 | +- `ANY_ORDER`: the expected calls must all appear, but order does not matter. |
| 52 | + Useful when the agent may reorder independent tool calls. |
| 53 | + |
| 54 | +The `threshold` is `1.0`, so every expected call must match for the case to pass. |
| 55 | + |
| 56 | +### Why `response_match_score` uses a `0.6` threshold |
| 57 | + |
| 58 | +`adk eval` runs live inference, so the exact wording of the agent's final |
| 59 | +response varies from run to run (for example, "I have turned off device_2." vs |
| 60 | +"device_2 has been switched off."). `response_match_score` is a ROUGE-1 score, |
| 61 | +which measures word overlap rather than exact-string equality, so it tolerates |
| 62 | +this phrasing variation. The `0.6` threshold requires the response to share most |
| 63 | +of its wording with the reference while still allowing some rewording. Raise it |
| 64 | +toward `1.0` for stricter wording, lower it to tolerate more paraphrasing. |
| 65 | + |
| 66 | +### Expectations captured from a real run |
| 67 | + |
| 68 | +The expected `tool_uses` (tool names and args) in `home_automation.evalset.json` |
| 69 | +were captured from an actual `adk eval` run of the agent: run with |
| 70 | +`--print_detailed_results`, read the printed Actual-vs-Expected, then set the |
| 71 | +expected values to match what the agent really produced. The reference |
| 72 | +`final_response` for each case is an independently written natural answer (not a |
| 73 | +copy of the model output), which is exactly what ROUGE-1 is designed to tolerate. |
| 74 | + |
| 75 | +## Related Guides |
| 76 | + |
| 77 | +- Evaluation overview: https://adk.dev/evaluate/ |
| 78 | +- Evaluation criteria reference: https://adk.dev/evaluate/criteria/ |
0 commit comments