mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
1e527a328c
* Python: Remove unsupported memory scoping params from samples and docs Fixes #4353 The `Mem0ContextProvider` and `RedisContextProvider` no longer support `thread_id` or `scope_to_per_operation_thread_id` parameters. This commit updates the affected samples and READMEs to use only the currently supported API (`user_id`, `agent_id`, `application_id`). Changes: - mem0_sessions.py: Remove `thread_id` and `scope_to_per_operation_thread_id` from examples 1 and 2, rewrite to demonstrate user-scoped and agent-scoped memory patterns - redis_sessions.py: Update module docstring to remove references to removed thread scoping params - mem0/README.md: Update Memory Scoping docs to reflect current API - redis/README.md: Remove `thread_id` and `scope_to_per_operation_thread_id` references from docs * Address Copilot review: rename thread_scope functions, fix docstring - Rename `example_global_thread_scope` -> `example_global_memory_scope` - Rename `example_per_operation_thread_scope` -> `example_agent_scoped_memory` - Update example 2 docstring to mention `application_id` alongside `user_id` and `agent_id` since it's set in the provider config - Update module docstring scenario 2 to include `application_id` * fix: rebase onto main, address giles17 review feedback - Resolve merge conflicts by rebasing all 4 original files onto current main - Address giles17's agent review suggestions: - mem0_basic.py: update comment to remove thread_id from scoping list - mem0_oss.py: update comment to remove thread_id from scoping list - redis_sessions.py: rename Example 2 from "Agent-Scoped Memory" to "Hybrid Vector Search" to accurately describe what it demonstrates - redis/README.md: update Example 2 description to match renamed example --------- Co-authored-by: Tao Chen <taochen@microsoft.com> Co-authored-by: Giles Odigwe <79032838+giles17@users.noreply.github.com>
2.4 KiB
2.4 KiB
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_sessions.py |
Example demonstrating different memory scoping strategies with Mem0. Covers user-scoped memory (memories shared across all sessions for the same user), agent-scoped memory (memories isolated per agent), and multiple agents with different memory configurations for personal vs. work contexts. |
mem0_oss.py |
Example of using the Mem0 Open Source self-hosted version as the context provider. Demonstrates setup and configuration for local deployment. |
Prerequisites
Required Resources
- Mem0 API Key - Sign up for a Mem0 account and get your API key - or self-host Mem0 Open Source
- Azure AI project endpoint (used in these examples)
- Azure CLI authentication (run
az login)
Configuration
Environment Variables
Set the following environment variables:
For Mem0 Platform:
MEM0_API_KEY: Your Mem0 API key (alternatively, pass it asapi_keyparameter toMem0Provider). Not required if you are self-hosting Mem0 Open Source
For Mem0 Open Source:
OPENAI_API_KEY: Your OpenAI API key (used by Mem0 OSS for embedding generation and automatic memory extraction)
For Azure AI:
FOUNDRY_PROJECT_ENDPOINT: Your Azure AI project endpointFOUNDRY_MODEL: The name of your model deployment
Key Concepts
Memory Scoping
The Mem0 context provider supports scoping via identifiers:
- User scope (
user_id): Associate memories with a specific user, shared across all sessions - Agent scope (
agent_id): Isolate memories per agent persona - Application scope (
application_id): Associate memories with an application context