LLM Agent Memory Architecture for Production (2026)

LLM Agent Memory Architecture for Production (2026)

LLM Agent Memory Architecture for Production: The 2026 Guide

Last Updated: November 23, 2026

Every production agent with memory is, underneath, a database that a language model is allowed to write to. That single fact explains most of the failures teams hit: duplicate facts, stale preferences that never expire, contradictions the agent cannot resolve, and, since late 2025, injected “memories” that hijack later sessions. Getting the LLM agent memory architecture right in 2026 is less about choosing a vector store and more about applying database discipline to an untrusted writer. The tooling finally makes this practical. Anthropic’s memory tool is stable, OpenAI ships server-side compaction, Zep’s Graphiti models facts on two timelines, and Letta now versions agent memory in git. Yet the benchmarks vendors quote disagree by double digits on the same dataset. This guide gives you a vendor-neutral reference architecture, the read and write paths in detail, a consolidation design, and a threat model for memory poisoning.

What this covers: the five-plane reference architecture, read-path scoring with worked numbers, the write pipeline as a transaction, consolidation and “sleep-time” processing, an honest look at Mem0, Zep, Letta and LangGraph benchmarks, failure modes, and a production checklist.

Context and Background

Agent memory research has a clear lineage. Park et al.’s Generative Agents paper (2023) introduced the memory stream, importance scoring and periodic reflection. MemGPT (October 2023, now the Letta framework) reframed the context window as main memory and external storage as disk, with the model paging data between tiers. Both ideas still anchor the field. What changed between 2024 and 2026 is that memory moved from research prototypes into managed products and model APIs.

Three shifts matter for anyone designing an LLM agent memory architecture today. First, context windows grew large enough that “just keep everything” became a tempting baseline, and then evidence on effective context length showed why it fails at scale. Our fact-check on million-token context windows and context rot covers that evidence. Second, the providers built memory primitives directly into their APIs. Anthropic launched context editing and a client-side memory tool on September 29, 2025. OpenAI’s Agents SDK added a compaction session that calls the responses.compact endpoint. Third, the security community named the risk. The OWASP Top 10 for Agentic Applications, published December 9, 2025, lists Memory and Context Poisoning as ASI06.

The incumbent open-source and commercial layers are now well defined. Letta (formerly MemGPT) offers stateful agents with editable memory blocks. Mem0 offers an extraction-and-update memory layer. Zep offers a temporal knowledge graph built on its open-source Graphiti engine. LangGraph separates thread-scoped checkpoints from a cross-thread store. As of November 23, 2026, PyPI lists letta 0.34.12, mem0ai 2.2.1, graphiti-core 0.31.2, zep-cloud 4.1.0, langgraph 1.2.24 and openai-agents 0.25.0. All of these move quickly, so pin versions.

This post focuses on the production LLM agent memory architecture that sits around those tools. If you want a survey of memory system families, our companion piece on long-term memory architectures for AI agents catalogs them. Here the goal is narrower and more operational: how to build memory that stays correct, cheap and safe after a year of continuous writes.

The LLM Agent Memory Architecture: A Five-Plane Reference Design

An LLM agent memory architecture is the set of stores, pipelines and policies that decide what an agent keeps between model calls, how it is retrieved into a bounded context window, how it changes over time, and who may read or erase it. In production it has five planes: working context, session state, long-term stores, consolidation workers and governance.

LLM agent memory architecture reference diagram with five planes: working context, session state, long-term stores, consolidation workers and a governance plane

Figure 1: Five-plane reference LLM agent memory architecture. The orchestrator owns the context budget; long-term stores are written only through the write pipeline; consolidation and governance run off the hot path.

The diagram shows the agent loop at the top. The orchestrator assembles a working context from the system prompt, session state and retrieved memories, then calls the model. Tool results and model outputs flow into a write pipeline instead of straight into storage. Long-term memory is split into a fact store, an episode log and a procedure store. A consolidation worker reads episodes in the background and proposes new facts and procedures. A governance plane holds provenance, retention rules and the erasure index, and it gates every write.

Plane 1 and 2: working context and session state are different things

Working context is the exact token sequence sent on one model call. Session state is everything the agent needs to resume a conversation or task: message history, intermediate tool results, plan state and files. Frameworks have converged on this split. LangGraph persists session state through a checkpointer keyed by thread, while long-term memory lives in a separate store organized by namespace and key. OpenAI’s Agents SDK models session history as a Session object that can be wrapped by a compaction decorator.

The reason to keep these apart is cost and control. Session state can be large and verbose because it is only read on resume. Working context must be small because every token is paid for on every call and competes for attention. The orchestrator’s job is to project session state into working context under a token budget. Compaction, context editing and summarization are the projection tools. Anthropic’s context editing clears stale tool results on the client side. Its compaction feature summarizes the whole conversation server-side near the context limit. Use both deliberately, and treat neither as long-term memory.

Plane 3: long-term memory needs three stores, not one

The cognitive-science split into semantic, episodic and procedural memory survives because it maps onto distinct engineering requirements. LangGraph’s documentation uses the same three categories. Facts about users and entities are semantic memory. Records of what happened during past tasks are episodic memory. Instructions and learned rules are procedural memory.

Each store has a different write pattern and a different failure mode. Facts are updated in place and go stale, so they need validity intervals. Episodes are append-only and grow without bound, so they need tiered retention and summarization. Procedures change behavior globally, so they need review before activation. Putting all three into one vector collection makes it impossible to apply these policies cleanly. A fact store with a temporal model, an episode log with metadata filters, and a small versioned procedure store is the minimum shape that scales.

Plane 4 and 5: consolidation and governance are first-class components

Consolidation is the background process that turns raw episodes into durable facts and procedures, merges duplicates and retires stale entries. Generative Agents triggered reflection when recent importance scores summed past 150. Letta’s sleep-time agents run on a configurable frequency and can use a stronger, slower model because they are off the latency path. OpenAI described a similar background process for ChatGPT, called “dreaming,” in a June 4, 2026 post.

Governance is the plane most teams omit, and it is where this architecture differs from most tutorials. Every memory record carries provenance: which session, which source, which model wrote it, and what trust tier the source had. Retention and erasure rules attach to provenance rather than to individual records. Without this plane you cannot answer the two questions auditors and incident responders ask first. Where did this belief come from? And can you delete everything derived from this user?

Inside the Read Path and the Write Path

In any LLM agent memory architecture, the read path decides what enters the context window. The write path decides what becomes durable. Most production incidents trace back to a write-path shortcut, but most latency budget is spent on the read path. Treat them as separate pipelines with separate SLOs.

Sequence diagram of the agent memory read path from query rewrite through hybrid retrieval, temporal filtering, reranking and token-budget packing

Figure 2: Agent memory read path. Retrieval fans out to the fact, episode and procedure stores in parallel; a temporal filter drops invalid facts before reranking; the packer enforces the token budget and logs exclusions.

The sequence runs left to right. The orchestrator rewrites the user turn into one or more retrieval queries. Queries fan out in parallel to the fact store, the episode log and the procedure store. Results pass through a temporal validity filter, then a reranker, then a packer that fits them into the memory slice of the context budget. The packer writes a retrieval trace before the model call goes out.

Query formation and hybrid retrieval

Embedding the raw user message is the weakest possible query. LongMemEval, the ICLR 2025 benchmark of 500 questions over long chat histories, found that commercial assistants and long-context LLMs lost about 30% accuracy on its tasks. The authors’ fixes are read-path fixes: finer-grained session decomposition, fact-augmented key expansion at indexing time, and time-aware query expansion. In practice that means three things. Index facts and episodes at the granularity you will query. Add extracted entities and dates to each record’s index keys. Rewrite queries to include explicit time constraints when the user says “last week” or “before the migration.”

Hybrid retrieval combines dense vectors with lexical search. Dense search alone confuses semantically similar but factually different records, such as last quarter’s price and this quarter’s price. BM25 catches exact identifiers like order numbers, tool names and error codes. Zep’s paper describes three search functions over its graph: cosine similarity, Okapi BM25 and breadth-first graph traversal from seed nodes. Results are combined with reciprocal rank fusion, maximal marginal relevance or a cross-encoder. Our pgvector vs Qdrant hybrid search ADR covers the storage side of that decision.

Scoring: relevance, recency, importance and trust

Generative Agents scored each memory as the sum of three min-max-normalized terms: recency, importance and relevance, with all weights set to 1. Recency decayed by a factor of 0.995 per game hour since last access. Importance was an LLM rating from 1 to 10 assigned once at write time. Relevance was cosine similarity. That formula is still a reasonable baseline, but production systems need a fourth term: trust.

Trust encodes where a memory came from. A fact confirmed by an authenticated user in a settings page is more trustworthy than one inferred by the model from a pasted web page. A procedure approved by an operator outranks one proposed by a reflection job. Making trust explicit in scoring lets you down-weight low-provenance memories without deleting them.

A worked example makes the decay term concrete. Suppose you use exponential decay with a 14-day half-life. The decay constant is ln(2)/14, about 0.0495 per day. A memory last accessed 30 days ago keeps about 23% of its recency score. One accessed 90 days ago keeps about 1.2%. If your domain is customer support for a fast-moving product, a 7-day half-life might suit you. For a research assistant, months may be right. These half-lives are illustrative starting points, not measured optima; tune them against an evaluation set.

import math
from dataclasses import dataclass

@dataclass
class Candidate:
    relevance: float      # cosine or reranker score, 0..1
    days_since_access: float
    importance: float     # 1..10, assigned at write time
    trust: float          # 0..1, from provenance tier
    valid: bool           # temporal filter result

def score(c: Candidate, half_life_days=14.0, w=(1.0, 0.5, 0.3, 0.7)):
    if not c.valid:
        return None                       # drop invalidated facts before ranking
    lam = math.log(2) / half_life_days
    recency = math.exp(-lam * c.days_since_access)
    importance = (c.importance - 1) / 9
    w_rel, w_rec, w_imp, w_tru = w
    return w_rel*c.relevance + w_rec*recency + w_imp*importance + w_tru*c.trust

The weights in that snippet are placeholders. The point is structural: invalid facts are removed before scoring, not penalized during it. A superseded fact with a high relevance score should never compete with the current one.

Packing under a token budget

The packer solves a small knapsack problem. The hard constraint is the memory slice of the context budget: total window minus system prompt, tool definitions, session excerpt and reserved output. The soft constraints are diversity, source attribution and conflict signalling. A simple greedy pass by score per token works well, with an MMR-style penalty to avoid packing five near-duplicates of the same fact.

Placement matters for cost as well as quality. Stable content such as the system prompt, procedures and long-lived user profile should sit at the start of the prompt where prefix caching can reuse it. Volatile retrieved memories belong after the stable prefix. Our analysis of prompt caching economics across providers shows why a shuffled memory block can quietly destroy cache hit rates.

Every packing decision should be logged. The retrieval trace records which candidates were included, which were excluded for budget, their scores and their provenance. When an agent gives a wrong answer, this trace is how you tell a retrieval miss from a reasoning error. Emit it as spans in your tracing system; our guide to LLM observability architecture covers the plumbing.

Agent-directed versus orchestrator-directed retrieval

There are two ways to trigger reads. In orchestrator-directed retrieval, code fetches memories before every model call. In agent-directed retrieval, the model calls a memory tool when it decides it needs something. MemGPT pioneered the second style, and Anthropic’s memory tool follows it: Claude checks its /memories directory before starting a task and reads files on demand.

Agent-directed retrieval keeps context small and lets the model decide what matters. Its weakness is silent omission: the model may not realize it lacks information. Orchestrator-directed retrieval is predictable and testable but wastes tokens on irrelevant memories. The pragmatic hybrid is to always inject a small, high-trust profile block and the procedure store, then expose search tools for everything else. Letta’s memory blocks follow this pattern: core blocks stay in context while archival memory is searched by tool call.

The Write Path as a Transaction

The write path converts observations into durable memories. It is the part of an LLM agent memory architecture that most teams design last, and it is where the “database written by an LLM” framing pays off. Treat every write as a proposed transaction that must pass validation, conflict detection and authorization before commit.

Flowchart of the agent memory write path showing extraction, PII screening, trust tagging, conflict lookup, ADD UPDATE INVALIDATE or NOOP decisions, quarantine and commit

Figure 3: The memory write path as a transaction. Low-trust candidates go to quarantine; conflicts invalidate rather than delete; every commit records provenance for later erasure.

The flow starts from a turn or tool result. An extractor proposes candidate memories. A screening step removes secrets and flags personal data. Each candidate receives a trust tier from its source. A conflict lookup retrieves similar existing records, and a decision step chooses add, update, invalidate or no-op. Low-trust candidates go to quarantine. Committed writes update the store and the provenance index together.

Extraction and the four operations

Mem0’s 2025 paper gives a clear, reproducible design for this step. For each new message pair, an extraction prompt combines a running conversation summary with the last 10 messages and asks an LLM for candidate facts. For each candidate, the system retrieves the 10 most similar existing memories. An LLM then chooses one of four operations through a tool call: ADD when nothing equivalent exists, UPDATE to enrich an existing memory, DELETE when new information contradicts an old memory, or NOOP when nothing should change.

This is a good starting point with one production modification. Replace DELETE with INVALIDATE. Zep’s Graphiti shows why. Graphiti tracks two timelines: when a fact was true in the world (valid and invalid timestamps) and when the system learned or retired it (created and expired timestamps). When a new edge contradicts an older one with overlapping time, the older edge’s invalid timestamp is set to the new edge’s valid timestamp. The old fact remains queryable as history. “The user lived in Berlin until March 2026” is information. Deleting it loses the ability to answer temporal questions and to audit why the agent once believed it.

Hot-path versus background writes

LangGraph’s documentation frames the choice cleanly. Hot-path writes happen during the interaction, typically through a tool such as save_memories. They make new memories available immediately, but add latency and split the agent’s attention between the task and bookkeeping. Background writes run asynchronously after the turn, which removes latency but forces you to decide when to trigger them.

A practical split is to write explicit user statements on the hot path and everything else in the background. If a user says “always send invoices to the finance alias,” that is a high-trust, user-asserted fact worth committing immediately. Inferences such as “the user seems to prefer short answers” belong in a background job, where a stronger model can extract them with more context and lower urgency. Letta’s sleep-time design goes further: the primary agent cannot edit its own core memory at all, and only the background agent can.

Trust tiers and quarantine

The most important write-path control in 2026 is refusing to let untrusted content become trusted memory. The MINJA paper (arXiv 2503.03704, first submitted March 2025 and revised through February 2026) demonstrated memory injection through query-only interaction. The attacker never touches the memory store directly; they craft queries so the agent writes malicious records itself. Indirect prompt injection from web pages, documents and tool outputs follows the same path.

A trust-tier scheme blocks most of this. Assign each candidate a tier from its source: operator-authored, user-asserted in an authenticated channel, model-inferred from first-party data, or derived from third-party content. Allow only the first two tiers to commit directly. Model inferences commit with reduced trust weights. Third-party-derived candidates go to quarantine, where they are readable for the current task but never retrieved in other sessions until a validator or human promotes them. This mirrors how the MCP security community treats tool descriptions; see our MCP server threat model for the parallel.

Provenance and erasure lineage

Every committed record should store its source session, source message or tool call, the extractor model and version, the trust tier, and the subject identifiers it concerns. Store derivation edges too: a fact consolidated from three episodes points back to all three.

This lineage is what makes right-to-erasure feasible. Deleting a user’s raw messages is not enough if a consolidation job already turned them into facts, procedures or community summaries. With derivation edges, an erasure request walks the graph from the subject’s identifiers to every derived record. Without them, you are left re-embedding and searching for paraphrases, which is neither complete nor provable. Vector stores differ in how well they support targeted, filtered deletes, so test that capability before you choose one.

Consolidation, Sleep-Time Compute and Memory Evaluation

Consolidation is where an LLM agent memory architecture either compounds value or compounds error. Done well, it turns hundreds of noisy episodes into a handful of correct, well-organized facts and procedures. Done badly, it hallucinates generalizations and writes them with authority.

Flowchart of the background memory consolidation loop: scheduler, episode batch, reflection model, validator, human review for procedures, merge and decay, evaluation gate and versioned commit

Figure 4: Background consolidation loop. Reflections are validated against source episodes, procedure changes require review, and an offline evaluation gate guards every promoted memory version.

The loop begins with a scheduler that fires on a time interval, an importance threshold or idle periods. It loads a batch of recent episodes, and a reflection model proposes new facts, merged facts and procedure updates. A validator checks each proposal against its cited source episodes. Procedure changes route to human review. Approved changes go through merge and decay steps, then an evaluation gate, then a versioned commit.

Why background processing earns its cost

The Sleep-time Compute paper (arXiv 2504.13171, April 2025) quantifies the idea. Letting a model process context while idle, before queries arrive, reached the same accuracy with about 5x less test-time compute on stateful versions of GSM-Symbolic and AIME. Scaling sleep-time compute raised accuracy by up to 13% and 18% on those two tasks. When several related queries shared the same context, average cost per query fell by 2.5x. These are math-reasoning results, not agent-memory benchmarks, but the economics transfer. Work done once in the background is amortized across every later read.

OpenAI’s description of ChatGPT memory shows the same trajectory at consumer scale. Saved memories launched in April 2024 and were written only during conversations with explicit cues. In April 2025 OpenAI added background curation from chat history. The June 4, 2026 post introduced a newer version that keeps memories time-aware, so “you’re going to Singapore in July” can become “you went to Singapore in July 2026.” OpenAI reported about a 5x reduction in the compute needed to serve this to Free users but published no recall benchmarks.

Designing the reflection job

A reflection job should take a bounded batch of episodes, a snapshot of current facts and procedures, and a strict output schema. Each proposed memory must cite the episode IDs that support it. The validator then re-reads those episodes and checks that the proposal is entailed. A cheap natural-language-inference model or a second LLM call works. Proposals without valid citations are dropped.

Trigger policy is a cost-quality trade. Generative Agents’ importance threshold produced reflection roughly two or three times per simulated day. For a support agent handling thousands of sessions, a per-user trigger after N sessions plus a nightly global job is a sensible starting design. Track two numbers: cost per consolidation run and the fraction of proposals rejected by the validator. A rising rejection rate is an early signal that the reflection prompt or model is drifting.

Git-style versioning for memory

Letta’s Context Repositories, announced February 12, 2026 for Letta Code, store agent memory as files in a local git repository. Every memory change becomes a commit with a descriptive message. Subagents work in separate worktrees and merge through git conflict resolution. Built-in skills handle initialization, background reflection and “defragmentation,” which reorganizes memory into focused files after a backup.

You do not need Letta to adopt the principle. Version your memory, especially the procedure store. A bad consolidation run should be revertible in one operation, and every promoted memory version should be diffable. Anthropic’s memory tool supports a similar file-based pattern: the model works with view, create, str_replace, insert, delete and rename commands against a /memories path that your application maps onto real storage. Because storage is client-side, you can back it with a versioned store.

Evaluating memory honestly

Memory benchmarks are in a messy state, and the numbers deserve care. The table below summarizes published claims on LoCoMo, a long-conversation dataset. Every figure is self-reported or reported by a competitor, and configurations differ.

Claim Source Score on LoCoMo Caveat
Mem0 graph variant, 2025 paper Mem0 paper, April 2025 68.5% (as cited by Letta) Methodology disputed by Zep and Letta
Zep, rerun by Zep Zep blog, May 2025, updated June 2026 75.14% (±0.17) Says Mem0 misconfigured Zep users and timestamps
Letta agent with plain file storage Letta blog, August 2025 74.0% GPT-4o mini, no specialized memory tools
Mem0 April 2026 algorithm Mem0 blog, updated October 2026 92.5 Self-reported; not in the peer-reviewed paper

Two conclusions follow. First, the spread is driven as much by harness choices as by architecture. Mem0’s own benchmark page lists answer model, top-k, reranking, prompts and judge as factors that shift scores. Second, LoCoMo may not stress memory enough. Zep’s critique notes that LoCoMo conversations average roughly 16,000 to 26,000 tokens, which fits in modern context windows. It reported a full-context baseline of about 73%, above Mem0’s best 2025 result. LoCoMo also lacks knowledge-update questions. LongMemEval explicitly tests knowledge updates, temporal reasoning and abstention, making it the more relevant public benchmark for production agents.

The 2025 Mem0 paper’s own efficiency claims are worth knowing: a 26% relative improvement over OpenAI’s memory on its LLM-as-judge metric, 91% lower p95 latency and more than 90% lower token cost versus full context. Zep’s paper reports 94.8% versus MemGPT’s 93.4% on the Deep Memory Retrieval benchmark, and up to 18.5% higher accuracy with roughly 90% lower latency on LongMemEval. Treat all of these as vendor results on vendor harnesses.

The defensible approach is to build your own golden set. Sample real sessions, write questions that require cross-session recall, knowledge updates and abstention, and score with a fixed judge. Re-run it on every change to extraction prompts, embedding models, decay parameters or consolidation logic. Our guide to RAG retrieval evaluation with golden sets adapts directly to memory.

Capacity and cost: a back-of-envelope model

An illustrative calculation helps size the system. Assume 50,000 daily active users and 8 turns per user per day. Assume one in four turns yields a memory candidate after extraction, and roughly 40% of candidates become ADD operations rather than UPDATE or NOOP. That gives about 40,000 new records per day, or around 14.6 million per year before consolidation and decay. At 1,024-dimension float32 embeddings, that is roughly 4 KB of vectors per record, about 60 GB of raw vectors per year before index overhead. Every number here is an assumption for illustration, not a measurement.

The model-call side usually dominates cost. If extraction runs on every turn, that is 400,000 extra small-model calls per day. If the update decision retrieves 10 neighbors per candidate, it adds 100,000 vector queries and decision calls. Background consolidation on a nightly schedule is cheap by comparison when batched, and batch APIs typically discount it further. The practical lesson: gate extraction with a cheap classifier, so you only run the extractor on turns likely to contain durable information.

Choosing a Memory Layer: Mem0 vs Zep vs Letta vs LangGraph vs Provider Primitives

No single product covers all five planes of an LLM agent memory architecture. The choice is about which planes you buy and which you build. The matrix below reflects documented capabilities as of November 2026, not benchmark rankings.

Option Core model Strongest at Weakest at Fits when
Mem0 (mem0ai 2.2.1) LLM extraction plus ADD, UPDATE, DELETE, NOOP over vectors, optional graph Fast drop-in fact memory for assistants Temporal history once facts are deleted You need user-preference memory quickly
Zep or Graphiti (graphiti-core 0.31.2) Bi-temporal knowledge graph of episodes, entities and communities Facts that change over time; auditability Operational weight of a graph database Facts change and you must answer “when”
Letta (0.34.12) Stateful agents with memory blocks, sleep-time agents, git-backed memory for Letta Code Agent-directed memory and background editing Coupling to Letta’s agent runtime You want the runtime and memory as one system
LangGraph store (langgraph 1.2.24) Checkpointer per thread plus namespaced store with semantic search Fine-grained control inside your own graph You build extraction and consolidation yourself You already orchestrate with LangGraph
Provider primitives Anthropic memory tool and context editing; OpenAI compaction sessions Low-friction context management Cross-provider portability, governance Single-provider agents with modest memory

A note on LangMem: the LangChain memory-extraction library’s latest PyPI release is 0.0.30 from October 2025, so check its maintenance status before depending on it. For multi-agent systems, memory boundaries become a coordination problem too; our post on multi-agent orchestration with MCP, A2A and LangGraph covers shared state between agents.

A common, durable pattern combines layers. Use provider compaction or context editing for working context. Use LangGraph or your own orchestrator for session state. Use Graphiti or a temporal table in Postgres for facts. Use an append-only log for episodes. Keep procedures in a versioned repository. Build the governance plane yourself, because no vendor owns your provenance and retention rules.

Trade-offs, Gotchas, and What Goes Wrong

Memory poisoning is the top risk in any LLM agent memory architecture, not a corner case. OWASP’s May 13, 2026 commentary on ASI06 described Cisco’s “MemoryTrap” research on Claude Code. A routine workflow led to a persistent prompt injection reaching memory, hooks and the system prompt. OWASP reports that Claude Code v2.1.50 removed user memories from the system prompt, closing that specific path. The broader lesson stands: anything that persists across sessions can carry an attack forward.

Hallucinated reflections become authoritative. A reflection job that wrongly concludes “service X always requires parameter Y” writes a procedure that every later session obeys. Citation-checked validation and human review for procedures are the controls. Without them, consolidation amplifies errors instead of correcting them.

Deletion destroys history; invalidation preserves it. Hard-deleting contradicted facts makes temporal questions unanswerable and hides why the agent once acted as it did. Invalidate by default and hard-delete only for erasure or retention expiry.

Embedding model changes break retrieval silently. Vectors written with one embedding model are not comparable with queries from another. Upgrading requires a full re-embed and a dual-read period. Record the embedding model and version on every record. Our embedding model leaderboard for November 2026 helps when choosing a replacement.

Over-personalization becomes sycophancy. An agent that remembers every stated preference can start agreeing with outdated or harmful ones. Preferences need expiry and confirmation just like facts.

Cross-tenant leakage through shared namespaces. A single collection with a tenant filter is one missing filter away from a data breach. Enforce tenancy in the store’s access layer, not only in query code.

Benchmark theatre. Choosing a memory vendor from LoCoMo numbers is choosing by harness. Run your own evaluation on your traffic.

Runaway cost from eager extraction. Running an extractor and update decision on every turn can cost more than the main model on short turns. Gate extraction, batch background work and measure memory cost per session.

Practical Recommendations

Start your LLM agent memory architecture with the governance plane, even if everything else is simple. A Postgres table with provenance columns, a trust tier and validity timestamps will outlive any vector database decision. Separate session state from long-term memory on day one, and keep facts, episodes and procedures in distinct stores with distinct policies.

Make writes conservative and reads generous. Commit user-asserted facts immediately, push inferences to background jobs, quarantine anything derived from third-party content, and invalidate instead of deleting. On the read side, use hybrid retrieval, filter by validity before ranking, include trust in scoring, and log every inclusion and exclusion.

Run consolidation off the hot path with citations and a validator, and version the result so a bad run can be reverted. Finally, build a private memory evaluation set that covers cross-session recall, knowledge updates and abstention before you compare vendors. For the prompt-assembly side of these decisions, our guide to context engineering for production LLM agents pairs well with this one.

Checklist:

  • [ ] Session state (checkpoints) stored separately from long-term memory.
  • [ ] Facts, episodes and procedures in separate stores with separate retention.
  • [ ] Every record carries source, extractor version, trust tier, subject IDs and validity interval.
  • [ ] Contradictions invalidate; hard delete reserved for erasure and retention expiry.
  • [ ] Third-party-derived memories quarantined until validated.
  • [ ] Hybrid retrieval with a temporal filter before reranking.
  • [ ] Retrieval trace logged for every model call.
  • [ ] Consolidation runs in the background with citation validation and versioned commits.
  • [ ] Procedure changes require review.
  • [ ] Erasure walks derivation lineage and is tested end to end.
  • [ ] Private golden-set evaluation re-run on every memory pipeline change.

Frequently Asked Questions

What is the difference between RAG and agent memory?

Retrieval-augmented generation fetches documents from a mostly static corpus to ground a response. Agent memory adds a write path: the agent creates, updates and invalidates records from its own interactions, so the corpus changes every session. That brings problems RAG rarely faces, including contradictions, staleness, consolidation, per-user erasure and poisoning through the agent’s own writes. Retrieval techniques such as hybrid search and reranking transfer directly. The difference is lifecycle management. RAG is mostly read-only; an LLM agent memory architecture is a read-write system with governance requirements.

Do million-token context windows make agent memory unnecessary?

No. Long windows help within a session, but they do not persist across sessions, they cost money on every call, and accuracy degrades as context grows. LongMemEval found about a 30% accuracy drop for commercial assistants and long-context models on long-term memory tasks. Zep’s critique of LoCoMo makes the reverse point: when conversations fit in context, full context can beat memory systems. The practical answer is to use long context for the current task and a memory system for durable, cross-session knowledge.

Should I use a vector database or a knowledge graph for agent memory?

Use vectors when memories are mostly independent facts and preferences and you need fast semantic recall. Use a temporal knowledge graph when facts change over time, relate to each other, and you must answer when something was true. Graphiti’s bi-temporal model handles that second case directly. Many teams combine them: a graph or temporal table for facts, a vector index for episodes, and hybrid search over both. The operational cost of a graph database is real, so adopt it when temporal or relational queries are a requirement.

How does Anthropic’s memory tool work?

It is a client-side tool with type memory_20250818. Claude issues file commands such as view, create, str_replace, insert, delete and rename against a /memories path. Your application executes them against storage you control and returns results. Because storage is yours, you choose retention, encryption and versioning. The documentation lists it as stable and warns that your handler must block path traversal outside /memories. Anthropic recommends pairing it with context editing or server-side compaction for long-running agents.

How do I protect agent memory from prompt injection and poisoning?

Treat memory as an attack surface, as OWASP’s ASI06 category recommends. Tag every candidate memory with a trust tier from its source, and never let content derived from web pages, documents or tool outputs commit directly to cross-session memory. Quarantine it until validated. Keep procedures under review and version control. Do not place user-writable memory in high-authority prompt positions without separation. Log provenance so you can find and revert everything a poisoned source touched.

How do I delete a user’s data from agent memory under GDPR?

Deleting raw messages is not enough, because extraction and consolidation create derived records. Store subject identifiers and derivation edges on every memory, so an erasure request can walk from the user’s identifiers to every fact, summary and procedure derived from their data. Delete from primary stores, vector indexes, caches and backups according to your retention policy. Then verify by querying for the subject. Test the whole workflow before launch, because retrofitting lineage onto an existing store is slow and rarely complete.

Further Reading

By Riju — about

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *