LazyMem: Retrieve Broadly, Construct Selectively for Efficient Long-Term Agent Memory

Jing Yu, Yibo Zhao, Jiaming Zhang, Xiang Li
7/17/2026
8 citations
cs.AI

Official code: allacnobug/LazyMem (5 stars, Python, last commit 2026-10-19).

Abstract

Long-term memory enables LLM agents to leverage past interactions, but dialogue histories quickly exceed the context window, forcing agents to retrieve relevant subsets at query time. Because useful evidence is sparse and scattered across verbose conversations, retrieval faces a fundamental tension: broadening recall improves coverage but floods downstream reasoning with noise, while compressing memories at write time eases retrieval but irreversibly discards details that future queries may need.

Show full abstract

We introduce LazyMem, which resolves this tension by deferring all memory construction to query time. Given a retrieved candidate pool, a lightweight model processes it in overlapping parallel windows, selectively retaining and compressing only query-relevant content. The model is trained with supervised fine-tuning followed by reinforcement learning, using a reward that jointly encourages the identification of relevant messages and the generation of compressions that are faithful to the source and useful for answering the query. On LongMemEval, LazyMem-4B achieves an LLM-judge accuracy of 0.85, outperforming the strongest non-oracle baseline while using only 213 answer-context memory tokens, 21.0 times fewer than the baseline. It further generalizes to LoCoMo without target-domain training and reduces mean latency relative to the prior query-time baseline. Code is available at https://github.com/allacnobug/LazyMem.

View on arXivView PDF

Code Implementations(1)

allacnobug/LazyMemOfficial100%

LazyMem: From Write-Time Compression to Query-Time Memory Construction

50Python, ShellMay 22, 20261 months ago

Similar Papers

Cite this paper

@article{yu2026lazymem,
  title  = {LazyMem: Retrieve Broadly, Construct Selectively for Efficient Long-Term Agent Memory},
  author = {Jing Yu and Yibo Zhao and Jiaming Zhang and Xiang Li},
  year   = {2026},
  eprint = {2607.22690},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2607.22690v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2607.22690.svg)](https://codeofpaper.com/paper/2607.22690)

Discussion