Skip to content
be-human.ai
← Back to the journal

Testing & reliability

Replay Tests for AI Agent Runs: Reproduce Failures Safely

How to record an AI agent run's inputs, tool results and model version, then replay failures in staging without touching live systems.

Be Human typographic cover with the title: Replay Tests for AI Agent Runs: Reproduce Failures Safely
Conceptual illustration created with AI · Be Human

An AI agent replay test records everything a run depended on, including its inputs, the results each tool returned and the exact model and configuration version. The run is then repeated in a staging environment where the tools answer from the recording instead of the live systems. Done well, a failure can be studied as many times as needed without sending another message, issuing another refund or changing a record.

Key takeaways

  • Record each run as a sealed bundle: inputs, tool requests and responses, model and instruction versions, memory references and the permissions in effect.
  • Replay against recorded tool results, never against live endpoints, and turn every write into a logged intention.
  • Model wording will vary between runs, so judge the decision path and the first point where it diverges.
  • Redact personal and credential data at capture time, and limit who can open a recording.
  • Begin with the failures your team already disputes, then keep the replay set small and current.

Why a failed run is hard to study after the fact

By the time someone asks why an agent acted as it did, the world has moved on. The order record was updated, the customer replied, a memory note was overwritten, and the tool that returned an odd answer now returns a clean one. A standard log usually shows that a tool was called and that the run ended, but not the exact response the agent reasoned from. Without that response, the team can only guess, and guesses often lead to prompt changes that fix nothing.

Replay testing closes that gap. The aim is to rebuild the conditions of the run so the same decision path can be examined, repeated and compared after a change. It does not require the original infrastructure to be intact. It requires a faithful record of what the agent saw and what it was allowed to do.

What to record for every run

Capture is inexpensive while the run happens and very hard afterwards. For each run that reads memory, calls a tool or proposes an action, record the following:

  • The triggering input and the task state it arrived with, such as the open case or the conversation so far
  • The agent role version, the instruction version and the permission set in effect at that moment
  • The model identifier and every setting that affects output, such as sampling values and the maximum number of steps
  • Each tool call with its name, normalized arguments, timestamp, and the full response or error exactly as returned
  • The memory items read during the run, referenced by version or snapshot rather than copied in full
  • The final output and every proposed action, marked as executed, blocked or waiting for a person

Store the bundle as one unit under a run identifier, so everything belonging to a single attempt can be found together. If you already trace each step, the same identifiers can link the bundle to the trace. The OpenTelemetry documentation on observability concepts explains the vocabulary of traces and spans that makes this linking practical. For what to keep in day-to-day logs, see AI agent observability: what should you actually log?

How to replay a run in staging without touching live systems

The replay environment should be unable to reach production by design, not by hope. The steps below assume a bundle exists for the run you want to study.

  • Step 1: Create an isolated staging workspace with its own credentials, none of which can reach production systems or customer channels.
  • Step 2: Place every tool behind a replay adapter that returns the recorded response when the agent makes a matching call, matched by tool name and normalized arguments.
  • Step 3: Turn every write into a recorded intention. The adapter logs what would have been sent, including any idempotency key, and returns the recorded outcome.
  • Step 4: Pin the model version named in the bundle when the provider still offers it. If it has been retired, record the substitute and read the comparison with more caution.
  • Step 5: Start the agent from the recorded input, with the recorded instruction version and memory snapshot.
  • Step 6: Compare the new decision path with the original, step by step, and mark the first point of divergence.
  • Step 7: Attach the replay result to the incident note so the next reviewer sees the same evidence without repeating the work.

Step 3 deserves the most attention. A replay that re-sends an email or re-issues a refund is an incident of its own. Payment providers such as Stripe document idempotency keys so that repeated requests do not repeat effects, and the same discipline belongs in replay: the adapter should never forward a write at all. The design side of this is covered in Idempotent tool calls for AI agents: retries without duplicate work.

Handling model variation and nondeterminism

Language models do not always produce identical output from identical input, and a provider can change behavior behind a stable model name. A replay therefore should not demand matching sentences. It should check that the decision path is the same, or that any difference is explained. Useful questions include these:

  • Did the agent request the same tools with the same arguments, given the recorded results?
  • Did it reach the same decision from the same evidence?
  • Did it stay inside its approval boundaries, including the points where it would otherwise have written?
  • At the first point of difference, was the change a fix, a regression or harmless variation?

Judge with a rubric rather than a text diff. A short checklist of required steps, forbidden actions and expected escalations is easier to apply consistently than comparing transcripts line by line. When the stakes justify it, run the same replay several times and look for a stable pattern. One clean pass is evidence, not proof, and one failure is a reason to look more closely, not a verdict on the model.

An illustrative scenario: a refund that should have been a question

The following scenario is illustrative and does not describe a real company. A support agent receives a message asking why an order has not arrived. It calls the order lookup, which times out. The agent reads the timeout as a sign that nothing shipped and proposes a refund. A person in the approval queue nearly approves it before noticing that the order status was never returned.

The replay bundle makes the cause visible. The adapter returns the same recorded timeout, the agent produces the same refund proposal, and the team sees that the faulty step is how the timeout was interpreted, not the wording of the model. The fix is to treat an unreturned status as unknown, ask the customer or escalate, and never propose money movement from an unknown state. The team then replays the same bundle against the revised instructions. The recorded timeout stays the same, the proposal changes to an escalation, and the run is saved as a regression case. For how such timeouts should be reported, see Tool timeouts in AI agents: report unknown, not failed.

Protecting data inside recordings

A recording is a copy of business data, and it often holds more than the agent needed. Customer names, addresses, message bodies and tool responses can all contain personal information, and credentials sometimes appear inside error messages. Treat every bundle as sensitive from the moment it is written.

  • Redact secrets and tokens at capture time, not after the fact
  • Strip or pseudonymize personal fields that the replay does not need
  • Limit access to a named group, and log who opens a bundle
  • Set a retention period that matches the reason the bundle exists
  • Build shared test sets from synthetic or fully anonymized records

Obligations depend on where you operate and on the data involved, so confirm the approach with the person responsible for privacy in your organization. The NIST AI Risk Management Framework offers a practical structure for documenting these risks and the controls that address them.

Where to start with replay

In Be Human's managed operations, each agent keeps a record of its memory, tools, permissions and operating context, and run bundles belong to that record. Replays run in an isolated staging workspace, writes are intercepted, and confirmed failures become entries in the evaluation set that the agent is checked against after each controlled change. The work is remote, and the scope starts with one useful role rather than a general rebuild.

If you are unsure where replay would pay off first, pick the failure your team has already argued about twice. Save its bundle, write down the decision you expected, and check whether the replay agrees with you. Take the free Be Human AI diagnostic to find the first task worth handing to an agent.

Frequently asked questions

Does a replay need the original model to still be available? Not always. When the recorded model version is still offered, pin it and compare directly. When it has been retired, the tool side and the decision logic can still be replayed, but you should record the substitute model and expect some differences in wording.

Can I replay a run that already sent a message or changed a record? Yes, as long as the replay never forwards a write. The adapter records the intended action, includes the original idempotency key if one existed, and returns the recorded outcome. The live system is never called, so the replay cannot send a second message or issue a second refund.

How many replays are enough before I trust a fix? There is no fixed number. Start with the original bundle, then add bundles from similar failures. For high-impact actions, repeat each replay several times and look for a consistent decision path. A fix deserves trust when it holds across the bundles that failed before and does not break the runs that already passed.

Is replay testing the same as logging? No. Logs describe what happened in summary, while a replay bundle keeps the inputs and tool responses the agent used, so the run can be executed again under controlled conditions. Logging is still necessary, and the two work best when they share identifiers.

Your next step

See where an AI agent fits in your company first.

Take the free Be Human AI diagnostic. A few questions about your work show which task to hand to an agent first, what it needs to know and where a person approves.

Be Human editorial guidance. Examples are illustrative unless explicitly attributed. Sources provide background; implementation choices depend on your workflow.

Less busywork. More room for you.

Bring us the work you wish you had time for.

Book a call to try a personalized AI agent free for 7 days ↗Or take the free AI diagnostic →