adk-eval
Agent evaluation framework for Rust Agent Development Kit (ADK-Rust).
Stability: Stable — follows semantic versioning, so breaking changes wait for the next major release. See STABILITY.md.
Overview
adk-eval provides tools for testing and validating agent behavior. Unlike traditional software testing, agent evaluation must account for the probabilistic nature of LLMs while still providing meaningful quality signals.
Features
- Test Definitions: Structured JSON format for defining test cases (
.test.json) - Trajectory Evaluation: Validate tool call sequences with exact or partial matching
- Response Quality: Assess final output quality using multiple algorithms
- LLM-Judged Evaluation: Semantic matching, rubric-based scoring, and safety checks
- Multiple Criteria: Ground truth, similarity-based, and configurable thresholds
- Detailed Reporting: Per-case results, scores, and failure details
- Structured LLM Judge: Typed verdicts (pass/fail/partial) with scores and reasoning
- Rubric-Graded Outcomes:
OutcomeGradergrades a deliverable per criterion in a context of its own;RubricCheckAgentloops an agent until the rubric passes (default 3 attempts, at most 20), metered against the run budget - Embedding Similarity: Cosine similarity between embedding vectors (feature:
embedding) - Cost & Latency Tracking: Token usage extraction, dollar cost estimation, latency recording
- Trace Analysis: Detect redundant tool calls, execution loops, compute efficiency scores
- Regression Baselines: Save/load metric snapshots, detect quality degradation
- Vision: image fixtures pinned by SHA-256 and verified on load (
ImageFixture), andEvaluationCriteria::visionscoring regions, masks, OCR text, document fields, detections and click targets in source pixels against each turn'sexpected_vision(visionmodule) - Repeated Runs:
Evaluator::evaluate_test_file_runsruns an eval setnum_runstimes and reports each case's pass rate, score mean and sample variance, and flakiness (MultiRunReport); baselines from it carry apass_ratemetric - Metered Judging:
Evaluator::set_run_configputs every eval run and LLM-judge call under one budget, spend ledger and kill switch; a refusal stops the evaluation (EvalError::Refused) instead of failing cases - Online Evaluation:
online::OnlineEvaluatorjudges a seeded sample of finished production runs (filters by agent, request metadata and outcome) on a background worker with rubric, safety, hallucination, trajectory-efficiency and thread-level criteria, under its own budget and the kill switch; verdicts go to anOnlineEvalStore(in-memory or JSONL) and togen_ai.evaluation.resulttelemetry - Ledger Statistics: Median/MAD baselines per dimension and day class, warm-up, windowed deviation test, and drift runs with cooldowns over a content-free activity ledger (
ledger), also run ascargo adk eval --ledger - JUnit XML Output: CI-friendly report generation (feature:
ci-helpers) - Human Annotation: JSONL export/import workflow for human review
- A/B Comparison: Statistical significance testing with Wilcoxon signed-rank (feature:
statistics) - Web Experiments:
ExperimentAnalyzer— always-valid sequential tests with a fixed error budget for proportions and means, effect intervals, guardrail monitoring and a Bayesian option (feature:experiments) - Vertex AI Gen AI Evaluation Service: Service-backed judge and trajectory metrics via
evaluateInstances(feature:vertex-eval) - Test Case Generation: LLM-driven or event-based eval case creation
- Prompt Optimizer:
PromptOptimizer::optimize_candidatesiterates on an agent's instruction against an eval set, evaluating the agent built from each proposal (InstructionCandidates) - User Personas: simulated users for multi-turn evaluation (feature:
personas) - Conversation Metrics: Multi-turn scoring for context retention, goal completion, coherence, topic drift
- CI Integration: Eval sets run from integration tests or
cargo adk eval --agent-cmd, with JUnit XML and baseline regression checks;cargo adk eval --ledgergates on drift in an exported activity ledger
Quick Start
[]
= "3.0.0"
= "3.0.0"
= "3.0.0"
= { = "1", = ["full"] }
use Arc;
use LlmAgentBuilder;
use ;
use GeminiModel;
async
tests/geography.test.json:
Test File Format
A test file with an expected tool call:
The turns of a case run in order through one session of an in-memory session service, so each turn sees the history and state of the turns before it. The case's session_input sets the session's app_name, user_id (default eval_app and eval_user), and initial state.
Evaluation Criteria
Tool Trajectory Matching
Validates that the agent calls expected tools:
use ;
Arguments are compared recursively. With strict_args: false (the default), every expected key must be present with a matching value at any depth and extra keys are allowed; with strict_args: true, objects must have the same keys at every depth. Arrays match element by element, numbers compare by value (1 matches 1.0), and an expected tool use without args matches any arguments.
Response Similarity
Compare response text using various algorithms:
use SimilarityAlgorithm;
use ;
Available similarity algorithms:
Exact- Exact string matchContains- Substring checkLevenshtein- Edit distanceJaccard- Word overlap (default)Rouge1- Unigram overlapRouge2- Bigram overlapRougeL- Longest common subsequence
LLM-Judged Semantic Matching
Use an LLM to judge semantic equivalence between expected and actual responses:
use Arc;
use ;
use GeminiModel;
LlmJudgeConfig sets the judge's max_tokens and temperature; both default to None, which
leaves them to the provider, because Claude 5 and OpenAI reasoning models reject sampling
parameters. LlmJudge::with_config(model, config) applies them.
Rubric-Based Evaluation
Evaluate responses against custom rubrics:
use ;
Safety and Hallucination Detection
Check responses for safety issues and hallucinations:
use EvaluationCriteria;
An EQUIVALENT: NO, SAFE: NO, or HALLUCINATION_FREE: NO verdict fails the criterion regardless of its score, and a judge reply without the verdict line is a judge error.
Criteria That Cannot Be Judged
LLM-judged criteria fail the case with a score of 0.0, rather than being skipped, when no LLM judge is configured, the agent produced no text response, rubric_quality_score is set without rubrics, or the judge reply lacks a valid SCORE: line. A structured judge fail verdict also fails the case. A criterion's case score is the arithmetic mean of its per-turn scores, and an agent stream error fails the case with an execution failure.
Result Reporting
use Arc;
use Agent;
use Evaluator;
async
Batch Evaluation
Evaluate multiple test cases in parallel (results follow the order of cases; a concurrency of 0 or no cases is a ConfigError):
use Arc;
use Agent;
use ;
async
A case passes only when at least one criterion was evaluated and none failed: an empty test file, a case without turns, an evaluator without criteria, or a directory without *.test.json files returns EvalError::ConfigError, and a case no criterion applies to fails as not_evaluated. EvaluationReport::all_passed() is false for a report without results.
Repeated Runs
Run an eval set several times to separate reliable cases from lucky ones. Each case gets a fresh session every run; a case passes when it passes in at least min_pass_rate of the runs (every run by default):
use Arc;
use ;
use ;
async
When the budget, the spend ledger or a frozen kill switch refuses a run or a judge call, the runs stop: the report keeps the completed runs and says why in stopped. cargo adk eval --num-runs 3 --min-pass-rate 0.67 --judge-max-calls 50 does the same for an agent binary.
Online Evaluation
Judge a sample of production runs after they finish, without slowing them down. The evaluator's plugin samples runs on a Runner; a background worker judges them under the evaluator's own budget:
use Arc;
use ;
use EvaluationCriteria;
use ;
use PluginManager;
evaluator.store().list(&OnlineEvalQuery::default().failed_only()) returns the failed runs newest first. See the online evaluation guide.
Integration with cargo test
use Arc;
use LlmAgentBuilder;
use ;
use GeminiModel;
async
Advanced Features
Feature Flags
[]
= { = "3.0.0", = ["embedding", "ci-helpers", "statistics"] }
| Feature | Dependency | Capability |
|---|---|---|
embedding |
adk-memory |
Embedding-based semantic similarity |
ci-helpers |
quick-xml |
JUnit XML report generation |
statistics |
libm |
Wilcoxon signed-rank for A/B comparison |
vertex-eval |
adk-gcp, google-cloud-auth, reqwest |
Vertex AI Gen AI Evaluation Service bridge (VertexEvalClient, VertexEvalJudge) |
personas |
none | The personas module: simulated users for multi-turn evaluation |
experiments |
libm |
ExperimentAnalyzer: sequential analysis of web experiments with guardrails |
All other features (structured judge, cost tracker, trace analyzer, baselines, annotations, test generator, conversation scorer) work without extra feature flags.
The optional dependencies are not features of their own: enable vertex-eval, not adk-gcp,
google-cloud-auth, or reqwest. Through the adk-rust umbrella, its eval feature enables this
crate's personas, and its vertex-eval feature enables vertex-eval; adk-rust has no
personas feature.
Structured LLM Judge
use Arc;
use Llm;
use ;
async
Rubric-Graded Outcomes
A grader in a context of its own checks a deliverable against independently gradeable
criteria; RubricCheckAgent makes it the exit condition of a LoopAgent:
use Arc;
use ;
use ;
Each attempt's failed criteria and the grader's feedback reach the next attempt; the loop stops
once every criterion passes or after with_max_iterations graded attempts (3 by default, at most
20). The grading call counts against the run budget. OutcomeGrader grades once, outside a loop.
Cost and Latency Tracking
use CostTracker;
tracker.extract_metrics(&events, duration) returns token counts, cost_usd, and latency from a
run's events.
Execution Trace Analysis
use Event;
use TraceAnalyzer;
Regression Baselines
use HashMap;
use BaselineStore;
A baseline metric or case with no score in the new run, such as a case that errored, is a regression with current_value: None. A missing baseline file is an error rather than an empty result.
Vision
A turn shows the agent an image fixture by path and digest, and states what it must perceive
in expected_vision; the scores come from the agent's vision_detect, vision_segment,
vision_read and vision_describe responses.
| Scores | From |
|---|---|
region_iou, box_hit_rate, mask_iou |
Expected regions and masks |
detection_precision, detection_recall, detection_ap, detection_map |
COCO matching at iou_threshold |
ocr_char_accuracy, ocr_word_accuracy |
Expected page text |
field_exact_match, field_normalized_match |
Expected fields |
grounding_hit_rate, count_accuracy |
Click targets and the region count |
See Vision Evals.
Ledger Statistics
adk_eval::ledger compares the last 7 and 14 days of each dimension of an activity ledger with the median and MAD of the 28 days before them, per weekday and weekend class, and reports a deviation when |recent − median| > max(2.5 × MAD, floor) after a 14-day warm-up. Two deviating dimensions, or one for 10 days, are a meaningful drift. Everything is a pure function, with no I/O and no model.
use ;
cargo adk eval --ledger ledger.jsonl runs the same assessment as a CI gate; see the evaluation guide for the export format, the dimensions and their floors.
JUnit XML (CI Integration)
use ; // requires the ci-helpers feature
Human Annotation Workflow
use HashSet;
use ;
A/B Agent Comparison
use Arc;
use Agent;
use ; // requires the statistics feature
async
Web Experiments
ExperimentAnalyzer (feature experiments) analyses an experiment that splits visitors between a control and a variant, look by look, without spending more than its error budget however often it is consulted. Guardrails are checked first at every look; a proven harm beyond a guardrail's tolerance stops the experiment and keeps the control.
use ;
See Web Experiments for the method, its assumptions and the simulation results.
Auto-Generated Test Cases
use Arc;
use ;
use TestGenerator;
async
Multi-Turn Conversation Metrics
use Content;
use ;
async
Running Evaluations in CI
Run eval sets from an integration test, where the agent is constructed, and fail on case failures or baseline regressions. See "Running Evaluations in CI" in the evaluation guide for a complete test with JUnit XML output.
cargo adk eval runs an eval set against an agent binary that reads one JSON request per line on stdin ({"case_id","turn","user_text","session_id"}) and writes one JSON response per line on stdout ({"text","tool_calls":[{"name","args"}]} or {"error"}). It exits non-zero when a case fails or a score regresses:
See "Running an Agent Binary with cargo adk eval" in the evaluation guide for the protocol, flags, and an example agent binary.
License
Apache-2.0
Part of ADK-Rust
This crate is part of the ADK-Rust framework for building AI agents in Rust.