Agent Evaluation
Agent evaluation is the process of measuring whether an AI agent completes a task correctly, follows the expected process, uses tools properly, and behaves reliably across different situations.
How do we know that our agent is actually working well?
This is one of the most important parts of building production AI systems. An agent can produce a convincing answer and still fail at its task. It can call the wrong tool, pass incorrect arguments, skip a required step, or report success when an operation failed.
We need ways to detect these failures before and after deployment.
Why do we need agent evaluation?
Section titled “Why do we need agent evaluation?”Imagine you build an AI research agent.
A user asks:
Compare LangGraph and CrewAI. Research their key features and write a Markdown report.
Your agent performs these steps:
- Understands the request.
- Creates a plan.
- Calls a research tool.
- Collects information.
- Calls a report-writing tool.
- Returns the report location.
The agent responds:
I have completed the comparison. The report is saved at
output/comparison.md.
The response sounds correct. But several things could have gone wrong:
- It researched the wrong frameworks.
- It called the research tool with incomplete arguments.
- It skipped the research step.
- It wrote an empty report.
- It saved the report to a different location.
- It claimed success even though the file was never created.
Checking only the final response will not reveal all these failures.
This is the central challenge of agent evaluation:
We must evaluate both the result and the process used to produce it.
LLM evaluation vs Agent evaluation
Section titled “LLM evaluation vs Agent evaluation”An LLM evaluation usually measures the quality of a model’s response to an input.
Input:What is the capital of France?
Expected:Paris
Actual:ParisWe can compare the actual response with the expected answer.
But an agent performs multiple actions before producing its final response.
User request | vAgent | +----> Select tool | +----> Generate arguments | +----> Execute tool | +----> Read tool result | +----> Decide next action | vFinal responseEach step introduces a possible failure.
| LLM evaluation | Agent evaluation |
|---|---|
| Response quality | Task completion |
| Factual correctness | Correct tool selection |
| Relevance | Correct tool arguments |
| Instruction following | Correct execution sequence |
| Response format | Appropriate handling of failures |
| — | Correct use of state and memory |
Agent evaluation includes LLM evaluation, but it goes further.
A useful way to think about it:
- LLM evaluation: Did the model produce a good response?
- Agent evaluation: Did the system complete the task correctly?
What exactly should we evaluate?
Section titled “What exactly should we evaluate?”1. Task completion
Did the agent achieve the user’s intended goal?
2. Tool selection and arguments
Did it select the correct tool and provide valid arguments?
3. Execution trajectory
Did it follow a valid sequence of steps?
4. Response quality
Was the final response correct, relevant, complete, and useful?
5. Reliability and efficiency
Did it avoid unnecessary calls, excessive retries, and excessive cost or latency?
These areas are related, but they are not interchangeable.
For example, an agent can complete a task while making unnecessary tool calls. It can also follow the correct sequence but produce an incorrect final answer.
We should measure these dimensions separately.
Tool selection and argument evaluation
Section titled “Tool selection and argument evaluation”Tool calling is a critical part of an agent’s behavior.
def search_web(query: str): ...
def read_file(path: str): ...
def write_file(path: str, content: str): ...The user asks:
Read
notes.mdand create a summary insummary.md.
The expected behavior is:
- Call
read_filewithpath="notes.md". - Understand the file contents.
- Call
write_filewithpath="summary.md"and the generated summary.
We can evaluate two separate things.
1. Tool selection
Section titled “1. Tool selection”Did the agent select the correct tool?
| Expected tool | Actual tool | Result |
|---|---|---|
read_file |
read_file |
Correct |
write_file |
search_web |
Incorrect |
A simple metric is tool selection accuracy:

2. Argument correctness
Section titled “2. Argument correctness”Even when the agent selects the correct tool, it can pass incorrect arguments.

In practice, argument evaluation can use:
- Exact matching for fixed values.
- Schema validation for required fields and types.
- Semantic comparison for natural-language arguments.
- Custom rules for business constraints.
For example, if the user asks for a report about two frameworks, a test can check whether both framework names are present in the research tool arguments.
Important: Do not evaluate tool calls only by checking whether they are valid JSON. Valid arguments can still be semantically wrong.
Task completion evaluation
Section titled “Task completion evaluation”This measures whether the agent achieved the user’s actual goal.
Consider this task:
Create a report comparing LangGraph and CrewAI and save it as
output/comparison.md.
A weak evaluation check:
assert response is not NoneThis proves almost nothing.
A better evaluation checks the actual result:
from pathlib import Path
report = Path("output/comparison.md")
assert report.exists()assert report.stat().st_size > 100But even this is not enough. A file can exist and contain incorrect information.
We can add content checks:
content = report.read_text()
assert "LangGraph" in contentassert "CrewAI" in contentassert "Comparison" in contentThis gives us multiple levels of verification:
- Did the agent return a response?
- Did the expected artifact get created?
- Does the artifact contain the required content?
- Is the content factually correct and useful?
The last check may require a human evaluator, an LLM judge, or a trusted reference.
Success criteria
Section titled “Success criteria”Before evaluating an agent, define what success means.
test_case = { "task": "Compare LangGraph and CrewAI", "expected_file": "output/comparison.md", "required_sections": [ "Overview", "Features", "Comparison", "Conclusion" ]}This is important because an evaluator cannot reliably measure success if the expected outcome is unclear.
Agent trajectory evaluation
Section titled “Agent trajectory evaluation”A trajectory is the sequence of actions and observations produced during an agent’s execution.
User request | vAgent | +--> research_frameworks(["LangGraph", "CrewAI"]) | +--> Observation: Research completed | +--> write_report(research) | +--> Observation: File created | vFinal responseTrajectory evaluation helps us detect:
- Missing required steps.
- Incorrect tool order.
- Repeated tool calls.
- Unnecessary actions.
- Infinite loops.
- Incorrect decisions after tool results.
- Failure to recover from errors.
Do we need an exact expected trajectory?
Section titled “Do we need an exact expected trajectory?”There may be several valid ways to complete the same task.
For example, an agent may research two frameworks in parallel or one after another. Both can be correct.
Therefore, we should distinguish:
- Exact trajectory matching: Compare the agent’s actions with a predefined sequence.
- Rule-based trajectory evaluation: Check whether required actions and constraints were satisfied.
- Semantic trajectory evaluation: Use a judge to assess whether the actions made sense in context.
Exact matching is useful for deterministic workflows. Rule-based and semantic evaluation are more useful for flexible agents.
LLM-as-a-Judge
Section titled “LLM-as-a-Judge”Many agent outputs do not have one exact correct answer.
Suppose an agent writes a report comparing two frameworks. There may be several valid ways to structure the report.
A simple string comparison will not work.
This is where LLM-as-a-Judge becomes useful.
An LLM judge evaluates an output against defined criteria.
You are evaluating an AI research agent.
User task:Compare LangGraph and CrewAI.
Agent output:[Generated report]
Evaluate the output on:
1. Accuracy2. Completeness3. Relevance4. Clarity
Return:- A score from 1 to 5 for each criterion.- A short explanation for each score.- An overall pass or fail.The judge produces a structured evaluation.
{ "accuracy": 4, "completeness": 3, "relevance": 5, "clarity": 4, "passed": false, "reason": "The report does not cover deployment considerations."}How should we use an LLM judge?
Section titled “How should we use an LLM judge?”A good evaluation process has four parts:
- Define evaluation criteria.
- Provide the task and agent output.
- Ask the judge to score each criterion.
- Validate the judge’s output and apply pass/fail rules.
passed = ( result["accuracy"] >= 4 and result["completeness"] >= 4 and result["relevance"] >= 3)Limitations of LLM-as-a-Judge
Section titled “Limitations of LLM-as-a-Judge”An LLM judge is not ground truth.
It can:
- Reward confident but incorrect answers.
- Miss subtle factual errors.
- Prefer longer answers.
- Give inconsistent scores.
- Be influenced by how the output is presented.
Ways to improve it:
- Use clear scoring rubrics.
- Give it the original task and relevant reference material.
- Ask for evidence supporting each score.
- Test judge consistency on known examples.
- Use deterministic checks for facts that can be verified automatically.
- Use human review for important decisions.
Evaluation datasets and test cases
Section titled “Evaluation datasets and test cases”You cannot evaluate an agent properly with only one or two prompts.
You need a collection of test cases that represent the tasks the agent is expected to handle.
This collection is called an evaluation dataset or eval dataset.
eval_cases = [ { "id": "case_001", "input": "Compare LangGraph and CrewAI", "expected_frameworks": ["LangGraph", "CrewAI"], "expected_file": "output/comparison.md" }, { "id": "case_002", "input": "Research AutoGen and write a report", "expected_frameworks": ["AutoGen"], "expected_file": "output/autogen.md" }]Each test case should define:
- Input: What the user asks.
- Expected behavior: What the agent should do.
- Expected outcome: What successful completion looks like.
- Evaluation rules: How we will check the result.
What types of test cases should we include?
Section titled “What types of test cases should we include?”A good dataset should cover more than normal requests.
| Test type | Example |
|---|---|
| Happy path | Valid request with all required information |
| Missing information | User does not specify a framework |
| Ambiguous request | “Compare the popular agent frameworks” |
| Invalid input | Unsupported framework name |
| Tool failure | Research API returns an error |
| Empty result | Research tool returns no data |
| Large task | User requests 20 frameworks |
| Repeated request | User asks for the same report twice |
Why include failure cases?
Because an agent that works only when everything goes well is not ready for production.
A useful evaluation dataset should:
- Represent real user requests.
- Cover different levels of difficulty.
- Include edge cases and failure cases.
- Have clear expected outcomes.
- Avoid duplicate or near-identical examples.
- Be updated when product requirements change.
You should also keep a set of examples that are not used during development. This helps you check whether improvements generalize beyond the examples you repeatedly test.
Offline and online evaluation
Section titled “Offline and online evaluation”There are two major ways to evaluate an agent.
- Offline evaluation
Offline evaluation happens before a new version is deployed.
You run the agent against a predefined dataset and inspect its performance.
Evaluation dataset | v Agent v1 | v Evaluation | v ResultsFor example:
You have 100 test cases.
You run all 100 against the current agent version and record:
- Task completion rate.
- Tool selection accuracy.
- Argument accuracy.
- Average tool calls.
- Average execution time.
- Cost per task.
You then modify the agent and run the same dataset again.
This helps you understand whether the change improved or damaged performance.
Use offline evaluation for:
- Testing new prompts.
- Comparing models.
- Testing new tools.
- Changing agent architecture.
- Checking behavior before deployment.
- Online evaluation
Online evaluation happens after the agent is deployed.
You observe how it performs on real user requests.
Real user requests | v Production agent | v Execution traces | v Evaluation and monitoring | v Performance reportsFor example, you may discover that the agent completes 95% of internal test cases but only 78% of real user tasks.
Why?
Your test dataset may not represent actual user behavior.
Online evaluation helps detect:
- Real-world failure patterns.
- Unexpected user inputs.
- Tool failures.
- Quality changes.
- Increased latency or cost.
- Problems that were not represented in offline tests.
| Offline | Online |
|---|---|
| Uses a predefined dataset | Uses real production traffic |
| Controlled environment | Real-world conditions |
| Useful before deployment | Useful after deployment |
| Easier to reproduce | Harder to reproduce |
| Helps compare versions | Helps detect production issues |
Regression testing
Section titled “Regression testing”Regression testing checks whether a new change breaks behavior that previously worked.
Imagine your agent has 100 test cases.
Before a prompt change:
Agent version 1: 92% task completion rate
After the change:
Agent version 2: 84% task completion rate
Your change has reduced task completion by 8 percentage points.
Without regression tests, you might deploy this version and discover the problem from users.
How regression testing works
Section titled “How regression testing works”A typical process:
- Maintain a fixed evaluation dataset.
- Run it against the current agent.
- Save the results.
- Make a code, prompt, model, or tool change.
- Run the same dataset again.
- Compare the metrics.
- Block deployment if important metrics fall below acceptable thresholds.
This can be part of a CI/CD pipeline.
Pull request | vRun unit tests | vRun agent evaluations | vCompare with baseline | +----> Pass: allow deployment | +----> Fail: block deploymentOne important detail: LLM outputs are often non-deterministic. The same test may produce different results across runs.
For important evaluations, run tests multiple times and compare average performance and variation. Do not treat one successful run as proof of reliability.
Putting everything together: an evaluation pipeline
Section titled “Putting everything together: an evaluation pipeline”A practical evaluation pipeline looks like this:

Common mistakes in agent evaluation
Section titled “Common mistakes in agent evaluation”Mistake 1: Evaluating only the final answer
An agent can return a good-looking answer without completing the actual task.
Mistake 2: Using an LLM judge for everything
Use deterministic checks when possible. They are cheaper and more consistent.
Mistake 3: Testing only happy paths
Real users provide incomplete, ambiguous, and invalid inputs. Tools also fail.
Mistake 4: Using too few test cases
A handful of successful examples does not demonstrate general performance.
Mistake 5: Optimizing only task success rate
The agent might achieve a higher success rate at an unacceptable cost or latency.
Mistake 6: Treating benchmark scores as production guarantees
A benchmark measures performance on its own tasks. It does not guarantee performance on your users’ tasks.
Mistake 7: Not evaluating after changes
A new model, prompt, tool description, or workflow can change agent behavior. Run regression evaluations after meaningful changes.