CertSafari
    Databricks Certified Context Engineer Associate· Lessons

    Domain 1 · Lesson 3/45

    Diagnosing context poisoning, distraction, confusion and clash in agent traces

    Diagnose context failure modes: context poisoning, context distraction, context confusion, and context clash, given an agent trace.

    18 min read
    2.29% of exam
    9 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    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?

    Sources12

    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?

    Sources32

    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?

    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?

    Sources345

    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?

    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?

    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?

    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?

    Sources785

    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.

    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?

    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.

    Trace signature and recurrence-preventing fix for each context failure mode
    Failure modeWhat the trace showsFix that stops it recurring
    PoisoningOne unsupported value appears in a model output, then is reused across later spansQuarantine: remove the fact from history, summaries and memory; close the gap that let it in
    DistractionThe same action repeats with near-identical arguments; input tokens grow while progress stallsPrune: clear superseded raw tool results, keep their outcomes
    ConfusionA tool call or retrieved chunk that is valid in itself but irrelevant to the question drives the answerTrim the tool loadout and scope retrieval so irrelevant material never loads
    ClashTwo contradictory statements sit in the failing span's input; the output follows the stale oneRemove 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?

    Sources3

    Sources

    (9)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 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. 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. 3.
      “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. 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. 5.
      “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. 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. 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

    Also cited

    Ready to test yourself?

    Practise Databricks Certified Context Engineer Associate in quiz mode.

    Spotted a mistake, or was something unclear? Tell us.