Registry / llm-agents / langmem

langmem

JSON →
library0.0.30pypypi✓ verified 22d ago

LangMem (version 0.0.30) is a Python library providing prebuilt utilities for memory management and retrieval, specifically designed for AI agents and LLM applications. It offers abstractions for integrating with various embedding models and vector stores, facilitating the creation of intelligent systems with long-term memory. The library is under active development with frequent minor updates.

pip install langmem
INSTALL
IMPORT
SIG · LANGMEM
L
langmem
llm-agentspythonv0.0.30
Install
11.8s avg
Import
3727ms
Disk
130MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.30 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 14.15s
py 3.11
✓ —
✓ 12.4s
py 3.12
✓ —
✓ 10.25s
py 3.13
✓ —
✓ 10.2s
py 3.9
✕ build_error
✕ build_error
130MB installed
● package 130MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Prompt
from langmem import Prompt
from langmem import MemoryManager
ReflectionExecutor
from langmem import ReflectionExecutor
create_memory_manager
from langmem import create_memory_manager

This quickstart demonstrates how to set up `MemoryManager` with `OpenAIEmbeddings` and `Chroma` to add and recall memories. It assumes `openai` and `chromadb` are installed (e.g., via `pip install langmem[openai,chromadb]`) and `OPENAI_API_KEY` is configured in your environment. Note the use of `embedding_function` when initializing `Chroma`.

import os from langmem import MemoryManager from langmem.embeddings import OpenAIEmbeddings from langmem.vectorstores import Chroma # NOTE: For this example, you need to install 'openai' and 'chromadb' # pip install langmem openai chromadb # Ensure OPENAI_API_KEY is set in your environment variables. # For testing, you can uncomment and set it directly: # os.environ['OPENAI_API_KEY'] = 'YOUR_OPENAI_API_KEY' openai_api_key = os.environ.get('OPENAI_API_KEY', '') if not openai_api_key: print("Warning: OPENAI_API_KEY environment variable not set. OpenAIEmbeddings might fail.") # Initialize embeddings and vector store embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key) vectorstore = Chroma(embedding_function=embeddings) # Chroma requires embedding_function # Initialize MemoryManager memory_manager = MemoryManager(vectorstore=vectorstore) # Add memories memory_manager.add_memory("The quick brown fox jumps over the lazy dog.") memory_manager.add_memory("The quick red bird flies high in the sky.") memory_manager.add_memory("The lazy dog often naps under the oak tree.") # Recall information results = memory_manager.recall("What is the fox doing?") print("\nRecall results for 'What is the fox doing?':", results) results = memory_manager.recall("Where does the dog nap?") print("\nRecall results for 'Where does the dog nap?':", results)
Debug
Known issues
breakingAPI stability is not guaranteed below version 1.0.0. The library is in early development (0.0.x), and breaking changes may occur frequently between minor versions without extensive prior notice.
fix
Refer to the GitHub repository and commit history for recent changes. Pin your dependency versions to specific patch releases (e.g., `langmem==0.0.30`) to mitigate unexpected breaks.
affects: <1.0.0
gotchaMany useful components (e.g., specific embedding models, vector stores) are optional dependencies. You must explicitly install them (e.g., `pip install openai chromadb`) to use them with `langmem`.
fix
Consult the `pyproject.toml` or `setup.py` on GitHub for available `extras_require` groups, or manually install individual packages as needed for your chosen components.
affects: All
gotchaWhen initializing vector stores like `Chroma`, ensure you pass the embedding model instance using the correct parameter name, which is `embedding_function`, not `embeddings`.
fix
Use `vectorstore = Chroma(embedding_function=embeddings_instance)` to correctly configure your vector store with an embedding model.
affects: All
gotchaFor cloud-based embedding services (e.g., OpenAIEmbeddings), the necessary API key (e.g., `OPENAI_API_KEY`) must be set in your environment variables or passed directly during initialization. Forgetting this will lead to authentication errors.
fix
Set the API key as an environment variable (e.g., `export OPENAI_API_KEY='your_key'`) or pass it directly to the constructor (e.g., `OpenAIEmbeddings(openai_api_key='your_key')`).
affects: All
Upgrade
Version history
0.0.30latest on PyPI · released Oct 27, 2025
Audit
Dependencies
openaioptionalRequired for using OpenAIEmbeddings and other OpenAI-related components.
chromadboptionalRequired for using the Chroma vector store.
Agent activity
50 hits · last 30 days
node
44
OpenAI (training)
1
Resources
langmem — pip install langmem · libregistry