Testing AI Agents: Simulated Users, Eval Suites and Failure Cases
Testing AI agents needs eval suites, simulated users and a failure catalogue. Compare Promptfoo, DeepEval, Braintrust, LangSmith and Langfuse.
By Galactic News Editorial · Published 2026-11-23T07:28:18+00:00 · Updated 2026-11-23T07:28:18+00:00
Testing AI Agents: Simulated Users, Eval Suites and Failure Cases
An AI agent that passes a demo can still fail on its tenth real user. It books the wrong flight. It refunds the wrong order. It loops on a tool call until the bill explodes. Testing AI agents means catching those failures before production, not after. The method has three parts: eval suites that score real behaviour, simulated users that play realistic customers, and failure cases that probe the edges. This guide covers all three, with the tools that run them.
The five checks every agent test must answer
Before picking a tool, decide what you are testing. A production-ready agent test answers five questions. First, task success: did the agent complete the job, measured by what changed in the systems, not by whether the reply sounded right? A refund that was actually processed beats a polite message that did nothing. Second, trajectory: did the agent take a sensible path, with the right tool calls in the right order? Third, tool correctness: did each call use the right arguments, and did the agent handle errors and empty results? Fourth, safety: can the agent be talked into something it should not do, such as revealing data or changing another user's record? Fifth, cost and latency: how long did the run take, and what did the model calls cost?
Score all three levels of a run: the final response, the trajectory, and each tool call. Many teams score only the final answer. That misses the agent that got the right answer by luck, after three failed tool calls and a hallucinated parameter. Trajectory scoring catches that. It also catches the agent that solved the task but called a delete endpoint to do it.
Eval suites: turning agent tests into code
An eval suite is a set of test cases with expected behaviour, run the same way every time. The best suites live in the repository next to the code. They run in CI. They gate releases. A failing eval blocks the deploy, the same way a failing unit test does.
Promptfoo is the most direct way to start. It is open source and MIT-licensed, and it is now part of OpenAI. You define prompts, providers, and test cases in a YAML config. You attach assertions to the outputs. You run promptfoo eval the way you run a test suite. The command exits with code 100 when at least one test fails, or when the pass rate falls below the threshold you set. The default threshold is 100 percent, meaning no failures allowed. Test cases can come from YAML, JSON, JSONL, or CSV files. Promptfoo also has a red-team mode for prompt injection, jailbreaks, and data leakage, set up with promptfoo redteam setup.
DeepEval takes a similar code-first approach in Python. Test cases are called goldens. It ships metrics for tool correctness, task completion, and trajectory, and it runs as tests in your repo. Braintrust is the hosted option built around eval-gated releases. You run experiments against datasets, with code and LLM scorers, compare versions side by side, and turn production logs into new test cases. Its GitHub Action comments eval results on pull requests. LangSmith, from LangChain, adds tracing and evaluation for LLM applications, with datasets, experiments, and annotation queues. It fits LangGraph agents best, but it is not limited to them. Langfuse and Arize Phoenix are open-source platforms you can self-host, with tracing, datasets, and experiments on top. Phoenix ships ready-made evaluators for tool selection and tool invocation. Langfuse gates CI with a GitHub Action.
Simulated users: testing multi-turn conversations
Single-turn tests miss the failures that happen in conversation. A user changes their mind. They reveal a key fact only in turn four. They answer a question with another question. Simulated users handle this. An LLM plays the customer, with a goal and a persona, so the conversation goes wherever the agent takes it.
Promptfoo's simulated user provider is the clearest example. Set the provider id to promptfoo:simulated-user and give it instructions, such as a persona with a goal, constraints, and facts it knows. The conversation runs for up to maxTurns, which defaults to 10. It stops early when the simulated user emits ###STOP###. You can start from a fixed mid-conversation state with initialMessages, which is useful for reproducing bugs and testing edge cases without running the whole conversation. Two details from the docs matter. The target must accept messages in OpenAI chat format. And simulated-user messages are generated by Promptfoo's hosted models unless you set PROMPTFOO_DISABLE_REMOTE_GENERATION=true.
DeepEval's equivalent is the ConversationSimulator. You give it a simulated user with a goal, replace the chatbot callback with a call to your bot, then score each transcript against an expected outcome with a multi-turn metric. LangSmith's simulation runs through the open-source openevals package, where a language model plays the user. Langfuse's cookbook shows simulated multi-turn conversations built on openevals and scored afterwards by an LLM judge. The pattern is the same everywhere: define the persona, set the goal, cap the turns, score the transcript.
Write personas from real users, not from imagination. Take five real support conversations. Turn each one into a persona with a goal, a budget, a deadline, and a habit, such as answering briefly or changing their mind. A simulated user built from a real conversation finds the failures your scripted tests miss. A persona built from a guess finds nothing.
Testing AI Agents With Simulated Users: Eval Suites Compared
| Tool | Style | Simulated users | CI gating | Licence |
|---|---|---|---|---|
| Promptfoo | YAML config, CLI | Built-in simulated-user provider | Exit code 100 on failure | Open source, MIT |
| DeepEval | Python tests | ConversationSimulator | Runs as test suite | Open source |
| Braintrust | Hosted platform | Limited | GitHub Action on pull requests | Hosted |
| LangSmith | Hosted platform, tracing | Via openevals simulation | Experiments and datasets | Hosted, openevals MIT |
| Langfuse | Self-hosted or cloud | Via cookbook with openevals | GitHub Action | Open source |
| Arize Phoenix | Self-hosted or cloud | No built-in simulator | Evaluators on traces | Open source |
Failure cases to test before launch
Build a failure catalogue and test every entry. These are the cases that cost customers in week two, after the demo passed.
- Ambiguous requests. 'Cancel my booking' when the user has two bookings. The agent must ask which one. It must not guess.
- Missing data. A tool returns an empty result. The agent must say so and offer the next step. It must not invent a record.
- Tool errors. An API times out or returns a 500. The agent must retry once, then tell the user, then stop. It must not loop forever.
- Rate limits. The third-party API throttles the agent mid-task. The agent must pause, not fail the whole task silently.
- Changed data. A price or a record changes between the agent's read and its write. The agent must re-read before it commits.
- Prompt injection. A document or a message tells the agent to ignore its instructions. The agent must refuse and continue the real task.
- Scope creep. The user asks for one thing, then adds a second, then a third. The agent must track what was agreed and confirm before acting.
- Long conversations. The user returns after twenty turns. The agent must still remember the goal and the constraints from turn one.
For each failure case, write the expected behaviour as something a judge can check. 'Quotes the 30-day refund window and links the form' is checkable. 'Gives a good answer' is not. This is the rule that makes LLM-as-judge scoring work. Vague expectations produce vague scores.
After launch: production is the second test environment
Pre-launch testing catches the failures you imagined. Production finds the rest. Judge real production conversations after launch. Track verified resolution, escalation rate, silent-failure rate, and user frustration. A silent failure is the worst kind: the agent said it did something, and it did not. Find those first.
Feed every production failure back into the test set. A customer found a gap. Turn it into a test case. Run it in CI. That loop is the whole point of evals. Without it, the same failure ships again after the next model change. With it, the suite grows stronger every week.
Gate every prompt or model change on regression evals. A new model version can fix ten cases and break three. The suite tells you which three. Without the suite, you find out from customers. Run the evals on every pull request that touches the prompt, the tools, or the model. Keep the runtime short enough that developers actually wait for it. A suite that takes an hour gets skipped. A suite that takes five minutes gets run.
Bottom line
Start with Promptfoo or DeepEval. Both are free, code-first, and run in CI. Add simulated users with Promptfoo's simulated-user provider or DeepEval's ConversationSimulator, built from real conversations. Score the final answer, the trajectory, and each tool call. Build a failure catalogue for ambiguity, missing data, tool errors, rate limits, and prompt injection. Gate every change on the suite. Then keep testing in production, and feed every real failure back into the tests. An agent you test this way still fails sometimes. It fails in ways you have already seen, and you fix it once.