Zero Labs
Industry News / AI

How Context Goes Wrong in AI Agents

Source · Towards AI By Karthiknadar

From the publisher’s feed, collected in the ZeroLabs newsroom.

An agent’s context usually starts out fairly tidy. There’s a task, some instructions, and a set of tools. Then the agent gets to work. It reads documents, calls tools, receives results, and changes its plan. It writes notes about what it has found. It tries something that fails, explains the failure, and tries again.All of that information can end up in the next model call. Keeping everything feels sensible at first. The agent might need an earlier result, and throwing information away could make it repeat work. A larger context window makes this approach even more tempting. We have the space, so why spend time deciding what to remove?But information has a useful life within a task. Something that helped the agent choose its first step may contribute very little to its twentieth. An early assumption may have been corrected. A detailed tool result may have already been reduced to the one finding that matters.The conversation keeps growing, even as the useful information changes. Context engineering is how we handle that change. It covers what we retrieve, which tools we expose, what we carry forward, and what we revisit when new evidence arrives. Anthropic describes it as an ongoing process of curating the information available to an agent during inference. Effective context engineering for AI agentsFour ways context failsDrew Breunig describes four problems called context poisoning, context distraction, context confusion, and context clash. These names are useful because a bad answer alone tells us very little about what went wrong. The cause might be an old mistake, irrelevant material, or several statements that disagree with one another. How Long Contexts FailContext poisoningContext poisoning starts when an error enters the context and gets reused.The agent might misunderstand a tool result or draw a conclusion before it has enough evidence. That statement then becomes part of the material it reads on the next turn. Later decisions can build on it, spreading the effect of the original mistake.The especially awkward part is what happens when we summarize. In the original conversation, the statement may have looked uncertain. It might have appeared alongside competing possibilities or a note to investigate further. After summarization, those qualifications can disappear. What survives is a short sentence that sounds settled.The application has made the information easier to reuse, including the error. This makes generated notes worth checking. A conclusion should remain connected to the evidence that supports it. When that evidence changes, the active note needs an update as well.We can keep the earlier version in the history for debugging. Future decisions need a clear account of what we currently believe and why. Otherwise, the correction can exist somewhere in the conversation while the outdated conclusion continues to guide the work.Context distractionContext distraction happens when the accumulated history pulls the agent back toward earlier behavior.Long runs contain a lot of attempts. Some worked, some failed, and some stopped mattering after the plan changed. If every attempt remains equally visible, the agent has to keep working out which parts of its own history are still useful.The Gemini 2.5 technical report describes a related behavior in its Pokémon agent. In that setup, very long contexts sometimes led the agent to favor actions from its history and repeat earlier behavior. The report presents this as an observation about that particular agent. Gemini 2.5 technical reportThat observation raises a practical question for any agent that starts looping. How clearly does its context show that the earlier approach failed?A transcript can contain the attempt and its error without clearly recording what changed afterward. The agent sees plenty of activity, but the result of that activity may be hard to recover.Progress notes help when they capture what the agent learned. Which approach has been ruled out? Which part remains uncertain? What information is needed before another attempt is worthwhile?Those details give the next call a better starting point than a long record of actions alone.Context confusionContext confusion comes from information that doesn’t help the current task but still influences the response.Retrieved documents can introduce it, So can old messages and tool definitions. Before answering, the model has to decide which material applies, and similar-looking material can make that choice harder.Tools are a good place to notice this. Connecting another service gives an agent more capabilities, but it also adds descriptions, arguments, and instructions to consider. If several tools appear to do roughly the same thing, choosing between them becomes ambiguous.Research on dynamic tool selection has found benefits from presenting models with a smaller, relevant set of tools in particular function-calling workloads. The results depend on the model and setup, but they give us a reason to test tool selection as part of context preparation. Less is MoreTool responses deserve the same attention. A tool may return a large object because its API supports several use cases. The agent’s next decision may depend on only a few fields. Concise responses and a way to request more detail can reduce how much information the model has to sort through. Writing effective tools for agentsThe remaining information can stay available elsewhere. A later step may need it, but that doesn’t mean every step needs to read it.Context clashContext clash happens when different parts of the input disagree.This is easy to create in a conversation. Requirements often arrive gradually. The model attempts an answer, fills in missing details, and then receives information that changes the task. Its earlier answers remain in the history alongside the new requirements.The paper LLMs Get Lost in Multi-Turn Conversation studies tasks where requirements are revealed across several turns. Its analysis identifies premature assumptions and reliance on earlier responses among the behaviors associated with failure. LLMs Get Lost in Multi-Turn ConversationSimply adding the correction leaves some work unfinished. The model still has to infer which earlier statement it replaces and how much of the previous answer remains valid.Making that relationship explicit helps. A changed requirement should be recorded as a change. A disproved conclusion should carry its correction when it appears in later notes or summaries.Authority takes more care. A user can revise their own request. Conflicting documents may require checking versions, dates, scope, or ownership. Some disagreements will remain unresolved until more information becomes available.That uncertainty belongs in the context too. A summary that quietly picks one interpretation can make the task look clearer than it actually is.Context size and useful contextA context window’s advertised size tells us how much input the model can accept. It gives us much less information about how well the model will use a particular input.Finding a known phrase in a long document differs from combining evidence across documents, resolving contradictions, and deciding what to do next. An agent may need to do all of those things within the same run.Chroma’s Context Rot research explores this by varying input length, distractors, and the relationship between questions and supporting information. Performance changed with the content and structure of the input, even in controlled tasks. Context RotSo the evaluation needs to resemble the actual work.Retrieving the right passage is useful. We also need to know whether the agent interprets it correctly and carries the relevant finding into later decisions. A fact can be present in the input and still fail to influence the answer in the way we expect.Relevance changes as the task progresses, too. Material used during an initial investigation may add little to the final response. The reason an attempt failed may remain valuable long after the full error output has stopped being useful.That gives us a better question to ask before each call. What does the agent need to understand at this point in the work?Choosing what enters the next callContext preparation becomes easier to reason about when we treat it as a deliberate part of the application. The goal and its constraints need to remain clear. Evidence should support the decision being made. Notes should reflect the current understanding of the task. Earlier material can remain available for retrieval when it becomes relevant again.Breunig recommends keeping context in a structured form and assembling the model input before each call. This lets the application handle instructions, documents, and conversation history differently. How to Fix Your ContextIt also makes failures easier to investigate. We can see which documents entered a request, which notes carried forward, and what stayed elsewhere.Without that visibility, several different problems look the same from the outside. The agent might have received incomplete evidence. It might have received the right evidence alongside an outdated conclusion. Or the selection process might have removed a qualification that changed the meaning of a passage.Those failures need different fixes. There is a tradeoff here. Too little context leaves the model with gaps. More context can introduce irrelevant or conflicting material. The right balance depends on the task, and the way to find it is to compare actual outcomes.Keeping scratchpads usefulScratchpads are appealing because they’re simple. Give the agent somewhere to write down useful findings and progress, then let later calls consult those notes.This can help the agent continue after older details have left the active context. Anthropic describes structured note-taking as a way to preserve information outside the context window and bring it back when needed. Effective context engineering for AI agentsBut writing a note creates something that future decisions may trust. The wording matters.An assumption should remain recognizable as an assumption. A checked fact should retain a reference to its evidence. An open question should stay open until something actually resolves it.Scratchpads also need maintenance. Some entries become obsolete as the agent learns more. Others need correction or a clearer explanation. If the scratchpad only grows, it eventually inherits the same problems as the conversation it was meant to help manage.Useful notes describe the current position of the work. They preserve what has been established, what changed, and what still needs attention. They also give the agent a way back to the supporting material. When a later decision depends on a detail, the agent should be able to inspect the evidence behind the note.Compressing a long conversationSummarization looks like an easy win. We can reduce repeated messages and large tool outputs while preserving enough information to continue.The difficulty is deciding what “enough” means. Anthropic notes that aggressive compaction can remove details whose importance becomes clear only later in the task. A summary may preserve the overall direction while losing a condition needed for a later decision. Effective context engineering for AI agentsSome information needs precise preservation. Identifiers, current constraints, unresolved issues, and references to evidence can lose their value when loosely paraphrased. Other information can be reduced to a brief progress note.Corrections are particularly easy to mishandle. If a conclusion was disproved during the conversation, the summary needs to preserve that change. Otherwise, compaction can bring an old mistake back into the active context.The reasons behind decisions matter as well. If the summary records only the chosen approach, a later call may have trouble judging whether new evidence should change it.A useful way to evaluate compaction is to continue the same task from the compressed state. Does the agent still have what it needs? Does it preserve the correction? Can it recover the details behind a decision? The shorter input earns its value when the work can continue reliably.Retrieving and offloading informationKeeping information available doesn’t require including all of it in every request. Documents and tool results can stay in external storage, with relevant material retrieved as the task develops. Breunig discusses retrieval and offloading as ways to control what remains in active context. How to Fix Your ContextFor this to work, the route back to the original information has to be dependable. Selected passages and summaries can carry references to their sources. Later calls can then recover an exact value, inspect a qualification, or check whether an earlier summary left something out.Retrieval itself needs evaluation. If it misses the evidence required for the answer, the rest of the prompt is working with incomplete information.When tracing a failure, follow the evidence through the process. Was it present in the available sources? Did retrieval find it? Did context selection include it? Did the model interpret it correctly?This separates search problems from problems in how the retrieved material is used. It also avoids spending time improving a stage that already did its job.Isolating independent workSome work can be divided into independent subtasks, each with its own context. That keeps the detailed exploration of one subtask from accumulating in every other subtask. A coordinating agent can receive the findings it needs while the search histories remain available separately.Breunig calls this context quarantine and discusses its use in parallel research. Work that depends on extensive shared context is harder to divide this way. How to Fix Your ContextThe handoff is where this approach needs care. A short conclusion may be enough to report progress. Making a decision can require the evidence, assumptions, and unresolved questions behind that conclusion. If those disappear during the handoff, the coordinator has less ability to assess the result.Workers can also disagree because they used different source versions or interpreted the task differently. Keeping those differences visible gives the coordinator something to investigate before combining the findings.Separate contexts reduce how much information each worker processes. The returned result still needs enough detail to support whatever happens next.Testing context changesContext management involves deciding what to leave out. Every one of those decisions can remove something useful. Retrieval can miss a passage. A summary can omit a condition. A scratchpad can preserve an error. A worker can return a conclusion without enough evidence to check it.That makes repeatable tasks important. We need a way to tell whether a change improved the work or merely made the requests smaller. For context selection, check whether the agent still finds and uses the necessary evidence. For compaction, continue from the compressed state and inspect what breaks. For scratchpads, introduce a correction and follow whether later calls use it.Long tasks are especially valuable because some dependencies become visible only after many steps. Information that looks unnecessary early in a run may matter much later.Cost and latency belong in the evaluation alongside correctness. Smaller requests can reduce cost, while extra retrieval or additional model calls may add overhead. Measuring the cost of successful completion captures more of this tradeoff.Individual failures deserve attention even when the overall result improves. A new selection rule may help most tasks while breaking the ones that depend on a precise detail or a late correction. Keeping those tasks visible makes the choice easier to assess.Inspecting context when an agent failsWhen an agent ignores a correction or repeats a failed action, look at the exact request sent to the model.Which instructions survived? Which notes carried forward? Which source versions supplied the evidence? Is the current goal still clear, and do the earlier conclusions still apply?Keep that request alongside the tool results and the outcome. Together, they give us a record we can reproduce and inspect. Then change one part of the context preparation and rerun the task. Compare where the decisions diverge. We should be able to point to the information that changed and explain how it helped the agent continue.ConclusionAs an agent learns more about a task, the context we give it should change too. Useful findings need to survive, old assumptions need to be corrected, and the evidence behind important decisions should stay available.A good place to start is the exact input sent to the model. Follow how it changes across a run. You may find that a correction disappeared during summarization, an outdated note kept coming back, or a tool returned far more information than the next step needed.Those are concrete problems we can investigate and test.If you found this useful, follow along for more on AI agents, memory, retrieval, and evals.How Context Goes Wrong in AI Agents was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.