You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7f3517e
Browse filesBrowse the repository at this point in the historyBrowse files
feat(eval): run each eval case N times in adk eval for steadier verdicts
**Problem:**
An agent can answer the same eval case differently from one run to the next,
so a single `adk eval` run can pass or fail by chance. `adk eval` had no way to
repeat eval cases, so users scripted external loops.
**Solution:**
- Add `EvalConfig.multi_run_config` (`MultiRunConfig`) and an `adk eval
--num_runs N` flag. The flag overrides `multi_run_config.num_runs`; if
neither is set, each eval case runs once.
- `InferenceConfig.num_runs` makes `LocalEvalService.perform_inference` run
each eval case N times under its existing parallelism limit, each run in a
fresh session. A session pinned by the eval case is not reused, and a
warning says so.
- Every run is kept. `InferenceResult` and `EvalCaseResult` gain
`repetition_index`, the 0-based index of the run, and all runs are saved to
the eval history. `AgentEvaluator` labels its runs the same way.
- `adk eval` judges each eval case on all of its runs. By default each
metric's per-invocation scores are pooled across runs and their mean is
compared to the threshold, which is how `AgentEvaluator` already judges
repeated runs; a run scored only as a whole counts once, with its overall
score. As in `AgentEvaluator`, whether higher or lower scores pass is
inferred from the evaluator's own verdicts. A run that crashed before it
could be scored is left out of every count, and fails the case unless
`max_crashed_runs` allows it.
- `multi_run_config` also chooses how the runs are combined. Each setting is
named for working across the runs of a case, which is all they do:
- `cross_run_scoring`, and `cross_run_scoring_by_metric` for individual
metrics, name a method that combines scores (`mean_over_invocations`, the
default, `mean_of_runs` or `min_over_runs`), judged against the metric's
threshold in `criteria`, or give a rule such as
`{"method": "pass_rate", "threshold": 0.9}` that counts the runs in which
the metric passed.
- `cross_run_criteria` adds such rules for the case as a whole. A run counts
as passed when it passed with every metric evaluated, and the case fails
if any criterion fails.
- `custom_methods` declares methods of your own: Python functions
referenced by `CodeConfig`, as custom metrics are, each with
`uses_scores` saying whether it combines scores or counts passing runs.
The rules name them as they name built-in methods. A method receives one
`RunResult` per run, now exported from `google.adk.evaluation`, and
returns a number or `None`. `adk eval` imports them before it runs any
eval case, so a path that does not import fails at once.
- A rule left without a value, for example because no run passed or
failed, is not evaluated and is skipped, and the output says why.
- `max_crashed_runs`, 0 by default, is how many crashed runs a case
tolerates. A crashed run has no verdict, so it is left out of every count
of passing runs, and a case whose runs all crashed never passes.
- With `--print_detailed_results`, each case's verdict across its runs is
printed first, with how many runs passed, each metric's method, value and
threshold, and each cross-run criterion. Each of its runs follows.
- With the default of one run and no rule that counts passing runs, verdicts
and detailed results print as before.
Co-authored-by: ftnext <[email protected]>
Co-authored-by: Haran Rajkumar <[email protected]>
Co-authored-by: Yi Liu <[email protected]>
PiperOrigin-RevId: 1005364760
0 commit comments