LAM: Efficient Lossy Agent Memory Framework With A Retrieval-Score Error Bound

Baixi Sun, Le Chen, Anjir Ahmed Chowdhury, Xiaolong Ma, Chih-Hsuan Yang, Mingze Xia, Syed Zawad, Sheng Di, Rajkumar Kettimuthu, Huihuo Zheng, Rajeev Thakur, Venkatram Vishwanath, Feng YanarXiv 2026

TL;DR

LAM (Lossy Agent Memory) is a framework that prunes AI agent history by deduplicating records before they enter the context window, providing a mathematical bound on retrieval-score perturbation. By performing compaction on the host CPU and preserving the KV cache prefix, LAM achieves up to a 91x end-to-end speedup compared to traditional "delete-in-place" methods while retaining 99.984% of critical task evidence.

What Problem Does This Paper Address?

As AI agents interact with tools and environments, their memory (the conversation history) grows monotonically. This leads to two major issues:

  1. Inference Costs: Longer histories increase the time and compute required for every subsequent turn.
  2. Context Limits: Eventually, the history exceeds the model's context window, forcing the system to discard information.

Existing solutions like LLM-based summarization are "heavy"—they add significant latency and inference costs themselves. Furthermore, most memory management techniques lack theoretical guarantees; you don't know exactly how much "signal" you're losing when you compress or delete. Finally, deleting records already inside a context window typically invalidates the KV (Key-Value) cache for all subsequent tokens, forcing an expensive "re-prefill" step that can dwarf the actual inference time.

Methods

LAM introduces a three-layered, prefix-preserving compaction pipeline:

  • Layer 0 (Byte-exact hashing): Uses line-level hashing to catch exact duplicates (e.g., an agent reading the same file twice).
  • Layer 1 (Near-duplicate merging): This is the core innovation. LAM embeds arriving records and uses a query-independent substitution bound. If a new record is within a distance $\delta$ of a retained record, it is replaced by a tiny "stub." This ensures that the maximum retrieval score for any future query decreases by at most $\delta$.
  • Layer 2 (Byte compression): Compresses the embeddings of retained records using cuSZp to save storage space without affecting the text context.

Crucially, LAM changes the scheduling of compaction. Instead of waiting for the context to fill up and then deleting items (which breaks the KV cache), LAM tests each record on arrival.

System design and execution timeline

As shown in Figure 2, by admitting or stubbing records before they reach the accelerator, the prefilled prefix remains intact, avoiding the massive cost of re-processing the entire history.

Datasets

The authors evaluated LAM across several diverse agentic datasets:

  • SWE-smith: A corpus of 6,026 trajectories (136.3M tokens) where agents attempt to solve software engineering tasks. This serves as the primary benchmark for "evidence retention."
  • LHTB (Long-Horizon Terminal-Bench): 1,459 trajectories from 28 different models, providing a test for how the rule transfers across different agent scaffolds.
  • LoCoMo: A conversational-memory dataset used as a control to show that near-duplicates are specifically a characteristic of tool-using agents rather than standard chat.

Key Insights and Ideas

  • The "Schedule" is the Secret Sauce: The paper argues that how you delete is just as important as what you delete. Moving the "decision gate" to the arrival of a record (before prefill) is what enables the massive 70x-90x speedups.
  • Score vs. Rank: The authors provide a tight mathematical bound on retrieval scores (Theorem 1). They explicitly note that they do not guarantee unchanged rankings, as ranking is highly sensitive to even tiny score perturbations.
  • Line-Level Granularity: Through ablation, they found that hashing at the line level is far more effective than chunk-level or record-level hashing. This is because agents often reread files where only a few lines have changed; line-level hashing allows the system to deduplicate the unchanged portions.
  • CPU/GPU Overlap: Compaction (embedding and distance checking) runs on the host CPU concurrently with the GPU's inference. This "off-the-critical-path" approach means memory management costs almost zero in terms of serving throughput.

Key Results

  • Efficiency: LAM predicts a 71.4x to 91.6x end-to-end speedup by removing records before prefill rather than deleting them from a prefilled context.
  • Memory Reduction: On SWE-smith, LAM removes 22.47% of observation tokens at its default settings.
  • High Fidelity: Despite the lossy nature, LAM retains 99.984% of "gold-patch" evidence (critical lines needed to solve a task). In a test of 598 trajectories, it lost only a single critical line.
  • Performance Modeling: The authors developed a cost model (Table 1) that accurately partitions turn latency into context-scaling parts (KV reads) and non-scaling parts (weight streaming), allowing for precise speedup predictions.
Table 1: Inputs to equation 2, split into offline terms measured once per device by kernel mi- crobenchmark and online terms read from the run itself.

Limitations and Future Work

  • Semantic Limitations: LAM relies on embedding distance and exact hashes. It does not currently handle paraphrases or complex semantic redundancies that a full LLM summarizer might catch.
  • Task Success: While the paper measures "evidence retention" (a proxy for task success), it does not measure live task completion rates, which could be affected by the removal of subtle reasoning cues.
  • Redundancy Dependency: The benefits of LAM are proportional to the amount of redundancy in the agent's environment. In low-redundancy scenarios (like simple chat), the gains would be significantly lower.
  • Future Directions: The authors suggest that future work could explore "decision-preserving" bounds that might offer stronger guarantees on agent behavior rather than just retrieval scores.

Summary updated

BibTeX
@misc{sun2026lam,
  author = {Baixi Sun and Le Chen and Anjir Ahmed Chowdhury and Xiaolong Ma and Chih-Hsuan Yang and Mingze Xia and Syed Zawad and Sheng Di and Rajkumar Kettimuthu and Huihuo Zheng and Rajeev Thakur and Venkatram Vishwanath and Feng Yan},
  title = {{LAM: Efficient Lossy Agent Memory Framework With A Retrieval-Score Error Bound}},
  year = {2026},
  eprint = {2609.32256},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.32256},
}
Figure