ModelRefs / Long-Term Memory (RAG) — Agent Pattern
Long-Term Memory (RAG) — Agent Pattern
Persist embedded facts in a vector store and retrieve relevant ones at inference time. Standard production memory tier.
Overview
Write facts about users, projects, and domain knowledge as embeddings in a vector store. On each turn, retrieve top-K relevant memories and inject them into the prompt. Standard production memory tier.
When to use it: Your agent needs to remember facts across sessions or users.
Pattern details
| Pattern class | memory |
|---|---|
| Difficulty | intermediate |
| Autonomy | autonomous |
| Also known as | semantic memory, rag memory |
| Last reviewed | 2026-06-07 |
Known failure modes
- Memory pollution — Wrong or contradictory memories accumulate. Mitigation: Add a write-validator and dedupe/merge on write.
- Over-retrieval — Irrelevant memories crowd the prompt. Mitigation: Tune K and use a reranker.
When not to use it
- Storing every turn as a memory (use selective write-back).
Continue your research
Use these connected ModelRefs sections to compare alternatives, inspect implementation paths, and review the evidence and governance boundaries relevant to Long-Term Memory (RAG) — Agent Pattern.
Frequently asked questions
When should I use the Long-Term Memory (RAG) agent pattern?
Your agent needs to remember facts across sessions or users.
What are common failure modes of Long-Term Memory (RAG)?
Memory pollution • Over-retrieval
Is Long-Term Memory (RAG) production-ready?
Yes when paired with the safety controls and observability hooks documented on the pattern page.