Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

LangMem

LangMem exports utilities for extracting, updating, generalizing, storing, and retrieving information from interactions in LLM applications. It offers:

  1. Functions to extract and enrich memories from trajectories & interactions
  2. Configurable memory managers and agent tools that integrate with LangGraph's storage layer
  3. Deployable entrypoints that let you build and deploy memory systems in LangGraph Platform

This lets you build your own memory layer faster, using the level of abstraction and durability that suits your needs. Compared to raw LLM extraction, LangMem handles memory management configuration, letting you define how to form new memories and evolve or prune old ones through validated types. Compared to high-level frameworks, it exposes the lower-level primitives used to build exactly the memory system you want without being forced into adopting a specific database or storage layer.

Installation

pip install -U langmem

Configure your environment with an API key for your favorite LLM provider:

export ANTHROPIC_API_KEY="sk-..."  # Or another supported LLM provider

Here's how to create an agent with memory in just a few lines:

from langgraph.prebuilt import create_react_agent
from langgraph.store.memory import InMemoryStore
from langmem import create_manage_memory_tool, create_search_memory_tool

store = InMemoryStore()

agent = create_react_agent(
    "anthropic:claude-3-5-sonnet-latest",
    tools=[
        create_manage_memory_tool(namespace=("memories",)),  # Store memories
        create_search_memory_tool(namespace=("memories",)),  # Search memories
    ],
    store=store,
)

Then use the agent:

agent.invoke(
    {"messages": [{"role": "user", "content": "Remember that I prefer dark mode."}]}
)

response = agent.invoke(
    {"messages": [{"role": "user", "content": "What are my preferences?"}]}
)
print(response["messages"][-1].content)
# Output: "You've told me that you prefer dark mode."

The agent can now store important information from conversations, search its memory when relevant, and persist knowledge across conversations.

For more control over memory management, check out:

Next Steps

For more examples and detailed documentation:

Requirements

  • Python 3.11+
  • Access to a supported LLM provider (Anthropic, OpenAI, etc.)
  • Optional: LangGraph BaseStore implementation for persistent storage (for the stateful primitives); if you're deploying on LangGraph Platform, this is included without any additional configuration.

Metadata

Release files for langmem 0.0.5rc9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langmem 0.0.5rc9
File Size Uploaded
langmem-0.0.5rc9.tar.gz 40.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langmem 0.0.5rc9
File Interpreter ABI Platform
langmem-0.0.5rc9-py3-none-any.whl Python 3 none any Details

Total release size: 85.8 kB

Release files / langmem-0.0.5rc9.tar.gz

Download URL langmem-0.0.5rc9.tar.gz
Size 40.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8cf79de9801cc1993984f18e4314f35431de0449fc70c439d35ca91204c4b040
BLAKE2b-256 checksum
How to use checksums
eb3e5bb2ed9944209c960185ae4c7b1e931c0df426fe27f1abaf963bbacc1753
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.29

Release files / langmem-0.0.5rc9-py3-none-any.whl

Download URL langmem-0.0.5rc9-py3-none-any.whl
Size 45.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47b96c1635893937bb57690f823afd049b471d4cfdf37c6daefd16b303b1e887
BLAKE2b-256 checksum
How to use checksums
dd6562eace84d73421c64b28682803e4bdd1f1e5ad14fbf277575a127841b5fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.29

Release history Release notifications | RSS feed

0.0.30

2 release files

0.0.29

2 release files

0.0.27

2 release files

0.0.26

2 release files

0.0.25

2 release files

0.0.24

2 release files

0.0.23

2 release files

0.0.22

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.14

1 release file

0.0.13

2 release files

0.0.12

1 release file

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.6

2 release files

This release

0.0.5rc9 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page