How to build an evaluation framework for your AI agent
An evaluation framework is a written set of success criteria, test cases, scorers and a production feedback loop. It tells you whether your agent did what the user wanted, not only whether its calls succeeded.
By Arun Prasad · Published · Last updated
On this page
Why an evaluation framework matters
If you only check the final answer or the status of each call, you will miss runs where every step succeeds and the task still fails. AI agents don't fail like normal software. A tool can return a 200 and the task can still fail. Standard monitoring shows the request went through, not whether the answer was right.
Here is a hypothetical example. A support agent calls a refund tool, the tool returns 200, and the agent tells the customer the refund is done. The tool call was accepted, but it used the wrong order ID. Every span looks healthy, and the user did not get what they came for.
This is why evaluating agents on trajectory as well as output matters: a correct-looking answer can hide a failure in the path that produced it. So you need criteria tied to the user's goal, and criteria tied to the steps the agent took.
Step 1: Define what success means for your agent
Write down, for each thing a user can ask your agent to do, what a good result looks like. Do this before you build any scorer, because a scorer can only check what you have defined.
Start with one short statement per user goal: what the user wants, what the agent must do, and what it must never do. For the refund example, "the refund is issued for the correct order and the user is told the amount and timeline" is checkable. "The agent is helpful" is not. Split each statement into parts you can mark pass or fail, and note which parts a plain rule can check (the refund tool was called with the order ID the user gave) and which need judgment (the tone was appropriate).
Step 2: Build test cases before launch
Collect a set of realistic inputs for each success criterion, including the awkward ones, and run your agent on them before users do. A test set that only holds the happy path will tell you the agent works when everything goes right.
Cover these kinds of cases:
- Typical requests for each user goal.
- Changing intent: the user switches goals midway.
- Missing details: the user leaves out something the agent needs.
- Tool problems: a tool times out or returns an error.
- Out-of-knowledge questions: the correct behavior is to say the agent doesn't know.
If your agent retrieves documents, separate retrieval failures (the right source was never found) from reasoning failures (the right source was found and misused). They need different fixes. Get someone who knows the domain to review the cases, because they will spot wrong expected answers that an engineer would accept.
If you want simulated users written for you from an app description, Synthetic Scenarios (Beta) in PRISM by Block Convey does this. It is a Beta feature with a waitlist.
Step 3: Score the whole run, not just the final answer
Score the outcome (did the user get what they wanted?) and the trajectory (the tools chosen, the parameters passed, the retries and handoffs along the way). A right answer reached by a bad path is a failure waiting to happen.
A trajectory check asks questions such as:
- Did the agent pick the right tool for this request?
- Were the parameters correct, or did it guess?
- Did it retry in a loop before it succeeded?
- Did it hand off, and was the state passed along intact?
Trajectory scoring needs your integration to send the steps, so check that your traces include tool calls and retries before you rely on it.
You do not always need it. For a single-turn agent with no tools, scoring the outcome is usually enough.
Step 4: Score runs with an LLM judge you have calibrated
Use deterministic checks wherever a rule can decide, and use an LLM judge only for what rules can't. Before you trust the judge, compare its verdicts with human labels.
A deterministic check gives the same verdict for the same input and costs no model call. Examples are "the refund tool was called", "the reply contains no email address" and "the agent did not exceed three retries". An LLM judge reads the exchange and scores things like whether the answer was grounded in the source or whether the tone fit.
To calibrate a judge:
- Have people label a sample of real or test runs against your success criteria.
- Run the judge on the same runs.
- Look at where they disagree and rewrite the judge's question until it asks about something observable.
- Repeat after you change the judge prompt or the judge model.
Treat judge instability as a limit of the method. The same run can score differently on different days, so don't read small score movements as real changes. Test rubric stability by running the same judge prompt against the same set of runs more than once and checking how much the scores shift.
Step 5: Monitor evaluation in production
Run your scorers on real traffic, at the level of a single step and at the level of a whole conversation, and turn each failure you find into a new test case. Pre-launch tests cover the cases you thought of. Production shows you the ones you didn't.
Step-level scores tell you which tool call or retrieval went wrong. Conversation-level scores tell you whether the user's goal was met across several turns. You need both, because an agent can pass every step and still lose the user on turn four.
When a failure appears, save the input and the expected behavior as a test case, then run the suite after each change. Running these checks as regression gates in your CI/CD pipeline catches regressions before they reach users.
How this looks in production
In PRISM, evaluators score your real traces. Here is what that covers, and where it stops.
- Deterministic rules run on 100% of sessions. There is no sampling. They give the same verdict for the same input, with no model involved.
- The LLM judge is not sampled. It scores every incoming trace until your plan's allowance runs out. After that, only the deterministic rules run.
- Every verdict is traceable. Each one links to the rule, the span, the source checked and the reason, so you can read why a run failed.
- Steps are visible in Agent Runs. You see steps, tool calls, retries, handoffs and state. These appear when your integration sends them. See Agent Observability for traces and sessions.
- Failures are grouped. Repeated failures are grouped into patterns, with a count of how many sessions share each one.
- Fixes get a before and after. After a fix is merged, PRISM compares pass rates for the 7 days before and the 7 days after the merge.
- Failing scenarios become regression tests. This applies to Synthetic Scenarios (Beta), where access is by waitlist.
Limits to know about:
- You can't re-run evaluators over a date range, an intent or a replay set.
- There is no nightly test suite. Automatic tasks run about hourly.
- Core scores are on the Free plan. Custom evaluators and the Evaluators Hub need Builder or above. Builder also adds a human review queue.
The Evaluators page describes the deterministic and LLM-as-judge rules.
Common mistakes
Most evaluation frameworks fail because they score only the final answer, trust an uncalibrated judge, test only happy paths, or stop at launch.
- Scoring only the final answer. Runs with a bad path and a lucky answer pass. Fix: add trajectory checks for tool choice, parameters and retries, as in Step 3.
- Trusting an uncalibrated LLM judge. Scores can be biased or unstable, and you won't know. Fix: compare the judge with human labels, and use deterministic rules wherever a rule can decide.
- Testing only happy paths. The agent looks reliable until a user changes their mind or asks something outside its knowledge. Fix: add edge cases, tool failures and out-of-knowledge questions to the test set.
- Treating evals as a pre-launch task. Real users find failures your test set never held. Fix: score production runs and turn each failure into a regression test.
What are LLM evals?
LLM evals are tests that score a model's or an agent's outputs against criteria you set, using rules, a judge model or human review. For agents, the scoring also covers the steps taken, not just the final text.
The other common questions are answered above: trajectory evaluation in Step 3, LLM judges in Step 4 and production monitoring in Step 5.
Related
- AI agent evaluation and quality checksThe deterministic and LLM-as-judge rules in PRISM.
- Agent observabilityTraces and sessions: how runs, steps and sessions are recorded.
- Fix AI agent failures and compare pass rates before and afterFrom a failing pattern to a suggested change and a 7-day before-and-after comparison.
Find out whether your agent did what users asked
Send your agent's runs to PRISM and see deterministic and LLM-judge scores on real traces.
Free to start, 100 credits each month.