Skip to main content
Microsoft’s Agent Framework is a Python framework for building AI agents with tools, handoffs, and context providers. Supermemory integrates natively as a context provider, tool set, or middleware — so your agents remember users across sessions.

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:
Or with uv:
The --pre / --prerelease=allow flag is required because agent-framework-core depends on pre-release versions of Azure packages.
Set up your environment:
Get your Supermemory API key from console.supermemory.ai.

Connection

All integration points share a single AgentSupermemory connection. This ensures the same API client, container tag, and conversation ID are used across middleware, tools, and context providers.

Connection options

ParameterTypeDefaultDescription
api_keystrenv varSupermemory API key. Falls back to SUPERMEMORY_API_KEY
container_tagstr"msft_agent_chat"Memory scope (e.g., user ID)
conversation_idstrauto-generatedGroups messages into a conversation
entity_contextstrNoneCustom context about the user, prepended to memories
Pass this connection to any integration:

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

  1. before_run() — Searches Supermemory for the user’s profile and relevant memories, then injects them into the session context as additional instructions
  2. after_run() — If store_conversations=True, saves the conversation to Supermemory so future sessions have more context

Configuration options

ParameterTypeDefaultDescription
connectionAgentSupermemoryrequiredShared connection
modestr"full""profile", "query", or "full"
store_conversationsboolFalseSave conversations after each run
context_promptstrbuilt-inCustom prompt describing the memories
verboseboolFalseEnable detailed logging

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 query
  • add_memory — Store new information for later recall
  • get_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

ModeWhat it fetchesBest for
"profile"User profile (static + dynamic facts) onlyPersonalization without query overhead
"query"Memories relevant to the current message onlyTargeted recall, no profile data
"full" (default)Profile + query search combinedMaximum context

Example: support agent with memory

A support agent that remembers customers across sessions:

Error handling

The package provides specific exception types:
ExceptionWhen
SupermemoryConfigurationErrorMissing API key or invalid config
SupermemoryAPIErrorAPI returned an error response
SupermemoryNetworkErrorConnection failure
SupermemoryTimeoutErrorRequest timed out
SupermemoryMemoryOperationErrorMemory add/search failed

User profiles

How automatic profiling works

Search

Filtering and search modes

OpenAI Agents SDK

Memory for OpenAI Agents SDK

LangChain

Memory for LangChain apps