Repolode
langchain-ai

langchain-ai/langmem

A Python library that gives LangGraph agents long-term memory: extracting key information from conversations, managing memory tools, and running background memory consolidation.

Stars
1,715
Forks
201
Open issues
76
Last commit
18 days ago

What is it?

LangMem helps AI agents learn from their interactions over time. It extracts important information from conversations, refines agent behavior through prompt optimization, and keeps long-term memory across sessions.

The library offers functional primitives that work with any storage system, plus native integration with LangGraph's Long-term Memory Store. Agents can record and search memories during active conversations through memory tools, or a background memory manager can extract, consolidate, and update knowledge automatically.

The README's quickstart shows an agent built with LangGraph's create_react_agent, using InMemoryStore for development. The docs note that production deployments should use a database-backed store such as AsyncPostgresStore so memories survive restarts.

Key features

  • 01Core memory API that works with any storage system
  • 02Memory tools that let agents record and search information during conversations
  • 03Background memory manager that extracts, consolidates, and updates knowledge
  • 04Native integration with LangGraph's Long-term Memory Store

Use cases

  • Building chatbots that remember user preferences across sessions
  • Personalizing responses based on past conversations
  • Adding persistent memory to existing LangGraph agents

Quick start

  1. 1

    Install the package

    pip install -U langmem
  2. 2

    Set your LLM provider API key

    export ANTHROPIC_API_KEY="sk-..."
  3. 3

    Create an agent with memory tools and run it (see the README example)

Things to know

  • Requires an API key from an LLM provider such as Anthropic or OpenAI.
  • The example store is in-memory and loses data on restart; a DB-backed store is needed for production.
  • Built around LangGraph, so it fits best if you already use that stack.

Topics

FAQ

What is langmem?
A Python library that gives LangGraph agents long-term memory: extracting key information from conversations, managing memory tools, and running background memory consolidation. LangMem helps AI agents learn from their interactions over time. It extracts important information from conversations, refines agent behavior through prompt optimization, and keeps long-term memory across sessions.
Is langmem free to use? What license does it have?
langmem is open source under the MIT license. Check the license terms before using it in commercial products.
Is langmem still maintained?
Actively maintained. The last commit to langmem was on Oct 2, 2026.
What can I use langmem for?
Building chatbots that remember user preferences across sessions Personalizing responses based on past conversations Adding persistent memory to existing LangGraph agents
How do I install langmem?
Install the package: pip install -U langmem Set your LLM provider API key: export ANTHROPIC_API_KEY="sk-..." Create an agent with memory tools and run it (see the README example)
Where can I get langmem?
The source code and installation instructions are on GitHub: https://github.com/langchain-ai/langmem

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects