Why AI agent instructions don't actually last through an entire session

Users of agentic tools frequently encounter the same issue: at the start of a session, the agent follows rules precisely, but after fifty steps, it suddenly begins ignoring them, repeating the same mistakes, or providing generic answers instead of specific findings. It looks as if the model is "tired" or "broken." In reality, this is not a bug, but a direct consequence of how attention in transformers works and how agentic systems manage the context window.
An agent that is afraid of running out
A recent example from Anthropic illustrates this mechanic quite clearly. The team working on the company's agentic infrastructure discovered behavior in the Claude Sonnet 4.5 model they dubbed "context anxiety": the model would prematurely wrap up tasks when it felt the context limit approaching. The model would start cutting corners and closing tasks early, even when there was still plenty of room left in the window.
The solution at the time was simple—to build a forced context reset into the harness (the wrapper around the model). But when the same harness was applied to the newer Opus 4.5 model, it turned out that the behavior had disappeared on its own. The resets became dead weight. This is a good illustration of a general rule: wrappers around a model fix a specific weakness of a specific version, not the context window itself.
The model reads context unevenly
Even without "anxiety," any model has a more fundamental limitation: attention is distributed unevenly across the context. The classic effect is called "lost in the middle"—models are much more reliable at extracting and using information from the beginning and end of a long context than information buried in the middle. Furthermore, this is not a smooth degradation: information located in the middle third of a long context is significantly more likely to be ignored, distorted, or misinterpreted—even if it is formally within the context window and the model has not exhausted the tokens for processing it.
For open models with long context, another layer of complexity is added: some architectures do not physically scan the entire history at every step. Some modern models use a "sliding window + global layers" scheme: the local layer looks only at the last N tokens, while the global one looks at the entire window. This means that a rule set at the beginning of a long session formally remains in the context, but the model might not actually "look" at it—the attention mechanism simply works differently.
How agents sabotage their own instructions
A separate problem is the rule files that users write themselves for agents (analogous to system prompts for a specific project). The longer such a file is, the worse the model follows even important points. Best practice documentation states it directly: bloated instruction files cause the model to ignore actual instructions. Developers who have tested this in practice provide specific degradation figures: files under 200 lines show a compliance rate above 92%, while after 400 lines, it is only 71%.
It becomes a vicious cycle: the user sees the agent violating something, adds another rule—the file grows—and compliance with the remaining rules drops even further.
What to do about it in practice
- Keep your rule file short. If deleting a line won't lead to a specific error, delete it. General project descriptions ("this is a Next.js application on TypeScript") do not work as instructions and simply consume attention.
- Duplicate critical rules at the end, not just at the beginning. Since the model sees the beginning and end of the context best, the most important constraint should be reminded immediately before the agent is supposed to apply it, rather than counting on it to "carry over" from the system prompt.
- Break long tasks into stages with explicit context resets. Instead of one multi-hour session, use several shorter ones with a clean start and a brief summary of the previous stage's results.
- Monitor the window fill percentage, not just the token limit. Degradation begins long before the technical ceiling—often halfway through the available volume.
- Re-verify behavior when switching models. Workarounds tailored for one version may prove useless or even harmful for the next.
What this changes
Understanding that agent instructions are not a "set it and forget it" configuration, but a resource that is consumed and weakens over the course of a session, changes the very approach to working with AI tools. Instead of considering strange agent behavior a breakdown, it should be viewed as a signal: it's time to clear the context, duplicate a rule, or break the task into parts.
If you want to try agentic scenarios and different models in practice, check out the tools and models for chat, code, and generation already available in GEMERA AI—you can compare how different models maintain context on long tasks without having to delve into all the architectural nuances beforehand.