Beyond RAG for Agent Memory: Retrieval by Decoupling and Aggregation
MemoryAgent100+伦敦国王学院腾讯元宝https://zhanghao-xmemory.github.io/Academic-project-page-template
超越面向智能体记忆的 RAG:通过解耦与聚合实现检索
Abstract
Standard Retrieval Augmented Generation (RAG) is poorly matched to agent memory. Unlike large heterogeneous corpora, agent memory forms a bounded and coherent interaction stream in which many spans are highly correlated or near duplicates. As a result, flat top-
标准检索增强生成(RAG)与智能体记忆并不匹配。 不同于大型异构语料库,智能体记忆形成一条有界且连贯的交互流,其中许多片段高度相关或近乎重复。 因此,扁平的 top-
Based on this principle, we propose xMemory, which constructs a revisable hierarchical memory structure from original messages to segments, memory components, and groups. xMemory segments interaction history into local events, decouples each segment into memory components, aggregates related components into high-level groups using a sparsity--semantic faithfulness objective, and maintains this structure incrementally as memory evolves. At inference time, xMemory retrieves top-down, first selecting a compact backbone of complementary groups and components, and then expanding to segments and raw messages only when additional evidence reduces the reader's uncertainty. Experiments on LoCoMo and PerLTQA across diverse open source and closed source LLMs show consistent gains in answer quality and inference token efficiency, supported by analyses of redundancy, evidence density, and coverage.
基于这一原则,我们提出 xMemory,它构建了一种可修订的层级记忆结构,将原始消息依次组织为片段、记忆组件和分组。 xMemory 将交互历史切分为局部事件,把每个片段解耦为记忆组件,利用稀疏性--语义忠实性目标将相关组件聚合为高层分组,并随着记忆演化增量维护这一结构。 在推理时,xMemory 自顶向下检索:先选择由互补分组和组件构成的紧凑骨架,仅当额外证据能够降低读取模型的不确定性时,才继续扩展到片段和原始消息。 在 LoCoMo 和 PerLTQA 上针对多种开源与闭源 LLM 的实验表明,xMemory 持续提升回答质量和推理 token 效率;关于冗余、证据密度和覆盖率的分析进一步支持了这些结果。
1. Introduction

Large language model (LLM) agents increasingly rely on external memory to manage extended interaction histories, enabling capabilities such as multi-session dialogue, personalised assistance, and long-term task execution. In these settings, an agent answers new queries by retrieving useful evidence from memory systems rather than relying only on parametric knowledge. Current systems often approach memory retrieval as a standard RAG problem, relying on fixed top-
大语言模型(LLM)智能体越来越依赖外部记忆来管理扩展的交互历史,从而支持多会话对话、个性化辅助和长期任务执行等能力。 在这些场景中,智能体通过从记忆系统检索有用证据来回答新查询,而不是只依赖参数化知识。 当前系统经常把记忆检索视为标准 RAG 问题,并依赖固定的 top-
Unlike large heterogeneous document collections, agent memory forms a coherent interaction stream with substantial overlap in events and wording. Consequently, the central retrieval difficulty is no longer merely locating generally relevant text, but rather distinguishing decisive evidence hidden among highly similar histories. As a result, similarity top-k retrieval often returns multiple memories that are generally relevant but largely repetitive. This is particularly problematic when the answer hinges on a small update, constraint, or factual difference among otherwise similar interactions.
不同于大型异构文档集合,智能体记忆形成一条连贯的交互流,其中事件和措辞大量重叠。 因此,检索的核心难点不再只是定位大体相关的文本,而是区分隐藏在高度相似历史中的决定性证据。 于是,相似度 top-k 检索经常返回多条总体相关但高度重复的记忆。 当答案取决于其他方面相似的交互之间某个微小更新、约束或事实差异时,这一问题尤其严重。
This mismatch also exposes a limitation of existing memory organisation strategies. Recent systems use summaries, note structures, and hierarchical abstractions to improve scalability and navigation. Although these structures reduce the cost of flat retrieval, many still organise memory into a progressively compressed hierarchy, where nodes become fewer and more compressed at higher levels. Such designs can improve efficiency, but they do not directly address the need to identify answer-critical evidence from highly similar histories. Repeated compression often preserves shared background information while blurring the subtle details that distinguish one candidate from another.
这种不匹配也暴露了现有记忆组织策略的一项局限。 近期系统使用摘要、笔记结构和层级抽象来提升可扩展性与导航能力。 尽管这些结构降低了扁平检索的成本,但许多方法仍将记忆组织成逐步压缩的层级,其中越高层的节点越少、压缩程度越高。 这类设计能够提高效率,却没有直接解决从高度相似历史中识别答案关键证据的需求。 反复压缩往往保留共有背景信息,却会模糊区分候选项的细微细节。
Taken together, these considerations suggest a core design principle: decoupling before aggregation. As shown in Figure 1, rather than treating long, highly similar interaction logs as whole retrieval units, the memory system should first decompose them into smaller evidence units that isolate reusable facts, state updates, and distinguishing details. Aggregation then organises these units into a higher-level memory structure that remains compact and coherent. Crucially, this structure should be revisable rather than fixed: as agent memory evolves, new interactions can reveal better relations among previously stored components and trigger corresponding updates to the high-level organisation.
综合来看,这些考虑指向一项核心设计原则:先解耦、后聚合。 如图1所示,记忆系统不应把冗长且高度相似的交互日志作为完整检索单元,而应先将其分解为更小的证据单元,以分离可复用事实、状态更新和具有区分力的细节。 随后,聚合过程将这些单元组织为保持紧凑与连贯的高层记忆结构。 关键在于,这一结构应当可修订而非固定不变:随着智能体记忆演化,新交互可能揭示先前存储组件之间更合适的关系,并触发高层组织的相应更新。
Based on this principle, we propose xMemory, a framework that couples memory structuring with adaptive retrieval. Starting from raw messages, xMemory builds a hierarchical memory structure by following the principle of decoupling before aggregation: it extracts segments from raw messages as local events, decouples similar histories into memory components that isolate reusable facts and distinctive attributes, and then aggregates related components into groups for high-level access. To organise these components into useful groups, xMemory evaluates the component-to-group organisation with a guidance objective that balances sparsity and semantic faithfulness. This objective guides structure updates as memory evolves.
基于这一原则,我们提出 xMemory,一个将记忆结构化与自适应检索耦合起来的框架。 xMemory 从原始消息出发,遵循先解耦、后聚合的原则构建层级记忆结构:它从原始消息中抽取作为局部事件的片段,把相似历史解耦为能够分离可复用事实和差异性属性的记忆组件,再将相关组件聚合为便于高层访问的分组。 为了把这些组件组织成有用分组,xMemory 使用一个在稀疏性与语义忠实性之间取得平衡的引导目标来评估组件到分组的组织方式。 随着记忆演化,该目标会引导结构更新。
When new memory arrives, components are attached to compatible groups when possible, and the structure is revised as needed by splitting overly large or internally heterogeneous groups and merging overly small or isolated ones. Retrieval finally proceeds from coarse units to fine ones: the system first selects complementary groups and components, and expands to segments and original messages only when more detailed evidence is needed.
当新记忆到来时,系统会尽可能将组件连接到兼容分组,并在需要时拆分过大或内部异质的分组、合并过小或孤立的分组,从而修订结构。 最终,检索由粗粒度单元向细粒度单元推进:系统先选择互补分组和组件,仅在需要更详细证据时才扩展到片段和原始消息。
Our contributions are summarised as follows:
我们的贡献总结如下:
- We identify a key mismatch between standard RAG and agent memory, and argue that agent memory should follow the principle of decoupling before aggregation.
- We propose xMemory, which constructs a revisable hierarchical memory structure by segmenting local interaction history, decoupling segments into memory components, and aggregating related components into high-level groups.
- We develop a top-down adaptive retrieval method over this memory structure, and show on LoCoMo and PerLTQA that it improves both answer quality and inference token efficiency.
- 我们识别出标准 RAG 与智能体记忆之间的一项关键不匹配,并主张智能体记忆应遵循先解耦、后聚合的原则。
- 我们提出 xMemory,它通过切分局部交互历史、将片段解耦为记忆组件,并把相关组件聚合为高层分组,构建一种可修订的层级记忆结构。
- 我们在这一记忆结构上开发了自顶向下的自适应检索方法,并在 LoCoMo 和 PerLTQA 上表明,该方法同时提高了回答质量和推理 token 效率。
2. Related Work
RAG-style retrieval for agent memory. Many memory systems follow the standard RAG paradigm, storing past interactions as retrievable units and selecting a top-
面向智能体记忆的 RAG 式检索。 许多记忆系统遵循标准 RAG 范式,将过去的交互存储为可检索单元,并依据嵌入相似度选择 top-
Hierarchical and graph-based memory organisation. Recent systems organise memory into summaries, notes, temporal layers, semantic memories, or graph communities to improve scalability. While these structures reduce the cost of flat retrieval, many remain summary- or schema-centric: higher-level nodes abstract over lower-level content instead of preserving fine-grained distinctions. xMemory instead follows decoupling before aggregation: it first extracts reusable memory components from local segments, and then groups related components for efficient access.
层级与基于图的记忆组织。 近期系统将记忆组织为摘要、笔记、时间层、语义记忆或图社区,以提高可扩展性。 尽管这些结构降低了扁平检索的成本,但许多方法仍以摘要或模式为中心:高层节点对低层内容进行抽象,而不是保留细粒度差异。 xMemory 则遵循先解耦、后聚合:它先从局部片段中抽取可复用记忆组件,再对相关组件进行分组以实现高效访问。
Adaptive retrieval over dynamic memory structures. RAG-style memory systems usually treat past interactions as a static retrieval corpus, accessed by top-
动态记忆结构上的自适应检索。 RAG 式记忆系统通常把过去交互视为静态检索语料库,并通过 top-
3. Method

Given an interaction history
给定交互历史
3.1 Building a Revisable Memory Structure
We next describe how xMemory constructs the hierarchy and updates it as new memory arrives.
下面介绍 xMemory 如何构建这一层级,以及如何在新记忆到来时更新它。
From messages to components. We first partition the message stream into contiguous segments, each capturing a coherent local event, because answer-critical evidence in agent memory is often expressed across neighbouring turns rather than in isolated messages. Segments preserve this intact local context, but they are still too coarse to retrieve directly. We therefore extract one or more memory components from each segment, where each component represents a reusable fact, constraint, attribute, relation, or state update. This is the decoupling step of xMemory: it separates the decisive evidence from the surrounding local context before retrieval, while retaining links back to the source segment so that intact context can still be recovered when needed.
从消息到组件。 我们首先把消息流划分为连续的片段,每个片段捕获一个连贯的局部事件,因为智能体记忆中的答案关键证据往往跨相邻轮次表达,而不是存在于孤立消息中。 片段保留了这一完整局部上下文,但其粒度仍然过粗,不适合直接检索。 因此,我们从每个片段中抽取一个或多个记忆组件,每个组件表示一项可复用事实、约束、属性、关系或状态更新。 这就是 xMemory 的解耦步骤:它在检索前把决定性证据与周围局部上下文分离,同时保留指回源片段的链接,以便在需要时恢复完整上下文。
From components to groups. Once evidence has been decoupled into memory components, xMemory organises these components into higher-level groups, which serve as compact access units for retrieval. This is the aggregation step: rather than building the hierarchy directly over raw spans or summaries, we aggregate over already identified evidence units. The role of grouping is to make high-level retrieval both efficient and discriminative. If groups are too broad, retrieval becomes less discriminative and more redundant; if they are too fragmented, related evidence is scattered across many small units, weakening coverage for multi-fact queries. We therefore organise components into groups using an objective that balances sparsity and semantic faithfulness.
从组件到分组。 证据被解耦为记忆组件后,xMemory 会将这些组件组织为高层分组,作为检索时的紧凑访问单元。 这就是聚合步骤:我们不是直接在原始片段或摘要上构建层级,而是在已经识别出的证据单元上进行聚合。 分组的作用是使高层检索兼具效率和区分力。 如果分组过宽,检索的区分力会下降且冗余增加;如果分组过碎,相关证据会分散在许多小单元中,削弱多事实查询的覆盖能力。 因此,我们使用一个在稀疏性与语义忠实性之间取得平衡的目标将组件组织成分组。
Let
令
The sparsity term favours balanced groups by using the normalised inverse of the expected within-group scanning cost.
稀疏性项使用预期组内扫描成本的归一化倒数,偏好规模均衡的分组。
The semantic term encourages intra-group coherence and keeps the inter-group geometry navigable by Stage I's kNN-based retrieval.
语义项鼓励组内一致性,并保持组间几何结构能够被第一阶段基于 kNN 的检索有效导航。
Here
这里,
Dynamic maintenance. Because agent memory evolves over time, the memory structure is maintained incrementally rather than fixed after construction. A new component with embedding
动态维护。 由于智能体记忆会随时间演化,记忆结构采用增量方式维护,而不是构建后保持固定。 对于嵌入为
We additionally maintain top-
我们还在分组之间维护 top-
3.2 Retrieval from the Memory Structure
The memory structure separates two roles that raw interaction history entangles: groups and memory components expose high-level evidence, while segments and original messages preserve the intact local context in which that evidence was expressed. Retrieval therefore proceeds in two stages. We first identify a compact high-level backbone of relevant evidence, and only then expand to lower-level text when more context is necessary for answer generation.
记忆结构分离了原始交互历史中相互纠缠的两种作用:分组和记忆组件提供高层证据,而片段和原始消息保留这些证据被表达时的完整局部上下文。 因此,检索分两个阶段进行。 我们首先识别相关证据构成的紧凑高层骨架,仅在回答生成需要更多上下文时才扩展到低层文本。
Stage I: high-level backbone selection. Answers in agent memory are often supported by multiple related evidence units rather than a single best match. Stage I therefore selects a compact set of complementary high-level units, rather than repeatedly retrieving near-duplicate evidence by pure similarity ranking. To support this, we maintain kNN links among groups in the memory structure. These links record which high-level units are semantically close, even when they belong to different groups, allowing Stage I to avoid repeatedly selecting near-duplicate evidence and to identify related evidence regions that remain uncovered.
第一阶段:高层骨架选择。 智能体记忆中的答案通常由多个相关证据单元共同支持,而不是只依赖单个最佳匹配。 因此,第一阶段选择一组紧凑且互补的高层单元,而不是依据纯相似度排序反复检索近乎重复的证据。 为此,我们在记忆结构的分组之间维护 kNN 链接。 即使高层单元属于不同分组,这些链接也会记录它们在语义上的接近关系,使第一阶段能够避免重复选择近乎重复的证据,并识别仍未覆盖的相关证据区域。
We first retrieve a small pool of groups by similarity between query and centroid, and include their neighbouring groups and associated components as candidate set
我们首先依据查询与质心之间的相似度检索一个小型分组池,并将其邻近分组和相关组件纳入候选集
At each step, we greedily select the next unit by trading off structural coverage against query relevance.
在每一步中,我们通过权衡结构覆盖率与查询相关性,贪心选择下一个单元。
Here
这里,
Stage II: adaptive text expansion. The high-level backbone indicates where useful evidence resides, but it does not yet determine how much original text should be revealed to the reader. Expanding all linked segments and messages would often reintroduce the same redundancy that the high-level structure is designed to avoid. Stage II therefore adds lower-level text only when it further reduces the reader's uncertainty.
第二阶段:自适应文本扩展。 高层骨架指出了有用证据所在的位置,但尚未决定应向读取模型展示多少原始文本。 扩展所有已链接的片段和消息,往往会重新引入高层结构旨在避免的同类冗余。 因此,第二阶段仅在低层文本能够进一步降低读取模型不确定性时才加入它。
Starting from the selected components, we gather their linked segments and construct a coarse context. Let
我们从选中的组件出发,收集其链接片段并构建粗粒度上下文。 令
A segment is included only if it yields a positive marginal reduction, i.e.,
仅当片段带来正的边际降低量,即
4. Experiments
4.1 Experimental Setup
Datasets and metrics. We evaluate long-term agent memory on two complementary benchmarks: LoCoMo and PerLTQA. LoCoMo contains 50 multi-session dialogues, with an average of
数据集与指标。 我们在两个互补基准 LoCoMo 和 PerLTQA 上评估长期智能体记忆。 LoCoMo 包含 50 个多会话对话,平均约有
Baselines. We compare against six baselines, grouped by how they access and organise memory. These baselines cover full-context reading, flat similarity retrieval, post-retrieval compression, and representative structured-memory designs. Flat or minimally structured baselines include (1) Full Memory, which provides the complete available history to the reader model without retrieval; (2) Naive RAG, which chunks original messages and retrieves the top-
基线。 我们与六种基线比较,并按照它们访问和组织记忆的方式进行分组。 这些基线涵盖完整上下文读取、扁平相似度检索、检索后压缩以及具有代表性的结构化记忆设计。 扁平或最低限度结构化的基线包括:(1) Full Memory,不经过检索而向读取模型提供全部可用历史;(2) Naive RAG,切分原始消息并依据向量相似度检索 top-
Implementation details. We evaluate all compared methods with three reader LLMs: two recent open-source models, Qwen3-8B and Llama-3.1-8B-Instruct, and one closed-source model, GPT-5 nano. Final answers are generated with greedy decoding (temperature text-embedding-3-small, and each method uses the same backbone model for memory construction and answer generation. Since LoCoMo and PerLTQA require different answer formats, we use dataset-specific answer prompts within each dataset. For GPT-5 nano, which does not expose token-level logits, we estimate uncertainty with GPT-4.1-mini. All xMemory hyperparameters are fixed across datasets and backbone models; their values and implementation details are reported in the appendix for reproducibility.
实现细节。 我们使用三个读取 LLM 评估所有比较方法:两个近期的开源模型 Qwen3-8B 和 Llama-3.1-8B-Instruct,以及一个闭源模型 GPT-5 nano。 最终答案使用贪心解码(温度 text-embedding-3-small,每种方法在记忆构建和答案生成中使用相同的骨干模型。 由于 LoCoMo 和 PerLTQA 要求不同的答案格式,我们在每个数据集内使用数据集专用的回答提示。 对于不提供 token 级 logits 的 GPT-5 nano,我们使用 GPT-4.1-mini 估计不确定性。 xMemory 的所有超参数在不同数据集和骨干模型间保持固定;其数值和实现细节在附录中给出,以便复现。
4.2 Main Results
| Model | Method | Multi-hop | Temporal | Open-domain | Single-hop | Average | Token /query | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| BLEU | F1 | BLEU | F1 | BLEU | F1 | BLEU | F1 | BLEU | F1 | |||
| Qwen3-8B | Full MemoryF | 24.63 | 31.66 | 10.02 | 12.58 | 12.48 | 17.59 | 33.80 | 44.00 | 25.83 | 33.54 | 18535.90 |
| Naive RAGF | 22.46 | 34.28 | 17.21 | 21.32 | 12.35 | 17.08 | 35.68 | 45.22 | 27.95 | 36.48 | 8633.28 | |
| LightMemF | 19.63 | 26.23 | 22.67 | 27.61 | 9.83 | 14.37 | 31.34 | 40.66 | 26.04 | 33.66 | 5545.35 | |
| NemoriS | 24.68 | 36.82 | 25.78 | 33.76 | 12.71 | 18.48 | 38.02 | 47.52 | 31.44 | 40.88 | 7754.66 | |
| A-MemS | 23.32 | 33.26 | 22.29 | 32.53 | 9.08 | 16.72 | 33.61 | 42.52 | 27.84 | 37.13 | 9103.46 | |
| MemoryOSS | 17.12 | 21.74 | 26.84 | 32.26 | 14.53 | 16.25 | 35.83 | 40.37 | 29.20 | 33.76 | 7234.66 | |
| xMemory (Ours) | 27.24 | 38.57 | 29.58 | 37.46 | 15.55 | 20.69 | 40.94 | 50.94 | 34.48 | 43.98 | 4711.29 | |
| Llama-3.1-8B-Ins | Full MemoryF | 15.11 | 21.52 | 6.06 | 8.06 | 7.78 | 11.13 | 23.29 | 35.13 | 17.23 | 25.50 | 18524.70 |
| Naive RAGF | 13.77 | 19.40 | 6.20 | 8.61 | 6.99 | 10.22 | 21.90 | 35.37 | 16.21 | 25.30 | 11522.60 | |
| LightMemF | 16.43 | 23.76 | 12.44 | 15.61 | 9.83 | 13.70 | 21.68 | 25.08 | 18.05 | 22.15 | 5708.11 | |
| NemoriS | 18.18 | 26.30 | 19.23 | 26.09 | 9.24 | 12.06 | 26.19 | 40.18 | 22.21 | 32.95 | 9802.69 | |
| A-MemS | 15.88 | 20.90 | 19.92 | 24.91 | 9.92 | 11.34 | 24.86 | 39.90 | 21.52 | 31.51 | 10268.77 | |
| MemoryOSS | 13.26 | 17.83 | 19.88 | 23.95 | 11.48 | 12.92 | 24.76 | 28.67 | 20.81 | 24.72 | 7212.07 | |
| xMemory (Ours) | 22.21 | 30.99 | 21.20 | 27.42 | 11.58 | 14.61 | 28.43 | 41.15 | 24.73 | 34.77 | 5539.97 | |
| GPT-5 nano | Full MemoryF | 22.95 | 34.07 | 20.02 | 23.50 | 21.61 | 26.42 | 32.71 | 46.97 | 27.58 | 38.44 | 18544.25 |
| Naive RAGF | 21.34 | 32.31 | 28.43 | 29.05 | 22.63 | 26.56 | 36.68 | 46.35 | 31.28 | 38.94 | 7531.46 | |
| LightMemF | 23.13 | 32.07 | 41.06 | 55.23 | 21.27 | 26.38 | 37.52 | 44.31 | 34.60 | 43.23 | 6850.04 | |
| NemoriS | 24.80 | 37.11 | 41.56 | 54.25 | 22.61 | 29.29 | 40.35 | 51.67 | 36.65 | 48.17 | 9154.76 | |
| A-MemS | 24.12 | 35.88 | 40.87 | 54.67 | 20.83 | 27.61 | 38.42 | 46.13 | 35.22 | 44.88 | 9610.94 | |
| MemoryOSS | 24.47 | 36.13 | 39.78 | 55.34 | 21.45 | 28.71 | 39.39 | 48.68 | 35.62 | 46.53 | 7029.02 | |
| xMemory (Ours) | 27.56 | 39.97 | 46.10 | 57.62 | 25.53 | 30.92 | 41.14 | 52.63 | 38.71 | 50.00 | 6581.20 | |
LoCoMo: retrieval over coherent multi-session histories. Table 1 reports results on LoCoMo. Across all three backbones, xMemory achieves the best average performance, with especially clear gains on multi-hop and temporal questions. For example, with Qwen3-8B, average BLEU/F1 improves from 31.44/40.88 for Nemori to 34.48/43.98; with GPT-5 nano, it improves from 36.65/48.17 to 38.71/50.00 while reducing token usage from 9155 to 6581 per query.
LoCoMo:在连贯多会话历史上检索。 表1报告了 LoCoMo 上的结果。 在三个骨干模型上,xMemory 都取得了最佳平均性能,并且在多跳与时间问题上的提升尤其明显。 例如,使用 Qwen3-8B 时,平均 BLEU/F1 从 Nemori 的 31.44/40.88 提升到 34.48/43.98;使用 GPT-5 nano 时,它从 36.65/48.17 提升到 38.71/50.00,同时把每个查询的 token 用量从 9155 降至 6581。
Compared with both flat retrieval and structured memory baselines, these results suggest that agent memory benefits from decoupling decisive evidence before high-level organisation and retrieval. Full Memory and Naive RAG preserve large amounts of raw context but often return redundant or weakly discriminative evidence, while LightMem reduces cost mainly through post-retrieval compression and performs worse on multi-hop and temporal questions. Structured baselines introduce higher-level organisation, but their memory structures are not explicitly centred on decoupled evidence units and revisable grouping. By contrast, xMemory first decouples distinctive evidence into memory components, organises them into revisable groups, and retrieves top-down over this structure.
与扁平检索和结构化记忆基线相比,这些结果表明,在进行高层组织和检索之前先解耦决定性证据有利于智能体记忆。 Full Memory 和 Naive RAG 保留大量原始上下文,但经常返回冗余或区分力较弱的证据;LightMem 则主要通过检索后压缩降低成本,在多跳和时间问题上表现更差。 结构化基线引入了高层组织,但其记忆结构没有明确以解耦后的证据单元和可修订分组为中心。 相比之下,xMemory 先把差异性证据解耦为记忆组件,将其组织成可修订分组,再在该结构上自顶向下检索。
| Method | Qwen3-8B | Llama-3.1-8B-Ins | GPT-5 nano | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| BLEU | F1 | R-L | Tok. | BLEU | F1 | R-L | Tok. | BLEU | F1 | R-L | Tok. | |
| Full MemoryF | 32.73 | 42.15 | 36.65 | 25045 | 33.00 | 44.40 | 39.43 | 25098 | 24.37 | 34.97 | 29.81 | 25212 |
| Naive RAGF | 32.08 | 41.37 | 35.95 | 6274 | 33.67 | 44.84 | 39.65 | 9531 | 27.35 | 37.76 | 32.35 | 10756 |
| LightMemF | 29.12 | 40.21 | 34.67 | 7692 | 31.83 | 42.33 | 38.37 | 5452 | 24.84 | 34.51 | 29.33 | 7579 |
| NemoriS | 32.55 | 42.80 | 38.05 | 9092 | 41.01 | 49.62 | 44.65 | 11440 | 33.44 | 41.79 | 38.43 | 11883 |
| A-MemS | 31.36 | 40.92 | 36.45 | 9864 | 35.56 | 45.79 | 41.38 | 7707 | 33.12 | 41.17 | 37.94 | 14718 |
| MemoryOSS | 35.14 | 42.35 | 38.48 | 6499 | 34.79 | 42.03 | 38.22 | 6511 | 27.66 | 33.83 | 31.44 | 12669 |
| xMemory (Ours) | 36.24 | 47.08 | 42.50 | 5087 | 42.68 | 52.37 | 47.84 | 6066 | 36.79 | 46.23 | 41.25 | 7307 |
PerLTQA: generalisation to longer personalised memory. Table 2 reports results on PerLTQA, which contains longer contexts and more sentence-style answers than LoCoMo. xMemory remains consistently effective across all three backbone models, showing that the proposed retrieval principle transfers beyond multi-session dialogue recall to longer personalised memory reasoning. With Qwen3-8B, it achieves the best BLEU/F1/ROUGE-L at 36.24/47.08/42.50 while using the fewest tokens; with Llama-3.1-8B-Instruct, it reaches 42.68/52.37/47.84. These gains suggest that xMemory improves selective evidence access while preserving the information needed for coherent sentence-level reconstruction.
PerLTQA:向更长个性化记忆泛化。 表2报告了 PerLTQA 上的结果,该数据集比 LoCoMo 包含更长的上下文和更多句子形式的答案。 xMemory 在三个骨干模型上始终有效,表明所提出的检索原则能够从多会话对话回忆迁移到更长的个性化记忆推理。 使用 Qwen3-8B 时,它以最少的 token 用量取得最佳 BLEU/F1/ROUGE-L:36.24/47.08/42.50;使用 Llama-3.1-8B-Instruct 时,则达到 42.68/52.37/47.84。 这些提升表明,xMemory 在保留连贯句子级重构所需信息的同时,改善了选择性证据访问。
Efficiency. We report tokens per query as the average end-to-end inference cost, including retrieval, answer generation, and auxiliary calls. Across both datasets, xMemory achieves better answer quality with competitive or fewer tokens than strong memory baselines, indicating that its gains come from delivering more concentrated evidence rather than exposing more history. For example, on LoCoMo with Qwen3-8B, xMemory reduces token usage from 7755 for Nemori to 4711 while also improving average BLEU/F1 from 31.44/40.88 to 34.48/43.98. These results suggest that token efficiency in agent memory should be measured by evidence utility rather than context reduction alone.
效率。 我们使用每个查询的 token 数表示平均端到端推理成本,其中包括检索、答案生成和辅助调用。 在两个数据集上,与强记忆基线相比,xMemory 都以有竞争力或更少的 token 取得更好的回答质量,说明其提升来自提供更集中的证据,而不是暴露更多历史。 例如,在使用 Qwen3-8B 的 LoCoMo 上,xMemory 将 Nemori 的 token 用量从 7755 降至 4711,同时把平均 BLEU/F1 从 31.44/40.88 提升到 34.48/43.98。 这些结果表明,智能体记忆中的 token 效率应根据证据效用来衡量,而不能只看上下文缩减量。
5. Analysis
5.1 Ablation Studies
Retrieval stage analysis. We first ablate memory structuring and the two retrieval stages on LoCoMo with Qwen3-8B. As shown in Figure 3 (a), Memory-only improves average BLEU/F1 from 27.95/36.48 for Naive RAG to 31.81/40.77, showing that retrieval over decoupled memory units is more effective than retrieval over flat raw chunks, even with basic similarity matching. Adding Stage I improves selection over groups and components, while Stage II improves uncertainty guided expansion to segments and messages. Combining both stages gives the best trade-off, with the highest average BLEU/F1 and the lowest token usage.
检索阶段分析。 我们首先在采用 Qwen3-8B 的 LoCoMo 上,对记忆结构化和两个检索阶段进行消融。 如图3 (a) 所示,Memory-only 将 Naive RAG 的平均 BLEU/F1 从 27.95/36.48 提升到 31.81/40.77,表明即使只使用基本的相似度匹配,在解耦记忆单元上检索也比在扁平原始块上检索更有效。 加入阶段 I 改善了分组与组件层面的选择,而阶段 II 改善了以不确定性为引导、向片段和消息扩展的过程。 结合两个阶段取得最佳权衡,同时获得最高的平均 BLEU/F1 和最低的 token 用量。
Group size upper bound analysis. We next study the upper bound on the number of memory components per group. This parameter controls routing arity: a larger candidate set within each group makes decisive evidence harder to identify in dialogue memory with high semantic similarity, while an overly small group size scatters related facts. Guided by a Fano style lower bound, which shows that routing error increases with candidate size when discriminative information is bounded, we choose 12 as a practical threshold and then validate it empirically. Figure 3 (b) shows that this setting performs best, reaching 34.48 BLEU and 43.98 F1 with 4.48 components per group on average. Larger groups weaken discrimination, while smaller groups fragment the hierarchy. Full results and the detailed theoretical motivation are provided in the appendix.
分组大小上界分析。 接下来,我们研究每个分组所含记忆组件数量的上界。 该参数控制路由分支数:在语义高度相似的对话记忆中,每个分组内更大的候选集会使决定性证据更难识别,而过小的分组则会分散相关事实。 Fano 风格的下界表明,当判别信息受限时,路由误差会随候选集大小增加;在这一结果的指导下,我们选择 12 作为实用阈值,并通过实验加以验证。 图3 (b) 表明该设置表现最佳,达到 34.48 BLEU 和 43.98 F1,且每组平均包含 4.48 个组件。 更大的分组会削弱判别能力,而更小的分组会使层级结构碎片化。 完整结果和详细理论动机见附录。

5.2 Retroactive Restructuring in Memory Construction
Unlike standard RAG, where the retrieval corpus is usually fixed, agent memory evolves as new interactions arrive. In xMemory, later insertions can trigger split or merge operations over high-level groups, thereby revising the assignment of previously created memory components. We measure this effect with the dynamic reassignment ratio, defined as the fraction of existing components whose group assignment changes during later insertions.
标准 RAG 的检索语料库通常是固定的,而智能体记忆会随着新交互到来而演化。 在 xMemory 中,后续插入可以触发高层分组的拆分或合并操作,从而修订先前创建的记忆组件的归属。 我们使用动态重分配比例衡量这一效应,它被定义为在后续插入期间分组归属发生变化的现有组件所占比例。

Figure 4 shows that such retroactive restructuring improves downstream QA. Disabling both split and merge freezes the structure, yields 0% reassignment, and reduces average F1 to 38.59, whereas the full system reaches the highest reassignment ratio (44.91%) and the best average F1 (43.98). The structure statistics in the appendix further show that split and merge play complementary roles: split enables revision by repartitioning broad groups, while merge prevents the high-level index from becoming unnecessarily fragmented. These results support our claim that revisability is not merely an implementation detail, but a useful property for memory organisation under evolving evidence.
图4表明,这种追溯式重构能够改善下游问答。 同时禁用拆分和合并会冻结结构,使重分配比例降至 0%,并将平均 F1 降至 38.59;完整系统则达到最高的重分配比例(44.91%)和最佳平均 F1(43.98)。 附录中的结构统计进一步表明,拆分与合并发挥互补作用:拆分通过重新划分宽泛分组实现修订,而合并则防止高层索引产生不必要的碎片。 这些结果支持我们的主张:可修订性不只是实现细节,而是面对不断演化的证据时,记忆组织所需的一项有用属性。
5.3 Retrieval Efficiency and Cost Performance Trade-off

Evidence density and coverage efficiency. To understand why xMemory improves answer quality while reducing inference-time context cost, we compare three retrieval settings on LoCoMo with Qwen3-8B: (1) Naive RAG with top-
证据密度与覆盖效率。 为了理解 xMemory 为何能够在降低推理时上下文成本的同时提高回答质量,我们在采用 Qwen3-8B 的 LoCoMo 上比较三种检索设置:(1) 使用 top-
| Method | BLEU | F1 | Blocks ↓ | Tokens ↓ |
|---|---|---|---|---|
| Naive RAG | 27.95 | 36.48 | 10.81 | 1979.26 |
| RAG + Pruning | 26.55 | 34.58 | 13.31 | 1587.99 |
| xMemory | 34.48 | 43.98 | 5.66 | 974.56 |
We further evaluate coverage efficiency by comparing how many retrieved blocks and tokens are needed to cover all answer evidence units. Table 3 shows that pruning reduces token cost relative to Naive RAG, but requires more blocks and yields lower accuracy, consistent with fragmented evidence after compression. In contrast, xMemory achieves the best BLEU/F1 while covering answer evidence with substantially fewer blocks and tokens. This suggests that xMemory improves not simply by retrieving less context, but by concentrating more answer-relevant evidence into a smaller retrieval budget.
我们进一步评估覆盖效率,比较覆盖全部答案证据单元所需的检索块数和 token 数。 表3表明,与 Naive RAG 相比,剪枝降低了 token 成本,但需要更多检索块且准确率更低,这与压缩后证据碎片化的现象一致。 相比之下,xMemory 以显著更少的检索块和 token 覆盖答案证据,同时取得最佳 BLEU/F1。 这说明 xMemory 的提升并非只是因为检索了更少的上下文,而是因为它把更多答案相关证据集中在更小的检索预算内。

End-to-end cost--performance trade-off. The above analysis focuses on inference-time retrieval efficiency. We next examine whether this advantage remains after accounting for memory construction cost. Following the LightMem-style reporting setup, we calculate construction tokens and compute total token cost as average construction cost plus average inference tokens per query multiplied by the corresponding query count. The exact statistics used for this analysis are reported in the appendix.
端到端成本--性能权衡。 上述分析关注推理时的检索效率。 接下来,我们考察在计入记忆构建成本后,这项优势是否仍然存在。 按照 LightMem 风格的报告设置,我们计算构建 token,并将总 token 成本定义为平均构建成本,加上每个查询的平均推理 token 数与相应查询数量的乘积。 该分析使用的精确统计数据见附录。
As shown in Figure 6, xMemory achieves the most favourable trade-off. Flat baselines such as Naive RAG and LightMem use relatively low or moderate token budgets, but obtain lower answer quality. Structured memory baselines improve over flat retrieval in some cases, but usually incur higher construction and inference costs. In contrast, xMemory attains the highest average BLEU while using a lower total token cost than Nemori, MemoryOS, and A-Mem. This suggests that the denser evidence retrieved by xMemory not only improves local coverage efficiency, but also translates into a better end-to-end efficiency--quality balance after amortising construction cost.
如图6所示,xMemory 取得了最有利的权衡。 Naive RAG 和 LightMem 等扁平基线使用相对较低或适中的 token 预算,但回答质量较低。 结构化记忆基线在某些情况下优于扁平检索,但通常会产生更高的构建与推理成本。 相比之下,xMemory 获得最高的平均 BLEU,同时总 token 成本低于 Nemori、MemoryOS 和 A-Mem。 这说明,xMemory 检索到的更密集证据不仅改善了局部覆盖效率,而且在摊销构建成本后,也转化为更好的端到端效率--质量平衡。
6. Conclusion
We presented xMemory, a retrieval framework that uses hierarchical organisation to address the mismatch between agent memory and standard RAG assumptions. By disentangling highly correlated memories into semantic components and retrieving top-down over the resulting hierarchy, xMemory reduces redundancy while preserving temporally linked evidence. Across LoCoMo and PerLTQA, xMemory improves answer quality with lower token cost and retrieves more evidence-dense contexts than RAG baselines. These results suggest that effective agent memory should not only retrieve or compress past interactions, but also reorganise them into evidence-oriented structures that make subtle distinctions easier to access. We hope xMemory provides a useful step toward more adaptive and efficient memory systems for long-horizon LLM agents.
我们提出了 xMemory,这是一种利用层级组织解决智能体记忆与标准 RAG 假设之间不匹配问题的检索框架。 xMemory 将高度相关的记忆解耦为语义组件,并在所得层级结构上自顶向下检索,从而在保留时间关联证据的同时减少冗余。 在 LoCoMo 和 PerLTQA 上,xMemory 以更低的 token 成本提高了回答质量,并且比 RAG 基线检索到证据密度更高的上下文。 这些结果表明,有效的智能体记忆不仅应检索或压缩过去的交互,还应将它们重新组织为面向证据的结构,使细微差异更易访问。 我们希望 xMemory 能够为面向长程 LLM 智能体构建更具适应性和效率的记忆系统迈出有益一步。