PLUR Blog · 2026-07-13

How Do I Store and Recall Facts an AI Agent Has Learned Over Time?

How Do I Store and Recall Facts an AI Agent Has Learned Over Time?

Every time you tell an AI agent something — “I prefer TypeScript,” “the deploy script is in ~/scripts,” “never force-push to main” — that fact exists only in the current session’s context window. When the session ends, the context is gone, and the next session starts from scratch. You re-explain the same preferences, re-state the same constraints, re-correct the same mistakes. The solution is an external memory layer with four operations: learn (write a fact), recall (retrieve relevant facts), forget (delete an outdated fact), and feedback (rate whether a memory was useful, so retrieval quality improves over time). This is not RAG — RAG retrieves from a fixed external corpus at query time and cannot learn from interactions. Agent memory is read-write: the agent writes what it learns, retrieves what is relevant before acting, and improves through feedback. Zhang et al. (arXiv:2404.13501) identified memory as “the key component to support agent-environment interactions” and the foundation of “self-evolving capability” — the ability to improve through experience rather than retraining.

The pain: why facts don’t stick

Large language models are stateless. Each API call is independent: the model receives a prompt, generates a response, and forgets everything. The context window — the token limit on a single request — is the only “memory” the model has within a session, and it is volatile in three ways:

Session boundary. When the session ends, the context window is discarded. Everything the agent learned during that session — corrections, preferences, decisions — is gone. The next session starts as a blank slate.

Context eviction. Even within a single session, the context window has a fixed size. As the conversation grows, earlier messages are evicted or compressed. The agent forgets what it learned at the beginning of the session.

No write-back. The model cannot modify its own weights based on what it learns. Training data is baked in at fine-tuning time; everything else is ephemeral. Fine-tuning can encode facts into weights, but it is expensive, irreversible, and cannot prove erasure — making it unsuitable for personal data subject to GDPR’s right to be forgotten (Art 17, gdpr-info.eu/art-17-gdpr).

Without a memory layer, the agent has no mechanism to persist what it learns. Packer et al. (arXiv:2310.08560) identified this as the core limitation of LLMs in extended interactions: “limited context windows, hindering their utility in tasks like extended conversations and document analysis.”

The architecture: memory as a separate module

The research literature converges on a single principle: memory should be a separate module from the model, with its own storage, its own operations, and its own lifecycle. The agent reads from memory before acting and writes to memory after learning.

Sumers et al. (arXiv:2309.02427) proposed CoALA (Cognitive Architectures for Language Agents), a framework describing agents with “modular memory components, a structured action space to interact with internal memory and external environments, and a generalized decision-making process.” The memory is modular — it has its own structure, its own operations, and its own lifecycle — separate from the model’s parameters or the context window.

Zhang et al. (arXiv:2404.13501) organized the field around memory as the basis for “self-evolving capability,” identifying multiple memory operations: read (retrieve relevant memories), write (store new memories), reflect (consolidate observations into higher-level abstractions), and forget (decay or discard irrelevant memories). These operations form a complete lifecycle — not just storage, but active management.

The four operations: learn, recall, forget, feedback

1. Learn (write)

The agent stores a fact as a discrete, addressable record — not as a vector blob, not as a line in a log, but as a structured entry with a statement, a type, provenance, and metadata. The key properties:

Mem0 (github.com/mem0ai/mem0) provides an add() API that extracts facts from conversations using an LLM and stores them as discrete memories. Its April 2026 algorithm update introduced “single-pass ADD-only extraction” — one LLM call per interaction, no UPDATE/DELETE — so memories accumulate and nothing is overwritten. Entity linking connects related facts across memories for retrieval boosting.

Letta (github.com/letta-ai/letta, formerly MemGPT) stores memory in “core memory blocks” — editable text blocks the agent reads and writes during a conversation. The agent can call core_memory.replace() to update a block mid-conversation. Letta’s README describes agents that “learn and self-improve over time” through this mechanism.

PLUR (github.com/plur-ai/plur) stores facts as typed “engrams” — plain-text YAML entries with activation strength (ACT-R decay model), feedback signals, scope, and polarity (do vs. don’t). The plur_learn call takes a statement, type, domain, and scope. Engrams are stored together in a file (engrams.yaml) you can open in any editor, put under version control, and carry between machines.

LangMem (github.com/langchain-ai/langmem) provides “memory management tools that agents can use to record and search information during active conversations” plus a “background memory manager that automatically extracts, consolidates, and updates agent knowledge.”

2. Recall (retrieve)

Before acting, the agent retrieves memories relevant to the current context. This is not a full-text dump — it is a ranked retrieval based on semantic similarity, keyword matching, and contextual relevance.

Mem0’s April 2026 update introduced “multi-signal retrieval” — semantic, BM25 keyword, and entity matching scored in parallel and fused. Letta retrieves by reading core memory blocks into the context window. PLUR uses BM25 + BGE embeddings + reciprocal rank fusion, fully local with zero API calls. LangMem provides a “core memory API that works with any storage system” with search tools the agent calls during conversations.

3. Forget (delete)

Memory that grows without bound is its own problem — an agent with 10,000 memory entries retrieves noise alongside signal. Forgetting is not a bug; it is a feature that keeps the memory store useful.

Mem0’s ADD-only model means memories accumulate without automatic deletion — you must explicitly call delete() to remove outdated facts. PLUR engrams have activation strength that decays over time (ACT-R model) and can be explicitly retired via plur_forget. LangMem’s background memory manager “automatically extracts, consolidates, and updates agent knowledge,” handling consolidation.

4. Feedback (improve)

The memory system learns which memories are useful. When the agent acts on a recalled memory and the outcome is positive, that memory is reinforced. When the outcome is negative, the memory is demoted. Over time, retrieval quality improves.

PLUR engrams support explicit feedback signals (positive/negative/neutral) via plur_feedback, and co-access edges form automatically when engrams are recalled together. This creates a memory store that gets better with use — not through retraining, but through feedback-driven relevance tuning.

The memory lifecycle in practice

You correct your agent  →  learn() stores an engram   →  YAML on your disk
Agent starts a session  →  recall() injects relevant  →  agent remembers
Agent acts on a memory  →  feedback() rates it        →  quality improves
Memory is outdated      →  forget() removes it        →  provably erased
Unused memories         →  activation decays          →  fade from injection

The lifecycle is a loop, not a pipeline. The agent learns, recalls, acts, receives feedback, and learns again — improving through experience without retraining. Zhang et al. (arXiv:2404.13501) describe this as the basis for “self-evolving capability”: the agent improves through its own experience, not through weight updates.

Connecting memory to any agent: MCP

The Model Context Protocol (MCP, specification 2025-11-25, modelcontextprotocol.io) is an open protocol — JSON-RPC 2.0 based, inspired by the Language Server Protocol — that standardizes how LLM applications connect to external data sources and tools. An MCP-compatible memory server gives any MCP-compatible agent runtime access to persistent memory operations.

The agent calls memory tools (learn, recall, forget, feedback) as part of its normal workflow. Memory is not stuffed into the context window — it is retrieved on demand, like a database query. The memory store persists across sessions, across agent restarts, and across model switches. Open engram implementations like PLUR expose memory over MCP, so any agent runtime — Claude Code, Hermes, OpenClaw, Cursor — can read from and write to the same memory store.

ToolLearn APIRecall APIForget APIMemory formatMCP support
PLURplur_learn()plur_recall() / plur_inject()plur_forget()Plain-text YAML engramsYes (native)
Mem0m.add()m.search()m.delete()Extracted facts + entitiesVia wrapper
Lettacore_memory.replace()Block read into contextBlock editText blocksVia Letta Agent
LangMemMemory toolssearch()Store deleteLangGraph storeVia LangGraph
Cogneecognee.add()cognee.search()Graph deleteKnowledge graphVia Graphiti MCP

(GitHub stars as of Jul 2026: Mem0 ~60.8K, Cognee ~27.9K, Letta ~23.8K, PLUR ~225. Star counts verified via GitHub API.)

What to store

Not everything belongs in memory. The signal-to-noise ratio matters — a memory full of irrelevant observations is as useless as no memory at all. Store:

  1. Corrections — “don’t do X, do Y instead.” The highest-value memory type; prevents repeating mistakes.
  2. Preferences — language choices, formatting conventions, tool preferences. Injected at the start of every relevant session.
  3. Procedures — validated workflows, successful strategies, reusable code patterns. Compounds agent capabilities over time.
  4. Key facts — project context, environment state, API endpoints. Referenced repeatedly but does not fit in the context window.
  5. Decisions and rationale — what was decided and why. Prevents contradiction and enables the agent to reconstruct its reasoning.

FAQ

How do I store and recall facts an AI agent has learned over time? Use an external memory layer with four operations: learn (write a fact), recall (retrieve relevant facts), forget (delete outdated facts), and feedback (rate whether a memory was useful). The agent writes facts as discrete, addressable records outside the model’s context window, retrieves relevant memories before acting, and improves retrieval quality through feedback signals. The memory store persists across sessions, context window evictions, and model switches. Research from Zhang et al. (arXiv:2404.13501) identifies memory as “the key component” for agent self-evolution. Tools like PLUR, Mem0, Letta, and LangMem provide these operations; MCP-compatible memory servers connect them to any agent runtime.

What is the difference between RAG and agent memory? RAG retrieves from a fixed external corpus at query time — it is read-only and cannot learn from interactions. Agent memory is read-write: the agent stores what it learns, retrieves what is relevant, and improves through feedback. RAG answers “what is in this document?”; agent memory answers “what has this agent learned from experience?”

Can an AI agent learn without fine-tuning? Yes. External memory lets the agent learn from experience by storing corrections, preferences, and procedures as discrete records it retrieves before acting. No weight updates are needed. Shinn et al. (arXiv:2303.11366) demonstrated this with Reflexion: agents that maintain an episodic memory buffer of past attempts produce significantly better results than agents without memory, through “verbal reinforcement learning” — reinforcing the agent through linguistic feedback stored in memory, not through weight updates.

How does an AI agent recall the right memory? Through ranked retrieval combining semantic search (embeddings capture meaning beyond keywords), keyword search (BM25 catches exact-term matches), and reciprocal rank fusion (combines both scores). Some systems add activation decay (memories that haven’t been accessed recently lose retrieval strength) and feedback signals (memories that were useful are reinforced). The goal is not to dump all memories into the context window, but to retrieve the few that are relevant to the current task.

Can I delete a specific fact an AI agent remembers? Yes — if the memory is stored as discrete, addressable records outside the model. Remove the entry and the memory is verifiably gone — inspect the store to confirm. This is the basis for real (not best-effort) erasure under GDPR Art 17. You cannot prove erasure from model weights (Bourtoule et al., arXiv:1912.03817).

What is the memory lifecycle in AI agents? Learn (write a fact), recall (retrieve relevant facts before acting), feedback (rate whether the memory was useful), and forget (delete or decay outdated memories). The lifecycle is a loop — the agent learns, recalls, acts, receives feedback, and learns again — improving through experience without retraining.