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:
- Functions to extract and enrich memories from trajectories & interactions
- Configurable memory managers and agent tools that integrate with LangGraph's storage layer
- 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:
- Memory Tools - Configure how memories are handled
- Functional Primitives - Build custom memory systems
- Storage Options - Add persistent storage
Next Steps
For more examples and detailed documentation:
- Quickstart Guide - Get up and running
- Core Concepts - Learn key ideas
- API Reference - Full function documentation
- Integration Guides - Common patterns and best practices
Requirements
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)
| File | Size | Uploaded | |
|---|---|---|---|
| langmem-0.0.5rc9.tar.gz | 40.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|