Skip to content

.NET: Add IContextProvider implementation for Foundry Memory #3673

@rogerbarreto

Description

@rogerbarreto

Part of #3440

Summary

Add an \AIContextProvider\ implementation for Azure AI Foundry Memory service, enabling agents to store and retrieve long-term memories automatically.

Implementation Details

New Package: Microsoft.Agents.AI.FoundryMemory

Introduces \FoundryMemoryProvider, a context provider that integrates with Azure AI Foundry's managed memory service. The provider automatically extracts memories from conversations and retrieves relevant memories to augment agent context on each invocation, following the same pattern established by the Mem0 provider.

Features

  • FoundryMemoryProvider implementing \AIContextProvider\ with automatic memory extraction and retrieval
  • Scoped memory storage by configurable identifier (e.g., user ID) for multi-tenant scenarios
  • Memory store management:
    • \EnsureMemoryStoreCreatedAsync()\ - Create memory stores with specified chat and embedding models
    • \EnsureStoredMemoriesDeletedAsync()\ - Clear memories for a scope
  • Async update polling: \WhenUpdatesCompletedAsync()\ polls pending memory updates in parallel until completion
  • Session serialization/deserialization support for state persistence
  • Configurable options: max memories, update delay, and context prompt

Configuration

Option Default Description
\MemoryStoreName\ (required) Name of the memory store in Azure AI Foundry
\MaxMemories\ 5 Maximum memories to retrieve per search
\UpdateDelay\ 0 Delay in seconds before processing updates
\ContextPrompt\ (default) Custom prompt prefix for injected memories

Environment Variables (Sample)

  • \FOUNDRY_PROJECT_ENDPOINT\ - Azure AI Foundry project endpoint
  • \FOUNDRY_PROJECT_MEMORY_STORE_NAME\ - Memory store name
  • \FOUNDRY_PROJECT_MODEL\ - Chat model deployment name
  • \FOUNDRY_PROJECT_EMBEDDING_MODEL\ - Embedding model deployment name

Deliverables

  • \Microsoft.Agents.AI.FoundryMemory\ package with provider implementation
  • Unit tests for constructor validation and serialization
  • Integration tests (skipped by default, requires Azure setup)
  • Sample application demonstrating end-to-end usage

Metadata

Metadata

Assignees

Labels

.NETagentsIssues related to single agentsblocked externalThis label indicates whenever an issue or a PR cannot proceed due to an external dependencypythonv1.0Features being tracked for the version 1.0 GA

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions