What you will be able to do
- Read an MLflow trace to find where bad context first entered and where the model reused it
- Tell context poisoning, distraction, confusion and clash apart from the trace evidence of each
- Pick the fix that stops each failure mode from recurring, including tool result clearing for stale outputs
- Explain why raising reasoning effort does not repair a contaminated context, and when a low reasoning_effort is the right setting
Key concept
Context failure mode — A context failure mode is a wrong answer or action caused by what is in the context window, not by a weak model. The four modes are poisoning, distraction, confusion and clash. You can only tell them apart by reading the steps between input and output, because each one leaves a different pattern in the trace.
1.Reading a trace for context failures
A context failure is an agent mistake whose cause is something in the context window: a wrong fact, too much history, irrelevant tools, or two statements that disagree. Models do not flag these mistakes. A poisoned answer and a correct one read with the same confidence, so the final response alone tells you almost nothing. The evidence is in the steps that led to it.
An MLflow trace records those steps. Internally it is a tree of spans. The root span is the whole agent request, and each child span is one LLM call, retriever lookup or tool invocation, with its own inputs, outputs, timing and errors. Diagnosing a context failure means walking that tree and asking, at each LLM span, what the model was shown and what it did with it.
Two questions sort almost every case. Where did the bad content first appear? That could be a model output, a tool result, a retrieved chunk or the system prompt. What happened to it afterwards? It might be reused as fact, repeated as an action, acted on although it was irrelevant, or contradicted by something later. Each of the four failure modes gives a different answer to the second question.
Genie Code and Issue Detection in MLflow can speed up the search, but they point to a span or execution step, not to the line of code that caused it. You still decide which failure mode that span shows, and that decision determines the fix.
Checkpoint 1 of 10· Check yourself
An agent confidently tells a user the wrong refund window. The trace is available in MLflow. What is the best first step toward finding which context failure caused this?
A wrong answer and a right answer read with the same confidence, and the root span's input and output alone cannot show which intermediate step went wrong. You find the cause by walking the child spans. Genie Code can point you to a span or execution step, but it does not point to a line of source code.
“With only an input and final response, you cannot tell which intermediate decision caused a failure.”Source: docs.databricks.com
2.Context poisoning: one wrong fact, reused as truth
Context poisoning happens when a hallucinated or wrong fact enters the context and later steps treat it as established. The typical way in is a gap. A retriever returns nothing, or a tool errors, and the model fills the gap with something plausible: a refund policy, a table name, an account ID. That output now sits in the message history. When it is next read, it looks just like a fact a tool returned.
The trace signature has two parts. First there is a single point of entry, usually an LLM span whose output contains a value that no tool or retriever output supports. Then the same value turns up again downstream: as a tool argument, in a plan, in a summary, in the final answer. That repeated reuse is what makes it poisoning rather than a one-off hallucination. The agent has built on the error, and every later step that depends on it inherits it.
The fix that stops it recurring is quarantine. Remove the poisoned fact from the context, and from any summary, scratchpad or memory store it was copied into. Then close the gap that let it in, for example by making the agent say it has no information when retrieval returns nothing. Appending "correction: the window is 14 days" leaves both values in the context, which turns poisoning into clash.
Checkpoint 2 of 10· Check yourself
In a trace, retrieval returned nothing and the model invented a 30-day refund window. Later spans reused it, and a memory pipeline copied it into the agent's memory store. Which fix stops the wrong value from coming back?
Quarantine means removing the poisoned fact from every place it was copied to and closing the gap that let it in. Appending a correction leaves both values in context, which is clash. Deleting the session does not touch the memory store, so the fact would come back in later conversations.
“deleting a session, or an entire session store, does not delete memory retained in a memory store.”Source: docs.databricks.com
3.Context distraction: history crowds out fresh reasoning
Context distraction happens when the accumulated history is so large that the model copies patterns from it instead of reasoning about the current step. The clearest trace signature is repetition. The same search, the same file read or the same failed edit appears again and again, often with nearly identical arguments, and nothing in between justifies the retry. Another sign is that the model's latest plan echoes an earlier plan when the task has since moved on.
Distraction builds up because the agent rereads its whole transcript every turn. Each raw tool output stays in the history and gets reprocessed on every later call, whether or not it still matters. A file listing thousands of lines long, fetched ten turns ago for a step that is finished, keeps taking up attention long after its usefulness ended. In a trace you can see the input token count of each LLM span rising while the work per span stays the same.
The fix is pruning, and the lightest form is tool result clearing. Once a tool's raw output has been superseded, the harness drops the bulky payload from the history and keeps a short record that the call happened and what came of it. The agent still knows it listed the directory and what it decided as a result. It just no longer rereads the thousands of lines. Heavier pruning, such as summarizing older turns, is a compaction decision covered in its own lessons.
Several plausible fixes do not work. Re-running the tool adds a second copy of the bulk. A system-prompt rule like "ignore old tool outputs" adds tokens and still makes the model read what it is told to ignore. Raising reasoning effort leaves the stale content in the window. Only removing the content reduces the attention it takes.
Checkpoint 3 of 10· Check yourself
MLflow Issue Detection flags a research agent that ran the same web search five times. In the trace, the repeats have nearly identical arguments, nothing between them justifies a retry, and the input token count of each LLM span keeps rising. Which failure mode does this trace show?
The signs of distraction are the same action repeated with no new reason and input tokens rising while each span does the same amount of work. The model is copying patterns from a long history. Poisoning would need an unsupported value that later spans reuse. Confusion is a call to a tool that should never have been loaded, not a repeated action. Clash needs two sources that disagree.
“A research agent repeats the same web search five times, slowing the response and increasing tool and token costs.”Source: docs.databricks.com
Checkpoint 4 of 10· Exam question
In a long-running coding agent session, a large raw file listing (thousands of lines) returned by a tool call several turns ago is still sitting in the message history, even though the agent has since moved on to unrelated edits. What is the most effective way to reduce the attention this stale content consumes?
Correct answer: A — Apply tool result clearing to discard the superseded raw output while keeping the turn's outcome in history
- A. Correct. Once a tool result deep in history is no longer needed verbatim, clearing that raw output is one of the lightest-touch and safest forms of compaction, freeing attention budget while preserving the decision or outcome that mattered.
- B. Incorrect. A higher reasoning effort spends more compute per response but does not remove the stale tokens still occupying context, so the underlying dilution remains.
- C. Incorrect. Re-running the tool call adds another large, mostly redundant listing to history, increasing token consumption rather than reducing it.
- D. Incorrect. An added instruction competes for attention just like any other token and does not actually remove the large stale listing from context, so the disproportionate consumption remains.
4.Reasoning effort is not a context repair
Reasoning effort controls how much the model thinks before it answers. It does not change what is in the context. A poisoned fact, a stale file listing or a contradiction stays where it is however hard the model reasons, and extended reasoning over a contaminated context can justify the wrong answer more convincingly. When a trace shows one of the four failure modes, fix the context. Turning up reasoning is a distractor.
The control itself is worth knowing precisely, because exam options swap parameter names. For reasoning-only models such as the GPT-5 family served through Databricks Foundation Model APIs, the request parameter is reasoning_effort, with values "low", "medium" (the default) and "high". Claude models on Databricks use a different shape: a thinking object together with an effort setting under output_config. Higher effort costs more: more reasoning tokens per request, more latency, and more cost at volume.
Choosing the level depends on the task, as covered in reasoning-mode selection against token budget. Effort pays off when a task is ambiguous and needs several steps. A router that sorts tickets into five known categories is the opposite case: the task is narrow and unambiguous, so extra reasoning tokens raise cost on every request without making classification more accurate. At high volume that cost adds up, so standard or reduced reasoning is the right choice. The reason is the nature of the task, not any platform rule about handoffs or multi-agent systems.
Checkpoint 5 of 10· Check yourself
After tracing a coding agent, you diagnose context distraction: old multi-thousand-line file listings sit in the history and the agent keeps repeating the same file reads. A teammate proposes switching the model's reasoning_effort from "medium" to "high". What should you expect?
Reasoning effort changes how much the model thinks, not what is in the window. The stale listings stay in context and are reread on every turn, while extra reasoning adds tokens and latency. Removing the content with tool result clearing is the fix for distraction.
“The model reads everything in its context, including the task, relevant memory and previous results, then decides what action to take next.”Source: www.databricks.com
Checkpoint 6 of 10· Exam question
A context engineer must choose a reasoning-effort setting for an agent built on a reasoning-only model family (such as the GPT-5 family) available through Databricks Foundation Model APIs. Which parameter and value range are used to control this?
Correct answer: A — reasoning_effort, with values such as "low", "medium", or "high"
- A. Correct. Reasoning-only models exposed through Databricks Foundation Model APIs, such as the GPT-5 family, use a
reasoning_effortparameter with values like low, medium, or high to control how much internal deliberation the model performs. - B. Incorrect.
budget_tokensis the parameter used for hybrid reasoning models like Claude and Gemini 2.5 to size a thinking budget, and it must stay below (not exceed)max_tokens; it is not how reasoning-only model effort is configured. - C. Incorrect.
thinkingwith{"type": "enabled"}is the hybrid-reasoning toggle used by Claude-style models, not the effort control for reasoning-only model families. - D. Incorrect.
attention_budgetwith narrow/balanced/wide values is not a documented Databricks Foundation Model APIs parameter; it does not correspond to any real reasoning-mode control.
Checkpoint 7 of 10· Exam question
A team is deciding on a reasoning mode for a routing agent that only classifies incoming tickets into one of five known categories before handing off to a specialist agent. Token cost per request is a primary concern because volume is extremely high. What is the strongest justification for using reduced or standard reasoning here?
Correct answer: A — The classification task is narrow and low-ambiguity. Extra reasoning tokens would raise per-request cost at high volume without materially improving classification accuracy.
- A. Correct. The classification task is narrow and low-ambiguity, so extra reasoning tokens would increase cost without meaningfully improving accuracy. At high volume, this cost multiplies, making reduced or standard reasoning the optimal token-budget tradeoff.
- B. Incorrect. The choice of reasoning mode is dictated by the complexity and cost requirements of the task itself, not by whether the agent hands off to another agent. Handoffs do not mandate reduced reasoning; a more complex handoff task could warrant extended thinking.
- C. Incorrect. Extended thinking is a per-call configuration and is not universally forbidden in multi-agent systems, including Databricks orchestration. While cost- and latency-sensitive classification tasks may use reduced or standard modes, the platform does not categorically prohibit extended reasoning.
- D. Incorrect. Reasoning mode selection determines the number of tokens spent on deliberation, not the size of the context window. Standard reasoning does not inherently provide a larger context window than extended thinking, so it does not better retain full ticket histories.
Sources6
5.Context confusion: irrelevant material steers the model
Context confusion happens when material that should not be in the context, such as unneeded tools, off-topic documents or loosely related retrieved chunks, gets used by the model and pushes it toward a wrong action or answer. The model is not making something up, as in poisoning, and it is not repeating itself, as in distraction. It is doing a reasonable thing with content it should never have been given.
In a trace, confusion shows up as a tool call or citation that answers a different question from the one asked. A finance agent loaded with forty tools calls search_marketing_assets for a revenue question because the description mentions "quarterly results". A RAG agent answers a question about the 2025 return policy from a retrieved chunk about the 2022 warranty program. The span that went wrong has a valid input and a valid output. The mistake was that the tool or chunk was available to it at all.
The fix that prevents recurrence is trimming the loadout: register only the tools the task needs, tighten tool descriptions so they do not overlap, and scope retrieval so off-topic chunks never reach the context. A larger toolset gives the model more chances to pick the wrong one, which is why the fix is to remove options rather than add instructions on how to choose among them.
Checkpoint 8 of 10· Check yourself
A billing support agent has 35 registered tools. A user asks about a 2025 invoice, and the agent calls list_marketing_campaigns once, because that tool's description mentions "billing cycles". The span's input and output are both valid, and no action repeats anywhere in the trace. Which change stops this from happening again?
There is one wrong call to a tool that should not have been available, and nothing repeats. That is context confusion, not distraction. The fix is to trim the loadout and make the tool descriptions clear. Pruning history, adding instructions on how to choose, or raising reasoning effort all leave the misleading tool in context.
“Clear tool and parameter descriptions ensure your agent understands your tools and uses them appropriately.”Source: docs.databricks.com
6.Context clash: contradictions inside the window
Context clash happens when two parts of the context contradict each other and the model follows the wrong one. The most common case is an agent's own history. An early attempt used the wrong join key or the wrong date range, a later turn corrected it, and both versions are still in the window. The model has no built-in rule that later text wins, so sometimes it goes with the earlier version.
The trace signature is two conflicting statements, both present in the input of the span that failed. Unlike poisoning, either one can have a legitimate source. A user may have changed their mind, a table may have been updated between tool calls, or a stored memory may disagree with today's lookup. The diagnostic step is to find both statements in the span input and confirm the model's output matches the stale one.
Memory systems make clash last longer. In Databricks, sessions and memories are independent stores. A correction made inside one conversation does not remove the old fact that a memory pipeline already distilled into long-term memory. The next conversation retrieves the stale memory alongside fresh tool output, and the clash comes back.
Clash. The turn-1 draft and the turn-3 correction both remain in context, and the model followed the stale draft. Remove or rewrite the superseded draft so only the fiscal-year instruction is left. Adding a third reminder would leave the contradiction in place.
The fix is to remove the stale side of the contradiction, not to outweigh it. Drop the superseded attempt from the history, overwrite or delete the outdated memory entry, and make sure summaries record only the corrected state.
Checkpoint 9 of 10· Check yourself
On Monday a user told the agent that their team had moved from the sales_v1 table to sales_v2, and the agent used sales_v2 for the rest of that conversation. A memory pipeline had already distilled 'team uses sales_v1' into the memory store. On Thursday, in a new conversation, the failing span's input contains both the retrieved memory 'uses sales_v1' and a fresh tool lookup that lists sales_v2, and the query runs against sales_v1. What is the diagnosis and the fix?
Two statements that disagree, both with a legitimate source, sit in the failing span's input, and the output follows the stale one. That is clash. Sessions and memories are independent stores, so the correction made on Monday never removed the distilled memory. The fix is to overwrite or delete that memory entry. Deleting the session leaves the memory in place, and adding a reminder only tries to outweigh the contradiction without removing it.
“deleting a session, or an entire session store, does not delete memory retained in a memory store.”Source: docs.databricks.com
Sources4
7.Telling the four apart and making the fix stick
Each failure mode comes from a different source of bad content and needs a different fix. Choosing the wrong fix can make things worse: appending a correction to a poisoned context creates clash, and adding tools to help a confused agent makes the confusion worse. Choosing which part of the system to change, whether harness, prompt or agent structure, is covered in matching an agent failure symptom to a context lever. The table below is about which change stops each mode from coming back.
| Failure mode | What the trace shows | Fix that stops it recurring |
|---|---|---|
| Poisoning | One unsupported value appears in a model output, then is reused across later spans | Quarantine: remove the fact from history, summaries and memory; close the gap that let it in |
| Distraction | The same action repeats with near-identical arguments; input tokens grow while progress stalls | Prune: clear superseded raw tool results, keep their outcomes |
| Confusion | A tool call or retrieved chunk that is valid in itself but irrelevant to the question drives the answer | Trim the tool loadout and scope retrieval so irrelevant material never loads |
| Clash | Two contradictory statements sit in the failing span's input; the output follows the stale one | Remove the stale or conflicting material instead of appending another correction |
Confirm a fix with production traffic, not one rerun. A trimmed toolset can pass the trace that exposed the confusion and still fail on queries you have not seen. In MLflow, an issue monitor scores new traces against the detected issue so you can check whether the issue rate falls after deployment and whether the failure returns.
Checkpoint 10 of 10· Check yourself
Your team diagnosed context confusion and trimmed the agent from 40 registered tools to 8. You then rerun the trace that exposed the problem, and the agent now calls the right tool. What should you do next to confirm the fix holds?
Passing one rerun says nothing about queries you have not seen. An issue monitor scores new traces against the detected issue, so you can check whether the issue rate falls after deployment and whether the failure returns.
“An issue monitor shows whether the issue rate decreases after deployment and whether the problem returns.”Source: docs.databricks.com
Sources3
Sources
(9)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Internally, a trace is a tree of spans.”
↩︎ Reading a trace for context failures“Each span represents one operation: it records what went in, what came out, how long it took, and any metadata.”
↩︎ Reading a trace for context failures - 2.
“identifying the span, input pattern, or execution step in the traces where a failure occurred”
↩︎ Reading a trace for context failures“Find traces where the retriever returned no results but the agent still tried to answer”
↩︎ Context poisoning: one wrong fact, reused as truth“identifying the span, input pattern, or execution step in the traces where a failure occurred”
↩︎ Prediction - 3.https://docs.databricks.com/aws/en/mlflow3/genai/tracing/observe-with-traces/analyze-tracesOfficial docs
“A customer-support agent invents a 30-day refund policy when answering a return request.”
↩︎ Context poisoning: one wrong fact, reused as truth“A research agent repeats the same web search five times, slowing the response and increasing tool and token costs.”
↩︎ Context distraction: history crowds out fresh reasoning“An issue monitor shows whether the issue rate decreases after deployment and whether the problem returns.”
↩︎ Telling the four apart and making the fix stick - 4.
“The agent reads it at the start of a turn and appends to it as the interaction runs.”
↩︎ Context distraction: history crowds out fresh reasoning“deleting a session, or an entire session store, does not delete memory retained in a memory store”
↩︎ Context clash: contradictions inside the window“deleting a session, or an entire session store, does not delete memory retained in a memory store”
↩︎ Exam trap 1“deleting a session, or an entire session store, does not delete memory retained in a memory store.”
↩︎ Checkpoint“deleting a session, or an entire session store, does not delete memory retained in a memory store.”
↩︎ Checkpoint - 5.https://www.databricks.com/blog/ai-harnessSecondary source
“Without a strategy to trim or summarize older context, performance often breaks down on long-running tasks.”
↩︎ Context distraction: history crowds out fresh reasoning“Giving the model too many tools at once increases confusion and slows decision-making before any work begins.”
↩︎ Context confusion: irrelevant material steers the model“When the harness pulls in the wrong information from memory or search systems, the model may confidently generate incorrect answers.”
↩︎ Context confusion: irrelevant material steers the model“The model reads everything in its context, including the task, relevant memory and previous results, then decides what action to take next.”
↩︎ Checkpoint - 6.
“The reasoning_effort parameter accepts "low", "medium" (default), or "high" values.”
↩︎ Reasoning effort is not a context repair“Higher reasoning effort may result in more thoughtful and accurate responses, but may increase latency and token usage.”
↩︎ Reasoning effort is not a context repair“Higher reasoning effort may result in more thoughtful and accurate responses, but may increase latency and token usage.”
↩︎ Exam trap 2 - 7.
“Clear tool and parameter descriptions ensure your agent understands your tools and uses them appropriately.”
↩︎ Context confusion: irrelevant material steers the model“Clear tool and parameter descriptions ensure your agent understands your tools and uses them appropriately.”
↩︎ Exam trap 3 - 8.
“Must guard against repeated or incorrect tool calls”
↩︎ Context confusion: irrelevant material steers the model
Also cited
“With only an input and final response, you cannot tell which intermediate decision caused a failure.”
↩︎ Key concept“With only an input and final response, you cannot tell which intermediate decision caused a failure.”
↩︎ Checkpoint