Skip to content

Evaluating LLM Agents in Practice: Metrics, Tests, and Pitfalls

Cover: Evaluating LLM Agents in Practice: Metrics, Tests, and Pitfalls LLM-based agent systems are becoming the standard for automating complex tasks. Unlike single model calls, an agent performs a chain of actions: plans, calls tools, analyzes results, and repeats the cycle. Evaluating such a system is more complex than measuring the quality of a single response. Below are practical approaches to evaluating LLM agents: which metrics to use, how to build test scenarios, and common errors.

What Makes Evaluating Agents Different from Evaluating Regular LLMs

Classical LLM evaluation focuses on the quality of a single response: accuracy, relevance, factuality. For an agent, this is insufficient. An agent is a process, not a result. An error can occur at any step: - incorrect tool selection; - incorrect call parameters; - getting stuck in an infinite loop; - ignoring the result of the previous step; - premature task termination. Therefore, evaluating an agent should consider not only the final response but also the trajectory of actions. For more details on agent system components, see the agents overview and agentic RAG patterns.

Metrics for Evaluating Agents

Three groups of metrics are distinguished: outcome, process, and economic. | Group | Metric | What it measures | |-------|--------|------------------| | Outcome | Task Success Rate | Proportion of tasks completed successfully | | Outcome | Goal Completion | Degree of goal achievement (partial success) | | Process | Tool Call Accuracy | Proportion of correct tool calls | | Process | Loop Count | Average number of iterations until completion | | Process | Dead-end Rate | Proportion of trajectories that hit a dead end | | Economic | Cost per Task | Average cost of task completion | | Economic | Latency | Average execution time | For outcome evaluation, the LLM-as-a-Judge approach is used, but with mandatory validation on a small labeled set. The judge model excels at semantic similarity assessment but may miss logical errors.

Building a Test Set

A test set for an agent should include not only 'ideal' scenarios but also edge cases. A set of three categories is collected: 1. Happy path — typical tasks that the agent should perform without errors. 2. Edge cases — non-standard input data, missing necessary tools, conflicting instructions. 3. Adversarial — attempts at prompt injection, requests for actions outside the allowed scope. For generating edge cases, synthetic data is used: real logs are taken and modified — changing the order of fields, adding typos, removing required parameters.

Tools for Evaluation

Known approaches: - Manual verification — suitable for early prototypes but does not scale. - Scripts with regular expressions — check only format, not semantics. - LLM-as-a-Judge — flexible but requires prompt tuning and calibration. - Specialized frameworks — for example, RAGAS for RAG, but few ready solutions for agents. The optimal combination is: scripts for checking structure (presence of required fields in JSON, correctness of tool names) and an LLM judge for semantic evaluation. It's important that the judge receives not only the final response but also the trajectory of actions.

Common Evaluation Errors

Common errors: 1. Evaluating only the final response. An agent may randomly arrive at the correct answer but with a suboptimal trajectory. This is not a problem if the task is completed, but it may indicate planning issues. 2. Ignoring cost. An agent that makes 20 calls instead of 3 may be more accurate but economically unviable. Cost per task is always calculated. 3. Lack of stability tests. An agent that works well on clean data may break on real data. 'Dirty' data is added to the test set. 4. Insufficient edge case coverage. Often, only happy path is tested. It is recommended to allocate at least 30% of tests to edge cases.

Practical Example

Consider an agent that orders products via API. Test scenario:

{
  "task": "Order 2 units of SKU-123 at $1500 each",
  "expected_tools": ["search_product", "add_to_cart", "checkout"],
  "expected_params": {"sku": "SKU-123", "quantity": 2},
  "success_condition": "order_id in response"
}
The scenario is run, and the following are checked: - are all tools called in the correct order; - parameters match expected; - response contains order_id. If the agent calls checkout without add_to_cart, this is an error, even if the final response contains order_id.

Conclusion

Evaluating LLM agents is a separate discipline requiring a combination of metrics, well-designed test sets, and automation. Start small: define key scenarios, add process and cost metrics, then gradually expand coverage. Remember that evaluation is not a one-time action but an ongoing process, especially when prompts or models change. Useful materials on related topics: RAG system evaluation, LLM evaluation metrics, LLM system observability and tracing.