LangMem logo

LangMem

Free

Help agents learn and adapt from interactions over time.

FreeFree tier
Type
Open Source
Company
LangChain AI

About LangMem

LangMem is an open-source Python library by LangChain AI that enables agents to learn and adapt from their interactions over time. It provides tooling to extract important information from conversations, optimize agent behavior through prompt refinement, and maintain long-term memory. The library offers functional primitives that work with any storage system and native integration with LangGraph's Long-term Memory Store. Key capabilities include a core memory API, memory management tools for active conversations (hot path), and a background memory manager that automatically extracts, consolidates, and updates agent knowledge. LangMem allows developers to build agents that continuously improve, personalize responses, and maintain consistent behavior across sessions. Installation is via pip, and it supports any LLM provider via an API key. The library is designed to be used with LangGraph but also provides standalone primitives for custom memory systems.

Key Features

Core memory API that works with any storage system
Memory management tools for active conversations (hot path)
Background memory manager that automatically extracts, consolidates, and updates agent knowledge
Native integration with LangGraph's Long-term Memory Store
Functional primitives usable with any storage backend
Supports any LLM provider via API key configuration

Pros & Cons

Pros
  • Simple API for adding memory to any LangGraph agent
  • Works with any storage system via functional primitives
  • Background memory management automates knowledge extraction
  • Open source and free to use
  • Hot path tools allow agents to actively manage memory during conversations
  • Designed for production with database-backed stores (e.g., AsyncPostgresStore)
Cons
  • Primarily designed for the LangGraph ecosystem; may require additional setup for other frameworks
  • Default InMemoryStore loses data on server restart; requires production store for persistence
  • Requires an LLM provider API key, adding external dependency
  • Background memory manager may introduce complexity for simple use cases

Best For

Building conversational agents that remember user preferencesPersonalizing agent responses based on past interactionsMaintaining consistent behavior across multiple sessionsExtracting and storing key information from conversations for later retrievalContinuous improvement of agent knowledge over time

FAQ

How do I install LangMem?
Install via pip: pip install -U langmem. Then configure an API key for your preferred LLM provider (e.g., export ANTHROPIC_API_KEY='sk-...').
What storage backends does LangMem support?
LangMem works with any storage system via its functional primitives. It natively integrates with LangGraph's Long-term Memory Store, using InMemoryStore for development and AsyncPostgresStore for production persistence.
Can I use LangMem without LangGraph?
Yes, LangMem offers functional primitives that can be used with any storage system. However, the memory tools (create_manage_memory_tool, create_search_memory_tool) are designed to work with LangGraph's BaseStore. You can build custom memory systems without agents.
Does LangMem work with any LLM provider?
Yes, LangMem is provider-agnostic. The documentation shows examples with Anthropic's Claude, but you can configure any supported LLM provider by setting the appropriate API key.