Python: Add Foundry Memory Context Provider#3943
Merged
eavanvalkenburg merged 13 commits intomainfrom Feb 24, 2026
Merged
Conversation
Copilot
AI
changed the title
[WIP] Add Foundry Memory Context Provider
Python: Add Foundry Memory Context Provider
Feb 15, 2026
Member
There was a problem hiding this comment.
@copilot couple of comments, please address
python/packages/azure-ai/agent_framework_azure_ai/_foundry_memory_provider.py
Show resolved
Hide resolved
python/packages/azure-ai/agent_framework_azure_ai/_foundry_memory_provider.py
Outdated
Show resolved
Hide resolved
python/packages/azure-ai/agent_framework_azure_ai/_foundry_memory_provider.py
Outdated
Show resolved
Hide resolved
python/packages/azure-ai/agent_framework_azure_ai/_foundry_memory_provider.py
Outdated
Show resolved
Hide resolved
Member
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
eavanvalkenburg
approved these changes
Feb 16, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Python context provider that integrates Azure AI Foundry Memory Store into Agent Framework’s context-provider pipeline, along with public exports, tests, and documentation/sample usage.
Changes:
- Introduces
FoundryMemoryProvider(BaseContextProvider) backed byazure.ai.projectsmemory store APIs. - Exposes
FoundryMemoryProviderviaagent_framework.azureandagent_framework_azure_aipackage exports/stubs. - Adds unit tests and a runnable sample demonstrating memory store creation, usage, and cleanup.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| python/packages/azure-ai/agent_framework_azure_ai/_foundry_memory_provider.py | Implements Foundry memory search + update hooks and session-state namespacing. |
| python/packages/azure-ai/tests/test_foundry_memory_provider.py | Adds unit tests covering init, hook behavior, state, and async context manager behavior. |
| python/packages/core/agent_framework/azure/init.py | Adds lazy export for FoundryMemoryProvider from agent_framework_azure_ai. |
| python/packages/core/agent_framework/azure/init.pyi | Adds typing export for FoundryMemoryProvider. |
| python/packages/azure-ai/agent_framework_azure_ai/init.py | Re-exports FoundryMemoryProvider from the azure-ai integration package. |
| python/packages/azure-ai/README.md | Documents the new provider and links to the sample. |
| python/samples/02-agents/context_providers/azure_ai_foundry_memory.py | Adds an end-to-end sample showing Foundry memory store setup and agent usage. |
python/packages/azure-ai/agent_framework_azure_ai/_foundry_memory_provider.py
Show resolved
Hide resolved
python/samples/02-agents/context_providers/azure_ai_foundry_memory.py
Outdated
Show resolved
Hide resolved
eavanvalkenburg
approved these changes
Feb 16, 2026
add1492 to
919fa08
Compare
4 tasks
eavanvalkenburg
approved these changes
Feb 17, 2026
westey-m
reviewed
Feb 17, 2026
python/samples/02-agents/context_providers/azure_ai_foundry_memory.py
Outdated
Show resolved
Hide resolved
westey-m
approved these changes
Feb 17, 2026
8b709ee to
1179457
Compare
Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>
Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>
Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>
…ger, move state to session.state Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1179457 to
15c9670
Compare
- Use Mock objects with memory_item.content for memory mocks - Assert 'content' instead of 'text' on SDK message items - Update exception types from ServiceInitializationError to ValueError - Remove unused ServiceInitializationError import Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add type: ignore[arg-type] for scope (str | None vs str) and items (list variance) passed to Azure SDK methods. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
TaoChenOSU
reviewed
Feb 23, 2026
giles17
approved these changes
Feb 23, 2026
github-merge-queue bot
pushed a commit
that referenced
this pull request
Feb 24, 2026
* Initial plan * Add FoundryMemoryProvider and tests Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com> * Add sample and documentation for FoundryMemoryProvider Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com> * Address code review feedback for FoundryMemoryProvider Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com> * Address PR review comments: Add DEFAULT_SOURCE_ID, use logging.getLogger, move state to session.state Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com> * Fix Foundry memory ItemParam usage and exports Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Refactor provider hook state and standardize source IDs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Support endpoint-based Foundry memory init Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * updated implementation and sample * updated code and samples * Fix foundry memory provider tests: mock structure and field names - Use Mock objects with memory_item.content for memory mocks - Assert 'content' instead of 'text' on SDK message items - Update exception types from ServiceInitializationError to ValueError - Remove unused ServiceInitializationError import Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix mypy errors in foundry memory provider Add type: ignore[arg-type] for scope (str | None vs str) and items (list variance) passed to Azure SDK methods. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix import --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com> Co-authored-by: eavanvalkenburg <github@vanvalkenburg.eu> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Agents need persistent semantic memory capabilities using Azure AI Foundry Memory Store. Existing context providers (Mem0, Redis) don't integrate with Foundry's memory APIs.
Description
Implements
FoundryMemoryProvideras aBaseContextProviderthat wraps Azure AI Projects SDK memory operations.Architecture:
before_run: Retrieves static memories (user profiles) once per session, then searches contextual memories per turn usingsearch_memoriesAPIafter_run: Firesbegin_update_memorieswith configurable delay (default 300s), chains operations viaprevious_update_idsession.state[source_id]for proper persistence and multi-provider supportproject_client(follows Mem0ContextProvider pattern with_should_close_clientflag)Key implementation details:
ItemParamfor message formatting, compatible with Foundry memory extraction pipelinesource_idprevents collisions when multiple providers are usedupdate_delayparameterDEFAULT_SOURCE_ID = "foundry"provides sensible default while allowing customizationlogging.getLogger(__name__)for loggingUsage:
Files:
_foundry_memory_provider.py(237 lines)azure_ai_foundry_memory.pydemonstrating memory store creation/cleanup with correct environment variable namesContribution Checklist
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.