LangMem

Long-term memory for LangChain agents

open-sourcebetapythonopen-sourcelangchainlanggraph

Memory Types

semantic, episodic, user-profiles

Integrations

langchain, langgraph


Overview


LangMem is LangChain's official library for adding long-term memory to LangGraph agents. It provides memory extraction, storage, and retrieval capabilities designed to integrate seamlessly with the LangChain ecosystem.


Key Features


  • **Memory Extraction**: Automatically extracts memorable information from conversations
  • **Semantic Memory**: Store and query facts and preferences
  • **LangGraph Integration**: Native integration with LangGraph agents
  • **Flexible Storage**: Supports various vector store backends
  • **Memory Namespaces**: Organize memories by user, session, or custom scopes

  • When to Use LangMem


    LangMem is ideal for:

  • Existing LangChain/LangGraph projects needing memory
  • Teams already invested in the LangChain ecosystem
  • Applications requiring tight integration with LangGraph workflows
  • Building agents that learn from conversations

  • Pros


  • Official LangChain support
  • Seamless LangGraph integration
  • Flexible and extensible
  • Good documentation
  • Active development

  • Cons


  • Requires LangChain/LangGraph knowledge
  • Relatively new library
  • Less standalone than other options
  • Tied to LangChain ecosystem

  • Getting Started


    from langmem import create_memory_store

    from langgraph.prebuilt import create_react_agent


    # Create memory store

    memory = create_memory_store(

    embeddings=embeddings,

    store=vector_store

    )


    # Use with LangGraph agent

    agent = create_react_agent(

    model=model,

    tools=tools,

    memory=memory

    )


    Architecture


    LangMem uses a modular architecture:


  • **Memory Store**: Handles storage and retrieval
  • **Memory Extractors**: Pull memorable info from conversations
  • **Memory Injectors**: Add relevant memories to prompts

  • Pricing


  • **Open Source**: Free, Apache 2.0 license