Source-linked AI summary
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
TL;DR
Continuously growing agent memory increases storage and retrieval costs, while existing compression approaches do not generally address already accumulated memories. MemForest partitions memories using semantic similarity and temporal continuity, compresses event structures with EventTrees, and retrieves temporal neighbors around anchors. At 50% compression, it retains 97.1% of Mem0 performance and 99.7% of M3-Agent performance, with 1.89× and 2.24× retrieval speedups.
Problem
Continuously accumulated agent memories increase storage and retrieval costs, while existing compression largely focuses on generation-stage processing or restricted settings.
Method
MemForest partitions memories by global semantic similarity and local temporal continuity, progressively merges EventTree nodes, and uses anchor-guided propagation retrieval.
Results
50% compression retains 97.1% of original Mem0 performance and 99.7% of original M3-Agent performance, with retrieval speedups of 1.89× and 2.24×, respectively.
Takeaways & Limitations
MemForest provides a general memory-compression framework that preserves performance while reducing historical memory and accelerating retrieval across unimodal and multimodal systems.
Takeaways & Limitations
The theoretical analysis assumes all embeddings are ℓ2-normalized and uses weighting coefficients to control score interpolation.
Abstract
from arXiv · showhide
Agent memory systems have demonstrated significant potential in long-term dialogue, personalized assistants, and video understanding. However, continuously accumulated memory introduces substantial storage and retrieval costs during inference. To address this issue, we propose \textbf{MemForest}, a general memory compression framework adaptable to various agent memory systems. Specifically, MemForest partitions historical memory into event-centric units by leveraging global semantic similarity and local temporal continuity. For each unit, it constructs a maximum spanning tree, termed an EventTree, and progressively merges redundant memory nodes by selecting high-weight edges, reducing storage overhead. Furthermore, we introduce an anchor-guided propagation retrieval mechanism that retrieves relevant memory nodes from the temporal neighborhoods of key nodes, improving retrieval accuracy. Extensive experiments demonstrate the effectiveness of MemForest. Under the unimodal Mem0 framework, MemForest retains \textbf{97.1%} of the original performance while compressing \textbf{50%} of historical memory across three benchmarks (LoCoMo, LongMemEval, and PersonaMem), achieving a \textbf{1.89x} retrieval speedup. Under the multimodal M3-Agent framework, it preserves \textbf{99.7%} of the original performance with a \textbf{50%} compression ratio across two benchmarks (M3-Bench-robot and M3-Bench-web), achieving a \textbf{2.24x} retrieval speedup. \textcolor{RoyalBlue}{\textit{Our code is available at [https://github.com/Celina-love-sweet/MemForest.}}](https://github.com/Celina-love-sweet/MemForest.}})
1 Introduction
Agent memory supports long-term interaction but continuously growing memories increase storage and retrieval costs. MemForest addresses this with event-aware compression and anchor-guided retrieval, retaining high performance while reducing memory and retrieval overhead.
- Motivation: Growing external memory creates storage and retrieval-efficiency challenges for agent systems.These systems support long-term dialogue, personalized assistants, and video understanding.
- Research gap: Existing compression methods mainly operate during memory generation, leaving already stored memories to accumulate.Post-processing compression is needed, but prior work is often limited to graph-based representations or streaming video.
- Design requirements: Effective memory compression must combine global semantic similarity with local temporal continuity.Semantically related nodes may recur across distant time windows, while nearby nodes with low similarity can belong to the same event.
- Proposed framework: MemForest partitions historical memory into event-centric EventTrees, progressively merges redundant nodes, and uses anchor-guided propagation to retrieve temporal neighbors.The framework is designed to improve storage and retrieval efficiency across agent memory systems.
- Results: 50% memory compression retains 97.1% of original performance under Mem0 and 99.7% under M3-Agent, with retrieval speedups of 1.89× and 2.24×.These results are reported across multiple unimodal and multimodal benchmarks.
2 Related Work
Agent memory systems extend models beyond a single context by storing and retrieving information over time, while token-compression research reduces context size through similarity, diversity, or attention criteria.
- Agent memory systems: Agent memory systems provide long-term storage and retrieval beyond a single context for persistent interaction and complex tasks.They include unimodal systems for textual data and multimodal systems for more complex inputs.
- Token compression: Visual token compression reduces token counts while preserving key information to lower computational cost and improve inference efficiency.Existing approaches are commonly categorized as similarity-based, diversity-based, or attention-based.
3 Methodology
MemForest compresses historical memory by organizing nodes into event-centric structures, merging redundant representations through EventTrees, and retrieving temporal neighbors around query-relevant anchors.
- Framework overview: MemForest represents historical memory as nodes containing content, embeddings, and timestamps, then targets a compact memory set.The framework is intended to support efficient compression while retaining memory structure.
- EventTree Semantic-Temporal Partitioning: Semantic-temporal partitioning combines global similarity and local continuity to assign memory nodes to event units.Initial clustering is followed by dual-score computation, score fusion, and reassignment to the highest-scoring event unit.
- EventTree construction: Each event unit is modeled as a maximum spanning tree whose edges represent pairwise embedding similarity.The tree is constructed from a fully connected graph using Kruskal’s algorithm.
- EventTree Progressive Merging: Progressive merging selects high-weight node pairs after adjusting edge weights for node degree, then replaces them with fused memory nodes until the target compression ratio is reached.Degree-aware weighting protects high-degree hub nodes that typically carry more core event information.
- Anchor-Guided Propagation Retrieval: Anchor-Guided Propagation Retrieval expands query-based candidates through temporal neighborhoods of selected anchor nodes.Candidate nodes and anchors are selected by similarity, chronological positions are identified, and query and propagation scores are fused for final ranking.
4 Theoretical Analysis
MemForest’s theoretical analysis explains why highly similar memory nodes should be merged: greater node similarity preserves query relevance, while low similarity increases semantic deviation.
- Query relevance is modeled through node-query similarities s_i and s_j and node similarity ρ_ij for two memory embeddings.
- The merged memory embedding is a normalized interpolation of the two node embeddings controlled by λ.
- As ρ_ij increases, the lower bound on merged-node query similarity increases monotonically; low ρ_ij implies larger semantic deviation.
- Merging highly similar memory nodes is preferred because retrieval can otherwise deviate from important nodes during top-k selection.
5 Experiments
Experiments evaluate MemForest across unimodal and multimodal memory systems, showing strong performance retention at 50% compression, effective ablations, and substantial retrieval speedups.
- Experimental Setup: MemForest is evaluated against pruning- and merging-based baselines on three Mem0 benchmarks and two M3-Agent benchmarks.Experiments use three runs on two NVIDIA A100 GPUs.
- Main Results: 97.1% performance retention is achieved across three Mem0 benchmarks while compressing 50% of historical memory.Without AGPR, MemForest outperforms the evaluated pruning- and merging-based baselines.
- Main Results: 99.7% performance retention is achieved across two M3-Agent benchmarks while compressing 50% of historical memory.At compression ratios above 50%, merging-based methods preserve more historical information than the reported pruning methods.
- Main Results: AGPR consistently improves performance, with gains at 50% compression of 1.2% for Mem0 and 21.0% for M3-Agent.The reported gains are larger after compression than without compression.
- MemForest Ablation Study: Combining global semantic similarity with local temporal continuity enables more accurate EventTree partitioning at 50% compression.Removing either component or replacing local continuity with a sliding window weakens the partitioning strategy.
- MemForest Ablation Study: Replacing the maximum spanning tree with random or minimum-spanning-tree merging produces significantly worse performance at 50% compression.This result supports the paper’s theoretical preference for merging highly similar nodes.
- Time Efficiency Analysis: 1.89× average retrieval speedup is achieved under Mem0, while M3-Agent achieves a 2.24× average speedup.The reported Mem0 speedups are 2.00×, 1.92×, and 1.76×; M3-Agent speedups are 2.41× and 2.06×.
6 Conclusion
MemForest is a general memory-compression framework that combines structured compression with anchor-guided retrieval across unimodal and multimodal agent systems.
- MemForest combines memory compression with anchor-guided propagation retrieval across Mem0 and M3-Agent frameworks.The retrieval mechanism targets relevant neighborhood information around key memory nodes.
- MemForest retains 97.1% and 99.7% of original performance at 50% historical-memory compression under Mem0 and M3-Agent, respectively.
- MemForest achieves 1.89× and 2.24× retrieval speedups under Mem0 and M3-Agent, respectively, at 50% compression.
- Agent memory frameworks: Mem0 dynamically extracts, consolidates, and retrieves key conversational information to support long-term interaction.
- Agent memory frameworks: M3-Agent builds entity-centric multimodal memory from continuous video and audio inputs for multi-turn reasoning and retrieval.
- Baselines: ToMe progressively merges similar memory nodes, while StreamMeCo compresses M3-Agent memory using representative sampling and structure-aware pruning.
A.2 Datasets
The evaluation spans textual and multimodal long-term-memory benchmarks, while the supplementary material also documents implementation settings and theoretical derivations.
- Unimodal benchmarks: LoCoMo evaluates long-term memory and reasoning across 1,986 questions from 10 long conversations and five question categories.
- Unimodal benchmarks: LongMemEval contains 500 multi-session dialogue histories and questions covering six long-term interactive-memory categories.
- Unimodal benchmarks: PersonaMem-32k contains 222 multi-session dialogue histories and 589 questions spanning preference, recall, reasoning, recommendation, and generalization tasks.
- Multimodal benchmarks: M3-Bench-robot contains 100 first-person robot videos and 1,276 questions requiring long-term multimodal reasoning.
- Multimodal benchmarks: M3-Bench-web contains 920 YouTube videos and 3,214 questions across 46 categories for cross-modal understanding and long-term memory reasoning.
- Implementation: Experiments use GPT-4o-mini for Mem0 evaluation and memory-node merging, GPT-4o for M3-Agent evaluation, and framework-specific embedding models.
B.2 Theoretical Analysis of MemForest
The theoretical analysis bounds compression loss through EventTree merging and argues that selecting highly similar nodes helps preserve query relevance under compression.
- Compression analysis: MemForest compresses each EventTree by progressively merging memory nodes, with total operations determined by the node counts before and after compression.
- Compression analysis: MemForest prioritizes the highest-similarity node pair at each merge, keeping the minimum similarity as large as possible and limiting semantic deviation.
- Compression analysis: The overall compression loss is accumulated from per-merge similarity losses across all EventTrees.
- Theoretical result: MemForest maintains high query relevance under high compression ratios by merging highly similar nodes and controlling error accumulation.
- Theoretical result: The analysis states that compression loss depends on compression scale and minimum EventTree similarity.
- Implementation: The memory-node merging prompt combines two memories and timestamps into a concise summary while resolving relative time expressions using timestamps.
D.1 Ablation Study under Different Ratios
Ablation studies compare EventTree partitioning and memory-node merging strategies at 30% and 70% compression, showing benefits from the proposed semantic-temporal design.
- EventTree partitioning: Tables 5 and 7 evaluate different EventTree partitioning strategies at 30% and 70% compression rates.
- Memory-node merging: Tables 6 and 8 evaluate different memory-node merging strategies at 30% and 70% compression rates.
- Memory-node merging: Alternative merging strategies produce a notable performance drop, consistent with earlier experiments.
D.2 Other Ablation Study
The ablations examine node degree and benchmark performance under compression, with results indicating that node degree improves performance and MemForest remains competitive across textual benchmarks.
- Node Degree Ablation: Node degree consistently improves performance across three representative benchmarks and compression ratios.The ablation indicates that higher-degree nodes typically represent core event information and should not be merged prematurely.
- Benchmark Comparison: MemForest consistently outperforms other approaches on LoCoMo and LongMemEval using B1 and F1 scores across compression ratios.Tables 10–11 and Figure 4 compare pruning and merging baselines under varying compression ratios.
D.4 Parameter Sensitivity Analysis
The parameter studies identify settings that balance semantic similarity, temporal continuity, node importance, and neighborhood propagation, while examples illustrate event partitioning and memory merging.
- Partitioning Parameters: At 50% compression, clustering ratio α=0.05 yields optimal performance on LoCoMo and M3-Bench-robot.Higher or lower values respectively risk grouping unrelated memories or fragmenting memories from the same event.
- Partitioning Parameters: Weighting coefficient β=0.8 achieves optimal performance by balancing global semantic similarity with local temporal continuity.Excessive emphasis on either factor degrades performance.
- Partitioning Parameters: Time-window coefficient w=5 provides the best performance by supplying temporal context without weakening semantic aggregation.Larger windows dilute semantic grouping, whereas smaller windows provide insufficient temporal information.
- Merging Parameters: Weighting coefficient η=0.99 performs best by combining node-degree information with semantic similarity during merging.At η=1, core nodes may be merged prematurely; smaller values can suppress merging of semantically similar nodes.
- Retrieval Parameters: Retrieval performs best with γ=0.9, L=4, and anchor-selection coefficient λ=0.2.These settings balance semantic similarity with neighborhood information and provide sufficient but non-redundant propagation.
- Merging Examples and Cost: Memory-node merging uses short prompts and two entries per merge, costing about $0.1 for 50% compression on LoCoMo with GPT-4o-mini.GPT-4o-mini and GPT-5.2 show comparable merging performance, while Qwen2.5-7B-Instruct performs worse, likely because of its smaller parameter size.
- Examples and Efficiency: The detailed results report significant speedup, while the examples show EventTrees grouping related memories and merged nodes preserving original information.The partitioning example combines distant semantic similarity with local temporal continuity, and the merging example produces a single summarized memory.
F Limitations
The limitations concern reduced performance at high compression for low-redundancy textual memory and open questions about specialized compression and merging models.
- Compression Scope: Mem0 performance degrades notably at high compression, reaching 93.3% of uncompressed accuracy when 70% of historical memory is compressed.The authors identify specialized methods for low-redundancy memory frameworks as future work.
- Future Directions: MemForest is general-purpose, leaving room for specialized methods and dedicated lightweight memory-merging models.The paper also identifies retrieval-mechanism optimization as a future direction.