Design: evaluation platform for agents
Pin dataset and agent versions, run each task k times in fresh seeded sandboxes, grade end state with code before judges or humans, store every trajectory, and gate releases on paired diffs with confidence intervals.
Analogy: A crash-test lab: identical cars, identical dummies, the same wall every time, many runs per model, and sensors that record the whole impact, not just whether the car looks fine afterwards.
Fundamentals you'll use
How it works
- Tier suites by cost: smoke per PR (~10 min), full nightly (~$225 a run), held-out per release.
- Calibrate each LLM judge on ~100–200 human-labeled trajectories, and pin its model and prompt.
- The paired CI gives three verdicts: pass, fail, or inconclusive: run more.
- The worst failure is a false green; hard gates on safety and money slices block any new failure.
- Report pass^k next to the mean pass rate: 90% per trial gives only ~59% pass^5.
Check yourself
Answer to mark it learned; your answers aren't scored.
Your agent eval gate uses a 2-point non-inferiority tolerance. A PR's paired diff against the baseline is −1 point, with a 95% bootstrap CI of [−6, +4]. What should the gate report?
Go deeper
Full explanation
An evaluation platform for agents answers one question for every change to a prompt, model, tool or grader: is this version better, worse or indistinguishable, and where? It turns Evaluating agents from a notebook into shared infrastructure with reproducible runs and release gates.
Requirements
- Functional: submit a run = agent config (prompt hash, model id, tool versions) × dataset version × k trials; execute tasks in isolated environments; grade outcome and trajectory; compare against a baseline; gate merges and releases in CI; browse and diff trajectories; turn production failures into new tasks.
- Non-functional: reproducible (dataset, image, seed, model and grader versions pinned); isolated (agents run code and side-effecting tools); a PR suite under ~10 minutes and a full suite under ~1 hour; bounded cost per run; honest statistics.
- Questions I'd ask: What kind of agents: coding (repo + tests), support (DB + APIs) or browser? How many tasks, how often, and who reads the results? Is there a checkable end state, or is quality subjective? Can production traces enter datasets, and after what PII treatment?
- Highest-cost failure: a false green. Noise, a stale dataset or a broken grader passes a regression and it ships. Its twin, a flaky false red, teaches teams to bypass the gate.
High-level design
- Dataset service: immutable, versioned tasks (instruction or simulated-user persona, initial-state snapshot, success check, tags, provenance) in smoke, full and held-out splits (Golden datasets & test sets).
- Orchestrator: expands a run into jobs on a queue.
- Sandbox runners: one fresh container per trial from a pinned image, seeded DB or repo, mocked third-party APIs, frozen clock, egress only to the model gateway, step and dollar caps.
- Trajectory store: every message, tool call, result, token count, latency and cost, plus the final environment state.
- Graders: Code-based graders & assertions on end state first, a rubric-based LLM-as-a-judge second, and a human queue for disagreements and audits (Human evaluation & annotation).
- Analysis and gates: pass rate, pass^k, paired diff against the baseline with bootstrap CIs, per-slice dashboards, and a verdict posted to the PR (Evals in CI/CD & release gates).
Offline loop: flagged production traces → triage → Error analysis: look at your data → a new reproducible task in the next dataset version.
Code A paired, bootstrapped release gate with three verdicts
import numpy as np
def gate(base, cand, tolerance=0.02, n_boot=10_000, seed=0):
"""base, cand: 0/1 arrays [n_tasks, k_trials] on the SAME tasks, same order."""
base, cand = np.asarray(base, float), np.asarray(cand, float)
diff = cand.mean(axis=1) - base.mean(axis=1) # paired: cancels task difficulty
rng = np.random.default_rng(seed) # the gate itself must be reproducible
idx = rng.integers(0, len(diff), size=(n_boot, len(diff)))
boot = diff[idx].mean(axis=1) # resample TASKS, not trials
lo, hi = np.percentile(boot, [2.5, 97.5])
pass_k = cand.min(axis=1).mean() # pass^k: all k trials succeeded
if lo > -tolerance:
verdict = "pass" # non-inferior within tolerance
elif hi < 0:
verdict = "fail" # a real regression
else:
verdict = "inconclusive" # CI too wide: add tasks or trials, don't guess
return verdict, diff.mean(), (lo, hi), pass_k
# Hard gates live outside this function: any new failure on a
# zero-tolerance slice (safety, money movement) blocks regardless.Real example
A PR rewrites the issue_refund tool description and moves the agent to a newer model. CI runs the smoke suite: 60 tasks × 3 trials = 180 sandboxes, 60 in parallel, ~25k tokens each, so ~4.5M tokens ≈ $14 at an assumed $3/M, done in ~9 minutes. Pass rate goes 0.82 → 0.85; the paired diff is +3 points with a 95% CI of [−2, +8], non-inferior within the 5-point smoke tolerance, so the PR merges. The nightly full run (500 × 5) finds the slice refunds over $500 dropping pass^5 from 70% to 52%. Trajectory diffs show the new model skipping verify_identity before issue_refund; the required-order check catches it, and that slice's hard gate blocks the release.
Trade-offs +4 · −4
+ You gain
- Every change (prompt, model, tool, judge) gets a comparable, reproducible number before it ships.
- Fresh seeded sandboxes make side effects safe and trials independent.
- Paired diffs with CIs turn "it feels better" into pass, fail or inconclusive with stated confidence.
- One trajectory schema for evals and production lets any production failure become a regression test.
− You pay
- Expensive: k trials × long trajectories × judges; it needs tiering and caching to stay affordable per PR.
- Environment fidelity is hard: mocks drift from real APIs, so evals pass while production breaks.
- LLM judges add their own noise and drift; they need calibration and versioning like any model.
- Datasets saturate and get overfit; a held-out split and a steady inflow of new cases are ongoing work.
Use it when
When several teams ship agents that take actions, prompts, models or tools change weekly, and a regression costs real money or trust.
Avoid it when
For one prototype agent: a script, 30 cases in a spreadsheet and manual trace review are faster. Build the platform when the second team needs the same harness.
Numbers to know 5
- Full run: 500 tasks × 5 trials × ~30k tokens = 75M tokens ≈ $225 at an assumed $3/M blended; nightly ≈ $6.8k/month.
- Wall clock: 2,500 episodes × ~3 min ÷ 200 parallel sandboxes ≈ 38 min; the CI time budget sets the parallelism.
- Resolution: at an 80% pass rate the 95% CI half-width is ±~3.5 pts with 500 tasks and ±~10 with 60, so a PR smoke suite only catches large regressions.
- Reliability: 90% per trial gives pass^5 ≈ 59% (0.9^5); report pass^k next to the mean, because customers live in pass^k.
- Storage: ~150 KB per trajectory; 2,500 nightly + 50 PR runs × 180 ≈ 11.5k trajectories/day ≈ 1.7 GB/day ≈ 50 GB/month.
Common pitfalls 4
- Comparing against last month's stored baseline: hosted models and mocks drift. Rerun the baseline in the same window.
- Grading the agent's final message instead of the end state: it says Refund issued and nothing happened.
- Reusing environments across trials: trial 2 sees trial 1's side effects. One fresh container per trial.
- Gating on a single run or on 30 slices at once: noise passes regressions and blocks good changes. Use k trials, paired CIs and a few pre-declared gated slices.
Interview questions 3
Answer out loud first, then reveal.
How do you make the CI gate trustworthy enough that teams don't bypass it?Show answer
Three things. Statistics: a paired comparison on the same tasks with k trials, a bootstrap CI over tasks, and three verdicts, so noise produces "run more" instead of a red build. Graders: code checks on end state first, judges calibrated against human labels, every grader versioned. Speed: the PR suite is ~60 tasks × 3 trials and finishes in about 10 minutes; the full suite runs nightly. Then I measure the gate itself: how often a red was overridden and later proved right, and escapes, meaning production regressions the gate passed.
The new model scores +4 points overall. Do you ship it?Show answer
Not yet. First, is +4 outside the CI of the paired difference? Then slices: an aggregate gain can hide a regression in a critical slice, like large refunds, one language or safety tasks, and those carry hard gates. Then pass^k, not only the mean: a model that's better on average but more erratic hurts customers. Then cost and latency per successful task. Finally the judge: if it shares a family with the new model, self-preference can inflate the score, so I check code-graded tasks separately. If all of that holds, I ship behind a canary with online metrics.
How do you evaluate an agent that sends emails and charges cards?Show answer
Never against real systems. Each trial runs in a fresh container with a seeded database and mocked external services: record/replay for read APIs, fakes for side-effecting ones like email and payments that record what would have been sent. The grader then checks the fake's ledger: exactly one $40 refund to the right account, no email to anyone else. Egress is blocked except the model endpoint, the clock is frozen and credentials are test-only. The main risk is mock drift, so I run contract tests of each fake against the provider's sandbox weekly.
Deep dive 5
Datasets and environments
A task is an instruction or simulated-user persona, an initial-state snapshot, a success check, tags and provenance. Datasets are immutable and content-hashed; a run pins the version, so a score is reproducible months later. Keep three splits: smoke for PRs, full for nightly and release runs, and a held-out set nobody tunes against, to catch overfitting to the eval. Environments are container images pinned by digest, with a seeded database or a repo at a commit, record/replay mocks for read APIs, and fakes for side-effecting ones (payments, email) that log what would have happened. Freeze the clock and block egress except to the model gateway. A reset is a new container, never a cleanup script. Simulated users are LLM personas with a hidden goal: pin and validate them too, because a pushy simulator changes the score.
Graders, in order of trust
Code first: end state (database rows, tests passing, files changed) and trajectory constraints (required calls such as verify_identity before issue_refund, forbidden calls, step and cost budgets). Then an LLM judge with a rubric for what code can't see: tone, policy adherence, asking before acting. Calibrate each judge on ~100–200 human-labeled trajectories and track agreement (e.g., Cohen's kappa); pin its model and prompt, and prefer a different model family from the agent's to limit self-preference. Upgrading the judge is itself a change that needs an eval. Humans review judge disagreements, low-confidence verdicts and a random ~2–5% audit sample. Every score is stored with its grader version: a new grader means re-scoring the baseline, never comparing numbers across grader versions.
Statistics and release gates
Agents are nondeterministic (Non-determinism: pass@k & variance), so run k trials (3 per PR, 5–10 nightly) and report both mean pass rate and pass^k. Compare candidate and baseline on the same tasks: per-task differences cancel task difficulty, and a bootstrap over tasks gives a 95% CI. Use three verdicts: pass if the lower bound clears −tolerance, fail if the upper bound is below 0, otherwise inconclusive: run more. Add hard gates on a few zero-tolerance slices (safety, forbidden actions, money movement) where any new failure blocks. Rerun the baseline in the same window, because hosted models and mocks drift. Beware multiple comparisons: across 30 slices at 95%, ~1.5 will cross the threshold by chance alone, so gate on pre-declared slices and show the rest as warnings.
Scale and cost control
The full suite is 2,500 episodes and ~$225 per run (see numbers); running it on 50 PRs a day would cost ~$340k/month, so tier it: smoke per PR, full nightly, held-out per release. Select by impact: a change to one tool runs the tasks tagged with that tool first. Cache environment images and judge verdicts keyed by (trajectory hash, rubric version, judge version). Don't replay cached agent responses when scoring a change: that hides exactly the variance you're measuring. Stop early once a sequential test is decided. Send judge calls through batch APIs (50% cheaper at OpenAI and Anthropic) when latency allows. Cap each episode's steps and dollars, so one looping agent can't burn the run's budget. Parallelism is set by the CI time budget and the provider's rate limits, not by container count.
Closing the loop with production
Use one trajectory schema for evals and production (LLM observability & tracing), so any production trace opens in the same viewer and can be replayed. Traces flagged by a thumbs-down, an escalation, a guardrail hit or an online judge sample land in a triage queue; Error analysis: look at your data groups them into failure modes, and an engineer turns each new mode into a reproducible task: a scrubbed state snapshot, the user goal and a success check, linked to the incident. PII is masked or replaced with synthetic values before anything enters a dataset (PII & data privacy). Track two numbers: the share of incident classes covered by a task, and the time from incident to regression test. Retire saturated tasks (passing in every version for ~30 days) to a cheap canary set so the suite stays sensitive. See Offline vs online evaluation.