I Run Automated Regression Tests on… AI recommendations | Parse
How can I run automated regression tests on my AI agent's responses?
Data as of Sep 26, 2026 · Based on 52 AI responses from ChatGPT Search and Google AI Mode · See how Parse measures this
Sources AI cites for this prompt
Source
Citation share
9 Best AI Chat Agent Testing Platforms for Automated QA and ...https://www.cekura.ai/discover/ai-chat-agent-testing-platforms
2%
Regression Testing and CI/CD | MLflow AI Platformhttps://mlflow.org/docs/latest/genai/eval-monitor/regression-testing/
2%
3. Automated regression testing plans with Agentic AIhttps://www.youtube.com/watch
2%
What's your process for automated testing for AI agents? - Communityhttps://community.openai.com/t/whats-your-process-for-automated-testing-for-ai-agents/295444
1%
EvalView – pytest for AI Agents | Open Source Agent Testing Frameworkhttps://evalview.com/
1%
Trust at Scale: Regression Testing Multi-Agent Systems in ... - Mediumhttps://bhargavaparv.medium.com/trust-at-scale-regression-testing-multi-agent-systems-in-continuous-deployment-environments-99dfcc5872e9
1%
Demystifying evals for AI agents \ Anthropichttps://www.anthropic.com/engineering/demystifying-evals-for-ai-agents
Running automated regression tests on an AI agent is fundamentally different from testing traditional software or a simple single-turn chatbot . Because agents execute trajectories —chains of reasoning, state updates, tool calls, and multi-turn interactions—a regression isn’t just a wrong final string; it can be an infinite loop, a missed API parameter, or a hallucinated tool selection.[1]
A robust automated regression testing pipeline for AI agents follows a 4-step architecture using modern evaluation stacks.
Step 1: Build a Golden Dataset of Agent Trajectories
You cannot test what you haven't recorded. Gather a dataset of representative test cases (inputs + expected agent behavior).
Single-turn expectation: Input → Expected final response or semantic meaning.
Multi-turn / Tool-use expectation: Input → Expected sequence of tool calls (e.g., must call get_weather before send_notification ) and final output.
Sources: Curate test cases from edge cases, past user complaints, and synthetic data generators built into tools like DeepEval.
The most reliable pattern is to treat your AI agent like a software component with a versioned evaluation suite, rather than expecting its responses to be byte-for-byte identical.
Question: How can I run automated regression tests on my AI agent's responses?
Yes. The most reliable approach is to treat your agent's behavior like a testable API: keep a versioned set of representative tasks, run the agent against them automatically, grade the outputs, and fail CI when quality regresses.
Question: How can I run automated regression tests on my AI agent's responses?
Integrate an evaluation framework that behaves like pytest or a CLI runner for your CI/CD pipeline. The leading options fit different parts of the workflow:
For fast CI/CD gating & local runs:Promptfoo is a lightweight CLI-driven tool that runs fast matrix tests and catches prompt/model regressions on every commit.
For comprehensive assertions & agent metrics:DeepEval provides Python-native unit testing for LLMs, checking things like hallucination, tool correctness, and multi-step tracking.
For deep multi-step tracing & observability:Arize Phoenix or LangSmith map out the agent’s execution graph to see where a decision drifted.
Step 3: Define Metrics Beyond Exact Match
Traditional string matching (assert output == expected ) fails for AI agents. Instead, use a blend of programmatic and model-based metrics:
Deterministic assertions: Did the agent invoke the correct JSON schema for a tool call? Did it avoid forbidden words (pii, competitor names)?
LLM-as-a-Judge: Use a stronger, stable model (like GPT-4o or Claude 3.5 Sonnet) with a defined rubric to grade the agent's trajectory. Prompt the judge with: "Given the user input X and the agent's tool execution steps Y, did the agent successfully accomplish the goal without unnecessary loops? Rate 1-5 and explain."
Semantic similarity / Correctness: Measure whether the meaning matches the golden reference, even if the phrasing changed.
Step 4: Wire into CI/CD (GitHub Actions / GitLab CI)
Trigger your eval suite automatically whenever a prompt changes, an underlying model version updates, or agent code is modified:
Developer pushes a prompt or tool-definition update.
CI/CD spins up and runs your evaluation harness (e.g., promptfoo eval or a pytest script running DeepEval metrics).
If the aggregate score drops below your threshold (e.g., faithfulness drops below 95% or a tool-selection failure occurs), the build fails and blocks deployment.
Export traces to a monitoring platform like Braintrust or LangFuse for root-cause inspection.
If you'd like to dive deeper, let me know:
What framework are you building your agent in (LangChain, LlamaIndex, CrewAI, custom Python)?
Are you primarily worried about text response regressions or incorrect tool/API calls?
I can provide a code snippet for setting up your first test suite.
A practical setup
Create a test dataset
50–500 representative user requests.
Include normal cases, edge cases, ambiguous requests, adversarial inputs, and previously observed failures.
Store expected properties rather than necessarily storing one exact answer.
Example:
{
"input": "Cancel my order #1234",
"expected": {
"intent": "cancel_order",
"must_not": ["claim cancellation succeeded without confirmation"],
"must_call_tool": "cancel_order"
}
}
For an agent, the trajectory is often more important than the final text. An answer can look correct while the agent used the wrong tool or fabricated information.
3. Use multiple graders
I recommend having separate tests for:
Correctness — Did it reach the right conclusion?
Instruction following — Did it follow your application's rules?
Tool use — Did it call the right tool with valid arguments?
Groundedness — Are claims supported by the retrieved/contextual information?
Safety — Did it avoid prohibited behavior?
Format/schema — Is structured output valid?
Conversation state — Did it preserve relevant context?
Efficiency — Excessive tool calls, latency, or token usage.
For deterministic properties, use ordinary code assertions. For subjective qualities such as correctness or groundedness, use an LLM judge plus a smaller set of human-reviewed cases. OpenAI's current grader system supports string checks, similarity graders, Python graders, score-model graders, label-model graders, and combinations of graders. OpenAI PlatformOpenAI Platform
4. Define pass/fail gates
More importantly, don't let an overall average hide critical regressions. A safety failure shouldn't be compensated for by 99 excellent answers.
5. Run the suite in CI
Your pipeline becomes roughly:
Pull request
↓
Build agent
↓
Run regression dataset
↓
Run deterministic assertions
↓
Run LLM graders
↓
Compare against baseline
↓
PASS → merge
FAIL → block + show changed cases
Keep the previous version's results so you can say:
For free-form responses, have a grader evaluate explicit criteria rather than comparing strings.
Add "golden" failure cases
Every time a production failure occurs, turn it into a permanent regression test:
production bug
↓
red test
↓
fix
↓
test becomes green
↓
test stays forever
This is particularly valuable for agents because their behavior can change when you modify prompts, models, tools, retrieval, or orchestration.
A simple Python architecture
You can start with something as simple as:
TESTS = [
{
"input": "What's the status of order 123?",
"checks": [
"uses_order_lookup",
"does_not_invent_status",
"answers_question",
],
},
{
"input": "Cancel order 456",
"checks": [
"uses_cancel_order",
"does_not_claim_success_before_tool_result",
],
},
]
def run_regression(agent):
results = []
for case in TESTS:
trace = agent.run(case["input"])
scores = {
check: run_check(check, trace)
for check in case["checks"]
}
results.append({
"input": case["input"],
"scores": scores,
"passed": all(scores.values()),
})
return results
Then your CI command can simply fail when the regression criteria aren't met:
python evals/run_regression.py
For an OpenAI-based agent
OpenAI's evaluation tooling supports datasets, evaluation runs, and multiple types of graders. The current documentation also recommends using Datasets for iterative evaluation work.
One important current detail: OpenAI says its existing Evals platform is being deprecated, with read-only access scheduled for October 31, 2026 and shutdown scheduled for November 30, 2026. So I would avoid building a new long-term infrastructure dependency specifically around the legacy Evals platform.
You can also use an external evaluation framework such as DeepEval, which explicitly supports regression testing across test runs.
The most important design choice is to save the complete agent trace, not just its final answer. That's what lets you distinguish "the model gave a different but acceptable answer" from "the model silently changed its tool-selection behavior."
If you tell me what your agent is built with (e.g. Python/OpenAI Agents SDK, LangGraph, LangChain, or a custom API), I can show you a concrete pytest-based regression suite that runs in CI.
[
{
"id": "refund_001",
"input": "I bought this 10 days ago. Can I get a refund?",
"expected": "The customer is eligible for a refund under the 30-day policy.",
"tags": ["refund", "policy"]
},
{
"id": "tool_002",
"input": "Cancel order #1234",
"expected": "The order should be cancelled using the cancellation tool.",
"tags": ["tools", "orders"]
}
]
Include:
Normal happy paths
Edge cases
Previously reported bugs
Tool-use scenarios
Multi-turn conversations
Cases designed to expose hallucinations
Safety/policy cases
Cases where the agent should refuse or ask for clarification
A handful of adversarial inputs
For an agent, don't test only the final text. Agent evaluation can also capture things such as which tools were called, retrieved context, and the execution trace.
2. Define assertions that tolerate natural variation
Avoid:
assert response == "Your refund has been approved."
LLM responses can legitimately vary.
Instead, test properties such as:
assert response.refund_eligible is True
assert response.order_id == "1234"
assert "refund" in response.text.lower()
For less deterministic qualities, use an evaluator:
Evaluate whether the response:
1. Correctly applies the refund policy.
2. Does not invent policy details.
3. Gives the customer a clear next step.
Return a score from 0 to 1.
Pass if score >= 0.85.
Tools such as deepeval.com support both deterministic assertions and LLM-based evaluation metrics, including end-to-end and component-level testing.
3. Test the agent at multiple levels
I'd use three layers:
Layer
Example regression
Unit
Did the router select refund_agent?
Component
Did the retrieval step return the correct policy?
End-to-end
Did the customer ultimately receive the correct answer?
This matters because an end-to-end failure doesn't tell you where the regression occurred. Agent evaluation frameworks can evaluate individual spans/components as well as the entire agent trace.
4. Run it automatically in CI
For example, with DeepEval:
import pytest
from deepeval import assert_test
from deepeval.test_case import LLMTestCase
from deepeval.metrics import GEval
correctness = GEval(
name="Correctness",
criteria="""
Determine whether the actual output correctly answers
the user's request according to the expected output.
""",
threshold=0.8,
)
cases = [
{
"input": "What is our refund policy?",
"expected": "Customers can receive a refund within 30 days."
},
# ...
]
@pytest.mark.parametrize("case", cases)
def test_agent_regression(case):
actual = my_agent(case["input"])
test_case = LLMTestCase(
input=case["input"],
actual_output=actual,
expected_output=case["expected"],
)
assert_test(test_case, [correctness])
Then your CI job can run:
deepeval test run tests/evals
DeepEval specifically supports running these evaluations as CI/CD tests on pushes or pull requests.
You'd fail the build because groundedness dropped substantially, even though the overall average improved.
Store each evaluation run with the relevant configuration—model, prompt version, temperature, retrieval configuration, etc.—so you can determine what change caused the regression. DeepEval supports logging these hyperparameters and comparing runs.
6. Don't require every test to pass perfectly
A practical CI policy is something like:
Hard failures:
- Wrong tool
- Fabricated information
- Safety violation
- Invalid JSON/schema
- Wrong numerical answer
Soft metrics:
- Helpfulness
- Style
- Conciseness
- Tone
Then establish thresholds:
overall score >= 0.90
critical-test pass rate = 100%
no metric may regress > 5 percentage points
The exact thresholds should come from your application's tolerance for errors.
7. Add stochastic testing
Because agent responses aren't deterministic, run important cases multiple times.
This catches agents that work reliably in one run but occasionally choose the wrong tool or produce an unsupported answer. DeepEval's CLI supports repeating test cases as part of an evaluation run.
8. Consider Promptfoo if you want a simpler matrix-testing workflow
promptfoo.dev is another useful option, particularly if you want to test multiple models/prompts against the same test cases and define assertions in YAML. Its basic workflow is essentially:
promptfoo eval
with test cases and assertions in promptfooconfig.yaml.
The key idea is: don't regression-test an AI agent by comparing strings; regression-test its behavior against a stable set of scenarios and measurable criteria.
If you tell me what your agent is built with (e.g. Python/OpenAI Agents SDK, LangGraph, LangChain, TypeScript, etc.), I can give you a concrete test-suite structure and CI configuration for that stack.
Running automated regression tests on an AI agent requires a hybrid approach compared to traditional software testing . Because agent responses and reasoning paths are non-deterministic, you need to test not just the final text output, but also the multi-step reasoning paths, tool/API selection , and state management.
A production-grade automated regression testing pipeline for AI agents relies on a structured, step-by-step framework.
1. Build a Golden Dataset (Test Cases)
Unlike traditional unit tests with exact string matches, your test cases should be declarative scenarios stored in version control (JSON, YAML, or code) alongside your application.
Input/Prompt: The user prompt or multi-turn conversational history.
Context/State: Any initial state or injected database records required.
Expected Behavior: This can be a reference output, an exact required tool call (e.g., "must call get_weather(lat, lon) "), or semantic assertions (e.g., "must not mention competitor X").
2. Choose Your Evaluation Metrics (The "Assertions")
You need a mix of deterministic checks and semantic "LLM-as-a-judge" metrics. Group your assertions into layers:
Deterministic / Code-based: Regex patterns (e.g., checking that an ID or URL matches a format), JSON schema validation of tool/API arguments, and latency/token-count thresholds.
Tool-Use Accuracy: Did the agent invoke the correct tool with the correct parameters in the correct sequence? (Crucial for preventing cascading failures in multi-step agents).
LLM-as-a-Judge: Use a stronger, pinned model (like GPT-4o or Claude 3.5 Sonnet) with a strict rubric to score dimensions like faithfulness (did it hallucinate?), relevance , and safety/policy adherence.
3. Integrate an Evaluation Framework & Tools
Manually writing scripts to parse LLM outputs is brittle. Use dedicated evaluation and observability ecosystems that handle dataset management, execution tracking, and scoring out of the box:
Enterprise / Hosted Platforms: Tools like Braintrust or LangSmith excel at tracing complex multi-step agent graphs, managing datasets, and running comparative evals.
Open Source / Self-Hosted:Langfuse provides great open-source tracing and evaluation capabilities.
Code-First / Local Testing: Frameworks like Pydantic Evals via Pydantic Logfire let you define test cases and evaluators directly as code objects in your repo.
4. Wire It Into Your CI/CD Pipeline
Turn your evaluation suite into a quality gate for your pull requests:
Trigger on PR: Whenever a prompt, system instruction, or underlying tool logic changes, trigger your evaluation pipeline via GitHub Actions or GitLab CI.
Compare Against Baseline: Run the new agent version against your golden dataset and compare aggregate scores (e.g., average correctness score or tool-success rate) against the main branch baseline.
Fail the Build: Set explicit regression thresholds (e.g., "Fail the CI build if overall semantic accuracy drops by >2% or if any critical tool-use test case fails").
If you'd like to dive deeper, let me know:
Is your agent single-turn or multi-step/conversational?
Do you prefer an open-source/self-hosted tool or a managed cloud platform?
I can help you sketch out a sample test case structure or a GitHub Actions workflow for your setup.
Running automated regression tests on an AI agent is fundamentally different from traditional software testing because an agent's outputs are non-deterministic . A code change or prompt tweak might subtly alter the tone, hallucinate a tool call, or break a multi-step reasoning loop without throwing a hard coding error.
To run reliable automated regression tests on an AI agent, you need a combination of golden datasets, LLM-as-a-judge evaluations , and CI/CD pipeline integration.
Step 1: Build a "Golden Dataset" of Test Cases
Assemble a version-controlled repository of representative user inputs (prompts, tasks, or edge cases) paired with expected behaviors. For an AI agent, a test case shouldn't just be an exact string match; it should define:
The Input: The user query or environment state.
The Constraints: E.g., "Must call tool get_weather " or "Must not mention competitor X."
The Expected Outcome/Reference Answer: A ground-truth response or a set of semantic criteria.
Step 2: Choose an Evaluation & Tracing Framework
Instead of writing custom assertions for semantic outputs, use specialized LLM evaluation frameworks that test for correctness, hallucinations, tool-selection accuracy, and toxicity. Leading options include:
DeepEval by Confident AI: An open-source (Apache 2.0) evaluation framework that provides 50+ ready-to-use, LLM-graded metrics (like faithfulness, answer relevance, and agentic tool-correctness).
Braintrust: Excellent for managing experiment loops, tracking regression scores over time, and hosting sandboxed agent playgrounds.
LangSmith: If your agent is built using LangChain/LangGraph, LangSmith natively handles step-by-step tracing and evaluation datasets.
Arize Phoenix: A great local-first, open-source choice for evaluating and debugging agent trajectories on your laptop or in Docker.
Step 3: Define Multi-Layered Assertions
Because an agent performs multi-step reasoning, your regression suite should check three distinct layers:
Deterministic Assertions (Unit Tests): Did the agent pick the correct tool/function definition? Did it output valid JSON? (Use parsing libraries like Pydantic for this).
Trajectory Evaluation: For multi-turn or agentic workflows, did the agent take the correct sequence of steps to reach the goal, or did it get stuck in a reasoning loop?
Semantic Evaluation (LLM-as-a-Judge): Pass the agent's final response and the golden reference response to a stronger, cheaper model (like GPT-4o or Claude 3.5 Sonnet) using a framework like DeepEval to grade whether the core meaning matches.
Step 4: Integrate into your CI/CD Pipeline
Turn your evaluation script into a standard test command (e.g., pytest tests/agent_evals.py ) and wire it into GitHub Actions or GitLab CI.
Set up a trigger to run your regression suite nightly or on pull requests that modify prompts, system instructions, or agent code.
Define score thresholds (e.g., overall semantic similarity or faithfulness cannot drop below 92%). If a commit causes a regression past your threshold, fail the CI build.
If you'd like, let me know:
What framework is your agent built on (e.g., LangGraph, AutoGen, custom Python)?
Is it a single-turn Q&A bot or a multi-step tool-using agent?
I can help you outline a sample evaluation script or pick the best metrics for your use case.
A good regression test suite for an AI agent is less like traditional unit tests and more like an evaluation (eval) harness. Because LLMs are probabilistic, you generally want to test behavior, not exact wording.
A practical setup looks like this:
Layer
What to test
Example
Unit tests
Deterministic code
Tool wrappers, parsers, business logic
Agent regression tests
End-to-end behavior
User asks a question, evaluate the final answer and tool usage
Production monitoring
Real traffic
Capture failures and add them back into the regression suite
1. Build a versioned evaluation dataset
Create a fixed collection of representative tasks.
For example:
- id: refund-policy
input: "Can I return an item after 45 days?"
expected:
must_include:
- "30-day"
should_not:
- "60-day"
- id: sql-agent
input: "How many users signed up yesterday?"
expected_tool: sql_database
Include:
common requests
edge cases
previous production failures
jailbreak attempts
ambiguous questions
long conversations
tool-using workflows
As bugs are found in production, add them to this dataset so they never reappear.
2. Run the same prompts every build
Your CI pipeline should execute every test whenever you change:
prompts
models
retrieval
tool definitions
agent workflow
system instructions
For example:
main
↓
Run 500 evals
↓
Score results
↓
Compare to previous baseline
↓
Pass/Fail
Even though it's faster and cheaper, you'd likely reject it because answer quality regressed.
8. Handle randomness
LLMs don't always produce identical outputs.
Instead of:
Run once
Do:
Run 5–20 times
Average scores
For high-stakes changes, compare distributions or use statistical tests so you don't block releases because of normal sampling noise.
9. Automate in CI
A typical GitHub Actions workflow:
on: pull_request
steps:
- checkout
- install
- run unit tests
- run agent eval suite
- compare against baseline
- fail if regression > threshold
Example release policy:
Task completion ≥ 95%
Hallucinations ≤ 2%
Tool accuracy ≥ 99%
Latency increase < 15%
If any threshold fails, block the merge.
10. Keep improving the suite
Each time production reveals a new failure:
Save the conversation.
Turn it into a regression test.
Fix the issue.
Add the test permanently.
Over time, your regression suite becomes a living record of behaviors your agent must continue to handle reliably.
Popular tools that support this style of testing include Promptfoo, Braintrust, LangSmith, OpenAI Evals, Google's ADK evaluation tooling, and Docker Agent evals, all of which integrate automated datasets, scoring, and CI workflows to help detect regressions before deployment.
8. Handle randomness
LLMs don't always produce identical outputs.
Instead of:
Run once
Do:
Run 5–20 times
Average scores
For high-stakes changes, compare distributions or use statistical tests so you don't block releases because of normal sampling noise.
9. Automate in CI
A typical GitHub Actions workflow:
on: pull_request
steps:
- checkout
- install
- run unit tests
- run agent eval suite
- compare against baseline
- fail if regression > threshold
Running automated regression tests on an AI agent's responses requires a shift from traditional exact-match unit testing to probabilistic and semantic evaluation . Because LLM outputs can vary slightly in wording while maintaining the exact same meaning, you have to test for intent, correctness, safety, and tool-call accuracy rather than hardcoded string matching.
A robust framework for automated AI agent regression testing involves a structured, 5-step pipeline:
Build a Golden Dataset (The Test Suite)
Curate a diverse set of representative user inputs, multi-turn conversations, and tricky edge cases (e.g., prompt injections, out-of-scope requests, messy inputs).
Define the expected behavior for each test case: this can be a reference text, a required JSON schema (for tool use), or explicit evaluation criteria (e.g., "Must mention refund policy," "Must not recommend competitors").
Store this dataset in version control (YAML or JSON).
Instrument CI/CD Integration
Trigger your evaluation suite automatically whenever a prompt changes, system instructions are updated, the underlying model is swapped, or agent tools/code are modified.
Use an evaluation-first framework like DeepEval (open-source unit testing for LLMs) or Braintrust / LangSmith to execute the test suite headlessly in your pipeline (e.g., GitHub Actions).
Implement "LLM-as-a-Judge" and Deterministic Metrics
Deterministic assertions: Check structural requirements instantly (e.g., Did the agent output valid JSON?, Did it trigger the correct API/tool call with correct arguments?, Does it contain forbidden words?).
Semantic/LLM-as-a-Judge assertions: Use a stronger, frozen model (like GPT-4o or Claude 3.5 Sonnet) as an impartial judge. Score the agent's output against your golden dataset using metrics like:
Faithfulness / Hallucination: Did the agent invent facts not present in its retrieved context (RAG)?
Answer Relevance: Did it actually answer the user's prompt without rambling?
Tool Correctness: Did it choose the right tool sequence to achieve the goal?
Track Latency, Cost, and Token Budgets
Regression isn't just about what the agent says; it's about performance. Track token consumption, end-to-end latency, and API costs per run. A prompt update that improves accuracy by 2% but increases latency by 300% might fail your regression criteria.
{
"id": "refund-001",
"input": "I want a refund for my order.",
"expected": {
"must_contain": ["refund"],
"must_not_contain": ["invented policy"],
"goal": "Correctly explain the refund process"
}
}
Don't make every expected answer an exact string. AI responses naturally vary, so exact matching is useful for structured fields and invariants, but poor for judging open-ended prose.
2. Use two kinds of assertions
Deterministic assertions are your cheapest and most reliable tests:
assert response.status == "success"
assert response.output is not None
assert len(response.output) < 2000
assert response.tool_calls[0].name == "lookup_order"
Then use an LLM judge for properties such as:
Is the answer correct?
Did it actually answer the question?
Is it grounded in the supplied context?
Did it follow the instructions?
Was the tone appropriate?
Did it make an unsupported claim?
This combination—deterministic checks plus model-based grading—is a common recommended pattern.
3. Score the agent on separate dimensions
Instead of one giant "quality" score, I'd use something like:
Metric
Example gate
Task success
≥ 95%
Factuality
≥ 95%
Tool correctness
≥ 98%
Safety
100%
Required format
100%
Answer relevance
≥ 95%
Latency
< 5 sec
Cost
< $0.05/test
For an agent, tool calls matter too. Modern evaluation frameworks can evaluate both the final response and the agent's execution trajectory/tool usage.
DeepEval explicitly supports running end-to-end LLM evaluations in CI/CD and turning failed evaluation metrics into test failures.
Another option is promptfoo.dev, which supports YAML-defined test cases, deterministic assertions, LLM-judge rubrics, result comparison, and CI integration.
Every time the agent produces a production failure:
Production failure
↓
Turn failure into a regression case
↓
Add it to dataset
↓
Fix agent
↓
Verify old + new tests
↓
Deploy
This is one of the most valuable properties of an eval suite: your production mistakes become permanent tests.
Also keep a holdout set that you don't tune your prompts against. Otherwise you can accidentally optimize the agent and grader specifically for your known tests. Promptfoo's current guidance recommends separate development/golden and holdout datasets for this reason.
What I'd use
For a new agent, I'd keep the architecture simple:
Promptfoo is particularly convenient if you want a lightweight, YAML/CLI-oriented regression system. DeepEval is attractive if you're Python/pytest-oriented and want deeper agent/trace evaluation.
If you tell me what framework your agent uses (OpenAI Agents SDK, LangGraph, CrewAI, custom Python/Node, etc.), I can give you a concrete regression-test setup with the dataset format, grader, and GitHub Actions CI configuration.
Running automated regression tests on AI agents is tricky because their outputs are non-deterministic . Traditional exact-match unit tests (assert response == "expected" ) fail because a rephrased or slightly varied valid response will break the build.
To build a robust regression pipeline for an AI agent, you need to combine golden datasets, LLM-as-a-judge metrics, deterministic assertions, and CI/CD integration.
Step 1: Build a "Golden Dataset" of Test Cases
Collect a diverse set of representative user inputs (single-turn prompts, multi-turn conversation flows, and edge cases where your agent previously failed or hallucinated).
Inputs: The user prompt or historical chat state.
Context/Tools: Expected tool calls, API parameters, or required grounding data (if RAG is involved).
Reference Outputs: Optional ideal responses or semantic rubrics.
Step 2: Choose an Evaluation Framework
Instead of writing a custom testing harness from scratch, leverage specialized open-source or enterprise evaluation frameworks designed for LLM workflows:
DeepEval: Excellent for agentic workflows, multi-turn conversation simulation, component-level evaluations, and native CI/CD integration.
Promptfoo: Great for CLI-driven evaluations, prompt management, and automated security/vulnerability red-teaming.
Braintrust or LangSmith: Best for data-driven, production-to-evaluation loops and collaborative team tracking.
Step 3: Combine Deterministic and "LLM-as-a-Judge" Checks
A solid regression check blends hard code logic with semantic AI evaluation:
Deterministic Unit Tests (The Guardrails): Check structural elements that must be exact. Did the agent pick the correct tool? Did it format a JSON output correctly? Did it avoid leaking restricted keywords?
LLM-as-a-Judge Metrics (The Semantics): Use a more powerful model (like GPT-4o or Claude 3.5 Sonnet) to grade the agent's behavior dynamically based on custom criteria:
Faithfulness: Did the agent make up facts not present in the retrieved context?
Answer Relevance: Did the agent actually address the core user request?
Tool Correctness: Did it use the parameters correctly in context?
Step 4: Integrate into your CI/CD Pipeline
Trigger your test suite automatically whenever a prompt changes, system instructions are updated, or agent code is modified (e.g., via GitHub Actions).
Export your evaluation suite as a Python script using pytest or a framework CLI command.
Fail the CI/CD build if the aggregate score drops below a specific threshold (e.g., overall pass rate falls below 95% or semantic similarity drops below 0.85).
If you'd like, let me know:
What framework or orchestration library (e.g., LangChain, LlamaIndex, custom Python) your agent uses
Whether your agent calls external tools/APIs or just generates text
I can give you a code snippet for setting up your first test harness.
Automated regression testing for an AI agent is similar to traditional software regression testing, but you usually test behavior, not exact text. Since LLM outputs are variable, good tests check whether the agent still satisfies requirements: correctness, tool use, safety rules, latency, cost, and conversation outcomes.
A practical setup looks like this:
1. Build a "golden" regression dataset
Create a set of representative conversations that your agent must continue to handle correctly.
Example:
[
{
"input": "I need to cancel my subscription",
"expected": {
"must_do": [
"identify the user account",
"explain cancellation policy"
],
"must_not_do": [
"cancel without confirmation"
],
"expected_tools": [
"get_subscription"
]
}
}
]
Include:
Common user requests
Previously failed cases
Edge cases
Adversarial prompts
Multi-turn conversations
Tool-use scenarios
A good practice is: every production bug becomes a permanent regression test.
2. Test more than the final answer
Avoid only checking:
assert response == "Expected answer"
Instead, test dimensions such as:
Response quality
Is the answer correct?
Does it follow instructions?
Is it concise enough?
Does it maintain tone?
Tool behavior
Did it call the right tool?
Were arguments correct?
Did it avoid unnecessary tools?
Example:
assert "lookup_customer" in trace.tools_called
assert trace.tool_args["customer_id"] == "12345"
Safety and policy
Examples:
Does it refuse prohibited requests?
Does it avoid leaking system instructions?
Does it protect private information?
Operational metrics
Track:
Latency
Token usage
Cost
Failure rate
Frameworks such as AgentEval and similar tools support graders for outputs, tool calls, trajectories, latency, and cost.
3. Use graders instead of exact matching
Common grading approaches:
Deterministic checks
Best for:
JSON schemas
Required fields
Tool calls
Keywords
Formatting
Example:
def check_order_response(output):
return (
"order number" in output.lower()
and "refund" in output.lower()
)
LLM-as-a-judge
Use another model to score:
Evaluate this response:
User:
"I forgot my password"
Agent:
"..."
Score from 1-5:
- Helpful
- Correct
- Follows policy
- Does not invent information
Use a fixed rubric so scores are comparable between versions.
4. Capture and replay real conversations
Production traffic is often the best test source.
Workflow:
Save anonymized conversations.
Label successful outcomes.
Convert failures into tests.
Run them before deployments.
Some evaluation systems support capturing traces and turning them into regression cases.
for i in range(10):
result = agent.run(test_case)
scores.append(evaluate(result))
assert mean(scores) >= 0.9
This catches agents that pass occasionally but fail unreliably.
8. Useful tooling options
Depending on your stack:
MLflow provides GenAI evaluation and regression testing workflows that can integrate with pytest-style checks and CI pipelines.
LangSmith is commonly used for tracing and evaluation workflows.
Agent-focused testing frameworks such as AgentEval provide configurable graders and regression detection.
A minimal architecture
Git commit
|
v
Run regression suite
|
+------------+-------------+
| | |
v v v
Output tests Tool tests Safety tests
| | |
+------------+-------------+
|
v
Compare baseline
|
Pass ---------------- Fail
| |
Deploy Block release
A strong starting point is usually 50–200 golden test cases, with every real failure added permanently. That gives you a regression suite that improves as your agent evolves.