mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
9355329dfd
* updated structure and samples * updated names and removed cross tests * updated projects etc * updated tests * updated test * test fixes * removed devui for now * updated all-tests task * removed old style configs * remove coverage from tests * updated to unit tests with all-tests * updated foundry everywhere * fix azure ai tests * fix merge tests * fix mypy
9355329dfd
ยท
2025-09-25 07:02:53 +00:00
History
Mem0 Context Provider Examples
Mem0 is a self-improving memory layer for Large Language Models that enables applications to have long-term memory capabilities. The Agent Framework's Mem0 context provider integrates with Mem0's API to provide persistent memory across conversation sessions.
This folder contains examples demonstrating how to use the Mem0 context provider with the Agent Framework for persistent memory and context management across conversations.
Examples
| File | Description |
|---|---|
mem0_basic.py |
Basic example of using Mem0 context provider to store and retrieve user preferences across different conversation threads. |
mem0_threads.py |
Advanced example demonstrating different thread scoping strategies with Mem0. Covers global thread scope (memories shared across all operations), per-operation thread scope (memories isolated per thread), and multiple agents with different memory configurations for personal vs. work contexts. |
Prerequisites
Required Resources
- Mem0 API Key - Sign up for a Mem0 account and get your API key
- Azure AI project endpoint (used in these examples)
- Azure CLI authentication (run
az login)
Configuration
Environment Variables
Set the following environment variables:
For Mem0:
MEM0_API_KEY: Your Mem0 API key (alternatively, pass it asapi_keyparameter toMem0Provider)
For Azure AI:
AZURE_AI_PROJECT_ENDPOINT: Your Azure AI project endpointAZURE_AI_MODEL_DEPLOYMENT_NAME: The name of your model deployment
Key Concepts
Memory Scoping
The Mem0 context provider supports different scoping strategies:
- Global Scope (
scope_to_per_operation_thread_id=False): Memories are shared across all conversation threads - Thread Scope (
scope_to_per_operation_thread_id=True): Memories are isolated per conversation thread
Memory Association
Mem0 records can be associated with different identifiers:
user_id: Associate memories with a specific useragent_id: Associate memories with a specific agentthread_id: Associate memories with a specific conversation threadapplication_id: Associate memories with an application context