keepcalculator

06 Numbers and Powers

How to Evaluate AI Agents Without Misleading Results

Card No. 06·27044 · Updated · Standard formula, shown below

This guide explains how to set up a fair, repeatable evaluation process for AI agents, so the results you get actually reflect real-world performance. You’ll learn how to define tasks, choose metrics, avoid common pitfalls like data leakage and overfitting to test sets, and interpret results honestly. By the end, you’ll have a practical checklist to run evaluations that stakeholders can trust.

What You’ll Need

  • A set of real-world tasks or scenarios the agent is supposed to handle (at least 20–50, depending on complexity).
  • A baseline to compare against (e.g., a simple rule-based system, human performance, or the previous version of the agent).
  • Clear success criteria for each task (what counts as a correct answer or a completed action).
  • A way to log agent inputs and outputs (e.g., a file, database, or logging library).
  • Access to a separate test environment that mimics production but is isolated from live data.
  • If using LLMs as part of the agent, a way to control the model version and temperature settings.
  • A simple script or notebook to compute metrics (accuracy, success rate, latency, cost).

Step-by-Step

  1. Define the agent’s scope and boundaries. Write down exactly what the agent should do and what it should not do. For example, if it’s a customer support agent, specify the types of queries it handles (refunds, technical issues) and the ones it must escalate (legal, medical). This prevents you from testing it on out-of-scope tasks and then misjudging its performance.
  2. Create a diverse test set that mirrors real usage. Collect examples from actual user logs, or if that’s not possible, write scenarios based on domain knowledge. Include edge cases, ambiguous inputs, and typical variations. Avoid using the same examples you used during development or fine-tuning—that would be data leakage and inflate results.
  3. Define success criteria for each task. For each test case, specify what a correct output looks like. This could be an exact string match, a set of required keywords, or a rubric for open-ended responses. For multi-step tasks, define what counts as a completed task (e.g., booking a flight, not just providing a link).
  4. Set up a controlled evaluation environment. Run the agent in a sandbox that mimics production but with mock external services (APIs, databases). This ensures you’re not accidentally calling live systems that might change state or behave differently.
  5. Choose evaluation metrics that match the task. For classification tasks, use accuracy, precision, recall, F1. For generation tasks, use a combination of automated metrics (like BLEU or ROUGE) and human judgment. For task completion, measure success rate (percentage of tasks completed correctly) and partial credit if the agent gets partway. Also track efficiency: latency and cost per task.
  6. Run the baseline and the agent under identical conditions. Use the same test set, same environment, same random seeds (if any). If the agent uses a stochastic model, run each test multiple times (e.g., 3–5) and report the average and variance. This prevents a lucky run from being mistaken for improvement.
  7. Analyze results by subgroup. Break down performance by task type, difficulty, or user intent. For example, does the agent perform well on simple queries but fail on multi-turn conversations? This helps you understand where to improve and avoids a single aggregate number hiding critical weaknesses.
  8. Check for overfitting to the test set. If you’ve been iterating on the same test set, you might be tuning to that specific set. Hold out a small portion of the test set (e.g., 20%) that you never look at until the final evaluation. This “held-out” set gives a more honest estimate of generalization.
  9. Document all settings and assumptions. Write down the model version, temperature, prompts, and any post-processing steps. This makes the evaluation reproducible and helps others understand what was actually tested.
  10. Report results with confidence intervals and error bars. If you ran multiple trials, show the mean and standard deviation. If you evaluated on a sample, include a confidence interval (e.g., 95% CI) to indicate uncertainty. This prevents overclaiming based on small sample sizes.
  11. Do a final human review of a random sample. Even with automated metrics, have a human (or a second AI) review 10–20% of the outputs to catch issues that metrics miss, like hallucinations, inappropriate tone, or subtle errors.
  12. Publish the evaluation methodology alongside the results. Include the test set (if not proprietary), the prompts used, and the scoring rubrics. Transparency allows others to replicate or challenge your findings.

Common Mistakes

  • Testing on the same data you trained on. This gives artificially high scores. Always use a separate test set.
  • Using a single metric. Accuracy alone can be misleading if the task is imbalanced (e.g., 95% of queries are easy). Use multiple metrics and look at per-subgroup performance.
  • Not controlling for randomness. LLMs and some agents are stochastic. Running once and reporting the result as definitive is a mistake.
  • Ignoring edge cases. If your test set only has “normal” cases, you’ll miss failures on unusual but important inputs.
  • Comparing to an unfair baseline. If the baseline is a random guess or a trivial rule, any agent will look good. Use a strong baseline like a simple heuristic or a previous version.
  • Overlooking the cost and latency. An agent that’s 99% accurate but takes 10 seconds and costs $1 per query may not be usable in production. Include efficiency metrics.

Tips

  • Start small and scale. Begin with 10–20 tasks to sanity-check your evaluation pipeline, then expand to hundreds.
  • Use a rubric for subjective tasks. For open-ended responses, define levels (e.g., 0 = incorrect, 1 = partially correct, 2 = fully correct) and have multiple raters to reduce bias.
  • Automate what you can, but keep humans in the loop. Automated metrics are fast, but human judgment is still the gold standard for quality.
  • Version your test set. If you add new cases over time, keep track of which version was used for which evaluation.
  • Run a dry run before the full evaluation. This catches bugs in your logging or scoring code before you waste hours.
  • Consider adversarial testing. Deliberately include prompts designed to trick the agent (e.g., prompt injections, ambiguous instructions) to see how robust it is.

Troubleshooting

  • Results are wildly inconsistent between runs. This usually means the agent is stochastic and you’re not averaging enough runs. Increase the number of trials (e.g., to 10) and report the mean and variance. Also check if you’re using the same temperature setting each time.
  • The agent fails on tasks that seem easy. Look at the specific failure cases. Is it a misunderstanding of the prompt? A missing capability? A bug in the integration? Fix the root cause, not just the test case.
  • Your test set is too small. With fewer than 20 cases, results are unreliable. Expand the set, even if you have to write synthetic examples. Use bootstrapping to estimate confidence intervals.
  • Human reviewers disagree on scores. Define a more detailed rubric with concrete examples for each score level. Have reviewers rate a few practice cases together to align their understanding.
  • The agent performs well on the test set but fails in production. This is a sign of overfitting to the test set or a mismatch between test and real-world distributions. Collect more real-world data and use a held-out set that you update periodically.
  • You can’t reproduce the results from a paper or report. Check if the methodology is fully documented. If not, contact the authors for the test set and prompts. If you can’t get them, treat the results as unverifiable.

Frequently Asked Questions

How many test cases do I need?

There’s no magic number, but for a meaningful evaluation, aim for at least 30–50 cases per task type. For high-stakes applications, you may need hundreds to get statistically significant differences. Start with 20 and add more as you identify gaps.

Should I use a separate test set from the development set?

Yes, absolutely. The development set is used to tune the agent, so using it for evaluation gives a biased view. Keep a separate test set that you only touch for the final evaluation.

What if I don’t have real user data?

You can create synthetic examples based on domain knowledge, but be careful—they may not capture the full variability of real usage. If possible, get a domain expert to review the synthetic set for realism.

How do I handle subjective tasks like “write a polite email”?

Use a rubric with specific criteria (e.g., includes greeting, clear request, closing). Have multiple human raters score each output and use the average score. You can also use an LLM as a judge, but validate its judgments against human ones.

What’s the best way to compare two agents?

Run both agents on the same test set under identical conditions, and use a paired statistical test (like the Wilcoxon signed-rank test) to see if the difference is significant. Report the effect size and confidence intervals.

How often should I re-evaluate?

Whenever you change the agent’s prompts, model, or core logic. Also re-evaluate periodically on a rolling sample of new real-world data to catch drift.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →