What you can do
- Automatically inject user memories before every agent run (context provider)
- Give agents tools to search and store memories on their own
- Intercept chat requests to add memory context via middleware
- Combine all three for maximum flexibility
Setup
Install the package:Get your Supermemory API key from console.supermemory.ai.
Connection
All integration points share a singleAgentSupermemory connection. This ensures the same API client, container tag, and conversation ID are used across middleware, tools, and context providers.
Connection options
Pass this connection to any integration:
Context provider (recommended)
The most idiomatic integration. Follows the same pattern as Agent Framework’s built-in Mem0 provider — memories are automatically fetched before the LLM runs and conversations can be stored afterward.How it works
before_run()— Searches Supermemory for the user’s profile and relevant memories, then injects them into the session context as additional instructionsafter_run()— Ifstore_conversations=True, saves the conversation to Supermemory so future sessions have more context
Configuration options
Memory tools
Give agents explicit control over memory operations. The agent decides when to search or store information.Available tools
The agent gets three tools:search_memories— Search for relevant memories by queryadd_memory— Store new information for later recallget_profile— Fetch the user’s full profile (static + dynamic facts)
Chat middleware
Intercept chat requests to automatically inject memory context. Useful when you want memory injection without the session-based context provider pattern.Memory modes
Example: support agent with memory
A support agent that remembers customers across sessions:Error handling
The package provides specific exception types:Related docs
User profiles
How automatic profiling works
Search
Filtering and search modes
OpenAI Agents SDK
Memory for OpenAI Agents SDK
LangChain
Memory for LangChain apps