Build a Regression-Testing Platform for LLM Agent Releases
System DesignModel answerLast updated
Design a platform where agent-building teams can test a new prompt or model against a baseline and see the effect on answer quality, tool usage, latency and cost before shipping.
Several product teams in your company build LLM-powered agents. One example is an agent that reads customer-support call transcripts and writes a structured summary report. These teams change their agents often: they edit the system prompt, swap in a different model, or modify the set of tools the agent can call. Today they judge such changes by eyeballing a handful of outputs, and regressions reach production.
Design a shared platform that lets a team evaluate an agent configuration and compare it with another one (for instance the current production version against a proposed change).
The comparison should cover at least:
- Output quality (is the report correct, complete and faithful to the transcript?)
- Tool use (did the agent call the right tools with the right arguments, and avoid needless calls?)
- Speed (end-to-end latency and its tail) and, ideally, cost
- The effect of changing the system prompt versus changing the model
In your answer, discuss:
- Clarifying questions and the assumptions you make
- Core data model and how versions are tracked
- How evaluations are executed at scale
- How outputs are scored, including cases with and without ground truth
- How two versions are compared in a statistically sound way
- The user-facing surface (APIs, reports, CI integration)
- Privacy, multi-tenancy, cost control and online evaluation
Hints
Hint 1
Treat an agent version as an immutable, hashable bundle (model, parameters, prompt, tool definitions). Everything else, such as datasets, runs and results, should reference versions by ID so any result can be reproduced.
Hint 2
LLM output is nondeterministic and datasets are small, so a single pass with an average score is misleading. Think about repeated runs, paired comparison on the same cases, and confidence intervals.
Hint 3
Separate cheap deterministic checks (schema validity, tool-call trajectory, latency) from expensive judgments (LLM judge with a rubric), and decide how you will check that the judge agrees with human reviewers.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Clarify and scope
I would confirm these assumptions first:
- Agent contract: an agent is a configuration (model, sampling parameters, system prompt, tool set) that the platform can run, with an optional adapter for teams that host their own endpoint.
- Modes: offline evaluation on curated datasets is the core. Online evaluation on sampled production traffic is a second phase.
- Data: a mix of curated transcripts, sampled and anonymized production data, and some synthetic cases. Some have human reference reports, many do not.
- Metrics: quality, tool-use correctness, latency (p50/p95), cost per case.
- Gating: a run should be able to block a merge, so a typical run should finish in about 10-20 minutes.
2. Data model
- AgentVersion (immutable, content-hashed): model ID, parameters, system prompt, tool schemas, tool implementation versions.
- Dataset / DatasetVersion: test cases with an input (transcript), optional reference output, optional expected tool calls, and tags for slicing (language, call length, topic).
- Evaluator: a versioned scoring function (code check, metric, or LLM judge with rubric and judge model).
- Run: (AgentVersion, DatasetVersion, evaluator set, seed, repeat count).
- CaseResult: output, full trace (every model and tool call with timings and token counts), and per-evaluator scores.
Immutability and versioning matter because "why did the score move?" must always be answerable by diffing two versions.
3. Execution at scale
- A run is expanded into (case, repeat) tasks on a queue, executed by stateless workers.
- Rate limits and retries: a per-provider token bucket, exponential backoff, and idempotent task keys so retries do not double count.
- Tool determinism: tools are either mocked or replayed from recorded responses so that differences come from the agent, not from a changing world. Live-tool runs are a separate, labeled mode.
- Caching: cache by hash of (version, input, seed) to skip unchanged work, and cache judge calls by hash of (output, rubric).
- Nondeterminism: run each case k times (for example 3-5) at the production temperature. Report both the mean and the variance.
- Latency measurement: measure from traces, on workers with controlled concurrency, otherwise queueing noise pollutes the numbers. Run the baseline and candidate interleaved on the same infrastructure.
4. Scoring
Deterministic checks (cheap, run on everything):
- Output schema validity, required fields present, length limits.
- Tool trajectory: required tools called, argument correctness against expected values, no forbidden calls, call count and redundant-call rate, error and retry rate.
Reference-based (where ground truth exists):
- Field-level exact or fuzzy match for extracted fields, and similarity or entailment-based scoring against human reports. Do not rely on n-gram overlap alone; it rewards wording rather than correctness.
Reference-free LLM judge:
- A rubric with separate criteria (faithfulness to the transcript, coverage of key points, actionability, format), each scored on a small ordinal scale with a short justification.
- Prefer pairwise comparison (candidate vs baseline, order randomized) for A/B decisions, since judges are more reliable at relative than absolute scores.
- Calibrate against a human-labeled set: track agreement (for example Cohen's kappa) and re-check whenever the judge model or rubric changes. Mitigate known biases: position, verbosity and self-preference (use a judge from a different model family than the one being judged where possible).
- Faithfulness checks: extract claims from the report and verify each against the transcript to detect hallucination.
Operational metrics: latency, time to first token, tokens and cost, all taken from traces.
5. Comparing versions
- Compare on the same cases (paired design). Compute per-case difference, then a bootstrap confidence interval on the mean difference, or a paired test for continuous scores and McNemar for pass/fail.
- Average the k repeats per case first, so cases, not repeats, are the unit of analysis.
- For latency use percentiles with bootstrap intervals, not means.
- Define decision rules up front, for example "no quality metric drops more than 1 point with 95% confidence, and p95 latency does not rise more than 10%". With many metrics and slices, control false discoveries (Benjamini-Hochberg) or designate a few primary metrics.
- Slicing: show results per tag (long calls, non-English, specific topics). Overall gains often hide a regression in a segment.
- Prompt vs model: to attribute effects, run a factorial grid (prompt A/B x model X/Y) so interaction effects are visible, rather than changing both at once.
- Check dataset power: if the confidence interval is wider than the effect you care about, report "inconclusive" and suggest more cases rather than a fake verdict.
6. Product surface
- API/SDK:
POST /runswith version and dataset IDs,GET /compare?base=...&cand=.... - Report: a summary table with deltas and intervals, a slice breakdown, a latency distribution, and a case-level diff view showing input, both outputs, traces and judge rationales, sorted by largest regression.
- CI gate: run a small "smoke" dataset on every pull request and the full set before release, with pass/fail based on the pre-declared rules.
- Human loop: reviewers label disputed cases, and those labels feed judge calibration and grow the dataset (every production bug becomes a regression case).
7. Online evaluation, privacy, cost
- Online: sample production traces, score asynchronously with the same evaluators, and alert on drift. For rollouts, use shadow traffic or a canary split with the same paired or two-sample statistics.
- Privacy and tenancy: PII redaction at ingestion, per-team datasets with access control and encryption, retention limits, and no sharing of one team's transcripts with another team's evaluators.
- Cost control: tiered evaluation (cheap checks first, judge only on cases that pass them or on a sample), judge caching, per-team budgets and quotas, and early stopping when a candidate is clearly worse.
Common mistakes
- Comparing single runs and calling a 1-point difference a win.
- Trusting an uncalibrated LLM judge, or using the candidate model as its own judge.
- Letting live tools or changing data introduce noise into the comparison.
- Reporting only averages, which hides regressions in slices and in tail latency.
- Changing prompt and model together and then attributing the effect to one of them.
- Treating the dataset as static instead of continually adding production failures.