Evals & Observability·Question 52 of 83Advanced

How would you build a deterministic replay harness for agent evals, and what does it genuinely buy you?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Record every non-deterministic boundary during a live run and stub it on replay. That means tool responses, retrieval results, model completions, clock reads, random seeds and simulated user turns, each keyed by a canonicalised call signature such as tool name plus normalised arguments. On replay, your orchestration code runs for real and everything it observes comes from the recording.

Full worked answer with diagram

Record every non-deterministic boundary during a live run and stub it on replay. That means tool responses, retrieval results, model completions, clock reads, random seeds and simulated user turns, each keyed by a canonicalised call signature such as tool name plus normalised arguments. On replay, your orchestration code runs for real and everything it observes comes from the recording.

What it buys: CI runs in seconds with no API spend and no flakes; you can re-run a specific production failure a thousand times while changing only your code; and orchestration bugs get isolated from model variance, which otherwise swamp each other. When an agent fails, "is this my retry logic or did the model just roll badly" is the question that eats days, and replay answers it.

The limits are the more important half, and this is where candidates oversell it. Replay only exercises paths you recorded. Change the prompt and the agent asks a different question, your key misses, and you either hard-error or silently fall through to a live call and lose determinism. So replay is exact for "did I break the plumbing" and worthless for "is the new prompt better". Anyone gating prompt quality on a replay suite is measuring nothing.

So layer it. Replay for unit and integration tests on every commit. A stateful mocked sandbox for behaviour evals nightly: give the agent a simulated database it can actually write to, then grade the final world state against an annotated goal rather than grading the conversation. That is the tau-bench shape, and it tolerates novel trajectories, which is exactly what replay cannot. Live or staging integration for a small suite before release.

Practical details that bite: define miss policy explicitly (strict error versus record-and-passthrough in update mode); handle side effects and idempotency; and re-record on a schedule, because recorded tool responses rot as the real APIs drift, and a green replay suite against a stale recording is a false sense of safety.

Worth sketching. The key-miss branch is the honest part of the answer, and it is much easier to draw than to describe.

flowchart TD
    L["Live run"] --> REC["Record every boundary:<br/>tool results, completions,<br/>clock reads, seeds"]
    REC --> ST["Keyed by tool name plus<br/>normalised arguments"]
    ST --> RP["Replay: your orchestration runs,<br/>everything it observes is stubbed"]
    RP --> H{"Key hit?"}
    H -->|"yes"| OK["Seconds, no spend, no flakes"]
    H -->|"no"| MS["Prompt changed the question:<br/>hard error, or lose determinism"]
    MS --> SB["Behaviour evals need a stateful<br/>mocked sandbox instead"]

What a good answer covers

  • Record every non-deterministic boundary during a live run and stub it on replay
  • That means tool responses, retrieval results, model completions, clock reads, random seeds and simulated…
  • On replay, your orchestration code runs for real and everything it observes comes from the recording
  • What it buys: CI runs in seconds with no API spend and no flakes; you can re-run a specific production…
  • When an agent fails, "is this my retry logic or did the model just roll badly" is the question that eats…

Interviewer follow-ups to expect

  1. How do you detect that your recordings have gone stale?

  2. Where does the mocked sandbox stop being worth its maintenance cost?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep