Interface Experiment<V>

Type Parameters:
V - the reply type of the agent's command handler

@DoNotInherit public interface Experiment<V>
Cases bound to the agent under test, ready to run. Obtained from ExperimentCases.agent(akka.japi.function.Function2<A, C, akka.javasdk.agent.Agent.Effect<R>>).

An experiment is immutable. Every setting returns a new experiment and leaves this one unchanged, so call run() on the experiment the last setting returned.

Not for user extension.

  • Method Details

    • gate

      Experiment<V> gate(Gate gate)
      Sets the gate run() checks. Without a gate every case must pass.
      Parameters:
      gate - the gate condition to satisfy
      Returns:
      a new experiment with the setting applied
      Throws:
      IllegalArgumentException - when gate is null
    • grade

      Experiment<V> grade(Grader<V> grader)
      Sets how the reply of an attempt is compared with the expected reply of its case. Without a grader the runner compares them with Object.equals(java.lang.Object), which suits a mocked model or a typed reply. The result of the comparison is the ExperimentRunner.EXPECTED result of the attempt, next to the verdicts of the bound evaluators, and the gate and the report treat it like an evaluator verdict.

      The grader is not called when the agent call failed or returned no value. The ExperimentRunner.EXPECTED result is then inconclusive.

      Parameters:
      grader - the grader to evaluate the expected reply against the actual reply
      Returns:
      a new experiment with the setting applied
      Throws:
      IllegalArgumentException - when no case has an expected reply, or grader is null
    • name

      Experiment<V> name(String name)
      Sets the name the report carries, see ExperimentRunner.EvalReport.name(). It names the report file, so it must be usable as a file name on every platform: not blank, at most 200 characters, and without < > : " / \ | ? * or control characters. Without a name the report is named after the test method that called run(), for example SupportAgentEvalTest.qualityGate.
      Parameters:
      name - the report name
      Returns:
      a new experiment with the setting applied
      Throws:
      IllegalArgumentException - when the name is not usable as a file name
    • reportDirectory

      Experiment<V> reportDirectory(Path directory)
      Sets the directory run() writes the report file to, see ExperimentRunner.EvalReport.reportFile(). Without one the report goes to target/eval-reports under the working directory.
      Parameters:
      directory - the directory to write the report file to
      Returns:
      a new experiment with the setting applied
      Throws:
      IllegalArgumentException - when directory is null
    • withoutReportFile

      Experiment<V> withoutReportFile()
      Disables writing a report file on run().
      Returns:
      a new experiment with the setting applied
    • evaluationTimeout

      Experiment<V> evaluationTimeout(Duration timeout)
      Sets how long an attempt waits for the ledger to hold its interaction and one evaluation per bound evaluator, ExperimentRunner.DEFAULT_EVALUATION_TIMEOUT unless set. An evaluator without an evaluation at the timeout is inconclusive on that attempt. Raise it for a judge that calls a real model or for a durable evaluator with slow steps.
      Parameters:
      timeout - duration to wait, must be positive
      Returns:
      a new experiment with the setting applied
      Throws:
      IllegalArgumentException - when timeout is null, zero, or negative
    • repeat

      Experiment<V> repeat(int times)
      Runs every case this many times in total, each time in a fresh session. Once by default. The gate, the rates and the spend count every attempt, so Gate.allCasesShouldPass() passes only when every case passed in every run. The report names the evaluators that passed in some runs and failed in others of the same case, see ExperimentRunner.EvalReport.cases().

      A case that passes in every run is not shown to always pass: times runs cannot show a failure rate below one in times. The stubs and the runtime are not reset between runs, so a stub or an evaluator must not depend on state an attempt writes.

      Parameters:
      times - number of times to run each case, at least 1
      Returns:
      a new experiment with the setting applied
      Throws:
      IllegalArgumentException - when times is less than 1
    • run

      Runs all cases, checks the gate and writes the report file. Does not throw on a failed gate; assert on the report.
      Returns:
      the evaluation report