Memory types · Flagship guide

Long-Term Memory for AI Agents

Long-term memory for AI agents is external storage that persists facts, preferences and conversation history across sessions — implemented with vector databases, knowledge graphs or memory frameworks like Engram, Mem0, Zep and Letta.

4
LTM subtypes
6
Pipeline stages
8+
Frameworks

LTM pipeline

1
Extract
Salient facts
2
Embed
Vectors
3
Store
Persist
4
Retrieve
Search
5
Consolidate
Promote

Definition

What is long-term memory in AI agents?

Long-term memory (LTM) is information an agent retains beyond the current turn or session and can retrieve later.

LTM is distinct from short-term/working memory (the context window), parametric memory (model weights) and RAG (static document corpora). A user who said “I prefer dark mode” last Tuesday should still get dark-mode defaults today — that persistence is LTM.

Short-term memory · Memory vs RAG

Motivation

Why agents need long-term memory

Stateless LLMs start every session blank — without LTM, agents repeat questions, cannot personalize and eventually overflow context.

With LTM: personalization across sessions, conversational continuity, knowledge accumulation and lower per-turn token cost because history lives in external stores, not the prompt.

Why AI agents need memory

Comparison

Long-term vs short-term memory in agents

DimensionShort-termLong-term
ScopeCurrent task / sessionCross-session
LocationContext windowVector DB, graph, KV
VolatilityCleared when session endsConsolidated, durable
PromotionExtraction → consolidation

Short-term vs long-term · Memory consolidation

Mechanism

How long-term memory works

The LTM pipeline runs extract → embed → store → retrieve → consolidate → update/forget.

1
Extract
Decide what to keep
2
Embed
Create searchable vectors
3
Store
Persist to backend
4
Retrieve
Inject before response
5
Consolidate
Promote & forget

How AI memory works (full loop) →

Storage

How long-term memory is stored

Vector databases index embeddings for semantic similarity; knowledge graphs model relationships and time; hybrid stacks combine both.

Engram runs as a vector-native memory layer on Weaviate — extraction, deduplication and retrieval on the same platform, no separate memory store. Mem0 and Supermemory use managed vector APIs. Zep uses temporal knowledge graphs. DIY paths use Redis, Postgres/pgvector or Pinecone.

Vector databases · Knowledge graphs · Writing memories

Frameworks

Long-term memory frameworks and tools

NeedFrameworkPattern
Weaviate stackEngramVector-native layer
Managed APIMem0Per-user vector memory
Temporal factsZepGraph + invalidation
Virtual pagingLettaMemGPT tiering
LangGraphLangMemCheckpointer + store
Knowledge graphCogneeStructured KG memory

Best AI memory tools · Frameworks hub

Research

Papers on LLM long-term memory

MemGPT (Packer et al., 2023) introduced OS-style paging between context and deep store. MemoryBank explored persistent LLM memory. 2024–2025 surveys catalog agent-memory architectures.

Virtual context & MemGPT

Build

How to build long-term memory

Fastest POC paths: Engram on Weaviate Cloud, Mem0 API, or LangMem on LangGraph. Full implementation covers store selection, extraction, retrieval ranking and eviction.

Build long-term memory guide

Evaluation

Long-term memory benchmarks

LOCOMO tests long-conversation recall; LongMemEval tests cross-session recall.

Run both on your domain queries before choosing Engram vs Mem0 vs Zep vs DIY. Good LTM hits high recall at acceptable latency and token cost.

LOCOMO benchmark · LongMemEval

Decision

Long-term memory vs fine-tuning vs RAG

ApproachUpdatesBest for
LTMPer-session, dynamicUser facts, preferences
Fine-tuningBatch, slowDomain style, static knowledge
RAGDocument corpusOrg docs, manuals

Memory vs RAG · Memory vs fine-tuning

FAQ

Frequently asked questions

What is long-term memory in AI?

Long-term memory is information an AI agent persists in external storage across sessions — facts, preferences and conversation history retrievable later. See short-term vs long-term.

What is the difference between short-term and long-term memory in AI agents?

Short-term memory lives in the context window and clears when the session ends. Long-term memory persists in vector DBs, graphs or KV stores across sessions. See short-term vs long-term.

How do LLMs store long-term memory?

LLMs don't store LTM in weights — agents extract facts after each turn, embed them, and write to external stores like vector databases or knowledge graphs. See writing memories.

What is the best long-term memory framework?

Depends on stack: Engram for Weaviate, Mem0 for managed API, Zep for temporal graphs, Letta for paging, LangMem for LangGraph. See best AI memory tools.

Does Claude have long-term memory?

Claude's built-in memory is product-specific. For custom agents, implement external LTM via Engram, Mem0, Zep or your own vector store. See persist conversation memory.

How do I add long-term memory to LangGraph?

Use LangMem for native checkpointer integration, or Mem0/Zep as external APIs. See LangMem and build long-term memory.

Is a vector database the same as long-term memory?

No — a vector DB is the storage backend. LTM is the full pipeline: extract, embed, store, retrieve, consolidate and forget. See vector databases for memory.

What is Weaviate Engram?

Engram is a vector-native memory layer on Weaviate — dynamic writes and retrieval on the same platform without a separate memory store. See Engram explained.

How do I test long-term memory quality?

Run LOCOMO for long-conversation recall and LongMemEval for cross-session recall on your domain queries. See evaluation hub.