Evaluation

Feature set: Evaluations Contact our support for access.

Evaluation runs an agent through a set of eval cases and judges each interaction with the evaluator components bound to the agent. This section covers evaluation in tests. Evaluation explains how it relates to evaluation on recorded and live traffic.

Overview

An evaluation is a JUnit test that extends TestKitSupport. The agent runs in the in-process runtime with its tools, session memory and guardrails, and nothing leaves the test JVM.

The checks are evaluator components, the same kind of component that judges production traffic. A test keeps its own evaluators in src/test/java and binds them to the agent in the TestKit configuration, see The test class. An evaluator written for a test can move to src/main/java and run in production without a change.

Use evaluation for three purposes.

  • Check the wiring in every build. With the model mocked by TestModelProvider, the cases are deterministic. They check that the agent, its tools and the evaluators fit together.

  • Measure the quality of an agent against a real model. Run a set of cases as one batch behind a gate that requires a minimum pass rate. A real model does not give the same reply twice, so the default gate, which requires every case to pass, does not fit.

  • Attack an agent and check that it holds. The command of the case is an attack, the evaluators state what a breached reply looks like, and a guardrail stops what the model must never do. See Adversarial tests.

Evaluation is not the place for the following.

How a case runs

ExperimentRunner runs the cases one after the other, in the calling thread.

  1. The runner calls the agent’s command handler through the TestKit component client, in a fresh session, with the case’s command.

  2. The runtime records the interaction in the ledger and triggers every evaluator bound to the agent, as in production.

  3. The runner reads the interaction and the guardrail decisions of the turn from the ledger, and waits for one evaluation record per bound evaluator.

  4. Each evaluation record becomes a result on the case: pass, fail, inconclusive, or not applicable.

  5. The gate checks the results of all cases, and the run returns the report. The report is also written as a JSON file under target/eval-reports, see Reading the report.

flowchart TB Case[EvalCase] --> Runner[ExperimentRunner] Runner -->|command| Agent[Agent in the TestKit runtime] Agent -->|interaction| Ledger[(Ledger)] Agent -.->|trigger| Evaluators[Bound evaluators] Evaluators -->|evaluations| Ledger Ledger -->|interaction, decisions, evaluations| Runner Runner --> Gate --> Report[EvalReport]

A case whose agent call throws fails with a result named target. It does not abort the batch. When a guardrail denial stops the interaction, the result is named guardrail, not target. It passes when the cases run as an attack, see How an attack judges a guardrail denial. A case with an expected reply adds a result named expected. The runner compares the reply with the expected reply using equals or a Grader. See Cases with an expected reply. An evaluator that records no evaluation within the evaluation timeout is inconclusive on that case.

The parts of an evaluation

Type Role

EvalCase

One case: an id, the command sent to the agent and optionally the expected reply. See The first case and Cases with an expected reply.

EvalCases

Reads cases from a JSON Lines file. See Cases in a file.

Evaluator component

Judges one interaction and records a verdict. Bound to the agent in the configuration. See The evaluators and Evaluators.

ExperimentRunner

Builds the experiment step by step: the cases, the agent, the gate, then the run. See The first case.

Gate

What the batch must satisfy over all case results. Without a gate every case must pass. See Gates and reports.

EvalReport

The outcome: whether the gate passed, the pass rate, every case result with its evidence, and the report as text. See Gates and reports.

Evidence

What one attempt left in the ledger: the interaction and the guardrail decisions. See Reading an attempt that did not pass.

The testkit types are in the akka.javasdk.testkit.eval package. Evaluator is in the akka.javasdk.evaluation package of the SDK. The API documentation is at akka.javasdk.testkit.eval.