Contents (8)
Turning production traces into evals means taking recorded agent runs, above all the failures, and making them tests that run in CI on every change. The hard parts are privacy, choosing which runs to keep, and replaying them without calling the model. Example: the export shipped with trace-to-fixture holds three runs of a refund agent, and one approved a $900 refund over a $500 limit. It is demo data, not a customer incident.
That failing run belongs in a test suite. A trace-to-fixture build records it as a known failure in the manifest. The offline snapshot test passes, and the opt-in live test marks it as an xfail, a test expected to fail while the bug is open. The run itself becomes a fixture, a saved run with its assertions that pytest replays. FAULTLINE publishes this guide and makes trace-to-fixture, free and open source, disclosed where it appears. The method applies to a LangSmith, Langfuse or Braintrust dataset as well.
01 / Production traces are the test data you already have
Real failures make better regression cases than invented ones, and the main platforms already document a traces-to-dataset path.
Microsoft states the case directly: "Production traces are the most representative source of how your agent behaves with real users" (Microsoft Learn). A benchmark you wrote tests the cases you imagined. A trace records the case a customer actually hit, with the prompt, the tool calls and the state that produced the failure.
The export step is already built. Braintrust tells you to "Select the most representative failing cases and create a dataset directly from the filtered logs" (Braintrust). LangSmith says "The LangSmith Engine can automatically generate ground truth dataset examples from your production traces" (LangSmith docs). Langfuse documents a workflow to "select production traces where the application did not perform as expected" and let "an expert add the expected output" (Langfuse docs). Phoenix lets you "add any span or group of spans using the Phoenix UI" (Phoenix docs).
A production failure is a scenario with a witness. The vendors call the result an eval dataset. For CI the useful part is narrower: assertions that fail when a known behaviour changes.
02 / Check what the export actually contains before you build tests
A trace can be valid and still useless as a test, because the content that made the run fail may never have been recorded.
OpenTelemetry's GenAI conventions treat model instructions, user messages and model outputs as sensitive. Instrumentations "SHOULD NOT capture them by default, but SHOULD provide an option for users to opt in" (OpenTelemetry). The convention gates "model instructions, prompts, completions, tool definitions, retrieval queries, prompt template variables, and memory records" behind that opt-in (same document). An agent instrumented to that default ships spans, the individual operations inside a run, plus timings and token counts. It ships no prompt, so the export can prove that a tool was called but not why.
Tool calls have a quieter failure. On faultgate's loader, "a structurally valid export whose tools are not read passes every check by default" (faultgate docs). The export loads, the checks pass, and part of the run was never read. The same docs give the countermeasure: "Compare the tool-step count with what your agent actually ran".
The export format and the run boundary matter too. faultgate's loaders read OTLP, OpenInference, Langfuse, LangSmith and Braintrust exports (trace-to-fixture). The input is a file, because "Input is an export file: there is no vendor API puller" (same page). That keeps the scrub inside your environment, and it also means the export is your responsibility.
Three checks decide whether the file can support a test:
- Are the prompts and completions in it?
- Does the tool-step count match the run?
- Does one trace hold one agent run, as faultgate's trace format expects?
If any answer is no, fix the exporter first. A test built on a trace with no content grades only the instrumentation.
03 / Scrub deterministically, then prove the verdict did not change
Masking is a change to the test data, so the pipeline has to show the change did not move a single verdict.
Start with stable placeholders. "The same private value consistently maps to the same placeholder under your secret salt so equality checks work" (trace-to-fixture). That property is load-bearing. A test that asserts the refund went to the customer's own account compares two strings from different parts of the trace, and both must map to the same placeholder or the assertion breaks for the wrong reason.
Then compare verdicts. trace-to-fixture "Runs checks on each trace before and after scrubbing" and requires that "Verdicts must match exactly" (same page). If a check passed on the raw trace and fails on the scrubbed one, the scrub changed the evidence, and the fixture no longer replays production.
Where masking happens matters. In faultgate, "Rules always see the raw values", and "Only what leaves the machine is masked" (redaction docs). Microsoft Foundry takes the other placement and redacts private content "by default" (Microsoft Learn). Neither order is wrong. The question is whether anyone compared the check result on both sides. In the pages reviewed for this guide, only trace-to-fixture describes that comparison.
Private data is not rare in these files. On 30 real benchmark traces, faultgate's masker found "81 emails, 39 phone numbers and 69 JWT access tokens" (redaction docs). Those traces come from a benchmark, not a customer export. They are enough to show that a trace export is a data-handling problem before it is a test asset.
The build ends with a leak scan of everything it wrote, after load, precheck, scrub, verdict proof, grouping, selection and writing (trace-to-fixture). The verify command runs a leak scan of every file, checks hashes, loads the fixtures in faultgate-zero and faultgate, and checks the snapshot verdicts (product page). The explain command shows one trace's changed fields by path, kind and length, "never values", next to the raw and scrubbed verdicts (same page).
The limits are part of the tool. It "masks the private data its detectors can find", is "not an anonymisation or compliance product", and "detectors miss things such as internal customer ids" (trace-to-fixture). Presidio, the optional detector for names and places, says in its own FAQ that "there is no guarantee that Presidio will find all sensitive information" (Presidio). A person reads the scan output and reviews the fixtures before they are committed (trace-to-fixture). That review is a required step.
04 / Keep one example per behaviour, and every failure
A regression suite has one job, which is to notice when a known failure returns, so selection must keep every failing behaviour before it spends a slot on a clean run.
trace-to-fixture groups runs "by distinct behavioral signature". Every group "where a check fired is kept", and the largest clean groups fill the rest up to --max-clean, default 20. The selection is deterministic (trace-to-fixture). Call the grouping key a behavioural signature: the fingerprint of what the run did, as the checks see it. Two runs with the same signature land in one group, and if a check fired in that group, one of its runs becomes the fixture.
The alternative methods answer a different question. Foundry's sampling "Selects a diverse, representative sample by using MinHash so the result covers the range of your agent's scenarios rather than overindexing on frequent, near-identical prompts" (Microsoft Learn). MinHash is a similarity estimate over sets, so the sample spreads across scenarios instead of following prompt frequency. Braintrust asks for "the most representative failing cases" (Braintrust). Both are sensible for a review set or a coverage eval, where the goal is to see the range of behaviour. A regression gate has a narrower goal. A rare failure that never makes the sample is a failure the suite will not catch when it returns.
No source reviewed here measures how often diversity sampling drops a rare failure, so this guide puts no number on it. The safe design starts from every failing group and adds clean examples afterwards. Determinism matters for a second reason. The same export produces the same fixture set on every build, so a change in the fixtures is a change someone made, not noise from a sampler.
05 / Offline fixtures by default, live replay on request
An offline fixture replays that saved recording without a model, and it should be the test that runs on every change.
trace-to-fixture ships offline tests that "pass on day one with no model calls" (trace-to-fixture). The claim is stronger than it sounds. Chronicle reports that "full replay issues zero model calls and is bit-stable across 20 repetitions" (Chronicle). Bit-stable means the replayed output is identical on every repetition, which is what a CI gate needs.
The design detail behind that stability is which boundaries come from the record. Chronicle's cut-point replay serves a chosen subset of them from the recording and executes the rest live with new code. In a mutation study of the guarded tools, "cut-point tests catch every mutant that lets the recorded unsafe action through", while a baseline that "stubs every boundary" with the same assertion "catches none" (Chronicle). Stubbing everything removes the decision the test is supposed to make.
Live replay answers a different question, and after a model change it can answer a different world. The Replay Gap preprint measured six paired runs and about 900 rollouts. Model swaps rewrote "61-94% of post-fork actions" and left "only 3% of replayed states valid" (Replay Gap). A second 2026 preprint found that restorations which "agreed with one another in 24 of 24 states" still differed "from the live continuation in 9 and 20 of 24" (counterfactual paper). The replayed run is evidence about the recording. The live run is evidence about today's model and today's tools.
Keep them separate. trace-to-fixture runs live tests "only when requested with -m agent_live or T2F_LIVE=1" (trace-to-fixture), and those tests call "your own tools in your own test environment" rather than mocks (same page). That is an integration test with a real model. Run it on a schedule and around model or tool changes, not on every pull request.
The output still has to gate something. Phoenix records evals through ordinary pytest, so "the exit code of the test run becomes your CI gate" (Phoenix). Once a failure is promoted to a guard, the live replay lane returns 1 when that failure comes back in the agent, and 0 when the suite is clean.
One install detail before you start: version 0.1.0 needs faultgate-zero below 0.2, while fault-contract needs 0.2 or newer, so the two cannot share an environment yet (trace-to-fixture).
The quickstart is three commands:
When the fix ships, the fixture changes role. The live test fails with instructions to run trace-to-fixture promote DIR ID, which turns the scenario into "a permanent regression guard" (same page). The demo export that ships with the tool takes the same path. Its known failure is an xfail that still fails like production until the fix lands and someone promotes it.
06 / Where the test data ends up: SaaS datasets or files in your repo
Choosing where scrubbed traces live is a security decision, and each option has its own leak path.
| Tool | How a trace becomes a dataset | Where the data lives | Source |
|---|---|---|---|
| LangSmith | The Engine generates dataset examples from traces | SaaS, or your infrastructure when self-hosted | Datasets, Self-hosted |
| Langfuse | Select under-performing traces, an expert adds the expected output | SaaS, or self-hosted open source | Datasets, Self-hosting |
| Braintrust | Filter failing logs, pick representative cases | Not stated in the pages reviewed | Analyzing production logs |
| Arize Phoenix | Add spans from the trace UI, run evals in pytest | Not stated in the pages reviewed | Datasets, pytest |
| Microsoft Foundry | MinHash sampling with default redaction | An Azure project, retention not claimed | Traces to dataset |
| trace-to-fixture | Scan, build, prove, select, write, leak scan | Files in your repo, salt in a secret store | Product page |
The storage decision is the one a security lead should sign. LangSmith is explicit that a public dataset exposes examples, experiments, runs and feedback "to anyone with the link", "even if they don't have a LangSmith account" (LangSmith docs). A fixture file committed to a repository inherits the repository's readers, including everyone who can read its history.
Self-hosting changes the answer for two of the tools. LangSmith self-hosting keeps "trace and operational data" in your environment (LangSmith docs), and Langfuse "is open source and can be self-hosted using Docker on your own infrastructure" (Langfuse docs). For Braintrust and Foundry, retention and residency, meaning how long the data is kept and where it is stored, were not part of the pages reviewed, so do not assume either way.
The salt is the other secret. Keep it "in a secret store or CI secret, never in git", and use "one salt per customer audit" (trace-to-fixture). Raw values stay out of every artifact, since they live "only in memory: never in files, logs, exceptions, or the manifest" (same page). The detectors cover secrets, emails, US SSNs, card numbers, IP addresses and phone numbers, with names and places when the optional pii extra is installed, plus anything listed in a deny file or as a sensitive key (same page). Anything a detector misses has to be named by hand.
07 / What to change on Monday
The decision: take the last 30 days of failing production runs, export them, confirm the export holds content and tool spans, build scrubbed fixtures with the verdict-equality check, commit them as offline tests, and schedule live replay as a separate opt-in job.
The agent's engineering owner does the work. The security lead signs off two things, the scrub review and where the fixtures are stored. Neither sign-off is a formality, because a missed detector can put customer data in a file that gets pushed to a repository.
Track three numbers. The share of known production failures that have a committed offline test. Scrub runs with a verdict mismatch or a leak-scan hit, with a target of zero. Live-replay failures reviewed per release.
The wider method is in the guide to testing AI agents and the agent regression testing guide. Export and masking details are in the trace formats and redaction docs, and the checks inside the offline tests come from faultgate-zero.
Questions#
How do you turn production traces into test cases?
Export the failing runs, confirm the file holds the prompts and tool spans, scrub private values with stable placeholders, and check that every verdict is identical before and after scrubbing. Then group runs by behaviour, keep every failing group, write the fixtures as offline pytest tests, and run a leak scan before committing them. Live replay stays a separate, opt-in job.
Is it safe to use production traces as test data?
Only with deterministic scrubbing, a leak scan and a human review. Detectors miss things such as internal customer ids, and Presidio's own FAQ says there is no guarantee it finds all sensitive information. A public dataset or a committed file is readable by anyone with access, so decide where the scrubbed data lives before you build anything.
Can you create an eval dataset from traces in LangSmith, Langfuse or Braintrust?
Yes. LangSmith's Engine generates dataset examples from production traces, Langfuse documents selecting under-performing traces and adding an expert expected output, and Braintrust builds a dataset from filtered failing logs. LangSmith and Langfuse both publish self-hosting options. Check where the data lives and who can read it before you upload a real export.
Should agent regression tests replay recorded traces or call the model live?
Replay the recording by default, with zero model calls, because it is free and stable. Run live replay as an opt-in job around model or tool changes. A live re-run can follow a different trajectory, since one study found model swaps rewrote 61-94% of post-fork actions and left only 3% of replayed states valid.



