LangMem SDK
Python library that gives agents long-term memory and prompt-based learning
- Tool type
- Agent long-term memory library
- Made for
- Developers building adaptive agents
- Runs on
- Python, in your own app
- Installed as a package; needs an LLM provider API key
What it does
LangMem SDK is a Python library for adding long-term memory to AI agents. It takes in conversation messages, existing stored memories and, for prompt optimization, scored interaction trajectories with feedback comments. It produces extracted facts and knowledge, consolidated memory updates, and revised system prompts. Memories are namespaced, for example per user or team, so they can be kept separate or shared.
Developers use it in two ways: give an agent memory-management and memory-search tools that it calls during a conversation, or run a background memory manager that extracts and updates knowledge afterward. It covers semantic memory (facts, user preferences) and procedural memory (prompt rules that evolve from feedback). Episodic memory has no opinionated utilities yet. Its core API works with any storage system and agent framework, with native integration into LangGraph's long-term memory store.
It suits developers building personalized or adaptive agents who are comfortable with Python and have an API key for an LLM provider. Install is via pip; the library is MIT-licensed, but LLM and embedding calls are paid separately. The example in-memory store loses data on restart, so production use needs a database-backed store. It handles recall across conversations, not within-thread context.
What it can do
- Extract facts and preferences from conversations into semantic memory
- Memory tools an agent calls to store and search memories during a chat
- Background memory manager that extracts, consolidates and updates knowledge
- Prompt optimizers that rewrite system prompts from scored interaction trajectories
- Namespaced memories scoped to users, teams or an agent's shared procedures
Works with
- LangGraph
Example workflows
- Remember user preferences in a chat agent
- Input: a LangGraph agent, a store and user messages. Steps: add the manage-memory and search-memory tools with a namespace, tell the agent a preference, then ask about it later. Output: the agent answers from the stored memory.
- Refine a system prompt from feedback
- Input: conversation trajectories with scores and comments, plus the current prompt. Steps: create a prompt optimizer, pass in the trajectories and prompt. Output: a revised prompt reflecting patterns in good and poor interactions.
Before you choose
- The in-memory store example loses memories on restart; production needs a persistent store such as Postgres.
- Episodic memory has no opinionated utilities yet, per the launch post.
- Memory extraction and prompt optimization call an LLM, so provider costs apply separately.
Listed under
Get started
Docs and quickstarts at the official docs site
- Run pip install -U langmem in your Python environment.
- Export an API key for your LLM provider, such as ANTHROPIC_API_KEY.
- Choose a memory store (in-memory for testing, a database-backed store for production) and add the memory tools to your agent.
Plans and prices
The MIT-licensed SDK is free to install. Model, embedding and infrastructure charges are separate. Managed services, where used, have their own terms.
LangMem SDK is free to use. See their pricing page ↗
Sources for this overview
Product pages, documentation, and pricing checked 29 Oct 2026. Each source supports part of the overview; availability and prices can change.
- LangMem SDK for agent long-term memory ↗www.langchain.com
- Introduction ↗langchain-ai.github.io
- GitHub - langchain-ai/langmem · GitHub ↗github.com
- LangSmith Plans and Pricing ↗www.langchain.com
- Home - Docs by LangChain ↗docs.langchain.com
Ratings and reviews
No ratings for LangMem SDK yet.
What’s changed
Free accountSignals
Free accountData and security
Free accountCompare with similar tools
Free accountWhere this comes from
How we research- Company website
- langchain-ai.github.io: product, pricing and policy pages
- YC directory mirror
- Batch and company name
- Social accounts
- Accounts the company links, and its posts on X
- Human review
- Checked by a person
- knowledge_base
Last checked 29 Oct 2026. Every field keeps its source and date; unknown means we couldn’t confirm it.