By the end of this guide you will have an AI agent that remembers things between conversations: a user's preferences, decisions from earlier sessions, facts about a project. The ingredient is a memory layer, a library or service that extracts useful facts from conversations, stores them, and hands back only the relevant ones when the agent needs them.
Giving an AI agent long-term memory is mostly a design problem, because storing everything is easy and recalling the right thing is hard. This guide covers what to remember, how to pick between the kinds of memory tool, and how to test recall, and it compares seven options from our Developer platforms category.
Key takeaways
- Decide what the agent should remember and for how long before choosing a tool: preferences, facts, decisions, or whole sessions are different jobs.
- The main choice is a memory layer you add to your own agent, a platform where agents are stateful by design, or a database you build memory on.
- Scope memory by user, project or agent, so one person's details never surface in another's conversation.
- Memories can be wrong or sensitive. Give users a way to review and delete what is stored, and treat stored personal data with the same care as any database.
What you need before you start
- An agent that already works. It can hold a conversation or run a task, and you can edit its code or prompts.
- A list of what to remember. For example, user preferences, project decisions, or past errors and fixes.
- A privacy decision. Where memories may be stored, who can see them, and how a user can have them deleted.
- A model API key. Many memory tools use a language model to extract and compress facts.
- Time. A basic memory integration can work in under a day. Tuning recall quality takes longer.
- Difficulty. Moderate: you wire memory calls into your agent's request loop and test the results.
Which kind of AI tool fits this job
Pick by how your agent is built and where the memory should live.
A memory layer you add to an existing agent. Mem0 lets assistants remember facts and preferences about each user between conversations. You send it messages, it extracts and stores useful facts, and it returns the most relevant ones at query time. It ships as an open-source Python package you host yourself and as a managed platform. Hindsight offers retain and recall calls organized into separate memory banks, such as one bank per user, with an MIT-licensed self-hosted engine on PostgreSQL and a managed cloud. LangMem is a Python library from the LangChain team with tools for agents to record and search memories, plus a background manager that extracts and consolidates knowledge.
A platform where the agent is stateful by design. Letta, formerly MemGPT, builds stateful agents that keep memory and learn across sessions, run from a terminal interface, a browser or an SDK.
Memory for coding agents. agentmemory runs as a local server next to a coding agent, records what happened in each session such as file edits, shell commands and errors, and injects relevant context into the next session. It serves several agents over MCP with one shared store.
A database to build memory on. HydraDB is an open-source graph database on object storage that links people, projects and events so an agent can follow relationships. LanceDB is an open-source vector database that its listing names as a common choice for agent memory, among other uses. These give you more control and more work.
Step 1: Decide what the agent should remember
You finish this step with a short memory policy.
- List the kinds of memory you want: user preferences, long-lived facts, task history, or lessons from past mistakes.
- For each, decide who it belongs to: one user, a team, a project or the agent itself.
- Decide how long it should live, and what must never be stored, such as passwords or payment details.
- Decide how users will see, correct and delete what is stored.
Check it worked by writing three example memories and one example the agent must not keep.
Step 2: Choose a memory approach
Match the tool to your existing stack.
- If your agent is built on LangGraph, LangMem integrates natively with its long-term memory store.
- If you want a ready-made API, look at Mem0, which lists JavaScript and Python SDKs, or Hindsight, which lists a Python client, an API and MCP support.
- If you are starting from scratch and want memory as a built-in feature, consider Letta.
- If the agent is a coding assistant, agentmemory targets that case.
- If you need relationships across documents, chats and decisions, consider a graph database such as HydraDB, or a vector database such as LanceDB.
Check it worked by naming the tool and one reason it fits your stack.
Step 3: Decide where memory is stored
Hosted and self-hosted options carry different privacy and operations trade-offs.
- Decide whether memories may leave your infrastructure. Mem0, Hindsight and HydraDB all offer self-hosted and managed options, while agentmemory is a local-first server.
- If you self-host, plan for running it. Mem0's open-source version must be hosted and operated by you, and Hindsight's self-hosted engine is maintained by you.
- Check the production storage needs. LangMem's in-memory store loses memories on restart, so production needs a database-backed store.
- Read the vendor's data terms and security features for anything involving personal data.
Check it worked by writing down where memories will live and who can access them.
Step 4: Connect memory to your agent
Wire two calls into the agent loop: write after a turn, read before a turn.
- After each exchange (or at the end of a session), send the messages to the memory layer so it can extract and store facts.
- Before the agent answers, query memory with the current message and add the top results to the prompt.
- Scope every call by user, project or agent identifier, so memories stay separate. Mem0 scopes memory by user, agent, app and run, and Hindsight uses separate memory banks.
- Limit how much memory goes into a prompt so it does not crowd out the task.
Check it worked by telling the agent a preference, starting a new session, and seeing it come back.
Step 5: Tune what gets stored and recalled
Raw memory fills up with noise, so shape it.
- Review a sample of stored memories. Look for duplicates, trivial facts and wrong inferences.
- Use consolidation features where they exist. Mem0 lists a memory consolidation feature called Dream on Pro, and agentmemory supersedes near-duplicate memories.
- Adjust how many results you retrieve, and test queries that should and should not match.
- Remember that extraction may run in the background (LangMem has a background manager), so a fact may not be recallable the instant it is said. Check each tool's notes.
Check it worked by running ten recall questions and recording how many return the right memory.
Step 6: Handle privacy, correction and deletion
Memory is personal data, so build the controls before launch.
- Give users a way to view what the agent remembers.
- Provide a way to correct or delete a memory, and test that deletion removes it from recall.
- Check access controls. Hindsight lists role-based access and scoped API keys, and its Enterprise tier adds Memory Defense, described as redacting secrets and blocking prompt injection.
- Tell users that the agent keeps memory, and what for.
- Have a person review the policy if you store health, financial or children's data.
Check it worked by deleting a test memory and confirming that the agent no longer mentions it.
Step 7: Monitor and test regularly
Memory quality drifts as data grows.
- Keep a fixed set of recall tests and rerun them after changes.
- Watch storage growth and plan limits. Mem0's Hobby plan allows a set number of add and retrieval requests each month.
- Spot-check for memories that leak between users.
- Review the cost of the language-model calls used for extraction.
Check it worked by passing the recall test set after a new release.
Tools for this job compared
| Tool | Good fit for | Pricing | Stated limits |
|---|---|---|---|
| Mem0 | A memory layer for user context, open source or managed | Freemium, paid from $19/mo (checked 24 Oct 2026) | Hobby plan allows 10,000 add requests and 1,000 retrieval requests per month; graph memory and Dream are not on Hobby or Starter |
| Letta | Stateful agents with persistent memory; CLI, web, API | Freemium, paid from $20/mo (checked 24 Oct 2026) | Free plan is limited to 3 stateful agents; Pro allows up to 20 stateful agents |
| LangMem | Python agents on LangGraph | Open source | InMemoryStore loses memories on restart; requires a Python agent setup and your own LLM key |
| Hindsight | Retain and recall with per-user memory banks | Open source | Cloud and Enterprise prices are not published; SSO, MFA and audit logs are Enterprise features |
| agentmemory | Memory for coding agents over MCP, local-first | Open source | Needs Node.js 18 or newer; compression and graph extraction need an LLM provider key |
| HydraDB | Graph-based context across documents, chats and decisions | Open source, paid from $25/mo (checked 24 Oct 2026) | Cloud plans carry a monthly minimum usage of $25 (Ship) or $300 (Scale); self-hosted use has community support only |
| LanceDB | Open-source vector database for agent memory and RAG | Open source | OSS runs in a single process and shares CPU with the host application; Enterprise pricing is not published |
Prices and plan limits change, so confirm the current terms on each vendor's site before you commit.
Common mistakes to avoid
- Storing everything. Raw transcripts bloat storage and bury the useful facts. Fix it by extracting facts and preferences, and by consolidating or expiring old entries.
- Not scoping memory. Without clear user or project boundaries, one person's details can surface for another. Fix it by passing an identifier on every write and read, and by testing cross-user leakage.
- Using a throwaway store in production. An in-memory store resets when the process restarts. Fix it by using a database-backed store, as LangMem's documentation notes.
- Trusting remembered facts blindly. The agent may store a wrong inference and repeat it. Fix it by letting users review and correct memories, and by tracking recall quality.
- Ignoring personal-data duties. Stored memories can be personal data. Fix it by writing a retention and deletion policy, and by asking a qualified person to review it when the data is sensitive.
How we put this together
This is an evidence-based guide built from each tool's listing in our directory, which is compiled from the vendor's own site and pricing page. It is not a review based on using the tools. We don't rank tools, and nobody paid to be included. Some outbound links may be affiliate links; see our disclosure.
Frequently asked questions
Is there a free way to add memory to an AI agent?
Yes. LangMem, agentmemory, Hindsight's self-hosted engine and HydraDB's open-source edition are free to use, though you run them yourself. Mem0 has a free Hobby plan and Letta has a free plan, both with caps. You still pay for the language model calls.
What is the difference between memory and a bigger context window?
A larger context window lets the model read more in one request, but it forgets everything when the session ends and costs more as the prompt grows. A memory layer stores facts across sessions and returns only the relevant ones. Many designs use both.
Do I need a vector database for agent memory?
Not always. Memory layers such as Mem0 and Hindsight handle storage for you, while LanceDB and HydraDB are for teams who want to build their own memory on a database. Choose by how much control and operations work you want.
Can I keep agent memory private?
Yes, if you choose a self-hosted or local-first tool. agentmemory runs as a local server, and Mem0, Hindsight and HydraDB list self-hosted options. Read the data terms of any managed service before you store personal data.
Which tool suits a coding agent?
agentmemory is built for coding agents such as Claude Code and Cursor, recording edits, commands and errors from each session. Check its platform notes: the one-command install targets macOS and Linux.
Compare more options in our Developer platforms category.