What you will be able to do
- Explain why an agent's reasoning and retrieval quality can decline as one interaction grows longer
- Group traces into sessions so quality can be judged across a whole conversation, not one turn at a time
- Pick the retrieval, response and token metrics that show the point where a growing context starts to hurt quality
Key concept
Context rot — When one interaction keeps adding history to the model's context, the model reasons less well. The agent was fine in the early turns and gets worse as the transcript grows, so you find the problem by looking for the point where quality drops, not by checking any single answer.
1.Why a long interaction degrades
An agent that answers its first questions well can still fail in turn forty, even though nobody changed the model, the prompt or the tools. The difference is how much context it now carries. On Databricks, the state of one interaction is its session: most often the conversation history, meaning the ordered transcript of messages, tool calls and results. The agent reads this at the start of each turn and appends to it as it works. The documentation describes a session as something that grows within the interaction and is complete on its own.
Databricks' AI harness article calls this failure context rot. As history accumulates, reasoning quality falls, and without a strategy to trim or summarize older context, performance often breaks down on long-running tasks. The problem sits in the harness, the system around the model that manages memory and runs tools, so the fix belongs there as well. A related harness failure makes things worse: when the harness pulls the wrong information from memory or search, the model may confidently generate incorrect answers. A long, cluttered context hurts both of the qualities this objective names, reasoning quality and retrieval accuracy. (Two terms from the exam vocabulary, "lost in the middle" and "attention budget", do not appear in the sources for this lesson, so this lesson makes no specific claims about them.)
Checkpoint 1 of 4· Check yourself
Which statement best describes context rot as Databricks frames it?
Context rot is about the growth of conversation history inside one interaction. Stale indexes and brittle tool wiring are different failures.
“Without a strategy to trim or summarize older context, performance often breaks down on long-running tasks.”Source: www.databricks.com
2.Measuring quality across the whole session
You cannot see degradation over time if every turn is graded on its own. Traditional single-turn evaluation scores each agent response independently. MLflow's conversation evaluation instead scores whole sessions, and the documentation lists the qualities that only show up at that level. The one most closely tied to context length is knowledge retention: does the agent remember information from earlier in the conversation? If retention fails only after many turns, the size of the context is the likely cause.
Session-level evaluation depends on instrumentation. A trace records one complete execution of the agent, including every LLM call, retriever lookup and tool call. A session is a tag that groups the traces of one multi-turn conversation. Set it on every trace, and MLflow groups the traces by that tag when it evaluates them.
Be clear about what a session-level judge gives you. Multi-turn assessments are stored on the first trace of each session and are marked as conversation-level, linked to the session ID. They describe the conversation as a whole, so they tell you that a conversation went badly, not which turn it went bad at. To locate the turn, you need metrics recorded on each trace, which the next section covers, and you read them in session order.
Checkpoint 2 of 4· Fill the gap
Which MLflow call attaches the session tag to the current trace?
import mlflow
@mlflow.trace
def my_chatbot(question, session_id):
mlflow. ? (
tags={"mlflow.trace.session": session_id}
)
# ... your chatbot logicupdate_current_trace sets the mlflow.trace.session tag inside the traced function. search_traces and search_sessions read traces back afterwards.
Source: docs.databricks.com# Get complete sessions (each session is a list of traces)
sessions = mlflow.search_sessions(
locations=["<your-experiment-id>"],
max_results=50,
)3.Metrics that show where quality drops
Once traces are grouped by session, you need metrics that separate the two kinds of damage the objective names. Databricks' recommended RAG metrics divide into retrieval, response, cost and latency. Retrieval metrics show whether the right chunks are still coming back as the conversation grows. Response metrics show whether the model still reasons correctly over what it was given. The token-count metrics show how large the context has become. Comparing these by position in the session tells you when the context grew and whether quality fell at the same point.
| Metric | Dimension | What it answers | Needs ground truth? |
|---|---|---|---|
| chunk_relevance/precision | Retrieval | What % of the retrieved chunks are relevant to the request? | No |
| context_sufficiency | Retrieval | Are the retrieved chunks sufficient to produce the expected response? | Yes |
| groundedness | Response | Is the response a hallucination or grounded in context? | No |
| total_input_token_count | Cost | How many input tokens did the LLM generations consume? | No |
To pinpoint the degradation point, line the per-trace metrics up in session order. For each session, take the traces in chronological order and read chunk_relevance/precision, groundedness and total_input_token_count for each one. Then plot the quality metrics against the turn number, or against the input-token count. Early turns give you a baseline. The degradation point is where a quality metric turns downward while total_input_token_count keeps climbing. For example, if precision holds steady for the first stretch of turns and then falls as input tokens keep rising, the context size at that bend is the point to act on. If precision stays steady but groundedness falls, the retrieved chunks are still fine, so look at how the model handles the context it was given. The sources give no fixed threshold, so judge the drop against your own early-turn baseline, and check that it repeats across several sessions before you treat it as context rot. Then use the session-level knowledge retention result to confirm that the conversation as a whole suffered.
Some products report a limit directly, but be careful about what it measures. In a Genie Agent, text instructions and metadata are converted into tokens, and a warning appears when the agent approaches its token limit. That count reflects the agent's configuration rather than how long the conversation has run, so it shows how context filtering can cost quality but is not a measure of a growing interaction. Genie uses context filtering to keep the tokens it considers most relevant. Responses should still be generated at the warning, but quality may be reduced if important context is filtered out. Only when the limit is exceeded can you no longer send or receive messages. So the warning means quality is at risk. It does not mean the agent has stopped working.
Checkpoint 3 of 4· Check yourself
A Genie Agent shows a token-limit warning. What is the correct reading?
The warning marks the point where filtering may drop useful context. Messages are blocked only after the limit is exceeded.
“While responses should still be generated when a warning appears, quality may be reduced if important context is filtered out.”Source: docs.databricks.com
Checkpoint 4 of 4· Match them up
Match each signal to the question it answers when you are diagnosing a degrading long conversation
Tap a term, then the definition that fits it.
Retrieval metrics, response metrics, token counts and multi-turn judges each show a different part of the failure. Used together, they show both when the context grew and what broke.
“Precision is the proportion of retrieved documents that are actually relevant to the user's request.”Source: docs.databricks.com
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.Running the usual per-response evaluation on every turn is enough to catch an agent that forgets earlier information in long conversations.Why is that wrong?
Single-turn evaluation scores each response on its own. Knowledge retention can only be judged when traces are grouped into a session and the full conversation history is evaluated.
Covered in Measuring quality across the whole session
2.A token-limit warning in a Genie Agent means the agent has stopped answering.Why is that wrong?
At the warning, responses are still generated but may be lower quality because of context filtering. Messages are blocked only once the limit is exceeded.
Covered in Metrics that show where quality drops
Sources
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“A session grows within the interaction and is complete on its own.”
↩︎ Why a long interaction degrades - 2.https://www.databricks.com/blog/ai-harnessSecondary source
“As conversation history grows, the model’s reasoning quality degrades.”
↩︎ Why a long interaction degrades“When the harness pulls in the wrong information from memory or search systems, the model may confidently generate incorrect answers.”
↩︎ Why a long interaction degrades“As conversation history grows, the model’s reasoning quality degrades.”
↩︎ Key concept“Most operational agent failures come from the harness, not the model itself.”
↩︎ Prediction“Without a strategy to trim or summarize older context, performance often breaks down on long-running tasks.”
↩︎ Checkpoint - 3.
“Knowledge retention: Does the agent remember information from earlier in the conversation?”
↩︎ Measuring quality across the whole session“Multi-turn assessments are stored on the first trace (chronologically) in each session.”
↩︎ Measuring quality across the whole session“Traditional single-turn evaluation assesses each agent response independently.”
↩︎ Exam trap 1 - 4.
“Session grouping lets you evaluate conversation quality end-to-end, not just turn by turn.”
↩︎ Measuring quality across the whole session - 5.https://docs.databricks.com/aws/en/agents/tutorials/ai-cookbook/evaluate-assess-performanceOfficial docs
“Retrieval metrics help you understand if your retriever is delivering relevant results.”
↩︎ Metrics that show where quality drops“Precision is the proportion of retrieved documents that are actually relevant to the user's request.”
↩︎ Checkpoint - 6.
“Genie uses context filtering to prioritize the tokens it considers most relevant to a question.”
↩︎ Metrics that show where quality drops“Text instructions and metadata in a Genie Agent are converted into tokens.”
↩︎ Metrics that show where quality drops“When the token limit is exceeded, you can no longer send or receive messages in the Genie Agent.”
↩︎ Exam trap 2“While responses should still be generated when a warning appears, quality may be reduced if important context is filtered out.”
↩︎ Checkpoint