Agent Design Patterns

Top 5 Agent Memory Libraries for Persistent User Context

Persistent user context can make an agent feel more coherent from one session to the next, but choosing a memory library is about more than finding somewhere to store chat history. You need to decide what should be retained, how memories can be updated or retrieved, and which deployment and integration trade-offs your team can support.

This shortlist compares five approaches rather than naming one universal winner. Some focus on manageable extracted memories or structured profiles; others build temporal knowledge graphs, make memory part of a stateful agent runtime, or offer a local self-managed starting point.

I’d start by matching the memory model to the job. The right choice for a compact user profile may not suit an agent that must track changing relationships, and local deployment still requires checking what models, storage, and operational work are involved.

Digital illustration of cyberpunk cats in neon-lit urban scenes, engaged in AI-agent tasks such as coding, debugging, or analyzing data streams. The style features glowing outlines, high contrast, and a vibrant acid-color palette. No brand logos, no invented software screenshots, no legible text.: Top 5 Agent Memory Libraries for Persistent User Context

Quick picks

  • Mem0 — Best for manageable extracted memories. It supports add, search, update, and delete operations, with user, agent, and run scoping. Its defaults use OpenAI for the LLM and embeddings; a local configuration requires alternatives.
  • Graphiti — Best for changing facts and relationships. It incrementally builds temporal knowledge graphs and supports semantic, keyword, and graph-based retrieval. Plan for a graph backend and model-provider setup.
  • Letta — Best for persistent agent identity. Memory and message history persist across conversations for the same agent. Its approach is centered on Letta’s runtime, with local-disk and cloud-backed storage options.
  • LangMem — Best for profiles and controlled memory updates. It supports structured profiles or collections of retrievable memories, with configurable schemas and retrieval controls. Persistent storage uses LangGraph’s BaseStore, and enrichment requires a language model.
  • Cognee — Best for exploring local text memory. Its documented quick start can ingest and retrieve text without an LLM API key. The bundled GLiNER extractor is described as a demo, so assess and configure an appropriate extraction pipeline before production use.

Product shortlist

1. Mem0

Mem0: A cyberpunk cat places one glowing glass bead into a small brass cabinet with neat, open compartments. The cabinet stands on a dark workbench, its drawers catching cyan and magenta light against a near-black studio. The compartments hold a few other smooth, unmarked beads..Mem0
Mem0 — AI editorial illustration, not a product photo or screenshot.

Mem0 is a practical option if you want an agent to retain selected user context across sessions without building every memory operation yourself. Its documented workflow includes adding, searching, retrieving, updating, and deleting memories, with user, agent, and run identifiers available to scope them.

I like that this gives teams control over how context is organized while leaving the underlying components configurable.

What I like

  • You can use Mem0 as a Python or JavaScript library, or run it as a self-hosted server, so it can fit different application architectures.
  • Memory operations include search and explicit update or delete actions, which are useful when stored context needs review or correction.
  • Developers can configure the language model, embedder, vector store, and reranker rather than being locked into the documented defaults.

Limitations

  • The default configuration uses OpenAI for the language model and embeddings, so a fully local setup requires configuring alternatives.
  • Self-hosting gives your team control over infrastructure, but also leaves infrastructure choices and responsibilities to your team.

My take

Mem0 suits teams that want a dedicated memory layer with explicit operations and scope identifiers, rather than treating the entire chat history as persistent context. Those controls can help you decide which memories belong to a user, an agent, or a particular run.

Best for

Consider Mem0 if you need persistent, manageable user context and want a choice between embedding the library in an application and operating a self-hosted server. If local processing is important, plan to configure alternatives to the default OpenAI components and account for the infrastructure you will manage.

Sources: Open Source Overview — Mem0.

2. Graphiti (by Zep)

Graphiti (by Zep): A cyberpunk cat loops a bright thread around one metal node on a branching wall sculpture of connected disks. The sculpture rises in a dim workshop, with older links fading into shadow and the newest connection glowing cyan. Every disk and prop is plain and unmarked..Graphiti (by Zep)
Graphiti (by Zep) — AI editorial illustration, not a product photo or screenshot.

Graphiti is a good fit when an agent needs to remember how a user's facts and relationships change across sessions, rather than just retrieve a static profile. I like its episode-based approach: new text or structured information can update a temporal knowledge graph, and retrieval can combine semantic, keyword, and graph-based search.

That flexibility is useful, but it comes with more infrastructure choices than a simple profile store.

What I like

  • Incremental graph updates are designed to reflect changing facts and relationships over time.
  • Hybrid retrieval gives developers more than one way to find relevant context, including semantic, keyword, and graph-based search.
  • The open-source framework supports graph backends including Neo4j, FalkorDB, and Amazon Neptune.

Limitations

  • You need to choose and configure a supported graph backend, which adds operational work.
  • The documented quick start requires Python 3.10 or later and a model or embedding provider; its defaults use OpenAI, though the documentation lists alternatives including local Ollama models.

My take

I would consider Graphiti when the relationships between remembered facts matter, or when context needs to evolve as new information arrives. Its retrieval options can help tailor how an agent finds relevant details, but they also mean you should decide which search modes and graph structure suit your application.

The main trade-off is setup: this is a framework with a graph backend and model-provider configuration, not a plug-in profile store. If your use case only needs a small set of stable user preferences, that added infrastructure may not be worthwhile.

Best for

Best for developers building agents that need to track changing facts and relationships over time, and who are prepared to operate a graph backend. For simpler, mostly static user preferences, a lighter-weight memory approach may be easier to manage.

Sources: Welcome to Graphiti — Zep Documentation; Quick Start — Graphiti Documentation.

3. Letta

Letta: A cyberpunk cat tucks a polished brass compass into a sturdy, open travel case. The case rests on a low stone ledge in a quiet, near-black room, its worn velvet lining illuminated by a soft magenta glow. A few smooth keepsakes sit securely inside..Letta
Letta — AI editorial illustration, not a product photo or screenshot.

Letta takes a runtime-centered approach to persistent context: an agent keeps its identity, memory, and message history across conversations. I’d consider it when you want continuity to be part of the agent’s operating model, rather than adding memory as a separate storage-and-retrieval component.

Its local and cloud-backed storage options also make the deployment choice part of the decision.

What I like

  • Memory and message history are tied to a persistent agent identity, supporting continuity between that agent’s conversations.
  • Agents can be stored on local disk without an account, which offers a local option.
  • Signed-in agents can use cloud-backed storage through Letta’s CLI and web app.

Limitations

  • The memory model is centered on Letta’s stateful-agent runtime, so it may be a less direct fit if you only want a memory component to embed in an existing framework.
  • Local and cloud-backed storage differ in access and backup implications, so choose a mode with your operational needs in mind.

My take

What stands out to me is that Letta treats persistence as part of the agent itself, not just a place to store retrieved facts. That makes it worth considering when you want the same agent’s memory and conversation history to carry across sessions.

The trade-off is integration shape: Letta’s documented model is built around its runtime. If your existing agent stack is already established and you want a standalone memory layer, check that fit before committing; also decide whether local storage or cloud backup suits your access and backup requirements.

Best for

Developers who want persistent agent identity and context as part of Letta’s stateful-agent runtime. If you need only an embeddable memory-and-retrieval library, compare its runtime-centered approach with more modular options.

Sources: Stateful Agents — Letta Docs.

4. LangMem

LangMem: A cyberpunk cat presses one luminous geometric tile into an orderly mosaic panel. The panel fills a dark alcove, with distinct clusters of shapes and a clear open space around the new tile. Cyan and lime light glint across the unmarked surfaces..LangMem
LangMem — AI editorial illustration, not a product photo or screenshot.

LangMem is a good fit if you want to shape what an agent remembers rather than treating every past interaction as equally useful. I like its choice between a compact, structured user profile and a collection of separate memories that can be retrieved when relevant.

Its controls for memory updates and retrieval make it worth considering, especially for teams already using LangGraph.

What I like

  • You can define schemas and instructions to guide which user details the system extracts and retains.
  • Profiles keep current user context in one structured document, while collections support retrieval across multiple memories.
  • The memory manager offers controls for namespaces, query limits, inserts, and deletes.

Limitations

  • Persistent storage uses LangGraph's BaseStore, so teams on another stack need to provide or adapt the storage and integration layer.
  • Memory enrichment requires a configured language model, adding a model dependency to the workflow.

My take

LangMem gives developers useful control over both the shape of stored context and the process for updating it. That can help when an agent needs a concise profile, searchable recollections, or both.

I’d shortlist it for a Python project that can work with LangGraph storage and wants explicit memory policies. If your existing stack uses a different storage layer, account for the integration work before choosing it.

Best for

Best for developers building Python agents who want schema-guided user profiles or retrievable memory collections, with configurable update and retrieval controls.

Sources: Core Concepts — LangMem; Memory API Reference — LangMem.

5. Cognee

Cognee: A cyberpunk cat sifts fine dark sand through a shallow metal sieve above a clear glass bowl. A handful of bright, smooth stones remain in the sieve while the finer grains fall through. The simple setup rests on a near-black floor, edged with a restrained cyan glow..Cognee
Cognee — AI editorial illustration, not a product photo or screenshot.

Cognee is worth considering if you want to keep a memory pipeline under your own infrastructure rather than depend on a cloud LLM for basic text retrieval. Its documented local quick start can ingest and retrieve text without an LLM API key, which makes it a practical starting point for experimenting with persistent context.

I’d treat that as a deployment advantage, not proof that its default extraction is ready for production.

What I like

  • A local path for basic text ingestion and retrieval means you can try the workflow without supplying a cloud LLM key.
  • Self-hosting gives your team control over the infrastructure and pipeline configuration.
  • The documented no-key workflow offers a useful way to explore the library before deciding whether to add LLM-dependent stages.

Limitations

  • The bundled GLiNER entity extractor is described by the project as a demo, with a caveat about accuracy and label coverage for production use.
  • Self-hosting means your team must operate and configure the pipeline; the available evidence does not establish a managed-service option or operating cost.

My take

I’d shortlist Cognee when deployment control and a local starting point matter more than a fully managed setup. Its basic retrieval path can be useful for prototyping how an agent carries information between sessions, but you should assess whether its extraction pipeline captures the kinds of user facts your application needs.

For production, plan to evaluate extraction quality on your own data and configure a suitable pipeline. Choose another option if you need a turnkey managed service or verified extraction performance without taking on that work.

Best for

Best for teams that want to explore persistent text context locally and are prepared to operate and tune a self-hosted pipeline.

Sources: Cognee — Official GitHub Repository.

How to choose

Start with what should persist: a concise profile, separate retrievable memories, or facts and relationships that change over time. Then check how much control you need over updates and retrieval, whether the library fits your agent framework, and which model, storage, and infrastructure choices you can support.

Common Mistakes to Avoid

Don’t choose graph infrastructure when a simple profile will do, or assume a local quick start proves extraction is production-ready. Check model-provider and storage requirements before committing.

Frequently Asked Questions

Can I keep memory local? Some options document local or configurable deployments, but the setup and extraction trade-offs differ.

Final Verdict — Which One Would I Choose?

I’d choose by architecture: structured profiles and update controls, temporal relationships, persistent agent runtime, or self-managed local processing each point to different options. Test retrieval and corrections against representative user data before deciding.

Sources: Open Source Overview — Mem0; Welcome to Graphiti — Zep Documentation; Quick Start — Graphiti Documentation; Stateful Agents — Letta Docs; Core Concepts — LangMem; Memory API Reference — LangMem; Cognee — Official GitHub Repository.

Which option fits?

I’d choose based on the kind of continuity your agent needs, not on a blanket ranking. For explicit memory operations and scope identifiers, consider Mem0; for evolving facts and relationships, Graphiti’s temporal graph model is a closer fit.

LangMem makes sense when you want structured profiles or retrievable collections and can work with its storage integration.

If persistence should belong to the agent runtime itself, Letta is worth considering. If keeping a basic text-memory workflow local is the priority, Cognee offers a documented starting point, but its demo extractor makes production evaluation especially important.

Before settling on any option, check its model and storage requirements against your deployment constraints. Then test what it retains, retrieves, updates, and removes using representative user data; the supplied documentation describes capabilities, not comparative performance.