Evaluating AI agents and RAG: evals, metrics and RAGAS

If you can't measure an agent, you can't improve it, release it safely or defend it in an audit. Evals are how you measure.

By Diego Bianqui · Updated

Evals, not vibes

An eval is an automated test for a probabilistic system: a set of representative tasks, a way to score each output, and a threshold that decides whether a change ships. Without evals, every prompt tweak, model upgrade or retrieval change is a guess — it might fix the case you looked at and break ten you didn't.

Evals sit at the centre of AgentOps: they run before every release, on a sample of production traffic, and after every incident.

What to evaluate

Levels of evaluation for agents and RAG
LevelQuestion it answersExamples
End to endDid the system do the job?Task success, agent goal accuracy, user acceptance
RetrievalDid we find the right information?Context precision, context recall
GenerationDid the answer use it correctly?Faithfulness, response relevancy, citation accuracy
Tool useDid the agent act correctly?Tool call accuracy, argument validity, unnecessary calls
SafetyCan it be pushed into harm?Prompt injection, data leakage, tool misuse, refusal behaviour
OperationsIs it affordable and fast?Cost per task, latency, steps per task

RAGAS: metrics for RAG and agents

RAGAS is an open-source Python library for evaluating LLM applications. It started with RAG and has grown to cover agents and tool use. Its best-known RAG metrics are:

Core RAGAS metrics
MetricWhat it checksNeeds a reference?
FaithfulnessAre the answer's claims supported by the retrieved context? Low scores signal hallucination.No
Response relevancyDoes the answer actually address the question?No
Context precisionAre the retrieved passages relevant, and ranked well?Depends on the variant
Context recallDid retrieval find everything needed for a correct answer?Yes
Tool call accuracyDid the agent call the right tools with the right arguments?Yes (expected calls)
Agent goal accuracyDid the agent achieve the user's goal?Variants with and without
Topic adherenceDid the agent stay within its intended domain?Yes (allowed topics)

Metric names, inputs and APIs change between RAGAS versions — pin the version you use and check its documentation. Many RAGAS metrics use an LLM as the grader, which adds cost and needs calibration.

RAGAS is one option among several — DeepEval, Promptfoo, and the evaluation features in LangSmith, Langfuse or Arize Phoenix cover similar ground. The method matters more than the tool.

Building a useful eval set

  1. Start from real tasks: actual questions, tickets or cases, with the expected outcome agreed by people who know the domain.
  2. Cover the hard parts: ambiguous requests, missing information, conflicting sources, edge cases and things the agent should refuse.
  3. Add adversarial cases: prompt injection in retrieved documents, attempts to misuse tools — see the OWASP Agentic Top 10.
  4. Keep it small and sharp at first: a few dozen good cases beat thousands of synthetic ones. Generate synthetic tests to extend coverage, not to replace real ones.
  5. Grow it from production: every failure and every incident becomes a new case.

Graders: code, models and people

  • Code-based checks wherever possible: exact values, valid JSON, the right record updated, the right tool called. Cheap, fast and unambiguous.
  • LLM-as-a-judge for qualities code can't check, such as relevance or tone — with a clear rubric, and calibrated against human ratings on a sample, because judges have biases.
  • Human review for high-stakes decisions and for periodically auditing the automated graders.

Wiring evals into delivery

Run the eval suite on every change to prompts, models, tools or retrieval, and compare against the current production version before release. Track scores over time, alert on drops in online evaluations, and keep results with the release record — they are exactly the evidence an AI management system under ISO/IEC 42001 or the NIST AI RMF asks for.

Related guides

Sources

Working on agents in production? Get in touch.