Build an Evaluation Platform for a Tool-Using AI Agent
Machine LearningModel answerLast updated
Design a safe, repeatable harness that runs a tool-calling agent offline, grades its trajectories, and gates releases without touching production state.
Background
Your team ships a conversational AI agent that can call external tools — think web search, a code interpreter, a calendar API, or a customer database — to complete multi-step tasks. Before any new version of the agent reaches users, you need confidence that it performs better (or at least no worse) than the current one.
Your job is to design the harness and evaluation platform that makes this possible. You are not designing the model itself or the serving infrastructure; focus on everything that surrounds and measures the agent during offline evaluation.
Pick a concrete task domain to anchor your design. State it up front and make your assumptions explicit as you go.
What the system must support
- Safe execution. The agent under test must never touch real external systems or mutate production state.
- Repeatable task sets. Running the same evaluation twice should produce comparable, auditable results — not arbitrary noise.
- Trajectory tracing. Every model call, tool invocation, intermediate result, and final answer must be captured in enough detail to reproduce and diagnose failures.
- Multiple grading strategies. Some outcomes have a ground-truth answer you can check programmatically. Others require a rubric, a reference model, or a human reviewer.
- Repeated trials. Because model outputs are stochastic, a single run is not enough to distinguish a real regression from luck.
- Privacy. Evaluation tasks may reference real user data. That data must not leak into prompts, logs, or the model's context in uncontrolled ways.
- Regression gates. The platform must produce a clear, defensible signal for whether a candidate version should advance toward release.
- Reward-hacking resistance. Graders and task sets must not be so transparent that the agent (or a human tuning it) can game the score without actually improving.
Constraints
- Tools may be slow, stateful, unreliable, or capable of destructive side effects.
- Trajectory length — and therefore cost — varies widely across tasks.
- The evaluation dataset itself is a sensitive artifact that must be versioned and access-controlled.
- A candidate agent version must be isolated from the production version running live traffic.
What a strong answer covers
Spend your time on design decisions and trade-offs rather than a list of buzzwords. A complete answer addresses:
- How tasks are specified, stored, and versioned.
- How the execution environment isolates the agent and stubs or replays tool calls.
- What a trajectory record contains and how it is stored.
- How graders work, how their own reliability is measured, and how scores are aggregated across stochastic trials.
- How the platform decides whether a candidate version passes.
- How privacy, contamination, and reward-hacking risks are controlled.
- How failures feed back into the task set over time.
Hints
Hint 1
Start by decomposing the pipeline into distinct stages — task specification, execution, observation, grading, reporting — and assign clear ownership and data contracts to each boundary before going deeper into any one stage.
Hint 2
For tool isolation, think about the spectrum from full simulation to recorded replay to sandboxed real calls. Each point on that spectrum trades fidelity for safety and cost differently; name the trade-off explicitly.
Hint 3
Evaluator reliability is not free. Describe at least one concrete mechanism — inter-rater agreement, calibration tasks with known answers, or evaluator consistency checks — that lets you measure how much to trust your graders.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Anchoring assumption
I'll use a customer-support agent that can look up order history, issue refunds, send emails, and escalate tickets. This domain has a natural mix of deterministic outcomes (was the refund amount correct?), rubric-based outcomes (was the response tone appropriate?), and real safety stakes (an accidental mass-refund run would be costly and irreversible).
1. Task specification and dataset management
A task is a self-contained record: a starting conversation state, the user's goal expressed as a natural-language instruction, any required tool fixtures (e.g., a synthetic order record), and one or more grading specifications.
Tasks are stored in a versioned repository with semantic versioning — eval-set v2.4.1 — so that any experiment can be pinned to an exact snapshot. The set is divided into a core regression suite (~200 tasks covering known failure modes) and a held-out challenge set that is never used for prompt engineering or fine-tuning decisions. Exposing the challenge set to the team routinely will cause it to leak into development choices, so access is restricted and it is only run at release-candidate stage.
New tasks are added from two sources: manually authored cases that exercise specific capabilities, and automatically harvested failures from previous evaluation runs after human review and anonymization.
2. Execution harness and isolation
The harness spins up the candidate agent in an isolated runtime (a container with no egress to real APIs) and injects a tool router that intercepts every outbound call. The router chooses one of three modes per tool:
- Replay: return a pre-recorded response from the task fixture. High fidelity for deterministic tools like order lookup.
- Stub: return a minimal synthetic response. Cheaper and faster; used for tools like email send where the side effect is what we're avoiding.
- Sandboxed live call: route to a staging environment. Used sparingly when realistic latency or error injection matters.
The key invariant is that no candidate run writes to any production system. The harness enforces this at the network layer, not just by convention.
Because tool calls can fail in the wild (timeouts, 500s, malformed responses), the harness has a fault injection mode that randomly introduces these conditions to test agent robustness. Flakiness should be a property of the evaluation scenario, not an accidental property of the infrastructure.
3. Trajectory schema
Every run produces a structured trace. At minimum each trace contains: task ID, agent version, timestamp, the full sequence of (model input → model output → tool call → tool response) tuples, wall time and token count per step, the final answer, and any exceptions raised. Traces are written to append-only storage and are never modified after the run.
Sensitive fields (PII in the order fixture, customer names) are tokenized at ingest and stored in a separate secrets vault. The trace references a token, not the raw value. Analysts can join on the token if they have vault access, but logs flowing to dashboards or shared debugging sessions never contain the raw data.
4. Grading
Deterministic graders parse the agent's final action and check it against a ground-truth specification: did the refund amount match the expected value within $0.01? Did the agent escalate when the policy requires it? These run instantly and produce a binary pass/fail with no ambiguity.
Rubric-based graders use a separate judge model (a larger, frozen LLM with a structured scoring prompt) to evaluate dimensions like tone, factual accuracy, and conciseness on a 1–5 scale. The judge model is never the same model as the agent under test to avoid self-serving bias.
Evaluator reliability is measured by running a set of ~50 calibration tasks with known human-consensus scores through the judge model at the start of each evaluation campaign. If the judge model's scores drift more than 0.3 points (MAE) from the consensus, the grading run is flagged for review before results are reported. This prevents a judge-model regression from masking an agent regression.
Human review is reserved for a random sample (~5%) of high-stakes tasks and any task where the deterministic and rubric scores disagree beyond a threshold.
5. Repeated trials and statistical aggregation
Because outputs are stochastic, each task is run N=5 times for core regression tasks and N=3 times for the broader set. The primary metric is pass-rate per task (proportion of trials that pass all graders), aggregated into a weighted composite score across task categories.
Comparing candidate to baseline uses a paired permutation test over per-task pass-rates. The regression gate requires: the composite score does not drop more than 1.5 percentage points (absolute) at p < 0.05, and no individual task category drops more than 5 points. A candidate that passes on aggregate but regresses sharply on refund-accuracy tasks does not advance.
Cost (total tokens × price) and latency (p95 time-to-final-answer) are tracked as secondary metrics with soft limits, not hard gates.
6. Privacy, contamination, and reward-hacking controls
- Task fixtures are synthetically generated from real distributions, not copied from production logs. When real-world seeds are needed, they go through a de-identification pipeline before entering the eval store.
- The held-out challenge set is behind a separate access control policy. Model trainers and prompt engineers do not have read access.
- Grading rubrics are kept internal to the eval team. Publishing them in detail gives an optimization target that doesn't generalize.
- Score reports show aggregated metrics and per-category breakdowns, not per-task pass/fail in a queryable form, so it's harder to reverse-engineer which specific tasks failed.
7. Failure triage and the feedback loop
After each evaluation run, failures are automatically clustered by tool involved, error type (wrong action, hallucinated parameter, policy violation, stalled trajectory), and task category. This produces a failure taxonomy that the team reviews weekly.
High-frequency failure clusters trigger a targeted task expansion: three to five new tasks authored around the cluster are added to the regression suite (after human review) and the candidate is re-evaluated with the expanded set before the next release decision. This prevents the eval set from going stale as the agent improves.
Common mistakes to avoid
- Treating a single stochastic run as a reliable signal. Always run multiple trials and report uncertainty.
- Using the same model family to grade the model you're testing. The judge will be systematically biased toward its own style.
- Letting the eval dataset grow without access controls. Once engineers can query per-task results, the dataset is effectively contaminated.
- Hardcoding tool stubs without fault injection. An agent that only sees perfect tool responses will fail badly when real tools behave poorly.
- Setting a regression gate only on the composite score. A model can compensate for a serious regression in one category with improvements elsewhere.