arXiv(opens in a new tab)cs.AISep 2026Cited by 4 papers on PaperVantage

Manuscript Offprint

arXiv:2609.08273

MemForest: Efficient Agent Memory Management via EventTree Partitioning and Progressive Merging

Junxi Wang, Te Sun, Jiayi Zhu, Chen Zhang, Siyuan Li, Xuyang Liu, Zichen Wen, Xiaobing Tu, Jinkui Ren, Xiantao Zhang, Ziqi Yuan, Linfeng Zhang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Agent memory systems have demonstrated significant potential in tasks such as long-term dialogue, personalized assistants, and video understanding. However, as inference progresses, continuously accumulated memory imposes substantial storage and retrieval burdens. To address this issue, we propose MemForest, a general memory compression framework adaptable to various agent memory systems. Specifically, MemForest leverages both global semantic similarity and local temporal continuity of memory events to partition the historical memory into a set of event-centric independent units. For each independent unit, the framework constructs a maximum spanning tree structure, referred to as an EventTree, and performs progressive merging by iteratively selecting high-weight edges, thereby effectively compressing redundant memory nodes and reducing storage overhead. In addition, we introduce an anchor-guided propagation retrieval mechanism, which retrieves more relevant memory nodes from the temporal neighborhoods of key memory nodes, thereby enabling more accurate memory retrieval. Extensive experiments demonstrate the effectiveness of MemForest. Under the unimodal Mem0 framework, across three benchmarks (LoCoMo, LongMemEval, and PersonaMem), MemForest preserves 97.1% of the original performance while compressing 50% of historical memory, achieving a 1.89× retrieval speedup. Under the multimodal M3-Agent framework, across two benchmarks (M3-Bench-robot and M3-Bench-web), MemForest retains 99.7% of the original performance under a 50% compression ratio, while achieving a 2.24× retrieval speedup. Our code is available at https://github.com/Celina-love-sweet/MemForest.

1 Introduction

In recent years, the application of LLMs has grown rapidly, expanding from initial dialogue tasks [3, 30] to a wide range of problem-solving scenarios [6, 17]. In these contexts, long-term memory is crucial for maintaining contextual continuity and capturing dependencies across time. To address this, agent memory systems have emerged, storing historical interactions and key information as external memory to enhance a model’s ability to capture long-term dependencies. These systems have shown significant potential in long-term dialogue [8, 11, 19], personalized assistants [27, 31, 35], and video understanding [22, 42]. However, as dialogue turns accumulate, memory growth poses challenges to both storage and retrieval efficiency. As shown in Fig. 1(a), under the Mem0 framework [8], expanding memory nodes increases storage pressure and reduces retrieval efficiency. Therefore, exploring efficient memory compression methods has become an important and urgent problem.

†Corresponding author.

Preprint.

Figure

Figure 1: (a) Challenges brought by the continuous growth of memory. Each complete user Q&A involves three time costs: Embedding time: converting the query into a vector; Retrieval time: searching for corresponding memory nodes via similarity computation; Response time: generating the model's answer. (b) An example from the LoCoMo benchmark. This example illustrates that memory events exhibit global semantic similarity and local temporal continuity.

However, existing research on memory compression largely focuses on the generation stage [10, 21], which cannot fundamentally curb the continuous growth of memory, as stored memories still accumulate over time. Therefore, it is necessary to adopt a post-processing perspective and perform compression on already generated memories to systematically optimize storage efficiency and retrieval performance. Although recent work has begun to explore the feasibility of post-processing memory compression [34], this method typically relies on graph-structured memory representations and is restricted to streaming video scenarios, limiting its general applicability. Consequently, designing a general and scalable memory compression framework remains an important and open challenge.

Since stored memories are retrieved as external context, memory compression is closely related to context-length reduction. Recent token compression methods [5, 7, 37, 41, 43, 46, 47] reduce context via similarity-based merging or diversity-based pruning, mainly for MLLMs. However, unlike redundant visual inputs, textual memories are more semantically rich and information-dense [24, 45, 47], making compression challenging; existing methods also overlook memory-specific properties such as event differentiation and temporal relationships. Inspired by the event-level organization of human memory [18, 33], we partition historical memory into events and identify two key features for each memory event:

(I) Global Semantic Similarity: Fig. 1(b) suggests that semantically similar memory nodes may recur across distant temporal windows. For example, the similarity between memory node m1m_1 and the temporally distant memory node m9m_9 is 0.73, and that between node m1m_1 and node m15m_{15} is 0.68. This indicates that similar memory nodes within the same event can reappear over long time spans.

(II) Local Temporal Continuity: Fig. 1(b) suggests that within adjacent temporal windows, memory nodes may exhibit substantial semantic differences yet still belong to the same event. For example, the similarity between memory node m1m_1 and node m2m_2 is only 0.12, and that between node m1m_1 and node m3m_3 is only 0.23, yet all three pertain to "Boston dining plan". This indicates that even when semantic similarity is low, temporally proximate memory nodes may still belong to the same memory event.

Consequently, the above analysis indicates that when performing memory compression, it is necessary to consider both global semantic similarity and local temporal continuity. To this end, we propose MemForest, a general agent memory compression framework adaptable to various agent memory systems. Specifically, MemForest leverages the EventTree Semantic-Temporal Partitioning module to combine global semantic similarity with local temporal continuity, thereby partitioning stored historical memory into a set of event-centric EventTrees. For each EventTree, we leverage the EventTree Progressive Merging module to perform iterative processing, progressively compressing its internal representations until a predefined compression ratio is achieved. Furthermore, we introduce an Anchor-Guided Propagation Retrieval (AGPR) mechanism to recover temporal structural information that may be degraded during compression, thereby enabling the retrieval of more relevant memory nodes. In summary, the main contributions are as follows:

  • General Compression Framework. Based on the above analysis, we propose MemForest, a general agent memory compression framework, which leverages global semantic similarity and local temporal continuity to significantly improve storage and retrieval efficiency.
  • Novel Retrieval Mechanism. We introduce an Anchor-Guided Propagation Retrieval mechanism to retrieve more relevant memory nodes from the temporal neighborhoods of key memory nodes, thereby enabling more accurate memory retrieval.
  • Excellent Empirical Performance. Under the Mem0 and M3-Agent frameworks, across several benchmarks, when compressing 50% of the memory, MemForest is able to retain 97.1% and 99.7% of the original performance, respectively, while achieving 1.89x and 2.24x retrieval speedups.

References (45)