Papers
Topics
Authors
Recent
Search
2000 character limit reached

TriMem: Tri-Granularity Lifelong Memory

Updated 5 July 2026
  • TriMem is a tri-granularity lifelong memory architecture that captures dialogue history through raw segments, extracted facts, and synthesized entity profiles.
  • It enhances memory fidelity, retrieval efficiency, and reasoning depth by combining traceable raw dialogue with semantically enriched profiles.
  • It leverages TextGrad-based prompt optimization to adaptively refine its extraction and profiling processes without updating model parameters.

TriMem is a tri-granularity lifelong memory architecture for LLM agents that stores dialogue history in three coexisting forms: raw dialogue segments anchored by source identifiers, extracted atomic facts, and synthesized entity profiles. The design is motivated by the claim that reliable long-term interaction requires a memory system that can simultaneously preserve evidential fidelity, support efficient retrieval, and enable deeper reasoning over accumulated interactions. Rather than treating extracted facts as the sole memory substrate, TriMem couples retrieval-oriented compression with traceable raw evidence and higher-level semantic synthesis, and it further uses TextGrad-based prompt optimization to evolve its extraction and profiling behavior without parameter updates (Sun et al., 19 May 2026).

1. Motivation and problem setting

TriMem is positioned against the standard fact-centric paradigm for agent memory: dialogue is segmented, atomic facts are extracted with a static prompt, the most similar facts are retrieved, and those facts are injected into downstream reasoning. The paper argues that this pipeline is efficient but structurally limited in three ways. First, fact extraction is lossy; the reported analysis states that extracted facts incur about 14.5% more information loss than original dialogue. Second, isolated facts are weak substrates for questions that require multi-fact fusion, behavioral inference, or entity understanding. Third, static prompts do not maintain consistent extraction granularity across heterogeneous conversations, so semantically important regularities may be omitted or represented inconsistently (Sun et al., 19 May 2026).

These limitations define TriMem’s central problem formulation. The architecture assumes that a single representation granularity cannot jointly optimize storage fidelity, retrieval efficiency, and reasoning depth. A plausible implication is that memory design should be decomposed along these three objectives rather than forcing one compressed representation to satisfy all of them. In that sense, TriMem is not merely a retrieval pipeline but a representational redesign of lifelong dialogue memory.

2. Three coexisting memory granularities

TriMem maintains three linked memory levels, each serving a different role in the overall system.

Granularity Primary role Key linkage
Raw dialogue segments Storage fidelity Source dialogue identifiers
Extracted atomic facts Efficient retrieval Embedded and indexed entries
Synthesized profiles Holistic reasoning Grouped by entity/person

The first level is raw dialogue segmentation. Historical dialogue is partitioned into overlapping windows using a sliding-window procedure. The overlap is intended to preserve coherence across window boundaries. Each extracted memory entry includes a source_dialogue_ids field, allowing later retrieval of the original dialogue lines rather than only their compressed representation. This source anchoring is the mechanism by which TriMem preserves traceability and exact evidence (Sun et al., 19 May 2026).

The second level is structured atomic fact extraction. The extraction prompt is described as a multi-dimensional schema rather than a free-form summary prompt. Reported fields include lossless_restatement, keywords, timestamp, location, persons, entities, topic, and source_dialogue_ids. The prompt is further constrained to skip greetings, thank-yous, and compliments; extract only novel factual information; resolve pronouns to actual names; convert relative times to absolute dates; preserve exact names, numbers, and entities; and identify described-but-unnamed entities using world knowledge. These fact entries are embedded with Qwen3-embedding-0.6b and indexed for similarity retrieval, with a retrieval cap of 25 entries (Sun et al., 19 May 2026).

The third level is entity profile synthesis. Facts are grouped by entity or person, and a profile prompt aggregates them into higher-level descriptions that cover identity, personality traits, hobbies and interests, career or education, values, beliefs or spirituality, relationships, life events, and preferences. This profile layer is intended to capture semantic regularities that would otherwise have to be inferred on demand from scattered fact fragments. The core claim is that profile construction externalizes multi-hop synthesis into memory maintenance itself rather than leaving all abstraction to the answering model.

3. Retrieval, source recovery, and reasoning

TriMem’s inference path couples the three levels rather than using them independently. The storage phase windows raw dialogue, extracts atomic facts, assigns source identifiers, and updates entity-grouped profile structures. The retrieval phase first analyzes the user question to generate a focused search query, then retrieves relevant atomic facts by semantic similarity. From the retrieved facts, the system can recover both the original raw dialogue segments through source IDs and the corresponding synthesized profiles through entity or person IDs. The reasoning phase then answers using a context bundle that includes retrieved facts, raw-source details, and profiles (Sun et al., 19 May 2026).

This workflow assigns distinct functional roles to the three levels. Atomic facts provide the primary retrieval index and reduce noise relative to full-context retrieval. Raw dialogue is reintroduced when omitted modifiers, exact wording, names, numbers, or other fine-grained details become necessary. Profiles are used when the target question depends on trait inference, preference synthesis, or relationship-level understanding rather than direct fact lookup. The architecture therefore uses compression for targeting, source recovery for evidential precision, and synthesis for semantic depth.

The paper’s prompt design makes these interactions explicit. Query planning prompts extract keywords, entities, time, and location from the question in order to generate minimal targeted search queries. The answering prompt instructs the model to answer from context and profiles, infer rather than say “unknown,” use world knowledge when descriptions imply named entities, and remain extremely concise. Qualitative examples illustrate semantic normalization: “25 minutes on, 5 minutes off” is normalized to Pomodoro technique, and “theme song from the wizard movie” is mapped to Harry Potter theme song / John Williams. These examples are used to show that a static literal fact store is insufficient for semantically normalized recall.

4. TextGrad-based prompt evolution

A distinctive feature of TriMem is that its lifelong adaptation occurs through prompt optimization rather than weight updates. The optimized prompt set consists of the extraction prompt and the profile prompt, and the system uses answer-quality feedback to iteratively refine both. TextGrad supplies textual gradients—natural-language edit suggestions—which are then applied to rewrite the prompts. The paper characterizes this as lifelong evolution without parameter updating (Sun et al., 19 May 2026).

The practical effect is targeted adaptation of the memory interface. If the system misses specific details, the extraction prompt is refined; if the profiles remain shallow or fail to capture behavior and personality, the profile prompt is revised. The appendix describes a prompt-evolution meta-prompt that ingests the current prompts and an evaluation JSON, identifies systematic failure patterns, rewrites only the relevant prompt sections, preserves output schema and examples, and makes small targeted additions per round. A senior model, Claude Opus 4.6, is used for failure analysis, and the paper reports 4 optimization rounds.

This optimization strategy reflects a broader design choice. TriMem treats memory quality as partly a prompt-engineering problem: the granularity, normalization, and synthesis behavior of the memory system can be improved through iterative instruction refinement. A plausible implication is that TriMem separates backbone capability from memory-formation policy more sharply than systems that rely on finetuning.

5. Evaluation, results, and ablations

TriMem is evaluated on LoCoMo and PerLTQA, using both high-capability and efficient backbones: GPT-4.1-mini, GPT-4o, GPT-5-nano, Qwen3-8B, and Llama-3.1-8B-Instruct. Compared baselines include Naive RAG, Mem0, MemoryOS, A-Mem, LightMem, SimpleMem, xMemory, and Full-Context. The main reported metrics are BLEU, F1, and, on PerLTQA, an LLM-judged correctness score using GPT-4.1-mini as evaluator. The paper also reports retrieval Hit@k, token cost or retrieved context length, and ablations over retrieval count and window size (Sun et al., 19 May 2026).

On LoCoMo, TriMem achieves the best average performance across all tested backbones. Reported averages include 43.79 BLEU / 54.26 F1 for GPT-4.1-mini, 42.73 / 50.23 for GPT-4o, 46.96 / 57.04 for GPT-5-nano, 40.66 / 49.65 for Qwen3-8B, and 31.37 / 38.70 for Llama-3.1-8B-Instruct. The paper emphasizes that these results are obtained with around 1.2k retrieved tokens, substantially below full-context baselines.

On PerLTQA, TriMem leads across major subtasks for both efficient backbones. For Qwen3-8B, the reported scores are 92.46 on Profile, 83.23 on Social Relationship, 85.72 on Events, and 55.79 on Dialogues. For Llama-3.1-8B-Instruct, the corresponding scores are 92.17, 82.28, 78.17, and 45.01. The pattern is especially strong on profile-centric and relational reasoning, which is consistent with the intended role of synthesized profiles.

The ablations are closely aligned with the architectural claims. Removing the profile layer degrades performance, supporting the claim that profiles matter for deep reasoning. Removing raw dialogue also degrades performance, supporting the claim that source-linked raw evidence matters for fidelity and omitted detail recovery. Performance improves with prompt evolution up to 4 rounds and then degrades when over-refined. Best performance is observed at top-25 retrieved entries. Generating a focused search query before retrieval improves performance despite adding retrieval time. For segmentation, a window size of 40 with stride 38 is reported as the best tradeoff.

TriMem’s main conceptual claim is that lifelong agent memory should not be reduced to a single fact store. Raw dialogue, atomic facts, and synthesized profiles are treated as complementary representations linked by source identifiers and entity structure. This directly challenges a common simplification in agent-memory design: the assumption that once facts have been extracted, the original dialogue can be discarded. TriMem instead assumes that compression, traceability, and synthesis are distinct operations that should remain simultaneously available (Sun et al., 19 May 2026).

This framing also clarifies what TriMem is not. It is not a full-context replay system, because it uses atomic facts as the primary retrieval substrate and only recovers raw dialogue when precise evidence is needed. It is not a pure fact-memory system, because profiles are explicitly introduced to support reasoning over dispersed evidence. And it is not a parameter-updated memory learner, because its adaptation mechanism is prompt evolution rather than finetuning.

The name should also be distinguished from TRIME, “Training with In-batch Memories,” which is a training framework for memory-augmented LLMs rather than a lifelong agent-memory architecture. TRIME uses in-batch examples as accessible memory during optimization and targets train–test alignment for local, long-term, and external memory in language modeling and machine translation (Zhong et al., 2022). TriMem, by contrast, operates over accumulated dialogue history for long-term agent interaction and centers its contribution on tri-granularity storage, retrieval, and reasoning (Sun et al., 19 May 2026). This distinction matters because both works address “memory,” but at different system layers: TRIME is a model-training method, whereas TriMem is an agent-memory architecture.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (2)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to TriMem.