Expand description
Evaluations for Rig agents.
An Experiment runs a Target (a Rig agent, an async function, or,
with the multiagent feature, a swarm or graph) on every Case of a
Dataset, scores each run with Evaluators, and hands the
Report to Sinks.
use rig_evals::{Dataset, Experiment, JunitFile, evaluators};
async fn run(agent: rig_agent::Agent) -> Result<(), Box<dyn std::error::Error>> {
let report = Experiment::new("support-bot")
.dataset(Dataset::load("evals/cases.jsonl")?)
.target(agent)
.evaluator(evaluators::contains("refund"))
.evaluator(evaluators::no_error())
.repetitions(3)
.threshold("contains", 0.8)
.sink(JunitFile::new("target/evals/junit.xml"))
.run()
.await?;
std::process::exit(if report.passed() { 0 } else { 1 });
}A dataset is a .jsonl file (one case per line) or a .json array. A case
has an id and either an input (one prompt) or turns (a conversation).
expected, trajectory (name and optional args per tool call),
assertions and metadata are optional references. A three-case file:
{"id": "refund", "input": "Order 7 arrived broken.", "expected": "A refund was issued.", "trajectory": [{"name": "lookup_order", "args": {"id": 7}}, {"name": "refund"}], "assertions": ["apologizes"]}
{"id": "hours", "input": "What are your opening hours?", "expected": "We are open 9 to 5.", "assertions": ["gives the hours"]}
{"id": "city", "turns": ["My favourite city is Lisbon.", "What is my favourite city?"], "expected": "Lisbon"}With the agentcore feature, AgentCore makes a runtime on AWS Bedrock
AgentCore a target, and AgentCore Evaluations’ evaluators evaluators.
Each run is a tracing span eval.trial inside an eval.experiment span,
and each score an OpenTelemetry GenAI gen_ai.evaluation.result event on
it, so a tracing exporter (such as rig-otel) puts the results on the
evaluated agent’s trace. The agent’s prompts and replies reach that trace
only when it records content, with AgentBuilder::record_content_telemetry(true).
A score’s explanation (the judge’s text) is recorded only with
Experiment::record_content(true).
Re-exports§
Modules§
- evaluators
- The built-in evaluators.
Structs§
- Agent
Core agentcore - The AWS clients AgentCore targets and evaluators share, and the spans downloaded so far, so several evaluators of one run download them once.
- Agent
Core Evaluator agentcore - An AgentCore Evaluations evaluator; see
AgentCore::evaluator. - Agent
Core Target agentcore - A runtime on AgentCore Runtime; see
AgentCore::target. - Case
- One input to run the target on, with the references evaluators check the run against: the expected answer, the expected tool calls, and assertions in plain language (for an LLM judge).
- Case
Change - A case whose outcome changed between the two reports.
- Comparison
- How a candidate run differs from a baseline run of the same experiment.
- Dataset
- The cases of an experiment.
- Evaluator
Delta - One evaluator in a
Comparison. - Evaluator
Summary - One evaluator’s results over all trials.
- Expected
Call - A tool call a case expects.
- Experiment
- An evaluation: a target run on every case of a dataset, a number of times, each run scored by every evaluator; the report goes to the sinks.
- FnTarget
- A target made of an async function; see
target_fn. - Json
File - Writes the report as JSON (
Report::to_json) to a file. - Junit
File - Writes the report as JUnit XML (
Report::to_junit) to a file, for CI test reports. - Latency
Summary - Run latencies over all trials.
- Markdown
- Writes the report as Markdown (
Report::to_markdown) to a file (such as$GITHUB_STEP_SUMMARY) or to standard output. - Named
- An evaluator renamed by
Evaluator::named. - Node
Target multiagent - A rig-multiagent node (a swarm, a graph, an agent) as a target; see
node_target. - Report
- What an experiment found.
- Score
- One evaluator’s verdict on one run.
- Target
Output - What one target run produced.
- Threshold
Result - Whether an evaluator’s pass rate reached its threshold.
- Tokens
- Model tokens over all trials.
- Tool
Call - A tool call the target made, and the result the tool returned when the target recorded it.
- Trial
- One run of the target on a case.
- Trial
Result - A trial and its scores.
- Turn
- One user turn of a multi-turn run and the answer it got.
- Turn
Failed - A multi-turn run that failed at one of its turns. The error of the turn
is prefixed
turn <n>:; the completed turns, their tool calls and usage (and the session id, if any) are kept inpartial, and the experiment puts them in the failed trial.
Enums§
- Agent
Core Error agentcore - Why an AgentCore target or evaluator failed.
- Dataset
Error - Why a dataset could not be read.
- Eval
Error - Why an evaluator could not score a run. An experiment records it as a
failed score labelled
"error"and carries on. - Experiment
Error - Why an experiment could not run, or could not deliver its report.
- Sink
Error - Why a sink could not record a report.
Traits§
- Evaluator
- Scores runs.
- Sink
- Receives an experiment’s report when it finishes.
- Target
- Something to evaluate: runs a case’s input and reports what it did.
Functions§
- node_
target multiagent - Evaluate a rig-multiagent
Node: its answer and usage. Nodes do not report their tool calls, so trials have none. - target_
fn - A target that runs
fon each case: a wrapper around an agent pipeline, a remote service, or a stub.freturns aTargetOutputor anything that converts into one (aString).
Type Aliases§
- Target
Error - Why a target run failed: a boxed error,
Send + Syncexcept on wasm.