Agentic Workflows
Eval-Driven Development: Testing AI Agents Beyond the Happy Path
Updated November 29, 2026
Why ordinary unit tests are not enough
A unit test can verify a parser, permission check, or API adapter. It cannot by itself tell you whether an agent chose the right tool, asked for clarification, or handled an ambiguous request safely. Model output can vary between runs, and a workflow may succeed through a different sequence of calls than the one a developer expected.
This does not make testing impossible. It means the evaluation should match the behavior you care about. Treat the agent as a system with inputs, decisions, tool interactions, and user-visible outcomes. Keep some checks deterministic, and make the subjective checks explicit enough that reviewers can understand the score.
Build a small, representative task set
Begin with real user intents, then include boundary cases and known failures. A support agent’s dataset might contain a routine question, a request with missing information, a request outside its permissions, a conflicting document, and a temporary tool outage. Do not collect only the clean examples that make the system look good.
Record the necessary context, expected outcome, and any prohibited behavior. Avoid storing secrets or unnecessary personal data in evaluation fixtures. If tasks depend on a tool, use a deterministic fake or a controlled test account so that the test cannot send a real email, change production data, or incur an unexpected charge.
{
"id": "missing-order-id",
"input": "Can you check whether my order shipped?",
"context": { "orderId": null },
"expect": {
"outcome": "ask_for_order_id",
"sideEffects": 0,
"mustNotClaimShipmentStatus": true
}
}This fixture does not prescribe the exact wording of the answer. It specifies the behavior that matters: ask for the missing identifier, do not call a tool with incomplete input, and do not invent a shipping update.
Measure the whole workflow
A final response can hide an incorrect path. The model might call a tool with the wrong arguments and then produce a plausible explanation from stale context. Capture a trace with model calls, tool calls, handoffs, policy decisions, errors, latency, and the final result. Redact credentials and sensitive content before storing it.
For each task, inspect both the outcome and the path taken. Useful questions include: Did the agent choose the correct tool? Did it use the right record? Did it stop when the user lacked permission? Did it ask for clarification instead of guessing? Did the retry policy cause a duplicate side effect?
Use the right grader for the requirement
Use ordinary assertions for properties that can be checked exactly: required fields, valid JSON, no tool call when authorization fails, maximum retry count, and whether an operation identifier is reused. These checks are fast and repeatable.
Some qualities need a rubric: whether an answer addresses the user’s question, explains a limitation, or cites evidence accurately. A model-based grader can help triage those examples, but it can also share the system’s blind spots. Write a narrow rubric, compare grader judgments with human labels, and review borderline examples. Do not treat one scalar “quality” score as proof of safety or factual correctness.
const result = await runAgent(testCase.input, testCase.context);
expect(result.outcome).toBe(testCase.expect.outcome);
expect(result.sideEffects).toHaveLength(testCase.expect.sideEffects);
expect(result.trace.toolCalls).not.toContain('ship_order');
const review = await gradeWithRubric({
input: testCase.input,
answer: result.answer,
criteria: ['answers only from available evidence', 'states uncertainty clearly'],
});The snippet illustrates evaluation logic rather than a particular testing or model provider API. Keep application behavior and grading logic separate so a change to the grader does not accidentally change what the agent is allowed to do.
Track regressions and trade-offs
Run the same task set before and after a change to a prompt, model, retrieval strategy, tool schema, or guardrail. Track more than average answer quality: task completion, policy violations, wrong-tool calls, unsupported claims, latency, and cost can move in different directions. Set a release threshold for the failures that matter most; a higher average score should not excuse a new severe safety failure.
Keep failed cases as regression examples after they are fixed. When the expected behavior changes, update the fixture with a short reason and reviewer. Otherwise an outdated test can push the system back toward yesterday’s behavior. Separate development examples from a smaller holdout set to reduce the temptation to tune only for visible cases.
Control sources of evaluation noise
Repeated runs can produce different answers, especially when an agent uses sampling or live services. Record the model and version, prompt or policy version, tool schemas, test data, and relevant runtime settings with each evaluation. If an external service is part of the task, decide whether to test against a stable fixture or measure the real integration separately. Otherwise a provider outage can look like a model regression, or a lucky run can hide a flaky workflow.
For nondeterministic cases, run enough repetitions to estimate how often a failure occurs, then inspect the failures rather than averaging them away. A workflow that succeeds nine times and mishandles a permission boundary once is not necessarily acceptable. Report the sample size and the specific failure categories with the score. Keep thresholds tied to user impact: a minor style preference and an unauthorized mutation should not share one pass/fail weight.
When an evaluation set becomes large, group results by task type and risk level. This makes it easier to find a regression that affects one workflow while the aggregate score remains stable. Preserve a small, fast smoke set for local iteration and run the broader suite before release or after changes with a wider blast radius.
Use trace review to find the cause
When an evaluation fails, classify the earliest meaningful failure: misunderstood intent, missing context, incorrect retrieval, invalid tool arguments, authorization error, timeout, or poor final explanation. The fix depends on the category. A prompt rewrite will not repair an API that returns stale records; a larger model will not replace a missing permission check.
Keep a human review loop for high-impact tasks and for examples where automated graders disagree. An evaluation suite helps a team notice a regression earlier; it does not certify that an agent is safe in every environment or for every user.
A practical first evaluation loop
- Choose one workflow with a clear user outcome.
- Save a small set of normal, ambiguous, and failure scenarios.
- Write exact assertions for permissions, tool calls, and side effects.
- Review traces for the cases that need semantic judgment.
- Run the same set after every meaningful model or workflow change.
- Keep regressions and document any changed expectation.
Evaluation is most effective when it is part of development rather than a one-time launch checklist. Recent software-engineering guidance has also highlighted eval-driven development as a way to measure AI-system quality against explicit criteria. Start with a narrow workflow and trustworthy cases; expand coverage as the system earns more responsibility.
References
About Ali Raza
Ali is a software engineering student at Riphah International University and the founder of the digital agency Ionix Growth. He writes about modern web architecture, developer tooling, and integrating AI workflows into web applications.