rig-evals
Evaluations for Rig agents: run an agent on a dataset of cases, score every run, and fail CI when a pass rate drops.
use ;
use TrajectoryMode;
let report = new
.dataset
.target
.evaluator
.evaluator
.evaluator
.repetitions
.concurrency
.threshold
.sink
.sink
.run
.await?;
exit;
Cases
A case has an id, an input, and the references evaluators check a run against: an
expected answer, an expected trajectory of tool calls, and assertions in plain
language. These are the reference inputs of AWS Bedrock AgentCore evaluations and the
fields of Strands Evals' cases. Dataset::load reads .json (an array) or .jsonl.
Multi-turn cases
A case with turns instead of input is a conversation: each turn is a user message,
sent in order on one conversation, so a later turn can refer to earlier answers. The
target answers the last turn, and the evaluators score that answer, the tool calls over
all turns, and the usage over all turns. The trial's transcript holds each turn and its
answer; the judge sees it too.
A failed turn makes the trial fail with turn <n>: ... as its error. The trial keeps the
turns that completed, their tool calls and usage; the evaluators see them as usual.
A case sets input or turns, not both; a dataset without turns reads as before. In
Rust, Case::multi_turn(id, turns) builds one. An agent target keeps the history itself, a
multi-turn case starting with an empty history (not the agent's memory store). An
AgentCore target sends every turn in one runtime session. A target_fn gets the whole
case: loop over case.prompts(), and return the last answer with transcript set. A
node_target runs single-turn cases only.
Targets
A Target runs a case. Rig agents are targets: the trial gets the answer, the tool calls
from the run's transcript, and the run's token usage (summed over the turns of a
multi-turn case). target_fn wraps an async
function. With the multiagent feature, node_target wraps a rig-multiagent swarm,
graph or node (answer and usage; nodes do not report tool calls).
Evaluators
An Evaluator scores a trial from 0 to 1 and says whether it passed.
| Evaluator | Passes when |
|---|---|
contains, contains_all |
the answer contains every string |
regex |
the answer matches the pattern |
equals |
the trimmed answer equals expected |
json |
the answer is JSON, with the required keys |
trajectory |
the tool calls match the trajectory: Exact, InOrder or AnyOrder; given args match as a subset |
budget |
output tokens, total tokens and latency stay within limits |
no_error |
the target did not fail |
LlmJudge |
a judge agent scores the answer against a rubric at least at the threshold |
LLM-judge presets
LlmJudge::helpfulness, LlmJudge::faithfulness and LlmJudge::goal_success are judges
with a fixed rubric, named helpfulness, faithfulness and goal_success. They share the
judge's prompt, its 0 to 1 score and its threshold (0.5 unless set). Faithfulness checks the
answer against the transcript, the tool calls and the case's references; goal success reads
every turn of a multi-turn case.
# use Agent;
# use ;
# async
A failed target run still gets scored, and the built-ins fail it. An evaluator that
errors (a case without expected, a judge without a verdict) gives a failed score
labelled error; the experiment carries on. named renames an evaluator, to use two of
a kind.
CI
Each evaluator has a threshold: the share of trials it must pass. It is 1 unless set with
threshold(name, min_pass_rate); with repetitions, a lower one tolerates a
nondeterministic agent. Report::passed() is false when any evaluator misses its
threshold: use it as the exit code. The JUnit report has one test case per trial and per
threshold, so CI test views show the failures.
Sinks
A Sink receives the report. JsonFile, JunitFile and Markdown (a file, such as
$GITHUB_STEP_SUMMARY, or stdout) are built in; Report::to_json, to_junit and
to_markdown give the same text. A sink that fails returns its error with the report.
OpenTelemetry
The experiment is an eval.experiment span, and each trial an eval.trial span
(eval.case, eval.repetition) that the agent's own spans nest in. Each score is a
gen_ai.evaluation.result event on the trial span, with gen_ai.evaluation.name,
gen_ai.evaluation.score.value, gen_ai.evaluation.score.label (the label, or
pass/fail) and gen_ai.evaluation.explanation: the event of the OpenTelemetry GenAI
semantic conventions (development status). The crate only emits tracing data; with
rig-otel installed, any OTel backend shows the results on the evaluated
run's trace.
Providers
AWS Bedrock AgentCore
With the agentcore feature, an agent deployed on AgentCore Runtime is a target, and
AgentCore Evaluations' evaluators (Builtin.Correctness, Builtin.Helpfulness,
Builtin.GoalSuccessRate, the trajectory matchers, or a custom evaluator id) are
evaluators. They follow AWS's
on-demand evaluation
flow:
AgentCoreTargetinvokes the runtime (InvokeAgentRuntime, HTTP protocol, payload{"prompt": <input>}) in a fresh session per trial and answers the reply'sresponse. A multi-turn case sends each turn in that one session, in order. The trial carries the session id.AgentCoreEvaluatorwaits for the session's spans in CloudWatch Logs: it queriesaws/spansand the runtime's/aws/bedrock-agentcore/runtimes/<runtime-id>-<endpoint>group with Logs Insights every 10 seconds, up to 5 minutes, until aninvoke_agentspan is in and the span count stops growing.- It sends the spans to
Evaluatewith the case's references:assertionsand the tool names of thetrajectoryfor the session,expectedfor the last invocation's trace. The score is the mean of the results (one per trace for trace-level evaluators), with their labels and explanations; it passes at the threshold (0.5 unless set). A result that is an error makes an error score.
The spans are downloaded once per session and shared by every AgentCore evaluator of the
same AgentCore.
use ;
let agentcore = from_env.await; // or AgentCore::new(&sdk_config)
let report = new
.dataset
.target
.evaluator
.evaluator
.evaluator
.sink
.run
.await?;
The agent must leave spans AgentCore Evaluations can read: deploy it with
rig-agentcore, export with rig-otel's aws feature,
and record content (record_content(true)), so the spans carry the prompts and answers.
Transaction Search must be on in the account.
The caller needs bedrock-agentcore:InvokeAgentRuntime on the runtime,
bedrock-agentcore:Evaluate, and logs:StartQuery and logs:GetQueryResults on both log
groups. .ingestion_timeout, .poll_interval and .runtime_log_group (for trials of
another target, given a session id) tune the evaluator; .qualifier picks another
runtime endpoint.
Langfuse scores as a Sink come next.
Testing
cargo test --all-features runs keyless: agents on scripted models, a scripted judge, and
in-memory OpenTelemetry exporters for the evaluation events. The AgentCore suite runs
against a real runtime only when RIG_EVALS_AGENTCORE_RUNTIME_ARN is set (with AWS
credentials and region), and skips otherwise.