Agent regression testing checks that changes to an AI agent do not break its tool use, workflow rules or effects on business systems. The reliable approach combines deterministic tests for known cases with trajectory scoring and state assertions, then uses controlled live-model runs to check behaviour that mocks cannot reproduce. If you are still deciding which workflows are safe to automate, start with our AI strategy and solutioning service; if you already have an agent, this guide shows how to make its releases safer.
A conventional unit test often expects the same function to return the same result for the same input. An agent is different. It chooses actions across several steps, interprets tool responses and may take more than one valid route to an outcome. A test that checks only the final sentence can miss a duplicate refund, a skipped verification or an unnecessary call that wastes time and money.
This guide lays out a practical method for building regression tests around those risks. It covers what to prepare, how to create deterministic environments, how to score alternative trajectories, and how to turn production incidents into durable tests. The method works with different orchestration frameworks and can be adapted to agents that use MCP servers or other tool interfaces.
What should agent regression testing prove?
A regression suite should answer a simple question: after a change, does the agent still reach an acceptable outcome through an acceptable process, without causing a forbidden side effect?
That question has three parts:
- Outcome: Did the agent satisfy the user’s request accurately?
- Trajectory: Did it use the right tools, pass valid arguments and respect dependencies between actions?
- State: Did the system of record end up in the correct state, with no duplicate or unauthorised changes?
A final-answer check is useful, but it covers only the first part. An agent might tell a customer that a refund is complete even though the refund tool was never called. It might also call the refund tool twice, then produce a perfectly plausible confirmation. You need evidence from the tool trace and the resulting state, not just a judge rating of the prose.
The AWS guide to agent failure detection and root-cause analysis describes failures across the agent’s steps and shows why intermediate events matter when diagnosing a bad result. The exact labels differ between frameworks, but the engineering lesson is consistent: capture enough detail to discover where the workflow first went wrong.
What do you need before writing tests?
Start with the workflow, not the evaluation tool. A testing platform cannot decide which actions are safe for your business. Your team must define that contract first.
1. Pick one bounded workflow
Choose a workflow with a clear start condition and a verifiable finish. Examples include checking an order’s refund eligibility, drafting a support response from approved policy content, or updating a customer record after identity verification.
Avoid starting with a broad goal such as ‘handle customer service’. That spans too many intents, permissions and failure modes. A bounded workflow gives you a testable unit and makes it easier to control the data and tools involved.
For the first workflow, write down:
- What the user can ask for.
- What the agent is allowed to do without approval.
- Which tools it may call, and which it must never call.
- What counts as success in the system of record.
- When it must stop, ask a question or hand the work to a person.
2. Map the agent’s dependencies
List the components that can change behaviour. That usually includes the system prompt, model and model settings, retrieval content, tool descriptions and schemas, orchestration code, access controls, and external services. You do not need to test every combination on every code change. You do need to know which layer changed so the release pipeline can run relevant tests.
A tool schema change, for example, should trigger checks that arguments still match the contract. A prompt change should run the workflow’s core examples and its safety cases. A retrieval change should include examples where the answer depends on updated source material.
3. Define the evidence you need to retain
For each test run, capture the user input, relevant context, model and prompt versions, tool calls and arguments, tool responses, timestamps, final answer, and state changes. Store secrets separately and avoid copying unnecessary personal information into test records.
This trace is what lets you compare a new run with a known-good run. It also gives you a useful starting point when a test fails. The LangChain explanation of evaluating agents at run, trace and thread level is a useful reference for thinking about evaluation at more than the final-answer level.
4. Agree what failure means
Make the release rules explicit before the first test run. A wrong final answer might be a failure. So might a correct answer delivered after a forbidden tool call, an invalid argument, a repeated write, or an excessive number of steps.
Separate hard failures from quality warnings. A prohibited action or incorrect database state should block release. A slightly different but valid order of independent lookups may deserve review, not a red build. This distinction helps keep the suite useful rather than turning every harmless variation into a release emergency.
Step 1: Build a small, risk-based test set
A good first dataset is not a large pile of loosely related prompts. It is a set of representative cases tied to explicit expectations. Include the routine path, boundary conditions, missing information, tool errors and attempts to exceed the agent’s permissions.
For a refund workflow, a starter set might include:
| Scenario | Expected behaviour | Evidence to check |
|---|---|---|
| Eligible order, verified customer | Check eligibility, then process the permitted refund | One refund record for the expected amount |
| Ineligible order | Explain the reason and do not process a refund | No refund write |
| Customer identity is unclear | Ask for clarification or escalate | No account lookup beyond allowed access |
| Eligibility tool returns an error | Stop safely or offer a supported next step | No invented eligibility result or refund |
| User requests an unauthorised amount | Refuse or route for approval | No override or write action |
| Tool returns an empty record | State that the record could not be confirmed | No fabricated customer or order details |
These examples are starting points, not a universal set. Your real cases should come from business rules, risk analysis and observed failures. Include cases that exercise the same rule in different wording, so the agent does not pass only because a test phrase resembles its prompt.
Do not treat success as a single string match. A user can ask the same thing in different words, and an agent can answer correctly in more than one way. Prefer checks that inspect the meaning, actions and resulting state. Keep exact text assertions for cases where wording itself is contractually important, such as a required disclosure.
A useful test record contains:
- A stable case identifier and a plain-language scenario description.
- The input and the controlled starting state.
- Expected allowed actions and forbidden actions.
- Required preconditions and postconditions.
- The maximum acceptable step or tool-call budget for that scenario.
- Any response-quality checks, with examples of acceptable variation.
The Arthur article on building regression datasets from production failures describes the value of converting real failures into repeatable cases. Use that idea carefully: retain the failure condition and the control that should have prevented it, but remove or replace private data before the case enters a test dataset.
Step 2: Create deterministic tools and state
Tests become unreliable when they depend on live third-party services, changing records or network conditions. A deterministic test environment replaces those dependencies with controlled responses and a state store you can inspect. Using mocks for agent testing isolates your harness from network flakes and unexpected API changes.
Mock at the boundary, not in the rule you are testing
A mock tool should represent the contract the agent sees. If the production tool accepts an order identifier and returns eligibility status, the test mock should accept the same shape and return controlled results. It should validate the input schema and fail clearly when the agent sends a malformed argument.
Do not mock the very business rule you want to verify. If the test is meant to check that a refund only happens after eligibility has been approved, keep that rule in the test harness. The fake eligibility tool can return approved or declined, but the assertion must independently check that the refund call followed the correct condition.
For each tool, define:
- The input schema, including required fields, types and permitted values.
- A small set of realistic response fixtures.
- Errors and timeouts the agent may encounter.
- Whether the tool is read-only or can change state.
- What state change a successful write should produce.
Use recorded responses with care
Recorded request and response cassettes can make integration tests repeatable. They are useful for preserving the shape of an external service response and testing your adapter’s handling of it. They can become brittle if they capture volatile fields, depend on stale data or contain sensitive records.
Before adopting replay, define which fields matter. Normalise values such as request IDs and timestamps where they do not affect the contract. Keep separate fixtures for materially different outcomes, such as a successful response, a validation error and a temporary service failure. Review fixture updates as code changes, rather than silently replacing the expected response whenever a test breaks.
Run write tests against throwaway state
If the agent writes data, give each test an isolated database or equivalent disposable state store. Set up a known starting record, run the agent, then inspect what changed. A test should be able to distinguish a single correct write from a duplicate write, a partial update or a write against the wrong record.
For a refund example, assert the final record count, amount, currency and order reference. Also assert that unrelated records remain unchanged. A natural-language statement that a refund succeeded is not evidence that the transaction was correct.
Test realistic faults deliberately
A stable mock environment should let you inject failures on purpose. For example, make a tool return a timeout, an empty payload, a malformed response or a rate-limit error. Then verify that the agent stops, retries only within the policy you have defined, or escalates. The agent must not fill gaps in a failed tool response with invented facts.
This is especially important for write operations. If a timeout occurs after a request reaches the service, the agent may not know whether the action completed. The safer behaviour may be to check the transaction status before retrying, or to hand the case to a person. Write the expected behaviour into the test rather than assuming that another attempt is harmless.
Step 3: Decide what is mocked and what stays live
A deterministic test suite does not mean that every model interaction must be mocked forever. It means separating tests by what they are meant to prove.
| Test layer | Model and tools | What it is good for | Typical release role |
|---|---|---|---|
| Unit and contract tests | Mock model decisions or call the tool adapter directly; mock external services | Schema validation, tool permissions, state rules and error handling | Run on every change |
| Agent regression tests | Run the agent against deterministic tools and controlled state | Prompt and orchestration behaviour across known cases | Run on relevant changes and before release |
| Live-model evaluation | Use a fixed dataset with real model calls and controlled tools | Detect behaviour changes that mocks cannot represent | Run on a schedule or release candidate |
| Production monitoring | Real traffic and real integrations, with controls | Find drift, new failure patterns and operational issues | Continuous after release |
Use mocked model outputs when you are testing code paths that do not depend on the model’s decision. For instance, you can test that an adapter rejects a malformed tool call without paying for a model run. But a mock that always selects the expected tool cannot prove that the actual model will select it.
For behaviour-sensitive cases, run the real model against a controlled environment. Keep the inputs, tools, data and scoring rules stable enough to compare runs. If the model provider, model version, system prompt or decoding settings change, record that change with the result. This lets you distinguish a product regression from a changed evaluation setup.
A practical pipeline splits work by cost and purpose. Run fast contract and deterministic checks on each relevant code change. Run a broader live-model evaluation before release or on a regular schedule. If the live run finds a new failure, promote it into the deterministic suite where possible. Keep the live-model suite focused on questions that genuinely require a model, rather than rerunning every low-level test through a paid endpoint.
Do not call a test deterministic just because you set temperature to zero. The agent still depends on the model service, retrieval, orchestration and any external response not fully controlled by the harness. Treat repeatability as something to measure and manage, not a setting you can switch on once.
Step 4: Score the trajectory, not an exact path
A trajectory is the sequence of decisions, tool calls and observations that make up an agent run. Scoring it is central to agent regression testing, but exact sequence matching is often the wrong default.
Suppose a workflow needs to look up an order and verify a customer. If those two read-only calls are independent, either order may be valid. An assertion that demands one exact sequence will flag the other as a failure even though the work is safe and correct. By contrast, processing a refund before eligibility is confirmed is a genuine failure.
Write checks around contracts and dependencies:
- Required action: A required tool must appear when the task and available information call for it.
- Precondition: A sensitive write is allowed only after its required verification result.
- Forbidden action: A tool outside the agent’s permission set must never appear.
- Argument validity: Tool arguments must meet the schema and business constraints.
- Result handling: The agent must use the returned data accurately and must not claim a tool succeeded if it failed.
- Budget: The run must stay within a justified step or tool-call limit.
- State: The final system state must satisfy the business rule.
A dependency graph can make these expectations clear. Represent each relevant action as a node and each required ordering rule as an edge. For example, verify_identity must precede read_account; check_eligibility must precede process_refund. Independent lookups have no edge between them, so either order can pass. Keep the graph small enough that reviewers can understand it.
Not every workflow needs a graph library. A simple trace validator can check whether the required event occurred before another event and whether its result met a condition. The important point is to encode the business rule, not a snapshot of one model’s preferred route.
Check tool arguments structurally. If a tool expects a UUID, date or monetary amount, validate its format and range before counting the call as acceptable. Schema validity alone is not always enough: a well-formed amount can still exceed the amount the user is entitled to receive. Keep format checks and business-rule checks separate so a failure report says what went wrong.
Set step budgets from the workflow, not from a generic target. A short lookup task should not be allowed to loop through many repeated calls simply because the agent eventually got the answer. Track repeated tool signatures, such as the same tool with the same arguments, and test that the agent stops or escalates under the conditions you define.
Step 5: Assert the system state and the user-facing answer
A good test has several layers of assertions. First validate the trace. Then inspect state. Finally assess the answer shown to the user.
For a refund test, the assertions might say:
- The order lookup used the expected order identifier.
- Eligibility returned an approved result before the refund action.
- The refund tool received the approved amount, not an amount invented by the agent.
- The test database contains one refund record for the expected order and amount.
- No other order or customer record changed.
- The final response accurately describes the result and does not overstate what happened.
This sequence helps with diagnosis. If the final answer is wrong but the tools and state are correct, investigate response generation. If the answer sounds right but the state is wrong, the defect is more serious and likely lies in tool selection, retries or transaction handling.
For free-form answers, avoid a brittle requirement that the response match one reference sentence. Check required facts and prohibited claims. You can use a human review or an automated evaluator for meaning, but do not make a language-model judge the only gate for a high-impact write. The agent’s own prose and a second model’s opinion do not replace checking the transaction that actually occurred.
Keep expectations for the final answer proportionate to the user’s need. A successful low-risk lookup may need a concise factual response. A failed write should clearly state that the action was not confirmed and explain the next step. A tool error should not be translated into certainty.
Step 6: Test repeatability and comparison fairly
Because an agent can take different routes across runs, one successful test run does not prove reliable behaviour. Repeat selected cases and record how often all required conditions hold. Distinguish between metrics that ask whether an agent succeeded at least once and metrics that ask whether it succeeded consistently. For operational workflows, the latter question is often closer to the customer’s experience: a customer usually gets one attempt, not several retries in a benchmark.
Do not turn a small run count into false confidence. Record the number of runs, the exact configuration and which checks passed on every run. A case that passes once and fails on another run should be investigated even if the average score looks acceptable. Repetition is most valuable for sensitive actions, known flaky scenarios and releases that change the model or its instructions.
When comparing release versions, use the same dataset, environment and scoring rules. Group the results by failure type rather than relying on one headline score. A change could improve answer quality while making tool selection worse. You want to see both, as well as state violations, invalid arguments, unnecessary calls and budget overruns.
Keep a reviewable baseline. When behaviour changes intentionally, update the expected trajectory rules or acceptable answers with a brief explanation and an owner. Do not simply accept a new baseline because the old test failed. That can convert a real regression into an unexamined new normal.
Step 7: Turn production incidents into regression cases
An incident is valuable test material if you preserve the conditions that caused it and the rule that should prevent it. The conversion process should be routine, not an afterthought.
- Find the trace. Collect the prompt context, relevant tool events, responses and final state for the failed interaction.
- Remove sensitive data. Redact or replace personal and confidential values. Use synthetic identifiers and amounts where the specific production values are not required to reproduce the failure.
- Describe the failure. State what the agent did, what it should have done and which control failed.
- Recreate the case. Build a fixture or controlled initial state that reproduces the important condition without reaching production systems.
- Add independent assertions. Check the missed precondition, forbidden call, bad argument or incorrect final state. Do not only assert that the final prose has changed.
- Run it against the fix. Confirm the test fails on the faulty version and passes on the corrected version.
- Keep the case. Add it to the suite that runs for future changes to the affected component.
For Australian organisations, be deliberate about personal information in traces and evaluation datasets. Production logs can contain details that are not needed to reproduce the behaviour. Apply your privacy and information-handling controls before sharing traces with a hosted evaluation service or placing fixtures in a repository. Security and privacy teams should review the storage and access model where the workflow handles sensitive information.
A useful incident test captures both the mistake and the barrier that should have caught it. If a timeout led to a duplicate write, for example, test the uncertain-outcome path and the idempotency or status-check behaviour. If a tool response was ignored, test that the final answer stays consistent with the returned result. A trace that merely reproduces the input without checking the original failure mode has limited value.
Step 8: Put the suite into the release process
A test suite is only effective if the right people see its results before release. Make the checks part of the workflow used by engineering, product and risk owners, and make failures understandable enough to act on.
A sensible release gate separates severity:
- Block release: forbidden tool call, unauthorised write, incorrect system state, missing mandatory verification, invalid high-risk argument or a failed critical case.
- Require review: meaningful answer-quality decline, unexpected but potentially valid trajectory, repeated-call increase or a new tool error pattern.
- Record and monitor: small non-critical wording variation or a metric movement that has not crossed an agreed threshold.
The exact thresholds should come from your workflow’s risk and operational requirements. Avoid borrowing a threshold from another team without understanding its test set and consequences. A support draft and a payment instruction should not be governed by identical release rules.
Make failure reports include the case identifier, changed configuration, failing assertion, relevant trace events and state diff. A developer should be able to see whether the problem was a missing precondition, a schema mismatch, an unexpected retry or a poor answer. A generic red status creates pressure to bypass the gate.
Keep the test data and environment versioned. Record changes to tool schemas, fixtures, prompts and evaluation rules. If a test passes only because its mock was updated to accommodate a new response shape, reviewers should be able to see whether that shape change is intended and whether the production integration has the same contract.
Common mistakes to avoid
Testing only the final response
A polished answer does not prove that the agent used the right tools or changed the right record. Test the trajectory and state as well as the response.
Demanding one exact tool sequence
Exact path checks create noise when independent actions can happen in either order. Assert dependencies and safety conditions instead.
Running every test against live services
Live calls can add latency, consume budget and make results depend on changing data or service availability. Keep most contract and state tests controlled, then reserve real model and integration runs for the questions that need them.
Treating mocks as proof of model behaviour
A deterministic mock proves the behaviour you put into the mock. It cannot prove how a live model will choose tools. Use both controlled regression tests and targeted live-model evaluations.
Ignoring duplicate and uncertain writes
A retry can be dangerous if the first request succeeded but the response was lost. Test timeouts around writes and verify the system state, not just the agent’s retry message.
Allowing the evaluator to share the agent’s blind spots
If the test checks only what the agent says, it may miss the same unsupported assumption the agent made. Use independently constructed assertions tied to business rules and stored state.
Replacing failing baselines without review
Changing expected outputs can hide a regression. Require a reason, a reviewer and an explanation of why the new behaviour is acceptable.
A practical first release plan
You do not need a large evaluation programme to start. Make the first suite narrow, explicit and useful to the team shipping the agent.
- Choose one bounded workflow with a clear outcome and a small set of tools.
- Write down its permissions and state rules, including actions that must never happen.
- Create representative fixtures for routine, boundary and error cases.
- Build deterministic tool mocks and an isolated store for write tests.
- Add trajectory, schema, budget and state assertions.
- Run a small live-model comparison for the cases where model choice matters.
- Connect the checks to release review and make failures easy to diagnose.
- Convert the next production failure into a new test after removing sensitive data.
Then expand where evidence tells you to. Add cases for incidents, new tools and changing business rules. Keep the suite focused on risks that matter to the workflow, and remove or repair tests that no longer represent production behaviour.
Where PADISO fits
At PADISO, we help teams design and productionise agents, including their tool boundaries, evaluations and release controls. Our AI agents and automation service can help you assess an existing workflow and build a testing approach around its real operational risks. If you need broader platform support, our platform engineering team can help align the agent’s test harness with its architecture and delivery pipeline.
Wrap-up
Agent regression testing is not a demand that every run follow one script. It is a way to define which outcomes, actions and state changes are acceptable, then check those rules consistently as the agent changes. Start with one workflow, mock its dependencies, score the important trajectory invariants, and inspect the resulting state. Add live-model checks where they provide evidence mocks cannot, and turn real failures into durable tests.
The next step is to choose one agent workflow with a consequential tool call and write down its required preconditions, forbidden actions and expected final state. If you want help assessing where to start, take the PADISO AI readiness test.