Compounding Context Windows Across Agent Steps
Errors in early agent steps multiply through context, not just accumulate.

In production multi-step agents, the dominant failure mode is context quality degradation, not running out of tokens, and if you mistake one for the other, you end up chasing fixes that don't address the real problem. The instinct, when an agent starts behaving badly over a long session, is to reach for a bigger context window. Providers have obliged, so context limits now reach far past what most tasks need, but a larger window doesn't fix the quality of what's inside it. It just gives bad context more room to spread. Atlan's 2026 guide to context window management states it directly: bigger windows scale bad context rather than curing it, and the resulting degradation has earned its own name among practitioners, "context rot. Context quality is a reliability constraint: it governs whether the agent does what it's supposed to do. So it needs a different diagnostic and a different fix. Teams that treat a quality failure as a size failure end up watching token counts, raising limits, and finding the same silent misbehavior playing out at greater scale, a dynamic that production monitoring for AI agents is specifically built to catch, since the failure stays invisible to error tracking even as the window keeps growing.
How errors in earlier steps worsen the steps that follow
Every step in a multi-step pipeline inherits more than the outputs of the steps before it. It inherits their errors too, and those errors don't just sit there as dead weight. They push the model toward making more errors, and that is worse than simple error accumulation. But multiplication of per-step error rates is only the first layer of the problem. A separate paper, from Fouad Bousetouane (arXiv:2607.14275, July 2026), backs this up from another angle: holding the model constant and varying only the context around it produces consistent, predictable shifts in behavior. The context is the active variable, not the model. That finding should reframe how teams think about failure location. When a multi-step agent breaks down at step eight, you usually won't find the cause sitting at step eight. It's sitting in the context that step eight was handed by everything before it.
Self-conditioning: how a model's own prior errors become instructions to err again
Self-conditioning happens when an agent's own earlier mistakes turn into authoritative material in its context window, shaping everything it reasons about afterward, and so the error rate on later steps climbs well above the base rate no matter how capable the underlying model is. The mechanism is simple to describe and hard to catch. The model reads its own prior output sitting in the context window. It has no built-in way to tell its own mistakes apart from correct reasoning, so it treats whatever pattern it already established as settled fact. The MPI-INF and TU Kaiserslautern paper measured this directly: the presence of prior errors in the context window raises the rate of new errors, and the degradation isn't linear. It looks like established context the model is obligated to respect. One of Bousetouane's seven context-quality criteria, instruction consistency, gives you a measurable handle on this. Inconsistent or contradictory instructions, including prior erroneous outputs that quietly contradict the agent's original instructions, predict drift in later behavior. This gives teams a way to track self-conditioning as it happens. Self-conditioning does not change the surface of the agent's reply, which still reads as confident and perfectly coherent. The error lives in the premise the agent is reasoning from, not in how it phrases the answer; response-level monitoring misses it for that reason.
Context-contaminated retries: why rerunning a failed step usually makes things worse
Retrying a failed step without clearing the context first leaves the failed attempt sitting in the window as evidence the model has to account for, and that evidence makes each following attempt more likely to fail than an independent attempt would be. Most harnesses ship with standard retry logic by default, and it assumes attempts are independent of each other. Zhanfu Yang's paper, "Why Retrying Fails: Context Contamination in LLM Agent Pipelines" (arXiv:2605.08563, submitted May 2026), gives the phenomenon formal treatment through what it calls the context-contaminated restart model. The paper derives a cascade ratio showing that a failed attempt makes each subsequent step more than seven times more likely to fail than the base error rate alone would predict. That number is striking: if attempts aren't independent, then any retry logic built on independence will systematically overestimate how reliable the system actually is, which is a different failure than self-conditioning, even though the two look related. Self-conditioning compounds errors the model produced on its own during normal operation. Context-contaminated retries compound errors the harness has already flagged as failures, and then left sitting in the window anyway. In multi-agent systems the problem gets worse before it gets better: Agent A's failed attempt can live on in its own context while Agent B receives A's output downstream, so the contamination has already propagated before anyone even triggers a retry.

Constraint loss under context compaction: what gets silently dropped when the window shrinks
Context compaction, the standard way long-running agent sessions manage a shrinking window, systematically drops the explicit constraints a user set earlier in the session, and the agent keeps operating as though no guardrails were ever set, because the compaction step dropped them before they could carry forward. Researchers at Penn State, in "Lost in Compaction: Evaluating Side-Constraint Loss under Context Compaction" (Wang et al., arXiv:2608.11242), name and measure this directly. They define Session Constraints as user-issued instructions meant to govern behavior for an entire session, things like "confirm with me before any action," and find that current compactors retain only a small fraction of them on average. Their evaluation suite, called COMPINT, tests this across three distinct long-context scenarios: multi-turn chat, agentic trajectory, and long-horizon research. The paper finds that most compactors retain constraints worse than if you ran the task without any compaction at all, so the compaction step removes a safety property the uncompacted session had preserved. The reason traces back to what compactors are built to optimize for. What gets lost specifically is the reasoning that justified a decision, which leaves the resulting action looking like an open question rather than a settled one, so the agent later reverses or optimizes away a choice that was deliberate. The consequences, when this goes wrong, are the hardest part of this entire piece to stomach: an agent that had been confirming before every action starts executing directly without asking. Wang and colleagues offer a fix: an SC-aware extractor that runs alongside the compactor as a plug-in module, achieving retention above 90% across all three COMPINT scenarios without needing to modify the compactor or the underlying model.
How these mechanisms interact in a real pipeline
None of these three mechanisms, self-conditioning, contaminated retries, and constraint loss under compaction, operates in isolation inside a real production pipeline, and it's the interaction between them that produces the long, silent failures no single-mechanism explanation predicts. Consider a realistic sequence. A self-conditioned error occurs at step three, degrading the context that step four inherits. As the session runs longer, compaction eventually fires, and it drops the exact constraint that would have caught the problem by the time the pipeline reaches step eight. Bousetouane's paper frames the underlying dynamic precisely: agents don't fail in isolation, because their behavior is shaped by the entire accumulated context, instructions, tools, memory, retrieved knowledge, guardrails, and untrusted inputs together, and when that context turns weak, agents drift, hallucinate, misuse tools, and ignore constraints without ever throwing a visible error. In multi-agent architectures, this gets worse through propagation. In a peer-to-peer setup, Agent B receives Agent A's output with no intermediate verification step. A's self-conditioned error becomes part of B's context. METR's empirical research on long-horizon task completion captures the consequence at the level of outcomes: success rates fall off sharply as task duration grows, because context contamination accumulates across the length of the task rather than models getting less capable over longer horizons. The 50% reliability horizon, the point at which an agent succeeds on half its attempts, keeps extending over time, but the gap between how reliably agents complete short tasks versus long ones remains wide. Traditional monitoring misses all of this because it isn't designed to track it. Traditional monitoring watches for crashes, elevated latency, and error codes, and all three of those indicators stay green while self-conditioning, contaminated retries, and constraint loss quietly erode what the agent actually decides to do.
Why current observability misses context-driven failures specifically
The monitoring most teams already have running, response logs, error rate dashboards, latency tracking, can't surface context-driven failures because those failures don't generate an error signal. A context-driven failure looks, by every metric traditional monitoring tracks, identical to a correct execution: HTTP 200, normal latency, no exception thrown. A payment-agent case makes the gap concrete. Bousetouane's paper makes the structural case for why this keeps happening: context engineering remains largely unmeasured across the industry, with teams inspecting prompts by hand, debugging only after something has already shipped, or relying on behavioral evaluations that can tell you an agent failed without ever isolating whether the failure started in the context itself. That's a real operational blind spot, and it's specific. The seven context-quality criteria the paper defines, role clarity, guardrail coverage, instruction consistency, tool schema quality, grounding sufficiency, injection hardening, and token efficiency, each predict a specific kind of behavioral failure, and measuring them before and during execution gives teams a signal ahead of the failure. Effective observability requires causal tracing across an entire session: not a log of what happened at each step in isolation, but a trace of how the context feeding each step was shaped by everything that came before it, so that a failure appearing at step eight can be traced back to where it actually originated, at step three. This is the specific gap Lemma is built to close: it audits every trace against an agent's own original instructions, groups the deviations it finds into actionable issues, and surfaces them without requiring a team to predefine every failure mode in advance, because what gets audited is the context behind the output, not just the output itself.
Engineering fixes by layer to limit compounding
Each of the three compounding mechanisms has a corresponding fix at the harness or context-engineering layer, and the three applied together change the reliability profile of a pipeline in ways that are measurable. Self-conditioning calls for context hygiene enforced at every step boundary: don't pass a prior step's raw output forward unchecked, validate intermediate outputs before they enter the next step's context, and treat anything a previous step produced with the same scrutiny given to untrusted user input, since the model itself has no way to tell its own errors apart from ground truth once they're sitting in its window. Contaminated retries call for a specific harness-level redesign: retry logic should clear or quarantine the failed attempt's context before running again, because a clean-snapshot retry behaves like a genuinely independent attempt while one that inherits the failed context compounds the original problem, and a factorial study on coding-benchmark data confirms that the independence assumption most retry logic is built on simply doesn't hold, which puts the fix squarely at the harness layer. Constraint loss under compaction calls for an SC-aware extraction step running alongside any compaction operation, because Wang and colleagues showed that a plug-and-play extractor of this kind achieves retention above 90% across multi-turn chat, agentic trajectory, and long-horizon research scenarios without touching the compactor or the model underneath it. The harness level carries the same bias. A factorial study across a coding benchmark found that harness-induced variance was substantially larger than model-induced variance, with model rankings reversing in six of nine harness pairings tested. So the same model can behave very differently depending on how its harness assembles and manages context, and most of that variance traces back to context handling, not to the model's own capability. The operational habit that ties all of this together is running evaluations continuously against production traces, not just at release: a trace that passed cleanly at step one but degraded by step eight tells you something specific about context compounding, not about model capability, and that signal appears only in trace-level data. An aggregate pass or fail rate never captures it.


