Context Engineering

Why Long AI Sessions Drift

Long context windows help agents keep working, but growing session history can dilute attention, bury evidence, preserve stale assumptions, and turn debugging into context management.

TLDR

Long AI session drift is measurable, has a name — contextual senescence — and is caused by two mechanisms: attention dilution and signal-to-noise collapse. RULER benchmarks show 15–64 point accuracy drops between 4K and 128K tokens, confirmed across all 18 models Chroma tested. Context is RAM, not storage — constraints buried in the middle of a long window are recalled less reliably than those at the start or end. The practitioner threshold, widely circulated in the Claude Code community: keep context under 30% fill before compressing or resetting. Bigger windows raise the ceiling but do not flatten the degradation slope — 1M-token models show the same curve at higher counts. The architectural fix is not more capacity: it is separating concerns. Working memory stays in-context, historical facts move to an external task brief or memory store, and deliberate session resets happen after major pivots. Context does too many jobs at once — log, scratchpad, state machine, and retrieval index — and none of them well past the 30% threshold.

The pattern is familiar in daily engineering work. A fresh session receives a feature design and produces a strong first implementation. Then real work starts: bugs appear, requirements change, logs arrive, docs are researched, partial fixes are attempted, and the session accumulates a long trail of obsolete hypotheses. After enough turns, the same agent may start mixing old assumptions with new instructions, proposing patchy fixes, forgetting why a decision was made, or confidently citing context that is no longer true.

Bigger context windows reduce hard truncation, but they do not automatically make every token equally useful. Lost in the Middle showed that models often use information best when it appears near the beginning or end of the context and worse when it is buried in the middle. A later Amazon Science paper, Context Length Alone Hurts LLM Performance Despite Perfect Retrieval, found degradation from longer inputs even when relevant evidence was retrievable. In other words, the issue is not only "can the model fit the conversation?" It is "can the model use the right parts at the right time?"

The Drift Loop
Feature design Clean goal, few constraints, high signal-to-noise ratio. Implementation Agent builds from a compact mental model and recent files. Debug turns Logs, failed fixes, hypotheses, docs, and changing requirements accumulate. Context pollution Stale facts compete with newer evidence; the model must infer what still matters. Drift More hallucination, brittle patches, repeated mistakes, and weaker prioritization.
Before / After
Healthy session Current goal is explicit, rejected hypotheses are marked, tests are recent, and edits are tied to file evidence. Drifting session Old logs, stale plans, partial summaries, and failed fixes compete with the actual bug in front of the agent.
The reader should be able to diagnose their own session state without reading the full taxonomy first.

What Is Actually Degrading?

In a session-based agent, context is doing several jobs at once. It is the conversation log, task state, scratchpad, audit trail, memory, retrieval result, and instruction stack. Those are different data structures, but many tools flatten them into one prompt. Once the prompt grows, the agent has to solve the task and also perform relevance ranking over its own history.

Failure What it looks like Likely cause Practical response
Instruction dilution New requirements are followed inconsistently. Important constraints are buried among old turns and low-value text. Keep a live task contract outside chat and restate only current constraints.
Stale hypothesis reuse The agent revives an old theory after it was disproved. The old theory remains in context without a durable invalidation marker. Record decisions, rejected paths, and "do not retry" notes in a compact handoff file.
Patchy solutions Fixes become local, hacky, or inconsistent with architecture. The agent optimizes against recent error messages instead of the original design. Periodically reset with a fresh summary, current code state, and architectural invariants.
False continuity The agent acts as if it remembers details it has actually compressed or misplaced. Summaries and retrieval snippets become substitutes for source evidence. Ask for cited evidence from files, logs, docs, or tests before accepting a fix.

Contextual Senescence: The Named Phenomenon

The 2026 practitioner community coined the term contextual senescence (attributed to @keon.me on X) to describe what was previously described only symptomatically: the progressive degradation of LLM response quality as context fills. RULER benchmarks quantify it precisely — 15 to 64 point accuracy drops between 4K and 128K tokens, confirmed across all 18 models Chroma tested. The effect is universal, not model-specific. It is also non-linear: performance drops faster than context grows.

Two mechanisms drive it. Attention dilution: the model's attention is spread across more tokens, reducing the relative weight of any individual instruction. Signal-to-noise collapse: as debugging attempts, obsolete hypotheses, and abandoned approaches accumulate, the relevant signal (the actual goal and constraints) accounts for an ever-smaller fraction of the window. A constraint mentioned once in the first 2,000 tokens is reliably recalled. The same constraint buried at position 60,000 in a 100K-token context is not.

The Measured Evidence
15–64 point RULER drops Accuracy drops between 4K and 128K tokens across all 18 models tested by Chroma. The effect is universal — not a weakness of any single model family. 30% fill rule Practitioner threshold from the Claude Code community: keep context under 30% fill before compressing or starting a fresh session. Above 30%, the degradation slope becomes practically significant. Context = RAM, not storage Framing from beam.ai that clarified the architecture debate: context has hard performance limits per fill level, just like RAM — a bigger context window raises the ceiling without flattening the curve. KV cache pressure RedKnot (arXiv 2606.06256) shows that KV cache eviction under memory pressure creates additional non-linear degradation. Cache management is a first-class architectural concern in long-session systems.
Practitioners @lami_thefirst, @austnnet, and @calcsam converged independently on the same pattern: when a session drifts, starting fresh with a well-structured task brief outperforms attempting to correct the drifted session. The brief is the invariant; the session is disposable.

Underlying Causes

Why Long Sessions Get Worse
Attention is not uniform Relevant facts can be present but underused because position and distractors matter. Context is lossy state Conversation text is a poor database for current requirements, decisions, and invalidated ideas. Agents create their own noise Failed plans, tool traces, retries, and partial summaries become future input.

This explains why long coding sessions can feel worse even before the model reaches its advertised limit. Recent work on long-context reasoning reports positional failures in reasoning benchmarks, not only retrieval tasks. Positional Failures in Long-Context LLMs argues that benchmark design can hide vulnerabilities that grow with context length. Another paper, Intelligence Degradation in Long-Context LLMs, studies threshold effects where performance drops well before the theoretical maximum context window.

Did The Latest Models Solve It?

The newest commercial models are materially better. OpenAI describes GPT-5 as having a 400K context length and reports stronger long-context retrieval in developer benchmarks. Anthropic's Claude Opus 4.6 announcement describes a 1M token context window in beta, and Claude documentation notes automatic context management during long conversations. Those are real advances.

But the research does not support the conclusion that raw window size solves long-session quality. Larger windows reduce forced truncation; they do not remove distractors, correct stale beliefs, preserve every causal dependency, or guarantee that the model reasons over the right evidence. The operational answer is not just a bigger window. It is better context management.

What Solutions Are Emerging?

The field is moving from "longer prompt" to "managed memory." A 2026 survey, Memory for Autonomous LLM Agents, groups memory approaches into context-resident compression, retrieval stores, reflective self-improvement, hierarchical virtual context, and policy-learned management. Agent-specific work such as ACON and Parallel Context Compaction for Long-Horizon LLM Agent Serving treats compaction as a runtime problem, not a casual summary. Other memory studies show the risk: retrieved memories can bias future behavior, so memory systems need filtering, attribution, and contradiction handling.

Better Long-Session Architecture
Working context Only the active task, current files, current error, and latest decision contract. Durable task state Requirements, accepted decisions, rejected paths, owners, test status, and next steps. Evidence retrieval Pull exact file lines, logs, docs, and test output on demand instead of keeping everything. Session reset Start fresh when the task state is clearer than the conversation history.
The agent should carry forward durable state, not the whole emotional history of debugging.

Context Does Too Many Jobs

The architectural problem is that the context window serves as at least four distinct systems simultaneously: a conversation log (every prior turn), a scratchpad (in-progress reasoning), a state machine (current goals and constraints), and a retrieval index (everything the agent might need to reference). None of these are optimized for the same access pattern. Logs are sequential and grow unbounded. Scratchpad content is ephemeral and mostly irrelevant after each step. State machine entries need to be reliably present throughout the session. Retrieval index entries need to be findable by topic, not position.

The Redis two-tier model is the architectural pattern emerging from production deployments: hot data (current task, active constraints, recent tool results) stays in-context; cold data (historical facts, prior session summaries, reference documents) moves to an external store with semantic retrieval. The context window becomes a working set, not a log. The task brief is the invariant that survives session resets — when a session drifts, the brief is what you carry forward, not the session transcript.

Separating Context Concerns
In-context: working set Current goal, active constraints, accepted decisions, last 3–5 tool results, test status. Compact and current. Never the full history. External: task brief Structured document surviving session resets. Captures why decisions were made, not just what was decided. Updated at each major pivot, not at every turn. External: memory store Historical facts, project context, prior session summaries. Retrieved semantically when needed — not loaded into every session regardless of relevance. No standard observability tooling As of June 2026, there is no standard tooling for monitoring context health — fill level, signal density, attention dilution — in production agent systems. This is the open gap.
Fable 5 takes an explicit note-taking approach internally — the model maintains a compact running summary of key decisions that persists through the session. This architecture externalizes what most models leave implicit in the attention mechanism.

Practical Playbook

  1. Keep a live task brief: current goal, constraints, accepted decisions, rejected approaches, and test status.
  2. Start a new session after major pivots, after repeated failed fixes, or when the model starts reusing disproved assumptions.
  3. Ask the agent to cite local evidence before making risky edits: file path, line, test output, or documentation link.
  4. Separate scratchpad from state. Failed hypotheses should not become permanent memory unless they are marked as rejected.
  5. Use retrieval for evidence and summaries for orientation; do not use summaries as proof.
  6. Prefer small, verified repair loops: reproduce, inspect, patch, test, then update the task brief.
  7. When context gets noisy, compress manually into a clean handoff and restart rather than waiting for automatic compaction.

What To Watch

Direction Why it matters Open risk
Longer native context Fewer hard resets and more room for code, docs, logs, and traces. More room can also mean more distractors and higher cost.
Context compaction Keeps long-running agents bounded without discarding every old turn. Summaries can omit the fact that later becomes decisive.
Structured memory Stores decisions, facts, source links, and contradictions outside raw chat. Bad writes and noisy retrieval can make memory confidently wrong.
Evidence-first agents Forces the model to ground fixes in current files, logs, tests, and docs. Requires tooling discipline and reliable source attribution.

Bottom Line

Long-session drift is not just a user habit problem and not just a model-size problem. It is an information architecture problem. Session history is convenient because it feels like memory, but it is a noisy, positional, lossy, and constantly changing substrate. The durable fix is to treat context as an engineered resource: small working set, explicit task state, source-backed retrieval, controlled compaction, and deliberate session resets.

References