Beyond RAG for Agent Memory: Retrieval by Decoupling and Aggregation
Zhanghao Hu, Qinglin Zhu, Hanqi Yan, Yulan He, Lin Gui
TL;DR
This work identifies a mismatch between standard RAG retrieval and agent memory, where memories are a bounded, coherent dialogue stream rather than heterogeneous external text. It introduces xMemory, a hierarchical memory framework that disentangles memories into semantic components (Original messages -> Episode -> Semantic -> Theme) and uses a sparsity–semantics objective to guide structure, enabling top-down retrieval that favors diverse, query-relevant themes before expanding to finer details. The method combines a two-stage retrieval (Stage I: representative selection on a kNN graph; Stage II: uncertainty-driven evidence inclusion) with retroactive restructuring to adapt the memory organization as new information arrives. Across LoCoMo and PerLTQA benchmarks and multiple LLM backbones, xMemory yields consistent improvements in answer quality and token efficiency, while delivering more evidence-dense retrieval than RAG plus pruning baselines, demonstrating the practical value of structure-aware memory management for long-horizon agent reasoning.
Abstract
Agent memory systems often adopt the standard Retrieval-Augmented Generation (RAG) pipeline, yet its underlying assumptions differ in this setting. RAG targets large, heterogeneous corpora where retrieved passages are diverse, whereas agent memory is a bounded, coherent dialogue stream with highly correlated spans that are often duplicates. Under this shift, fixed top-$k$ similarity retrieval tends to return redundant context, and post-hoc pruning can delete temporally linked prerequisites needed for correct reasoning. We argue retrieval should move beyond similarity matching and instead operate over latent components, following decoupling to aggregation: disentangle memories into semantic components, organise them into a hierarchy, and use this structure to drive retrieval. We propose xMemory, which builds a hierarchy of intact units and maintains a searchable yet faithful high-level node organisation via a sparsity--semantics objective that guides memory split and merge. At inference, xMemory retrieves top-down, selecting a compact, diverse set of themes and semantics for multi-fact queries, and expanding to episodes and raw messages only when it reduces the reader's uncertainty. Experiments on LoCoMo and PerLTQA across the three latest LLMs show consistent gains in answer quality and token efficiency.
