The platform for continuously improving AI agents.
import pytest
from overbae.models import EvalRun
from .datasets import JUDGE, tickets, upload
from .stack import drain, settle
pytestmark = pytest.mark.covers("evaluate")
WEAK_REPLY = "Your refund is on its way."
def test_evaluate(workshop, cli, sample_agent, worker, tmp_path, fake_llm, console):
fake_llm.extra_models.append("fake/weak")
fake_llm.on(lambda r: r.model == "fake/weak", WEAK_REPLY)
answer = workshop.capability("answer")
dataset = upload(
cli, sample_agent, tickets(tmp_path), "--intent", "eval", "--capability", answer["id"]
)
drain(worker)
group = workshop.call(
"run_evaluation",
{
"name": "compare",
"dataset": dataset,
"judge_model": JUDGE,
"targets": [
{"mode": "recorded", "label": "recorded", "is_baseline": True},
{"mode": "generate", "model_name": "fake/candidate", "label": "candidate"},
{"mode": "generate", "model_name": "fake/weak", "label": "weak"},
],
},
)
# A target's judging is queued once its generation commits, after the drain
# may already have found the queue empty.
def ended():
read = {run["label"]: workshop.read(run["resource"]["uri"]) for run in group["runs"]}
return read if all(run["status"] in EvalRun.TERMINAL for run in read.values()) else None
runs = settle(worker, ended)
assert {label: run["status"] for label, run in runs.items()} == dict.fromkeys(
("recorded", "candidate", "weak"), "completed"
)
assert len({tuple(m["name"] for m in run["matrix"]) for run in runs.values()}) == 1
compared = {
run["label"]: workshop.call("compare_evaluations", {"run": run["id"]})
for run in group["runs"]
if not run["is_baseline"]
}
assert all(c["baseline_label"] == "recorded" and c["paired"] == 3 for c in compared.values()), (
compared
)
assert compared["candidate"]["overall"]["status"] == "unchanged"
assert compared["weak"]["overall"]["status"] == "regressed"
assert compared["weak"]["losses"] == 3
project = workshop.project()["id"]
console.goto(f"/evaluations?projectId={project}")
for label in ("recorded", "candidate", "weak"):
console.sees(f"compare · {label}")
console.click("compare · weak")
console.sees("Re-run")
console.save_evidence("evaluate-weak-run")