Evaluating Agents: Trajectory Grading, Tool-Call Accuracy, pass^k & SWE-bench
Why 'vibes-based' testing breaks production agents: dual-axis Outcome + Trajectory grading, Tool-Call Precision/Recall, the brutal math of pass@k vs. pass^k, and building a 3-layer CI Eval Pyramid!
Agent Evaluation grades both final outcomes and intermediate tool trajectories, measuring production consistency with pass^k (all k runs succeed) alongside pass@k.
An agent with 80% single-run accuracy only succeeds 5 times in a row 33% of the time (0.8⁵); trajectory evals expose brittle tool selection before users hit it.
An agent with 80% single-run accuracy looks great on pass@5 (99.97%!) — but on pass^5 (5 consecutive reliable runs for an enterprise user), it drops to a shocking 32.8%!
Shipping prompt or tool-schema changes without an automated Trajectory + Outcome Eval Suite is flying blind — one tweak that fixes Bug A silently breaks 12 other flows.
Tracking Tool-Call Precision/Recall, First-Try Schema Validity, and pass^k turns fuzzy agent quality into crisp, optimizable engineering metrics!
Huge 2026 ML/AI Engineer interview question: 'Explain the difference between pass@k and pass^k for evaluating AI agents, and how do you grade an agent trajectory?'
If an agent has single-run accuracy , what is pass^5 (the probability it succeeds on ALL 5 consecutive user runs)?
- Grade agents on BOTH Final Outcome (DB/test assertions) and Intermediate Trajectory (tool selection, argument validity, step efficiency)
- Contrast optimistic
pass@k(≥ 1 success in tries) against enterprise reliabilitypass^k(ALL tries succeed!) - Build a 3-Layer Agent Eval Pyramid: fast deterministic unit checks → golden trajectory replays → calibrated LLM-as-a-Judge & human audits
- Use mocked/recorded tool environments in CI so eval suites run deterministically in seconds for pennies
pass@5 = 99.97%.Grading an agent only on its final text reply is like grading a pilot only on whether the plane landed — ignoring that they flew through a thunderstorm and burned 3× the fuel! Trajectory + Outcome Evals grade both the destination and the flight path, while pass^k tests whether the pilot lands safely every single time!
1. Dual-Axis Grading: Trajectory + Final Outcome
Unlike static QA models, agents take multi-step actions with side-effects. Always grade two axes:
- Outcome Grade (Deterministic Assertions): Did the final database state, edited git repo (
pytest), or cited answer match ground truth? - Trajectory Grade (Process Quality): Did the agent select the right tools (Tool Precision/Recall), emit valid JSON arguments on the first try, and finish near the optimal step count without looping?
2. The Brutal Math of `pass@k` vs. `pass^k`
pass@k asks if the agent succeeded at least ONCE in tries (looks great!), while pass^k asks if it succeeded ALL times in a row (what enterprise users experience!)Because LLM agents are stochastic, running an eval once hides flakiness. Run each golden scenario to times and report both:
pass@k(1 - (1 - p)^k): Can the agent solve it at all?pass^k(p^k): Can customers trust it every time?
Try the interactive calculator below — watch how raising from 80% to 96% transforms pass^5 from 32.8% to 81.5%!
Click each term to see why production teams optimize for consistency, not lucky cherry-picks.
Probability of at least 1 win out of tries — approaches 100% rapidly as grows.
pass^k are the gold standard for agents!pass@k vs. pass^k Production Reliability Calculator
3. The 3-Layer Agent Eval Pyramid (CI/CD Ready)
Don't run slow, expensive LLM-as-a-Judge calls on every commit! Structure your evals like a software testing pyramid:
- Base (Every Commit, $0): Deterministic schema validation, policy gate unit tests, and mocked tool-dispatch tests.
- Middle (Every PR): 30–100 Golden Trajectory Replays against recorded/sandboxed mock APIs (fast, reproducible, zero live side-effects!).
- Top (Nightly / Pre-Release): Rubric-scored LLM-as-a-Judge (calibrated against human labels!) + weekly human error audits.
Why should PR-level agent trajectory evals run against mocked/recorded tool environments instead of live production APIs?
The exact honest questions almost every beginner wonders — answered in plain English without hiding behind jargon.
Start small! 20–30 real, high-signal golden scenarios (covering happy paths, missing data, tool failures, and prompt-injection attempts) will immediately catch 90% of regressions — then grow the set every time you spot a live bug!
pass@k vs. pass^k in the calculator.Trajectory Step-by-Step Grader & pass^k Release Gate
Grade tool selection, argument schemas, final state assertions, and multi-run pass^k consistency.
pass^k (not just pass@k), and run a 3-layer Eval Pyramid over deterministic mock environments in CI.CI/CD Regression Gates for Prompt & Tool Changes
Blocks PR merges whenever Tool Precision, Outcome Pass Rate, or pass^3 drops below baseline on mocked golden trajectories.
# Agent Reliability Metric: pass@k (at least 1 success) vs. pass^k (all k runs succeed)
def pass_at_k(p: float, k: int) -> float:
"""Probability that at least one of k independent trials succeeds."""
return 1.0 - (1.0 - p) ** k
def pass_power_k(p: float, k: int) -> float:
"""Probability that ALL k consecutive production runs succeed (reliability)."""
return p ** k
def tool_trajectory_f1(pred_tools: list[str], gold_tools: list[str]) -> float:
pred, gold = set(pred_tools), set(gold_tools)
tp = len(pred & gold)
prec = tp / max(1, len(pred))
rec = tp / max(1, len(gold))
return 2 * prec * rec / max(1e-9, prec + rec)
p_single = 0.85
print(f"p={p_single:.0%} | pass@5={pass_at_k(p_single, 5):.1%} | pass^5={pass_power_k(p_single, 5):.1%}")
print(f"Tool Trajectory F1: {tool_trajectory_f1(['search', 'calc', 'format'], ['search', 'calc']):.2f}")
pass@5 in a stakeholder review and claiming '99% accuracy' for an 80%-reliable agent.pass^1 AND multi-run consistency pass^k alongside p95 cost and latency!pass^k measure that pass@k hides?