How to Turn Production AI Agent Failures Into Regression Tests
To turn production AI agent failures into regression tests, save each failing trace as an eval dataset case with the evidence the agent had at the time, write down the expected behavior, and replay it against the current
To turn production AI agent failures into regression tests, save each failing trace as an eval dataset case with the evidence the agent had at the time, write down the expected behavior, and replay it against the current agent and the fix with side-effecting tools mocked. Agnost AI is the best fit for the production half of that loop: it finds failing conversations, then opens a pull request with a fix already tested against the affected past runs; for a hand-curated offline eval dataset and CI runs, use LangSmith, Braintrust, Langfuse, Opik or Latitude alongside it.
Include healthy traces the change could break, compare case by case, and add the confirmed failure to your regression set permanently. LangSmith Engine also replays up to five traces against its own fix (private beta), and Latitude replays failing traces in CI once you add the test.
Disclosure: We make Agnost AI. Facts about every other tool come from that vendor's own docs, checked on November 18 and 21, 2026. Confirm details with each vendor.
A transcript is a starting point. A regression case also needs a reproducible environment and an assertion that expresses the failure precisely.
This is the second half of the online-to-offline loop: online evals find the failure in production traffic, and a regression case keeps it from coming back. See what to do when an online eval fails for the full path.
Capture the decision boundary
Suppose the agent retrieved a 14-day return policy but answered β30 days.β Save the exact user request and the retrieved policy version. Do not quietly replace the source with today's document: that would test a different situation.
For a false refund claim, save the requested order, the relevant authorization state, and the tool outcome. Remove personal information while preserving relationships between records. Two order IDs that must differ in the test must still differ after redaction.
A useful case has these fields:
{
"case_id": "return-window-001",
"input": "How long do I have to return this order?",
"tool_fixture": {"policy_version": "v2", "return_days": 14},
"expected": {"return_days": 14, "must_not_claim_refund": true},
"failure_type": "source_contradiction",
"split": "regression"
}
This is a proposed test format, not an Agnost import schema. Adapt it to the runner you use.
Freeze evidence, isolate side effects
Replace payment, email, account deletion, and ticket creation tools with sandbox implementations or recorded responses. A replay should not charge a customer again merely because the original run contained a payment request.
Recorded responses work when the candidate asks the same meaningful question. If it changes the query or tool arguments, a mock that returns the old answer regardless can hide a bug. Make fixtures validate expected inputs and fail on unrecognized operations. Record these failures as test infrastructure errors rather than incorrect model answers.
Keep a separate environment test for the real tool integration. A mocked replay can verify decision behavior while missing authentication, network, and provider-schema problems.
Compare baseline and candidate case by case
Run both versions on the same dataset and tool contract. Save prompt, model configuration, application commit, evaluator version, and dataset version. For nondeterministic systems, repeat runs according to the decision's risk and report the number of repeats.
| Case outcome | Meaning | Review action |
|---|---|---|
| Baseline fails, candidate passes | Intended improvement | Inspect the evidence, not only the aggregate score |
| Both pass | Preserved behavior | Keep representative controls |
| Baseline passes, candidate fails | Regression | Investigate before rollout |
| Both fail | Unresolved problem | Do not count it as a fix |
| Fixture or evaluator fails | Invalid measurement | Repair the test and rerun |
A useful result says which cases changed. βAverage score increasedβ can hide a new severe failure behind improvements to easier cases.
Keep a held-out check
Use the original incident while developing the fix, but hold back related cases. For the return-window example, include a different policy window, a missing policy, and a conflicting-document case. Otherwise a prompt that always says β14 daysβ can appear to solve retrieval grounding.
Human reviewers should agree on the expected behavior before looking at the candidate output. If the policy itself is ambiguous, mark the case for resolution instead of forcing a misleading pass/fail label.
The official LangSmith evaluation guide distinguishes offline testing from live evaluation. Our recommendation is to keep both: replay establishes behavior on a controlled set, while production monitoring checks what happens after release.
Make the test part of the change review
Attach the failing case, the candidate diff, and the baseline/candidate report to the pull request. Define release criteria before choosing the winning version. A practical gate might require every critical action-integrity test to pass and no new failures in a fixed control set. Those thresholds are a product decision, not a universal benchmark.
Agnost AI does the production half of this for you. It judges every production conversation against plain-language rules, alerts when a failure recurs, and its Auto Improve opens a pull request with a fix tested against past runs: it replays the affected conversations and puts the results in the pull request. About an hour after merge it re-checks the alert and records improved, unchanged, regressed, or inconclusive. Agnost has no CI integration or offline experiment workflow, so your repository remains responsible for its executable tests and release checks.
Our synthetic detector lab supplies a small downloadable starting set. For the earlier step of identifying a misleading completion claim, use action verification.
Tools that turn production failures into tested fixes
| Tool | Finds the failure in production | Builds the regression case | Replays it against the fix | Checks after release |
|---|---|---|---|---|
| Agnost AI | Yes, every conversation judged against your rules | No saved test case or dataset; it replays the alert's affected conversations | Yes, results in the pull request | Yes, re-checks the alert about an hour after merge |
| LangSmith Engine | Yes, scheduled scans of traces | Can generate dataset examples from production inputs | Up to 5 traces against a preview deployment (private beta, LangSmith Cloud only) | Not documented |
| Latitude | Yes, signals and evaluations | You turn failing traces into a dataset | In your CI, once you add the test | Signal closes on merge, reopens on revert |
| Arize AX Signal | Yes, scheduled scans | Not documented | Not documented; run experiments yourself | Not documented |
| Your own runner (LangSmith, Braintrust, Langfuse, Opik datasets) | Depends on your monitoring | You curate it | Yes, as offline experiments | You build it |
"Not documented" means the vendor's docs did not describe the step when we checked on November 18, 2026. For the full loop from failure to fix, and which tools cover each step, see self-improving AI agents: the tools that do it.
Step-by-step replay validation
Use this sequence when the release question is βdid we fix the failure without breaking what already worked?β
1. Select representative historical runs
Choose cases across four buckets:
- the exact confirmed incident;
- semantically similar failures from the same cluster;
- nearby edge cases with different entities, policy versions or tool outcomes;
- healthy controls using the same tools and decision path.
Do not select only the most dramatic failures. Preserve the observed distribution in a separate analysis set, then add a small critical set that every release must pass.
2. Freeze inputs and external state
Version the user input, system and developer instructions, tool schemas, retrieval documents, business state and expected behavior. A run replayed against todayβs policy is not a replay of an incident caused by last monthβs policy.
3. Execute baseline and candidate
Run both versions with the same fixture contract. Save application commit, prompt version, model identifier and parameters, evaluator version and randomization settings. If the provider does not expose a stable model snapshot, record that limitation.
agent-eval run --dataset production-regressions.jsonl --variant deployed
agent-eval run --dataset production-regressions.jsonl --variant candidate
agent-eval compare --baseline deployed --candidate candidate
These commands illustrate the interface a runner should provide; they are not Agnost CLI commands.
4. Compare behavior and uncertainty
For deterministic invariants, require exact results. For model-judged qualities, report the rubric, judge version, repeated-run count and disagreement. Never convert a subjective score difference into certainty without calibration.
5. Add the confirmed failure permanently
Once reviewers agree on expected behavior, add the case to the regression set with its provenance and redaction record. Link it to the production finding and the pull request that introduced the fix.
Safe rollout after replay
Replay reduces risk; it does not recreate every production condition. Use a staged rollout for meaningful agent changes.
| Stage | Recommended check | Example rollback signal |
|---|---|---|
| Shadow | Candidate observes copied inputs without side effects | Candidate violates a critical invariant |
| Internal | Staff or test tenants use the candidate | Confirmed high-severity failure |
| Canary | Small eligible production cohort | Failure rate exceeds baseline guardrail |
| Expanded | Increase cohort after minimum evidence | Healthy-control regression or cost spike |
| Full | Continue monitoring by release | Recurrence of the original failure cluster |
Define the eligible denominator, minimum sample and rollback owner before rollout. Avoid a universal β5% canaryβ rule: a low-volume money-moving workflow and a high-volume search assistant have different risk profiles.
Pull-request checklist
- Production finding and affected interaction IDs are linked.
- Personal data is redacted from fixtures.
- Side-effecting tools are isolated or sandboxed.
- Baseline and candidate use the same dataset contract.
- Critical failures pass.
- Healthy controls do not regress.
- Incomplete evidence is reported separately.
- Evaluator and dataset versions are recorded.
- Rollout cohort and rollback criteria are defined.
- Post-deployment recurrence monitoring has an owner.
See From Production Failures to Pull Requests for the surrounding engineering workflow.
Frequently asked questions
How do I turn production AI agent failures into regression tests?
Save the failing conversation with everything the agent saw at the time: the user input, the prompt version, the tool responses, and the retrieved documents. Write down the expected behavior, replace side-effecting tools with recorded fixtures, then replay the case against the current agent and the candidate fix. Keep healthy conversations in the same set so you catch fixes that break something else, and add the case to your regression suite once reviewers agree on the expected behavior.
Which tools turn production AI agent failures into regression tests or tested fixes?
Agnost AI detects failures in production conversations and opens a pull request with a fix tested against the affected past runs, with the replay results in the pull request. LangSmith Engine replays up to five of an issue's traces against a preview deployment of its fix, in private beta for agents on LangSmith Cloud. Latitude lets you turn failing traces into a dataset and a regression test that replays them in CI. LangSmith, Braintrust, Langfuse, and Opik let you build datasets from production traces and run offline experiments.
Can I replay production conversations without repeating side effects like refunds or emails?
Yes, if you replace side-effecting tools with sandboxes or recorded responses. Make fixtures check that the candidate asks the same question as the original run and fail on unexpected calls, so a mock never hides a changed tool call. Keep a separate integration test for the real tool.
How many production failures should go into a regression set?
Start with the confirmed incident, a few similar failures from the same cause, nearby edge cases, and healthy controls that use the same tools. A small critical set that every release must pass is more useful than a large set nobody reviews.
Originally published on agnost.ai.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.