Skip to content

How to Evaluate AI Agents: Metrics, Evals, and Benchmarks

How to evaluate AI agents: define task success, score outcomes and trajectories, measure consistency across runs, and use benchmarks as a sanity check only.

TechnoKeen Engineering 9 min read Published
On this page

To evaluate an AI agent, define what success means for each task, score both the final outcome and the path the agent took to reach it, and run every case several times, because agents are not deterministic. Public benchmarks show you what a model can do in general. Only an eval suite built from your own tasks tells you whether your agent is ready to ship.

Key takeaways

  • Evaluate outcomes first (did the task get done correctly?), then trajectories (did the agent get there safely and efficiently?).
  • Run each eval case multiple times. An agent that succeeds once in three tries is not the same as one that succeeds three times out of three, and a single run can’t tell them apart.
  • Prefer deterministic checks such as state assertions, schema validation, and exact matches. Use an LLM judge only for qualities code can’t check, and calibrate it against human labels.
  • Public benchmarks like SWE-bench are useful for choosing a model, but they are no substitute for a domain eval set built from real or realistic traffic.
  • Treat evals as a regression suite that gates every prompt, tool, and model change, not a one-time launch checklist.

Why agent evaluation is harder than model evaluation

Evaluating a single LLM call is fairly simple: one input, one output, one score. An agent breaks that model in three ways.

First, the output is a sequence of actions, not just text. A support agent might look up an order, check a refund policy, issue a refund, and write a reply. The final message can read perfectly while the refund went to the wrong order.

Second, agents change state. They write to databases, send emails, and open tickets. Your eval has to inspect the world after the run, not just the transcript.

Third, agents are stochastic across many steps. A small variation early on, such as a different search query, can send the rest of the run down a completely different path. Two runs with the same input can produce different tool calls, different costs, and different results.

The ReAct pattern (Yao et al.) that underpins most agent loops, where the model alternates between reasoning and acting, is exactly what makes this hard. Every reasoning step is a decision point, and every decision point is a place where runs can diverge. If you’re still choosing between a fixed workflow and an open-ended agent, our guide to workflows vs. agents covers how that choice affects how testable the system is.

The three layers of agent metrics

Useful agent metrics fall into three layers. You need all three, but in priority order.

Layer 1: Outcome metrics

Did the agent accomplish the task? This is the metric that matters to the business, and it should be checked against ground truth wherever possible.

  • Task success rate: the share of eval cases where the end state matches what was expected.
  • Correctness of side effects: the right record was updated, with the right values, and nothing else was touched.
  • Policy compliance: the agent didn’t take an action it should have refused or escalated.

Layer 2: Trajectory metrics

How did the agent get there? Two agents with the same success rate can differ a lot in risk and cost.

  • Tool-call correctness: were the right tools called with valid arguments?
  • Unnecessary or forbidden actions: did the agent call a destructive tool it didn’t need?
  • Step count and loop detection: did it finish in a reasonable number of turns, or wander?
  • Recovery behavior: when a tool returned an error, did the agent adapt or repeat the same failing call?

Layer 3: Operational metrics

What does a run cost, and how does it feel to the user?

  • Tokens and cost per task, and more usefully, cost per successful task.
  • End-to-end latency, including tool time.
  • Escalation rate: how often the agent hands off to a human, and whether those handoffs were appropriate.

The table below summarizes how to measure each layer.

Layer Example metric Best measured with Typical failure it catches
Outcome Task success rate State assertions against a sandbox Correct-sounding answer, wrong action
Outcome Policy compliance Rule checks plus targeted adversarial cases Refund issued above approval limit
Trajectory Tool-call validity Schema validation on recorded calls Malformed arguments, wrong tool
Trajectory Forbidden actions Allow/deny lists on the trace Agent deletes when it should archive
Trajectory Steps per task Trace span counts Loops, redundant searches
Operational Cost per successful task Token usage from traces Regressions hidden behind stable accuracy
Operational Latency (p50/p95) Trace timing Slow tools, excessive turns

Consistency: pass@k vs. pass^k

Because agent runs vary, a single pass/fail per case hides important information. Two measures are worth tracking separately.

pass@k asks whether the agent succeeded at least once in k attempts. It describes capability: can the agent solve this at all? It suits settings where a human or verifier picks the best of several attempts, such as code generation with tests.

pass^k asks whether the agent succeeded on all k attempts. It describes reliability: will it solve this every time? This is the measure that matters for an agent acting unsupervised on customer accounts. The τ-bench benchmark from Sierra popularized this framing for tool-using agents in customer service settings.

The gap between the two is diagnostic. A high pass@k with a low pass^k means the agent can do the task but does so inconsistently. That usually points to ambiguous instructions, an underspecified tool, or missing context, rather than a capability gap. Our post on context engineering covers the most common fixes.

Building an eval suite that reflects reality

The eval set is the most valuable asset in an agent project. Model choices and prompts will change. A good set of test cases keeps paying off.

Where eval cases come from

  1. Real traffic. If the agent replaces or assists an existing process, sample historical tickets, requests, or documents. Strip personal data, then label the expected outcome.
  2. Subject-matter experts. Ask the people who do the work today for the cases that trip up new hires. Those are usually the cases that trip up agents too.
  3. Production failures. Every incident, escalation, or thumbs-down should become a candidate eval case. This is how the suite gets better over time.
  4. Adversarial cases. Include prompt injection attempts, out-of-scope requests, and inputs that should trigger a refusal or escalation. See our guide to securing AI agents for the categories to cover.
  5. Synthetic variations. Use a model to paraphrase or perturb real cases, but have a human review them. Unreviewed synthetic data tends to test what the generator thinks is hard, not what is hard.

Start small. Twenty to fifty well-labeled cases that cover your main task types will catch more regressions than hundreds of unlabeled ones. Grow the set as production traffic reveals new failure modes.

Sandbox the environment

Agents that take actions need an environment to act in. Give your eval harness a resettable sandbox: a seeded test database, mocked or staging APIs, and a fake email outbox. Each case starts from a known state, and the grader inspects the end state. Without this, you’re only grading what the agent says it did.

A minimal eval harness in Python

The sketch below shows the core pieces: repeated runs per case, deterministic outcome checks, trajectory checks against the recorded tool calls, and per-case pass@k and pass^k. It assumes your agent exposes a run(input, env) function that returns a transcript of tool calls and a final answer, and that env is a resettable sandbox.

from dataclasses import dataclass, field
from statistics import mean
from typing import Callable, Any


@dataclass
class ToolCall:
    name: str
    args: dict[str, Any]


@dataclass
class RunResult:
    final_answer: str
    tool_calls: list[ToolCall]
    input_tokens: int
    output_tokens: int


@dataclass
class EvalCase:
    case_id: str
    user_input: str
    # Checks the sandbox state after the run. Returns True if the outcome is correct.
    check_outcome: Callable[[Any], bool]
    forbidden_tools: set[str] = field(default_factory=set)
    max_steps: int = 12


@dataclass
class CaseReport:
    case_id: str
    successes: list[bool]
    trajectory_violations: list[str]
    avg_tokens: float

    @property
    def pass_at_k(self) -> bool:
        return any(self.successes)

    @property
    def pass_hat_k(self) -> bool:
        return all(self.successes)


def check_trajectory(case: EvalCase, result: RunResult) -> list[str]:
    violations = []
    used = {call.name for call in result.tool_calls}
    for tool in used & case.forbidden_tools:
        violations.append(f"forbidden tool called: {tool}")
    if len(result.tool_calls) > case.max_steps:
        violations.append(f"too many steps: {len(result.tool_calls)}")
    # Flag identical consecutive calls, a common sign of a retry loop.
    for prev, curr in zip(result.tool_calls, result.tool_calls[1:]):
        if prev.name == curr.name and prev.args == curr.args:
            violations.append(f"repeated identical call: {curr.name}")
            break
    return violations


def evaluate(agent_run, make_env, cases: list[EvalCase], k: int = 3) -> list[CaseReport]:
    reports = []
    for case in cases:
        successes, violations, tokens = [], [], []
        for _ in range(k):
            env = make_env()  # fresh, seeded sandbox for every attempt
            result: RunResult = agent_run(case.user_input, env)
            traj = check_trajectory(case, result)
            # A run only counts as a success if the outcome is right AND the path was clean.
            successes.append(case.check_outcome(env) and not traj)
            violations.extend(traj)
            tokens.append(result.input_tokens + result.output_tokens)
        reports.append(CaseReport(case.case_id, successes, violations, mean(tokens)))
    return reports


def summarize(reports: list[CaseReport]) -> dict[str, float]:
    n = len(reports)
    return {
        "pass@k": sum(r.pass_at_k for r in reports) / n,
        "pass^k": sum(r.pass_hat_k for r in reports) / n,
        "avg_tokens_per_run": mean(r.avg_tokens for r in reports),
    }

A case definition then reads like a test:

refund_case = EvalCase(
    case_id="refund-over-limit-escalates",
    user_input="I want a full refund on order 88123, it arrived broken.",
    # Order 88123 is seeded above the auto-refund limit, so the agent must escalate.
    check_outcome=lambda env: (
        env.db.refunds_for("88123") == []
        and env.tickets.latest().queue == "refund-approvals"
    ),
    forbidden_tools={"issue_refund"},
)

Two design choices matter here. A run with a trajectory violation counts as a failure even if the outcome was right, because reaching the right answer by a forbidden path is still a production risk. And every attempt gets a fresh environment, so one run’s side effects can’t leak into the next.

Using LLM-as-judge without fooling yourself

Some qualities resist code-based checks: whether a reply was empathetic, whether a summary left out a material fact, whether the agent explained a policy clearly. For these, a second model acting as a grader is practical. It is also easy to get wrong.

Guidelines that hold up in practice:

  • Grade against a rubric, not a vibe. Ask specific yes/no questions (“Does the reply state the refund timeline?”) rather than “Rate this reply 1 to 10.”
  • Give the judge the reference answer or the relevant source material when you have it. Judging against ground truth is far more reliable than judging in a vacuum.
  • Ask for reasoning before the verdict, and store both. The reasoning is how you debug a disagreeing judge.
  • Calibrate against humans. Have people label a sample of cases, compare the judge’s verdicts to theirs, and revise the rubric until agreement is acceptable to you. Recheck whenever you change the judge model.
  • Watch for known biases. Judges tend to favor longer answers and can favor outputs from their own model family. Use a different model for judging where practical, and keep rubric questions length-neutral.

Keep LLM judges for the layer they suit. If a check can be written as an assertion on state or a schema, write the assertion.

Where public benchmarks fit

Public benchmarks are a useful signal when you’re choosing models and frameworks. SWE-bench measures whether an agent can resolve real GitHub issues in open-source Python repositories, verified by the repository’s own tests. Benchmarks such as τ-bench (customer service with tools and policies) and WebArena (web navigation tasks) cover other agent settings.

They have real limits for production decisions:

  • Domain mismatch. Your tools, data, and policies are not in the benchmark.
  • Contamination. Popular benchmark data can leak into training sets, which inflates scores.
  • Scaffold dependence. Reported scores often reflect a specific harness, prompt, and tool set. Your scaffold will produce different numbers with the same model.

Use benchmarks to build a shortlist. Use your own suite to make the final decision. Our guide to choosing an agent framework applies the same logic to framework selection.

Making evals part of the release process

Evals earn their keep when they run automatically. A workable operating model:

  1. Gate every change. Prompt edits, tool description changes, model upgrades, and framework bumps all run the suite in CI before merge.
  2. Set explicit thresholds per metric, such as a minimum pass^k on policy cases and a maximum cost per successful task, and block releases that regress them.
  3. Track trends, not just snapshots. A slow slide in cost or step count often shows up before success rate drops.
  4. Close the loop with production. Feed traced failures from agent observability back into the eval set every sprint.
  5. Review a sample by hand. Automated scores drift from reality. Have an engineer or domain expert read a handful of full transcripts each week.

Online evaluation complements this. Sample a percentage of live traffic, run your LLM judges and rule checks on it asynchronously, and alert on shifts. Offline evals tell you whether a change is safe to ship. Online evals tell you whether the world has changed under you.

FAQ

How many eval cases does an AI agent need?

There is no universal number, but coverage matters more than volume. A few dozen carefully labeled cases that span your main task types, edge cases, and policy boundaries are enough to start gating releases. Grow the set from production failures over time.

Should I use an LLM to grade my agent?

Use an LLM judge only for qualities that code can’t check, such as tone, completeness, or clarity. Write it as a rubric of specific questions, give it reference material, and calibrate it against human labels before trusting it. For state changes and tool calls, deterministic assertions are cheaper and more reliable.

What is the difference between pass@k and pass^k?

pass@k measures whether the agent succeeds at least once in k attempts, which reflects capability. pass^k measures whether it succeeds on every one of k attempts, which reflects reliability. For agents acting without supervision, pass^k is usually the number that predicts production behavior.

Can I rely on public benchmark scores to choose a model?

Benchmarks are a reasonable way to shortlist models, but they don’t reflect your tools, data, or policies, and scores depend heavily on the harness used. Run your shortlist against your own eval suite before deciding. Definitions of the terms used here are in our glossary.

Working with TechnoKeen

TechnoKeen builds eval suites, sandboxes, and CI gates as part of every agent we design and operate. If you want a second opinion on whether your agent is ready for production, get in touch or start with our agent readiness assessment.

  • #agent evaluation
  • #evals
  • #LLM-as-judge
  • #benchmarks

TechnoKeen Engineering

TechnoKeen is an enterprise agentic AI company. Our engineers design, deploy, and govern AI agents for organizations in regulated and complex industries, and share what we learn in the field.

About TechnoKeen →

Keep reading

Ready to put agents to work?

Book a 45-minute executive briefing. We will review your priority workflows, current AI efforts, and risk posture, then outline a clear path to agents in production.