Skip to contents

complete_trial() copies the scores, token use, cost and timing of an evaluation from eval_program() into a trial record and marks it "completed".

Usage

complete_trial(trial, eval_result, compiled_artifact_ref = NULL, notes = NULL)

Arguments

trial

A trial record from create_trial().

eval_result

The EvalResult returned by eval_program().

compiled_artifact_ref

Optional compiled program. When this trial is the best one in a TrialLog with a log_dir, the log saves the program as best_program.rds.

notes

Optional note that replaces the trial's note.

Value

The updated trial record, with status "completed".

Examples

program <- module_fn("x -> answer", function(x) list(answer = toupper(x)))
data <- data.frame(x = c("a", "b"), answer = c("A", "B"))
result <- eval_program(program, data, metric_exact_match(field = "answer"))
trial <- create_trial("my-search", params = list(variant = "baseline"))
complete_trial(trial, result)
#> 
#> ── Trial: trial_20261126_010952_ncnyz0 
#> ✔ Status: completed
#> Optimizer: my-search
#> Params: variant
#> Score: 1
#> Started: 2026-11-26 01:09:52