TrajWiki: Source-Grounded Memory Trajectories for Long-Horizon Dialogue Agents

Jingyu Sun, Yuyang Xue, Mingyang Li, Zhengtao Yao, Jiachen Li, Yang Cui, Wenhao Cai, Haozhe Liu, Fangying Wang, Magdalene Katharina Montgomery, Syed Murtuza Baker, Hongpeng ZhouNeurIPS 2026

TL;DR

Talking to an AI agent over weeks or months usually reveals a glaring flaw: its memory is either a messy pile of isolated sticky notes or an overwritten whiteboard that forgets why it changed its mind. TrajWiki gives conversational agents a structured, "git-commit-style" history of how facts evolve, compiled into an interlinked personal Wikipedia. The result is an agent that remembers long-term context better, catches contradictions, and lets you audit the exact conversation turns behind every belief.

What Problem Does This Paper Address?

Large Language Models (LLMs) have finite context windows—you can’t just paste six months of chat logs into every prompt without breaking the bank and confusing the model. To fix this, engineers give agents external memory using Retrieval-Augmented Generation (RAG): the system summarizes chats into notes and fetches relevant ones later.

However, conventional agent memory hits two walls in long-term conversations:

  1. Amnesia of evolution: Most systems overwrite old facts when things change. If you tell an agent you’re vegan in January, and in May say you eat fish now, standard memory just overwrites "vegan" with "pescatarian." It loses the timeline, the provenance (which exact message triggered the update), and the ability to answer temporal questions.
  2. Retrieval fragmentation: As thousands of tiny memory notes pile up, flat similarity search breaks down. Asking a complex question that spans multiple sessions ("How have my dietary habits and workout routines changed since my knee injury?") requires piecing together scattered fragments that standard search misses.
Figure 1: Comparison of conventional agent memory and TrajWiki’s source-grounded trajec- tory memory and Memory Wiki. Conventional memory retains only the current belief and retrieves flat, isolated memories. TrajWiki preserves source-grounded update trajectories and structures them into a Memory Wiki, enabling reasoning over how facts evolve, conflict, and relate across long- horizon dialogue.

Methods

Instead of treating memories as static database rows, TrajWiki separates memory into three distinct layers: evolution, organization, and hierarchical retrieval.

Figure 2: Overview of the TrajWiki architecture. TrajWiki converts dialogue history into source- grounded memory trajectories, compiles them into a persistent and interlinked Memory Wiki, retrieves evidence hierarchically from wiki pages to trajectories and source messages, and generates answers grounded in the retrieved evidence. The Memory Wiki serves as a compounding knowledge artifact, maintaining cross-references, flagged conflicts, and synthesized evidence as memory accumulates over time.
  • Provenance-Aware Memory Trajectories: Every dialogue exchange is turned into an immutable "snapshot" linked to the raw messages. Related snapshots are chained into append-only trajectories (capped at length $m=15$). Instead of deleting outdated info, TrajWiki applies explicit operations—ADD, REVISE, and DEPRECATE—preserving the entire evolutionary path of a belief.
  • Persistent Memory Wiki: To prevent trajectories from becoming a fragmented mess, an intermediate layer compiles them into structured, interlinked Wiki pages (index, entity, topic, and inventory pages for countable lists). Crucially, Wiki summaries don't replace the raw facts; they act as a semantic map pointing back to the underlying trajectories.
  • Hierarchical Retrieval & Grounded Synthesis: At query time, the agent doesn't search raw chat logs. It routes the query to the top-$t$ Wiki pages, follows their links to gather candidate trajectories, selects the best top-$k$ trajectories (balancing relevance, diversity, and non-redundancy), and unpacks them right down to the original timestamps and messages to generate a strictly source-grounded answer.

Datasets

The authors evaluate TrajWiki (without training any new models) across open-source (Qwen3-8B, Qwen3-32B) and closed-source (GPT-4o-mini) backbones on two existing benchmarks:

  • LoCoMo: An open-domain, very long-term conversational QA benchmark testing single-hop, multi-hop (cross-session), temporal, and world-knowledge reasoning.
  • MedMT-Bench: A high-stakes, multi-turn medical dialogue benchmark used here as a stress test. The authors evaluate subsets testing Long-Context Memory (LCMU), Resistance to Contextual Interference (RCI), and Information Contradiction (IC)—catching conflicts between patient history and new statements.

Key Insights and Ideas

  • Summaries are great maps, terrible destinations: In ablation studies, relying only on the Wiki summaries yielded 0.000 gold-source reference coverage. Summaries lose granular details, proving that the Wiki must serve as a router to raw evidence rather than a replacement for it.
  • Wiki routing drastically shrinks the search haystack: Searching trajectories directly without the Wiki layer forces the system to sift through 2.35× more candidates (130.4 vs. 55.6 on average) while dropping gold-reference coverage from 61.0% to 35.6%. Structure beats brute-force search.
  • Gradual evolution doesn't mean semantic drift: Analyzing embeddings along trajectories showed that while long trajectories naturally cover a wider topic span from start to finish, adjacent updates remain tightly coherent—meaning the system tracks smooth narrative evolution rather than randomly gluing facts together.

Key Results

TrajWiki consistently outperforms strong baselines—including Full Context, Naive RAG, LangMem, A-MEM, and Mem0—across backbones:

  • Multi-Hop Mastery: On LoCoMo with GPT-4o-mini, TrajWiki achieves 59.44% accuracy on multi-hop questions, leaping nearly 20 percentage points ahead of the strongest memory baseline, Mem0 (40.07%), and beating Full Context (32.98%).
  • Catching Contradictions: On MedMT-Bench's Information Contradiction test (GPT-4o-mini), where baselines crumble (Full Context hits just 7.47%, Mem0 hits 12.17%), TrajWiki reaches 17.68% pass accuracy. With Qwen3-32B, it leads all three medical subsets (33.42% LCMU, 27.33% RCI, 15.34% IC).
  • Compact Auditing: In a preliminary 24-case human audit, TrajWiki's diagnostic packets required 4.51× fewer tokens to inspect than full dialogues (5.93K vs. 26.74K) while helping auditors better localize where pipeline failures occurred.

Limitations and Future Work

  • Upfront Token Tax: Building trajectories and maintaining a Wiki isn't cheap. Out of 43.28M deployment tokens used in the LoCoMo run, 23.71M went into memory construction (vs. just 6.92M for answering). While this cost amortizes over many future queries, it is heavy upfront.
  • Fragility to Bad Formatting: Because the pipeline relies heavily on structured LLM outputs to manage edits and Wiki links, smaller or less compliant models can trigger expensive repair fallbacks.
  • The "Telephone Game" Effect: Repeated summarization can dull the salience of specific facts. A diagnostic funnel on 200 queries showed that while 100% of gold evidence entered raw memory and ~62% survived retrieval, only 33.6% made it into the final cited answer support—highlighting a clear bottleneck in how LLMs synthesize retrieved evidence. Future work is not explicitly detailed beyond positioning evolving, source-grounded structures as a foundation for more reliable long-term agents.

Summary updated

Abstract

Large language model agents have shown strong capabilities in generating coherent and contextually appropriate responses, yet robust long-horizon dialogue remains limited by the lack of external memory that is traceable, updatable, and diagnostically transparent. Existing memory-augmented agents often store memories as isolated records or overwritable states, making it difficult to preserve how information originates, evolves, conflicts, or becomes obsolete over time. We propose TrajWiki, a trajectory-based memory framework for long-horizon conversational agents. Instead of treating memory as static entries, TrajWiki represents each memory as a source-grounded evolution trajectory, maintained through immutable episodic snapshots and claim-level operations such as ADD, REVISE, and DEPRECATE. To reduce fragmentation and retrieval cost, TrajWiki further introduces Memory Wiki, a persistent intermediate layer that incrementally compiles dialogue history into structured and interlinked wiki pages capturing salient entities, events, quantities, topics, and conflicts. At inference time, queries are routed hierarchically from relevant wiki pages to linked memory trajectories, then to corresponding snapshots and source messages for evidence-grounded answer synthesis. Experiments on LoCoMo and MedMT show that TrajWiki improves long-horizon dialogue performance across both open-source and closed-source LLM backbones, while providing greater interpretability and diagnostic visibility into memory evolution, retrieval failures, and answer generation. Code is available at https://github.com/JingyuSunUOE/TrajWiki.
BibTeX
@inproceedings{sun2026trajwiki,
  author = {Jingyu Sun and Yuyang Xue and Mingyang Li and Zhengtao Yao and Jiachen Li and Yang Cui and Wenhao Cai and Haozhe Liu and Fangying Wang and Magdalene Katharina Montgomery and Syed Murtuza Baker and Hongpeng Zhou},
  title = {{TrajWiki: Source-Grounded Memory Trajectories for Long-Horizon Dialogue Agents}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=26nRwIZFcb},
}
Figure