Article · AI agent reliability

How to build regression tests for LLM agents

Turn one diagnosed failure into a repeatable test that catches the same mistake before release.

Intermediate10 minute readRegression testing

A regression test is most valuable when it preserves the evidence from a real failure. Instead of asserting only that the final answer was wrong, preserve the request, the execution path, the first divergence, and the evidence that should have grounded the answer.

Core idea: assert the first incorrect decision, not only the last visible error.

Example: preserve the wrong-tool trace

Take the Acme Corp request: “Who owns the Acme Corp account?” The planner identifies a CRM lookup, but the agent calls weather_api, accepts a weather response, and aborts. This is a better regression fixture than a generic “agent failed” case because it names the expected tool, the wrong tool, the irrelevant output, and the failure outcome.

Download the example trace JSON

1. Capture the failure as a fixture

Save the user request, expected behavior, tool definitions or identifiers, step order, relevant inputs and outputs, and the final outcome. Redact real customer data; this example uses synthetic Acme data.

{
  "request": "Who owns the Acme Corp account?",
  "expected_tool": "crm_lookup",
  "observed_tool": "weather_api",
  "first_divergence": "step_2",
  "outcome": "failed"
}

2. Use TraceProbe to find the assertion points

Read the failed fixture in the same order you will test it:

  1. Summary: record the failure count and primary diagnosis.
  2. Phase Timeline: record ordering, retries, and timing that matter to the failure.
  3. Reasoning Graph: locate the first wrong transition from plan to tool.
  4. Step Details: capture the tool name, arguments, raw output, and status detail.
TraceProbe phase timeline for a failed agent regression fixture

The timeline shows where the fixture spends time and whether the failure is isolated or amplified by retries. Use it to avoid writing a test that passes while a retry loop or timeout still exists.

TraceProbe reasoning graph showing the failed weather tool path

The reasoning graph identifies the wrong-tool transition. That transition becomes the most important assertion in the test.

TraceProbe step details showing the failed weather API result

Step Details supplies the evidence behind the assertion: the tool arguments and weather output cannot answer the CRM question.

3. Write assertions around behavior

Assert the expected decision and the evidence chain, not brittle presentation details:

// Illustrative test shape
assert.equal(run.steps[0].summary, "Plan CRM lookup");
assert.equal(run.steps[1].tool, "crm_lookup");
assert.match(run.steps[1].arguments.account, /Acme/i);
assert.equal(run.steps[2].output.account_owner !== undefined, true);
assert.equal(run.outcome, "success");

If your test is specifically guarding against the historical failure, keep a negative assertion too: a weather result must not be accepted as evidence for the CRM request.

4. Rerun the fixture after every relevant change

Run the fixture after changing prompts, tool descriptions, routing, retrieval, models, or orchestration. In TraceProbe, compare the new run with the original failure and verify that the first divergence is gone—not merely that the final text looks better.

  • The selected tool matches the plan.
  • The arguments match the tool schema.
  • The returned evidence answers the request.
  • The final outcome is successful without an unexplained retry or fallback.

Summary

A durable agent regression test turns a trace into a contract: given this request, the agent must make this decision, use this evidence, and produce this outcome. TraceProbe keeps the plan, tool calls, evidence, timing, and diagnosis together so the contract remains inspectable when the implementation changes.

Turn failures into guardrails.

Use TraceProbe to make every regression fixture explainable.

Get TraceProbe