Simon Willison’s Weblog: How to Fix Your Context

Source URL: https://simonwillison.net/2025/Jun/29/how-to-fix-your-context/#atom-everything
Source: Simon Willison’s Weblog
Title: How to Fix Your Context

Feedly Summary: How to Fix Your Context
Drew Breunig has been publishing some very detailed notes on context engineering recently. In How Long Contexts Fail he described four common patterns for context rot, which he summarizes like so:

Context Poisoning: When a hallucination or other error makes it into the context, where it is repeatedly referenced.
Context Distraction: When a context grows so long that the model over-focuses on the context, neglecting what it learned during training.
Context Confusion: When superfluous information in the context is used by the model to generate a low-quality response.
Context Clash: When you accrue new information and tools in your context that conflicts with other information in the prompt.

In this follow-up he introduces neat ideas (and more new terminology) for addressing those problems.
Tool Loadout describes selecting a subset of tools to enable for a prompt, based on research that shows anything beyond 20 can confuse some models.
Context Quarantine is “the act of isolating contexts in their own dedicated threads" – I’ve called rhis sub-agents in the past, it’s the pattern used by Claude Code and explored in depth in Anthropic’s multi-agent research paper.
Context Pruning is "removing irrelevant or otherwise unneeded information from the context", and Context Summarization is the act of boiling down an accrued context into a condensed summary. These techniques become particularly important as conversations get longer and run closer to the model’s token limits.
Context Offloading is "the act of storing information outside the LLM’s context". I’ve seen several systems implement their own "memory" tool for saving and then revisiting notes as they work, but an even more interesting example recently is how various coding agents create and update plan.md files as they work through larger problems.
Drew’s conclusion:

The key insight across all the above tactics is that context is not free. Every token in the context influences the model’s behavior, for better or worse. The massive context windows of modern LLMs are a powerful capability, but they’re not an excuse to be sloppy with information management.

Tags: ai, prompt-engineering, generative-ai, llms, drew-breunig, llm-tool-use, ai-agents

AI Summary and Description: Yes

Summary: The text discusses various challenges related to context management in large language models (LLMs) and introduces practical strategies to enhance model performance by addressing issues like context rot. This is particularly relevant for AI security professionals focused on optimizing LLM functionality while maintaining effective information governance.

Detailed Description:

The text explores critical aspects of context management in the realm of generative AI, particularly within the functioning of large language models (LLMs). It outlines significant challenges that arise during prompt engineering and provides novel solutions to these problems. Here are the key points:

– **Context Rot Patterns**: Drew Breunig describes four types of context rot:
– **Context Poisoning**: Involves errors or hallucinations that become entrenched in the context.
– **Context Distraction**: Occurs when overly long contexts lead the model to neglect learned training information.
– **Context Confusion**: Arises when unnecessary information muddles the context, leading to low-quality output.
– **Context Clash**: Happens when new conflicting information is introduced into the ongoing context.

– **Strategies for Improvement**:
– **Tool Loadout**: Emphasizes the importance of limiting the number of tools (preferably below 20) to prevent confusion in the model.
– **Context Quarantine**: Refers to isolating contexts within dedicated threads to prevent blending unrelated information. This is akin to employing sub-agents for different tasks.
– **Context Pruning**: Involves removing irrelevant data from context to streamline model focus.
– **Context Summarization**: The process of condensing information into a summary to fit within token limits effectively.
– **Context Offloading**: Storing information outside the LLM’s immediate context to improve information recall and management. Several coding agents utilize this strategy by maintaining updated files as they tackle complex tasks.

– **Key Insight**: The overarching message is that maintaining clarity and efficiency in context management is vital; every token’s presence can significantly shape a model’s output. The capabilities offered by LLMs necessitate careful information management to leverage their full potential effectively.

This discussion is essential for AI security and compliance professionals, as it underscores the need to optimize the management of contextual information in AI systems, potentially impacting their security posture and performance reliability.