NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

The Compaction Cliff in Long-Running AI Agent Memory

Saber Zerhoudi, Jelena Mitrovic, Michael GranitzerarXiv 2026 · DOI

TL;DR

Long-running AI agents rapidly lose critical safety rules during context window compaction, a phenomenon the authors term the "Compaction Cliff." To fix this, the paper introduces Knowledge Triage, a framework that classifies memory items by type and routes them through specialized retention operators to guarantee that safety constraints are never dropped or altered.

What Problem Does This Paper Address?

As AI agents engage in long-running sessions, their context windows inevitably fill up. To stay within token budgets, agent runtimes must periodically compress or "compact" their memory.

The core issue is that standard compaction methods are type-blind: they treat critical safety rules (e.g., "Never modify production schemas without a migration file") and low-priority episodic logs (e.g., "Refactored auth module yesterday") identically. When an LLM summarizes the context, safety rules are often paraphrased into oblivion or dropped entirely. The authors reveal that Claude Code’s /compact prompt on Sonnet 4.6 preserves only 53% of safety rules after one round of compaction, and a dismal 10% after five rounds.

Methods

The authors introduce Knowledge Triage, a framework that categorizes an agent's knowledge base into five distinct operational types: Constraint, Procedural, Belief, Preference, and Episodic.

Figure 1: Knowledge Triage. Classifier 𝜏assigns each working-set item one of five types; three deterministic operators apply per-type policies: TypeCompact compresses without dropping safety rules, TypeDecompose splits large topics and duplicates rules that span them, TypeRetrieve returns applicable rules first. A verifier checks that every constraint survived; if any are missing, the output is flagged unsafe, otherwise it becomes the next working set.

The architecture uses a specialized classifier called SafetyMargin to score items based on counterfactual safety (i.e., "Would removing this item make an action unsafe?"). Items are then managed via three deterministic operators:

  1. TypeCompact: Routes items into different fidelity lanes. Constraints and procedures are pinned verbatim (zero distortion), while beliefs and episodic logs are aggressively compressed or replaced with placeholders. A post-compaction verifier ensures all constraints survived.
  2. TypeDecompose: When a topic is too large for the budget, it partitions the topic and duplicates scoped constraints across all sub-partitions to ensure they remain local to the data they govern.
  3. TypeRetrieve: Instead of relying purely on semantic relevance for RAG, this operator pins all in-scope constraints to the top of the retrieved context before allocating the remaining budget to relevant facts.

Datasets

The paper evaluates its approach using a mix of existing benchmarks and newly introduced datasets:

  • AgentArtifactCorpus (AAC): A new dataset curated by the authors containing 396,934 agent knowledge artifacts scraped from 54,628 public GitHub repositories.
  • SafetyMed: A new 200-scenario medical compliance benchmark developed for this paper, which pairs MedQA scenarios with FDA boxed warnings and contraindications.
  • Standard Benchmarks: LongMemEval (for cross-domain validation), BEIR scifact (for retrieval), and $\tau$-bench (retail and airline splits for downstream behavioral testing).

Key Insights and Ideas

  • The "Phrasing Trap": Traditional rule-checkers rely on imperative verbs ("Never do X"). However, the authors found that roughly half of real-world safety text is declarative ("Patient is allergic to penicillin"). Type-blind compactors routinely drop these because they look like standard background facts.
  • Fidelity is Non-Uniform: Different types of knowledge tolerate different kinds of loss. A debugging trace can be summarized into a single sentence without harm, but a safety rule loses its enforceability the moment its exact wording is altered.
  • Relevance $\neq$ Priority: Standard RAG systems rank items strictly by query relevance. However, a safety constraint might have low semantic similarity to a specific user query while still being critically applicable to the broader operational scope.

Key Results

The Knowledge Triage framework consistently neutralized the compaction cliff across all experiments:

  • Constraint Preservation: Under 50% compression, TypeCompact achieved 100% constraint recall and stabilized at 96% over five sequential rounds, whereas standard LLM compactors plummeted toward 10%.
Figure 3: Constraint recall after 𝑁sequential compaction rounds at 50% per round, 20 AAC configurations.
  • Zero Locality Violations: TypeDecompose achieved 0% locality violations when partitioning knowledge bases, compared to a 93% violation rate seen in uniform token- or paragraph-based chunking baselines.
  • Perfect Retrieval Recall: TypeRetrieve hit 100% recall@50 for in-scope constraints, outperforming the best single-shot LLM retriever (73%) while consuming zero LLM tokens for the pinning step.
  • Downstream Safety: On the SafetyMed benchmark, TypeCompact achieved a 95.5% safety preservation rate, significantly outperforming production Sonnet 4.6 (81.0%).

Limitations and Future Work

  • Dependency on Classifier Recall: The framework's safety guarantee is entirely bottlenecked by the classifier. If SafetyMargin misses a constraint during the initial indexing phase, that rule will be routed to a soft lane and potentially compressed away.
  • Replication Token Overhead: In TypeDecompose, copying global constraints across multiple sub-partitions can introduce significant token overhead (up to 219% in worst-case scenarios with dense global rules).
  • Static vs. Dynamic Constraints: The current implementation assumes constraint status is static at indexing time. It does not yet account for constraints that emerge dynamically from session context or live user interactions.

Summary updated

BibTeX
@misc{zerhoudi2026compaction,
  author = {Saber Zerhoudi and Jelena Mitrovic and Michael Granitzer},
  title = {{The Compaction Cliff in Long-Running AI Agent Memory}},
  year = {2026},
  eprint = {2608.22752},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2608.22752},
}
Figure