MemFolder: Structure-Guided Memory Folding for Efficient Agent Memory Management: what it means for business leaders

MemFolder compresses an agent's long-term memory store after it is built, halving the number of records on Mem0 while keeping 99.0% of benchmark accuracy, then shortening what remains by roughly 40% at a cost of a few accuracy points.

1. What the method is

MemFolder is a post-construction compression layer for the external memory stores that long-running agents accumulate. It sits on top of an existing memory system such as Mem0 or MemOS and does two things in sequence. The first component, RecordFolder, groups records that concern the same entities and events and has a language model merge each group into one retrieval unit, so the store holds fewer records. The second, ContextFolder, rewrites each group into a compact symbolic text under a token budget proportional to the group's original length, and checks that the important facts can still be read back out of the result. The two share the same group assignments, which lets record count and text length be reduced separately. ContextFolder does not depend on how the groups were formed, so it can also be applied after other record-compression methods. Code is published on GitHub.

2. Why the method was developed

An agent's memory store grows with every session, and the authors identify two costs that grow with it. More records mean more storage, a larger index and a wider search on each retrieval. Longer retrieved text means more tokens the model must process on every query. Their own uncompressed stores hold 6,817 records for the ten LoCoMo conversations and 310,120 records, 3.7 million tokens, for LongMemEval. Existing methods address one cost at a time. Prompt compressors such as LLMLingua shorten each call but leave the store as large as before. Pruning shrinks the store but can delete evidence a later question needs. Consolidation keeps the evidence but produces fewer, longer units, so with a fixed number of retrieved items the context handed to the model can grow instead of shrinking. MemFolder was built to cut both costs without discarding facts an agent may need later.

3. Who should care

This matters to the teams that build or operate assistants and agents with persistent memory: customer-facing assistants that remember a user across months, internal copilots, and any agent fleet whose per-agent history keeps growing. Platform and infrastructure owners should care because retrieval latency and per-query token spend both scale with the store, and this is a maintenance job that can run offline against a snapshot. Product owners should care because the trade is explicit: a smaller, faster memory against a measured accuracy cost that varies widely by memory framework. Finance and procurement should note that the compression itself consumes language-model calls for entity extraction, merging, planning, encoding and verification, a cost the paper does not report. Anyone responsible for audit or data retention should note that the stored text becomes a rewritten, symbolic encoding in place of the original records, which changes what can be shown as the source of an answer.

4. How the method works

RecordFolder first uses a language model to label the entities in each record with canonical names, carrying a registry forward across sessions so that pronouns and aliases resolve to the same label. It then picks anchor records: the first by density-peak clustering on embeddings, later ones by a score that favours records far from anchors already chosen. Every record joins its nearest anchor. Assignments are then refined by an affinity that mixes embedding similarity with overlap on rare shared entities, and by Hungarian matching that links each record to at most one earlier and one later record, forming non-branching chains in time order. A model merges each group chronologically. ContextFolder then runs three roles per group: a planner extracts atomic facts, ranks them and writes a question for each; a compressor writes a compact encoding with fixed notation for dates, state changes and negation; and a blind reader answers the questions from the encoding alone while a judge scores it, for up to three rounds.

5. How it was evaluated

The evaluation covers three text benchmarks, LoCoMo, LongMemEval and PersonaMem, and two multimodal ones, M3-Bench-web and M3-Bench-robot, on three memory frameworks: Mem0, MemOS and M3-Agent. Every method starts from the same uncompressed store per framework and is scored with the same retrieval and question-answering procedure, with results averaged over three runs. Record compression is tested at 30%, 50% and 70% reduction on Mem0 against pruning baselines (random, KMeans, DART) and merging baselines (random merging, ToMe, MemForest), with StreamMeCo added on the multimodal sets. Context compression is compared with LLMLingua-2 and BabelTele after three different record compressors at 50% reduction. Memory extraction, merging and answer judging use gpt-4o-mini on the text frameworks and gpt-4o on M3-Agent, so accuracy is a model's judgment, not a human one. Ablations cover anchor selection, the affinity terms, pruning against merging and the planner and verifier. Retrieval latency is measured at full, 50% and 30% retention.

6. How it performed

On Mem0, RecordFolder kept 99.0% of average accuracy with half the records and 96.6% with 70% removed, against 97.1% and 93.3% for MemForest. On M3-Agent accuracy rose slightly, from 39.1 to 40.1 at 70% reduction. On MemOS the picture is weaker: 91.0% retained at 50% and 84.8% at 70%, still ahead of the baselines. Adding ContextFolder cut tokens per record by about 40% on LoCoMo and 38% on LongMemEval, but accuracy fell from 59.3 to 56.6 and from 55.0 to 51.8. Keeping 30% of records sped mean retrieval by 1.88 to 5.34 times. The paper has no limitations section; what it leaves open is the cost of the compression calls, behaviour on a store that keeps changing, and the verifier, which the authors call a heuristic. Our call: pilot RecordFolder on one Mem0-style store where retrieval cost is already a problem, and hold ContextFolder until we have measured its accuracy loss on our own data. (Source: arXiv 2611.26427, 2026)

← Back to dossier index