Class ExperimentRunner

Object
akka.javasdk.testkit.eval.ExperimentRunner

public final class ExperimentRunner extends Object
Runs cases against an agent and collects the results. Sequential and in-process; the only output is the report file written at the end of the run.

Per case: load the recorded tool calls, if any, into the bound stubs, call the agent in a fresh session, read the evidence the runtime traced for that session, and evaluate the expectations over it. The stubs a hand written case needs are prepared before the run, in the test.

An experiment is built in steps, each step offering only what comes next: the cases with optional evaluators and ToolBindings, the agent, an optional Gate, then Experiment.run(). Without a gate every case must pass, which suits a mocked model. With a real model gate on rates instead.

Experiment.repeat(int) runs every case several times. One execution of one case is an attempt, and the gate, the rates and the spend count attempts. The report names the requirements that passed in some runs and failed in others.

Experiment.run() writes the report as JSON to target/eval-reports/<name>-<start time>.json, see ExperimentRunner.EvalReport.reportFile().

The cases carry the command the agent's command handler takes, so the handler's own type is passed through unchanged.


 var runner = new ExperimentRunner(testKit);

 var report =
     runner.cases(cases).agent(SupportAgent::ask).gate(Gate.passRateShouldBeAtLeast(0.9)).run();
 assertThat(report.passed()).withFailMessage(report::render).isTrue();
 
  • Field Details

    • DEFAULT_REPORT_DIRECTORY

      public static final Path DEFAULT_REPORT_DIRECTORY
      Where Experiment.run() writes the report file unless the experiment names another.
  • Constructor Details

    • ExperimentRunner

      public ExperimentRunner(TestKit testKit)
      Parameters:
      testKit - the running TestKit the agent is called through
  • Method Details

    • cases

      @SafeVarargs public final <C> ExperimentCases<C> cases(EvalCase<C> first, EvalCase<C>... more)
      The cases the experiment runs.
      Parameters:
      first - the first case
      more - further cases, with the same command type
    • cases

      public <C> ExperimentCases<C> cases(List<EvalCase<C>> cases)
      The cases the experiment runs.
      Parameters:
      cases - at least one case