What you will be able to do
- Map over-retrieval to precision-style metrics and under-retrieval to recall-style metrics
- State which retrieval metrics need ground truth and which do not
- Use MLflow traces to find which retrieval step polluted or starved an agent's context
- Choose the memory-search setting or retrieval technique that addresses the diagnosed failure
1.Measure retrieval separately from the answer
Over-retrieval and under-retrieval both live in the retrieval step, but they show up in the answer only indirectly. An agent might answer correctly today while dragging ten irrelevant memories into every turn. That works until one of them misleads it. Databricks' guidance is that it is very important to collect both response and retrieval metrics, because only measuring both lets you tell the components apart.
There is a precondition: you need a reproducible evaluation system before you tune anything. A golden dataset, a synthetic evaluation set or ground-truth-free judges all qualify. Changing your memory search settings without measuring is guesswork, and it is easy to trade one failure for the other without noticing.
Checkpoint 1 of 6· Check yourself
A team plans to raise the memory search limit because users complain about forgotten preferences. They have no evaluation set. What does the Databricks retrieval-quality guidance say to do first?
The guide is explicit that measurement comes first. Without it, you cannot tell whether the change fixed under-retrieval or caused over-retrieval.
“If you don't have evaluation in place, stop here and set it up first.”Source: docs.databricks.com
2.Precision catches pollution, recall catches gaps
The two failure modes map onto the two classic retrieval metrics:
- Precision asks what percentage of the retrieved items are relevant to the request. Low precision means irrelevant material is getting in. That is over-retrieval. - Recall asks what percentage of the known-relevant items were retrieved. Low recall means needed material is missing. That is under-retrieval.
The cookbook example: two of three retrieved results were relevant, so precision was 0.66 (2/3). Those results covered two of four relevant documents, so recall was 0.5 (2/4). One retrieval can be mediocre on both.
Precision is 2/10 = 0.2 and recall is 2/2 = 1.0. Nothing was missed, but eight irrelevant entries went into the context. This is over-retrieval, and you would reduce it by returning fewer or better-ranked entries, not more.
There is a practical difference between the two metrics. Computing precision does not require knowing all the relevant items, so an LLM judge can score it on live traffic. Computing recall requires ground truth that lists every relevant item. In MLflow 3 the built-in judges follow the same split. RetrievalRelevance checks whether retrieved context is relevant to the request and needs no ground truth. RetrievalSufficiency checks whether the context provides all the information needed and does need expectations.
| Metric / judge | Question it answers | Failure it exposes | Needs ground truth? |
|---|---|---|---|
| chunk_relevance/precision | What % of the retrieved chunks are relevant to the request? | Over-retrieval | No |
| document_recall | What % of the ground truth documents are represented in the retrieved chunks? | Under-retrieval | Yes |
| context_sufficiency | Are the retrieved chunks sufficient to produce the expected response? | Under-retrieval | Yes |
| total_token_count | What's the total count of tokens for LLM generations? | Cost side of over-retrieval | No |
Checkpoint 2 of 6· Match them up
Match each built-in MLflow 3 judge to what it evaluates
Tap a term, then the definition that fits it.
RetrievalRelevance is the pollution check. RetrievalSufficiency is the gap check and needs expectations. RetrievalGroundedness judges the response against the context.
“Does the context provide all necessary information to generate a response that includes the ground truth facts?”Source: docs.databricks.com
Checkpoint 3 of 6· Exam question
A team suspects that a recent change to their memory retrieval configuration is causing more hallucinated answers, but they are not sure whether the cause is too much irrelevant context or too little relevant context. What is the best way to empirically diagnose this using their existing tooling?
Correct answer: A — Run MLflow evaluation with relevance and groundedness scorers over captured traces to compare the old and new retrieval configurations
- A. Correct: MLflow tracing captures what was retrieved and generated, and evaluation with relevance/groundedness scorers (LLM judges) lets the team measure, on real traces, whether the new configuration retrieves more noise (over-retrieval) or misses needed context (under-retrieval) compared to the prior configuration.
- B. Incorrect: manual, unstructured spot-checking is subjective, does not scale, and does not produce comparable metrics between the two configurations.
- C. Incorrect: shipping an unvalidated change to all production traffic and waiting for complaints is risky and reactive; it does not systematically diagnose the root cause before impacting users.
- D. Incorrect: verbose logs without structured traces or scorer-based evaluation provide raw detail but no comparative, quantified measurement of retrieval quality.
- E. Incorrect: rebuilding the index assumes the problem is data corruption rather than diagnosing whether the actual cause is retrieval breadth (over- or under-retrieval), and it discards data without evidence it is needed.
3.Use traces to see what memory actually returned
Metrics tell you that a failure exists. Traces show you where it happened. An MLflow trace records one complete execution of the agent, including every intermediate step (LLM calls, retriever lookups, tool invocations), along with latency and errors. Each of those steps is a span with its inputs and outputs. For a memory tool, the span shows the query the agent sent and the entries that came back.
That is how you tell the failures apart in practice. A span that returned many entries unrelated to the request points to over-retrieval. A span that returned nothing, or returned entries that miss a fact you know is stored, points to under-retrieval. The search tool below returns the literal text No memory found. when nothing matches, and that is easy to spot in a span's outputs:
@function_tool
def search_memory(query: str) -> str:
"""Search long-term memory for relevant facts about the user."""
results = memory_store.search(actor_id=actor_id, query=query, limit=10)
return "\n\n".join(f"{r.memory.path}: {r.memory.content}" for r in results) or "No memory found."Missing history often appears only across turns. A fact from turn two that the agent forgets by turn eight is invisible when you score turns one at a time. Tagging traces with mlflow.trace.session groups the turns of one conversation, so you can evaluate the conversation end-to-end.
Checkpoint 4 of 6· Check yourself
An agent forgets a constraint the user gave early in a long conversation. Scoring individual turns shows nothing wrong. What helps you catch this?
Session grouping exposes failures that span turns, such as lost earlier context, which per-turn scoring misses.
“Session grouping lets you evaluate conversation quality end-to-end, not just turn by turn.”Source: docs.databricks.com
Sources4
4.Match the fix to the diagnosis
Once you know which failure you have, the levers follow from it. In managed memory, the first lever is the limit on each search. Lowering it trims pollution, and raising it closes gaps. Re-measure precision and recall after each change. The other levers are writing better description text on entries so BM25 search finds them, and scoping each search to the correct actor_id.
If your agent also retrieves from AI Search indexes, the retrieval-quality guide offers techniques that improve one side without simply sacrificing the other:
- Metadata filtering dramatically improves precision by eliminating irrelevant results, and it also improves recall within the filtered subset. - Reranking boosts precision by achieving high recall with fewer candidates. You retrieve broadly, then keep only the best results. - Hybrid search improves recall by catching both semantic and keyword matches.
Which side to favour depends on the use case. When missing key context leads to wrong answers, weight recall. When the user needs the exact item at the top, weight precision.
Checkpoint 5 of 6· Fill the gap
Which parameter controls how many memory entries this search can return? It is the setting you lower to reduce over-retrieval and raise to reduce under-retrieval.
results = memory_store.search(actor_id="user-123", query="communication preferences", ? =10)The AgentKit SDK's memory_store.search takes limit. num_results is the parameter name in AI Search's similarity_search, a different API.
Source: docs.databricks.comCheckpoint 6 of 6· Exam question
In the context of an agent memory system, what does the term 'context pollution' refer to?
Correct answer: A — Degraded output quality caused by irrelevant retrieved memories crowding out the relevant ones in context
- A. Correct: context pollution describes the over-retrieval symptom where too much irrelevant or low-value memory content is included, diluting the relevant signal and degrading response quality.
- B. Incorrect: this describes a security/tampering issue, not the quality-dilution effect that context pollution refers to.
- C. Incorrect: this describes an availability failure, not the retrieval-quality issue captured by 'context pollution'.
- D. Incorrect: this describes a data-integrity or write-path issue, unrelated to the concept of irrelevant content diluting retrieved context.
Sources2
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.If the agent's final answers are correct, its memory retrieval does not need separate evaluation.Why is that wrong?
Good responses can rest on faulty retrieval, so response metrics alone hide over- and under-retrieval. Collect retrieval metrics too.
Covered in Measure retrieval separately from the answer
2.You need a fully labelled ground-truth set before you can detect any retrieval problem.Why is that wrong?
Precision, the over-retrieval signal, can be judged without knowing all relevant items. Only recall-style metrics need complete ground truth.
Sources
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://docs.databricks.com/aws/en/agents/tutorials/ai-cookbook/evaluate-assess-performanceOfficial docs
“A RAG application can respond poorly despite retrieving the correct context; it can also provide good responses based on faulty retrievals.”
↩︎ Measure retrieval separately from the answer“two out of the three retrieved results were relevant to the user's query, so the precision was 0.66 (2/3)”
↩︎ Precision catches pollution, recall catches gaps“Computing recall requires your ground-truth to contain all relevant items.”
↩︎ Precision catches pollution, recall catches gaps“It is very important to collect both response and retrieval metrics.”
↩︎ Exam trap 1“Computing precision does not require knowing all relevant items.”
↩︎ Exam trap 2 - 2.
“If you don't have evaluation in place, stop here and set it up first.”
↩︎ Measure retrieval separately from the answer“Dramatically improves precision by eliminating irrelevant results.”
↩︎ Match the fix to the diagnosis“Boosts precision by achieving high recall with fewer candidates.”
↩︎ Match the fix to the diagnosis“Improves recall by catching both semantic and keyword matches.”
↩︎ Match the fix to the diagnosis - 3.
“Is the retrieved context directly relevant to the user's request?”
↩︎ Precision catches pollution, recall catches gaps“Does the context provide all necessary information to generate a response that includes the ground truth facts?”
↩︎ Checkpoint - 4.
“every intermediate step (LLM calls, retriever lookups, tool invocations), latency, and any errors”
↩︎ Use traces to see what memory actually returned“Session grouping lets you evaluate conversation quality end-to-end, not just turn by turn.”
↩︎ Use traces to see what memory actually returned