What it is
Every interaction with a large language model happens inside a “context window” — a fixed budget of text the model can hold in view at once, measured in tokens. As an AI agent works through a long task — debugging code across dozens of steps, conducting a multi-hour research session, executing a customer-service conversation — the transcript of everything said and done keeps growing. Eventually it approaches the window’s limit, and the system faces a choice: stop, or compress.
Context compaction is the compression option. Rather than truncating the session or refusing to continue, the system uses a model — often the same one running the session — to summarize the accumulated history into a shorter, structured representation, then resumes the task from that summary instead of the full transcript. Anthropic describes the mechanism plainly in its own developer documentation: the system monitors token usage, and when it crosses a set threshold, it generates a summary, inserts it as a distinct block, and on the next request quietly drops everything that came before that block, continuing as if the summary were the whole history (Anthropic, Compaction docs).
The industry has converged on a handful of variations. Sliding windows simply drop older turns outright. Tool-output offloading writes bulky intermediate results to external storage and leaves only a short pointer in the live context, so nothing is destroyed. Lossy summarization — the version most relevant here — rewrites the discarded history as prose, which is efficient but has no guarantee that any particular fact, instruction, or constraint survives the rewrite (Redis, “Context Compaction for AI Agents”).
Why it matters for AI governance and narratives
Compaction sits at an unglamorous but consequential layer of agent architecture: it decides what an AI system remembers about the rules it is supposed to follow. A June 2026 arXiv paper, “Governance Decay: How Context Compaction Silently Erases Safety Constraints in Long-Horizon LLM Agents,” tested this directly. Researchers gave agents standing safety policies, then ran them through long sessions that triggered compaction. When the policy text survived the summarization step, violation rates stayed at zero. When it was dropped from the summary — which happened without any adversarial pressure, simply as an ordinary byproduct of compression — violation rates rose to 30% across tested models, and as high as 59% for some. The researchers also demonstrated a targeted “Compaction-Eviction Attack”: adversarial content engineered to bias the summarizing model into omitting legitimate safety constraints, which defeated every model tested (Chen, arXiv:2606.22528).
This is a mechanism, not an anecdote, and it matters for how the AI safety narrative is argued. Much of the public debate over AI risk trades in scenarios — models deceiving evaluators, models resisting shutdown — that are hard to verify and easy to dismiss as speculative. A finding that ordinary infrastructure, operating exactly as designed, can erase safety instructions as a side effect of memory management is a different kind of claim: falsifiable, reproducible, and rooted in a component nearly every long-running agent now depends on. It shifts part of the safety conversation from model alignment — what the model wants — to system architecture — what the model is even shown.
Key facts and dates
Anthropic’s server-side compaction feature (beta header compact-2026-01-12) is documented as applying to Claude Opus 5, Sonnet 5, and related model variants, triggering by default once a conversation reaches roughly 150,000 input tokens, with a configurable minimum of 50,000. Claude Code, Anthropic’s coding agent product, runs a related client-side auto-compaction that triggers near 98% of the effective context window. Both are framed by Anthropic as necessary trade-offs: without compaction, long sessions either fail outright or suffer degraded reasoning quality well before the hard token limit is reached (Anthropic, Compaction docs; Claude Code docs, Context Window).
The “Governance Decay” paper, submitted to arXiv in June 2026 by researcher Shiyang Chen, is the primary academic source establishing the safety-erosion effect described above; it also proposes a mitigation it calls “Constraint Pinning,” a training-free method for isolating governance rules from the lossy summarization pathway, which the paper reports restored violation rates to zero in its own benchmark. A related paper, “AI Guardrail Survival under Single-Cycle Agentic Self-Summarization,” examines the same failure mode with an emphasis on distinguishing rules that are merely present in a summary from rules the agent still actually obeys.
Where to learn more
- Anthropic — Compaction (official platform documentation)
- Shiyang Chen — “Governance Decay: How Context Compaction Silently Erases Safety Constraints in Long-Horizon LLM Agents,” arXiv:2606.22528
- Claude Code Docs — Explore the Context Window
- Redis — “Context Compaction for AI Agents: A Complete Guide”