Gates and reports

Feature set: Evaluations Contact our support for access.

A gate is a condition on the results of all cases in a batch. A report is the result of one run.

The attempt verdict

An attempt is one case in one run. Its results are the outcomes of the evaluators bound to the agent, one per evaluator. A failed agent call is a failed result named target. A guardrail denial that stopped the interaction is a result named guardrail instead. It passes in an attack and fails in an evaluation. See How an attack judges a guardrail denial. An evaluator that recorded nothing within the evaluation timeout is inconclusive. The timeout is 10 seconds unless the experiment sets another with evaluationTimeout(Duration). A case with an expected reply adds a result named expected. This result compares the actual reply with the expected reply. It passes or fails, and is inconclusive if the agent call failed or returned no value. An attempt with an expected result and no bound evaluator passes or fails on that result alone.

The verdict of the attempt follows from the results of all its evaluators.

Attempt verdict When

FAIL

Any result failed.

INCONCLUSIVE

No result failed and any result is inconclusive, or no result passed: every result is not applicable, or no evaluator is bound and the case has no expected reply.

PASS

At least one result passed and the others are not applicable.

An inconclusive result does not pass the attempt. The gate and the report show it. A not applicable result does not count for the gates. The report lists it.

Gates

A Gate is a condition on the results of all cases in the batch.

Gate Passes when

Gate.allCasesShouldPass()

Every attempt passed. An inconclusive attempt fails the gate. This is the gate that applies when none is given.

Gate.passRateShouldBeAtLeast(minimumRate)

The share of attempts that passed is at least minimumRate. An inconclusive attempt counts against the rate.

Gate.passRateShouldBeAtLeast(evaluatorClass, minimumRate)

The share of the evaluator’s results that passed is at least minimumRate. Inconclusive and not applicable results are left out of the count. The gate fails when the evaluator has no result to count. The evaluator is named by its component class.

Gate.targetShouldNotFail()

No attempt failed in the agent call. In an evaluation, a failed guardrail result counts as a failure. In an attack, the guardrail result passes and does not count.

Gate.expectedShouldPass()

The reply of every attempt matches the expected reply of its case: every expected result passed. An attempt without a reply to compare, because the agent call failed or returned no value, fails the gate. The gate fails when no case has an expected reply.

Gate.expectedPassRateShouldBeAtLeast(minimumRate)

The share of the expected results that passed is at least minimumRate, over the attempts where the comparison ran. An attempt without a reply to compare is excluded, so combine the gate with Gate.targetShouldNotFail() to fail the batch on failed agent calls. The gate fails when no case has an expected reply.

Gate.guardrailShouldNotDeny(name)

The named guardrail denied nothing in any attempt. For a guardrail that must stay silent on legitimate traffic.

Gate.guardrailShouldDeny(name)

The named guardrail denied in every attempt. For a guardrail that must catch an attack every case carries. A report-only denial counts.

Gate.guardrailShouldStop()

Every attempt ended with an enforcing denial from any guardrail that stopped the interaction. A report-only denial does not count.

Gate.guardrailShouldStop(name)

Every attempt ended with an enforcing denial from the named guardrail that stopped the interaction. A report-only denial does not count.

gate.and(other)

Both gates hold. The verdict lists both details.

The gates count attempts, not cases. An attempt is one execution of one case, so an experiment with repeat(3) has three attempts per case. Gate.allCasesShouldPass() then requires every case to pass in every run, and a pass rate is the share of all attempts that passed. An attempt with an inconclusive result, or without a passed result, is inconclusive and does not pass, see The attempt verdict. A pass rate pools the attempts of all cases: one case that fails in every run and three cases that each fail once give the same rate. See Running every case several times.

A failed gate does not throw. Assert on the report, and use the rendered report as the failure message.

Gating a judged batch

A judge can give the same reply a different score on another run. Gate a batch on the pass rate of the judge evaluator instead of asserting on one judged case. Gate.passRateShouldBeAtLeast(JudgeEvaluator.class, minimumRate) rates the evaluator over the attempts where it reached a verdict, and fails when it judged none.

@Test
public void repliesAnswerFromTheTools() {
  var report = new ExperimentRunner(testKit)
    .cases(OrderCases.CURATED)
    .agent(OrderAgent::ask)
    .repeat(3)
    .gate(
      Gate.passRateShouldBeAtLeast(JudgeEvaluator.class, 0.8).and(
        Gate.targetShouldNotFail()
      ) (1)
    )
    .run();

  assertThat(report.passed()).withFailMessage(report::render).isTrue();
}
1 At least 80% of the judged attempts must pass. The other evaluators still decide each attempt, but only the judge and the agent call are gated here.

Reading the report

run() returns an EvalReport.

Accessor Content

name()

The name given with name(…​), or the test method that ran the experiment, for example OrderAgentQualityIntegrationTest.qualityGate.

kind()

EVALUATION for cases run with cases(…​), ATTACK for cases run with attacks(…​).

passed()

Whether the gate passed.

passRate()

The share of attempts that passed.

runs()

How many times every case ran, see Running every case several times.

results()

One CaseResult per attempt: every case in the order the cases were given, its runs ascending. A CaseResult carries the case id, the run, the Evidence and the results. describe() renders one attempt as in the report.

cases()

One CaseSummary per case, in the order the cases were given. It carries the outcome over all runs, the number of runs that passed, failed and were inconclusive, the attempts of the case, and the verdicts of each evaluator. The outcome is PASSED when every run passed, FAILED when every run failed, INCONCLUSIVE when every run was inconclusive, and INCONSISTENT otherwise. verdicts() holds one EvaluatorVerdicts per evaluator of the case: the runs where the evaluator passed, failed, was inconclusive or was not applicable, and its outcome over the runs where it reached a verdict.

render()

The report as text.

document()

The report as data, a ReportDocument with every case, every attempt and its evidence, for tools that render their own reports.

reportFile()

The JSON file run() wrote to target/eval-reports/<name>-<start time>.json, for example OrderAgentQualityIntegrationTest.qualityGate-20261001-101530-123.json, holding document(). Every run keeps its own file. See the example report. ReportDocument.read(path) reads it back. reportDirectory(path) on the experiment changes the directory, withoutReportFile() writes none. Empty when no file was written.

A rendered report of a passing batch:

evaluation of 3 cases, 1 run: 3/3 attempts passed (100%)
gate: passed — pass rate 1.00 over 3 attempts (3 cases, 1 run), required 0.90; order-lookup rate 1.00 over 3 judged attempts, required 1.00; no target failures
  judge 3/3
  order-lookup 3/3
  refund-policy 1/1 (2 not applicable)
  reply-grounding 2/2 (1 not applicable)
spend: 7 model responses, 0 tokens in, 0 out, 31 ms in total, slowest full-refund run 1 at 14 ms, over 3/3 attempts with a recorded interaction

Line by line:

  1. The kind of the experiment, the cases, the runs, and the passed attempts with their share. The kind is evaluation or attack. Inconclusive attempts follow when there are any: evaluation of 3 cases, 1 run: 2/3 attempts passed (67%), 1 inconclusive. An attempt is one case in one run, so without repeat(n) on the experiment the attempts are the cases.

  2. The gate’s verdict and its detail. A combined gate lists the detail of each part. The detail counts attempts and names the runs a case failed or was inconclusive in: failed cases [order-status (run 2)], inconclusive cases [refund (run 1)].

  3. One line per evaluator, under its component id: the attempts it passed over the attempts where it reached a verdict. The attempts where it was inconclusive or not applicable follow in brackets, for example refund-policy 1/1 (2 not applicable). The runner’s own results, target, guardrail and expected, are listed the same way.

  4. One line per guardrail that decided in the batch, for example guardrail refund-limit: denied 1, allowed 0. Absent when no guardrail decided.

  5. The spend: model responses, tokens and latency summed over the attempts with a recorded interaction, and the slowest attempt. A mocked model reports no tokens.

  6. inconsistent across runs, only when an evaluator passed in some runs of a case and failed in others: one line per such evaluator with the runs it passed, failed and was inconclusive in, for example order-status order-lookup: passed in runs 1, 3, failed in run 2. An evaluator that failed in every run is not listed here. See Running every case several times.

  7. After these lines, every attempt that did not pass, failed or inconclusive, with its evidence, see Reading an attempt that did not pass.

Reading an attempt that did not pass

The rendered report ends with every attempt that did not pass, failed or inconclusive, and its evidence. The evidence is what the attempt left in the ledger: the reply, the tool calls with their arguments, the model spend, and the guardrail decisions. The report file holds more of the ledger record per attempt: the system message, the input as the model saw it, each model response with its tokens and tool calls, the model name and provider, and the value the command handler returned. This report is from the sample’s aReplyWithoutALookupFailsTheCase in the mocked variant, where the model answers without calling a tool:

@Test
public void aReplyWithoutALookupFailsTheCase() {
  orderModel.reset();
  orderModel.whenUserMessage(message -> true).reply("Order o_42 was delivered yesterday."); (1)

  var report = new ExperimentRunner(testKit)
    .cases(OrderCases.ORDER_STATUS)
    .agent(OrderAgent::ask)
    .run();

  assertThat(report.passed()).isFalse();
  assertThat(report.render())
    .contains("case order-status run 1 FAILED")
    .contains("FAIL order-lookup: no getOrder call for a message that names an order") (2)
    .contains("NOT_APPLICABLE reply-grounding: no order was looked up"); (3)
}
1 The script of a model that invents a status.
2 The lookup check fails and names what was called.
3 The grounding check had no tool response to compare the reply with.
evaluation of 1 case, 1 run: 0/1 attempts passed (0%)
gate: FAILED — failed cases [order-status (run 1)]
  judge 1/1
  order-lookup 0/1
  refund-policy 0/0 (1 not applicable)
  reply-grounding 0/0 (1 not applicable)
spend: 1 model responses, 0 tokens in, 0 out, 4 ms in total, slowest order-status run 1 at 4 ms, over 1/1 attempts with a recorded interaction
case order-status run 1 FAILED
  reply: Order o_42 was delivered yesterday.
  tools: none called
  model: 1 responses, 0 tokens in, 0 out, 4 ms
  PASS judge: answers from what the tools returned (score 0.90)
  FAIL order-lookup: no getOrder call for a message that names an order
  NOT_APPLICABLE refund-policy: no refund was issued
  NOT_APPLICABLE reply-grounding: no order was looked up

The report names such an attempt by its case and its run, and prints the reply, the tool calls with their arguments, the model spend, the guardrail decisions when there are any, and every result with its detail. The reply is cut to one line of at most 200 characters. CaseResult.evidence() gives the same facts as data: reply(), returned(), toolCalls(), failure(), guardrails(), denied(), and the InteractionRecord itself. A returned line follows the reply when the command handler returned something other than the model text, for example a typed reply or a failure mapped in onFailure.

A case whose agent call throws fails with a result named target:

@Test
public void anUnknownOrderIsATargetFailure() {
  var unknown = EvalCase.of("unknown-order", "Where is order o_404?");

  var report = new ExperimentRunner(testKit).cases(unknown).agent(OrderAgent::ask).run();

  assertThat(report.passed()).isFalse();
  var result = report.results().getFirst();
  assertThat(result.describe()).contains("FAIL " + ExperimentRunner.TARGET); (1)
  assertThat(result.evidence().failed()).isTrue(); (2)
  assertThat(result.evidence().toolCalls().getFirst().name()).isEqualTo(
    OrderAgent.GET_ORDER
  );
  assertThat(result.describe()).contains("PASS order-lookup"); (3)
}
1 The runner’s own result for the failed call.
2 The ledger still has the interaction, with the tool call that threw and the failure.
3 An evaluator bound with trigger-on-failure = true still judges the failed interaction. The other evaluators are not expected on it.

When a guardrail denial stopped the interaction, the runner reports a result named guardrail in place of target. See How an attack judges a guardrail denial.

Running every case several times

A case that passes once against a real model can fail on the next run with the same input. repeat(n) on the experiment runs every case n times in total, each time in a fresh session.

@Test
public void qualityGateOverRepeatedRuns() {
  var report = new ExperimentRunner(testKit)
    .cases(OrderCases.CURATED)
    .agent(OrderAgent::ask)
    .repeat(3) (1)
    .gate(Gate.passRateShouldBeAtLeast(0.85)) (2)
    .run();

  assertThat(report.passed()).withFailMessage(report::render).isTrue();
}
1 Every case runs three times. The runner runs every case once, then every case again, so the attempts of one case are spread over the batch.
2 The gate counts attempts: nine with three cases. 0.85 tolerates one attempt that did not pass, failed or inconclusive. 0.9 would require all nine.

The report lists the evaluators that passed in some runs of a case and failed in others under inconsistent across runs, see Reading the report. cases() carries the outcome of every case over all runs, and the verdicts of every evaluator over the runs of the case. A case whose two evaluators fail in different runs failed in every run, and the report lists both evaluators as inconsistent.

Three passes out of three do not prove that a case always passes. A case that fails one time in four passes three runs out of three in about four of ten experiments. Choose n by the failure rate you need to detect. Gate on a rate, not on every run passing, when the model is real.

Nothing is reset between runs. The stubs the agent’s tools call serve every run, a @BeforeEach runs once per experiment, and state that a tool writes to an entity is still there in the next run. A stub or an evaluator must not depend on state an attempt writes, or a side effect of run 1 fails every later run. The wall clock time and the model spend grow with the number of runs, and the calls of a judge are not part of the spend line.