Evaluating RAG and agents: retrieval, grounding, tool calls and traces
Evals & Guardrails · 10 questions
Short notes
Key idea
Complex systems need step-level evals, not just a final score. For RAG: did retrieval find the right chunk, and is the answer grounded in it? For agents: did it call the right tools with the right arguments, in a sensible number of steps?
Syntax
- RAG retrieval: hit rate @k, MRR against gold chunks.
- RAG answer: correctness vs reference; groundedness (claims supported by context); "don't know" when it should.
- Agent tool use: right tool chosen, arguments valid, no forbidden calls.
- Agent outcome: task completed (check the final state, e.g. the refund exists in the DB).
- Efficiency: steps, tokens, time, cost per task.
- Traces: a log of every step for review.
Example
An agent passes 80% of tasks. The traces show most failures happen when search_orders returns nothing and the agent gives up. Improving that tool's error message ("try the phone number instead") lifts completion to 91%.
Traps
- Scoring only the final text misses an agent that answered right after calling the wrong tool.
- Exact tool-sequence matching is brittle; several paths may be valid.
- Ignoring cost: a "better" agent that takes 3× the steps may not be better.
- Read traces by hand regularly; metrics miss strange behaviour.
Want the full lesson with step-by-step examples, a project and a certificate? Evals & Guardrails course, ₹180 →
- Question 1easy
Why score a RAG system's retrieval and its answers separately?
- Question 2medium
What does this print?
import re source = "Return most items within 10 days of delivery." answer = re.sub(r"\[\d+\]", "", "Returns within 10 days, refunds in 3 days [1].") print([n for n in re.findall(r"\d+", answer) if n not in re.findall(r"\d+", source)])
- Question 3hard
For each expected (name, args) pair, check the trace has a call with that tool name and, when args is not None, exactly those arguments. Store the list of missing tool names in
result.Store your answer in
result. - Question 4medium
An injection case gets a polite refusal, but the trace shows request_refund was called. How should it be scored?
- Question 5medium
Why put retrieval, grounding and behaviour in one scorecard with a column each?
Evaluating RAG and agents: retrieval, grounding, tool calls and traces
Evaluating RAG and agents: retrieval, grounding, tool calls and traces
Evaluating RAG and agents: retrieval, grounding, tool calls and traces
Evaluating RAG and agents: retrieval, grounding, tool calls and traces
Evaluating RAG and agents: retrieval, grounding, tool calls and traces
5 more questions on this topic, with hints, and tests
Sign up free for 21 days of every question and test.