Every change comes with its position and, for input/output changes, a line diff — so a failing test tells you what changed, not just that something did.
Save a baseline
Pick a known-good production run and save it under a name. The baseline is stored self-contained, and its source trace is pinned, so neither is removed by trace retention.Traces are ingested asynchronously. Saving by trace ID right after a run can return 404 until the trace lands — retry shortly, or save from the run’s context instead.
Check a run in tests
UseMatchesSnapshot like any other assertion — in a replay, a scenario, or on its own. A missing baseline, or one that can’t be loaded, fails the assertion; it never passes silently.
WithSnapshot(name, snapshot) (with_snapshot / withSnapshot) on the test SDK.
Guard every replay against its recording
A mocked replay already fails when your agent adds a call or skips a recorded step, and it reports calls whose input differs from the recording without failing on them (how calls are matched). Turn onCompareWithRecording and the replay also fails when its sequence or inputs drift from the trace it’s replaying:
Production monitoring
Compare live runs against the baseline and record every result in the dashboard, where each run shows expected and actual steps side by side:In live runs, inputs built from live data (today’s date, fetched records) differ from the baseline’s. Use
IgnoreFields, IgnoreSteps, or Normalize to leave those out, or compare only in replay where inputs are reproducible.Options
Python uses snake_case (
compare_inputs, ignore_fields, …); Node uses camelCase (compareInputs, ignoreFields, …).
Values are compared structurally: key order doesn’t matter, and a value loaded from the API compares equal to the same object built in your code.
SnapshotDiff
Baselines saved before step inputs were recorded (older snapshots) still load. They’re compared on the step sequence only, and the summary says so. Save the baseline again to get input comparison.
Choosing a baseline
Pick a run that represents the expected “happy path”:- All expected steps completed successfully, with no error steps
- Representative of typical production behavior
- Recent — save a new baseline whenever you change the agent on purpose
What’s next
Test with replay
Run your agent against recorded traces in tests.
Write assertions
Combine snapshots with the LLM judge and other checks.