NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

MGMem: An Efficient, Deterministic, and Provenance-Preserving Framework for Long-Horizon Agent Memory

Junhong Huang, Xin Tong, Jun XiaNeurIPS 2026

TL;DR

Giving AI agents long-term memory usually involves asking an LLM to summarize past conversations—an expensive game of "telephone" that introduces hallucinations, non-determinism, and high compute bills. MGMem throws out generative indexing altogether, using a classical linguistic parser to map recurring words into a clean co-occurrence graph that retrieves the exact, unedited past conversations. The kicker? It doesn't just save thousands of LLM calls; it actually beats complex LLM-rewritten memory systems on accuracy.

What Problem Does This Paper Address?

Large Language Models (LLMs) are inherently stateless—once a conversation scrolls past their context window, it’s forgotten. Simply stuffing months of chat logs into an ever-growing prompt is expensive and triggers the "lost-in-the-middle" phenomenon, where models glaze over crucial details buried deep in the text.

To fix this, most modern agent memory systems use a generate-then-retrieve paradigm: as conversations happen, an LLM continuously digests the chat into neat summaries, atomic facts, or semantic knowledge graphs. While intuitive, putting a generative LLM in charge of filing memories creates three major headaches:

  1. High Cost: Indexing just ten multi-session conversations can require thousands of LLM calls and up to 45 minutes of processing.
  2. Non-determinism: Run the exact same chat history through an LLM indexer twice, and you get two different memory banks—making debugging and reproducibility a nightmare.
  3. Loss of Provenance: When an LLM summarizes a conversation, subtle details get smoothed over or distorted. At query time, the answering model reads synthesized notes rather than what was actually said, breaking the audit trail back to the source.
Figure 2: An illustrative example of how three memory paradigms handle the same query.

Methods

MGMem replaces generative LLM indexing with a deterministic, fast pipeline built around classical natural language processing and graph math.

Overview of MGMem's offline indexing and online three-stage retrieval pipeline.
  • Deterministic Indexing (What's Standard, Repurposed): First, chat sessions are sliced into topical "episodes" whenever sentence embeddings detect a shift in conversation. Instead of asking an LLM to extract facts, MGMem runs a lightweight, deterministic parser (spaCy) to pull out people, dates, noun chunks, and verbs. These are normalized (lowercased, lemmatized) into canonical keys and wired into an incidence graph: nodes are mentions, edges count how often two mentions appear in the same episode, and every node keeps a strict pointer back to its raw source episodes. Notice what * doesn't* happen here: words like "husband" and "spouse" are deliberately kept separate during indexing so no irreversible semantic guesses are made prematurely.
  • Subject-Conditioned Three-Stage Resolver (What's Novel): When a question arrives (e.g., "What pets does Nate keep?"), MGMem parses it with the exact same spaCy extractor and hunts for matches in three stages:
  • Exact Match: Direct hits in the graph ("Nate", "keep") get full confidence.
  • Subject-Local Bridge: What about "pets" if the chat only mentioned "turtles" and "adopted dog"? Instead of searching a noisy global dictionary, MGMem looks strictly inside the ego graph of the query's subject ("Nate")—comparing dense embeddings (all-MiniLM-L6-v2) only against concepts that actually co-occurred with Nate.
  • Full-Graph Bridge: If slots remain, it searches the rest of the graph for semantic matches at lower confidence.
  • Scoring & Provenance: Candidate episodes are scored using a square-root Inverse Document Frequency (IDF) formula—which rewards rare, specific matches while muting ubiquitous words—alongside bonuses for query coverage and graph coherence. Finally, the top-5 raw, unedited dialogue episodes are arranged chronologically and handed to the reader LLM.

Datasets

The authors evaluate MGMem on two established English long-term dialogue QA benchmarks (no new datasets are introduced, and MGMem requires no training):

  • LoCoMo: A multi-session conversational QA dataset spanning ten long conversations. Following standard protocols, the main evaluation uses 1,540 questions across single-hop, multi-hop, temporal, and open-domain categories (with 446 adversarial questions analyzed separately).
  • LongMemEval-S: An independently constructed long-horizon memory benchmark of 500 test questions spanning six types (e.g., single-session preferences, multi-session reasoning, temporal, and knowledge updates).

Key Insights and Ideas

  • Deferring interpretation beats premature summarization: When an LLM summarizes a chat during indexing, it has to guess what might matter later—often dropping the exact detail a future question asks for (like a 1:1 coconut milk baking substitution). Keeping raw dialogue intact and only bridging synonyms after the question is known preserves nuance.
  • Personalization lives in the ego graph: Ablation studies reveal that Stage 2 (the subject-local bridge) is the single biggest driver of accuracy. Grounding abstract query words like "family" or "pets" specifically within the neighborhood of the person being asked about avoids generic false positives.
  • Aligned parsing matters: Swapping out the humble spaCy query parser for an "intelligent" LLM query parser actually hurts accuracy by 2.6 percentage points, because LLM parsers tend to silently drop subtle verb and modifier tokens that serve as great lookup keys.

Key Results

Generative LLM calls during indexing vs. LoCoMo QA accuracy.

Figure 1: Generative indexing calls vs. LoCoMo ac- curacy. Updated local results use three-run means; † denotes quoted references (Section 4.2).
  • Higher Accuracy at Zero Generative Cost: On LoCoMo (using GPT-4o-mini as the reader), MGMem achieves 75.89% overall accuracy across matched local runs—beating LLM-generated memory systems like EMem (73.29%), AnchorMem (71.69%), and LightMem (62.42%), as well as a BM25+Dense Hybrid retriever (66.62%). Meanwhile, feeding the "Full Context" straight into the LLM scores a dismal 15.06%.
  • Drastic Indexing Speedups: Across all ten LoCoMo conversations on an Apple M5 Pro, MGMem builds its complete index in 199 seconds with 0 generative LLM calls, compared to 984 seconds (4,059 LLM calls) for AnchorMem and 2,816 seconds (6,081 LLM calls) for EMem.
  • Retrieval & Provenance: For raw episode retrieval, MGMem hits 0.591 hit@1 and 0.837 hit@5 (beating Hybrid's 0.443 and 0.706). A human audit of 200 answers confirmed 94.00% direct evidence support. On LongMemEval-S, MGMem remains competitive at 72.60% overall (just behind BM25 at 74.60% and Hybrid at 73.80%) while leading or tying on single-session question types.

Limitations and Future Work

  • English-Centric Parsing: Because the pipeline relies heavily on spaCy's English transformer parser (en_core_web_trf), handling morphologically rich, non-English, or code-switched conversations requires dedicated future evaluation.
  • Fixed Budgets & Scaling: Passing a fixed top-$k$ (e.g., 5) raw episodes to the reader can cut off evidence needed for sprawling multi-session or complex temporal reasoning. Furthermore, query-time graph operations still scale with overall conversation history size.
  • Untested Beyond Chat: While the authors note that mention-incidence graphs should naturally extend to coding assistant logs or multi-agent action traces, testing beyond conversational QA is left for future work.

Summary updated

BibTeX
@inproceedings{huang2026mgmem,
  author = {Junhong Huang and Xin Tong and Jun Xia},
  title = {{MGMem: An Efficient, Deterministic, and Provenance-Preserving Framework for Long-Horizon Agent Memory}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=a9wmN45qso},
}
Figure