A fully managed platform in Microsoft Foundry for hosting, scaling, and securing AI agents built with any supported framework or model
Yes. Foundry Agent Service has a built-in managed memory capability: a memory store. This is the Microsoft-aligned way to add persistent user memory for a Foundry agent when the goal is to retain preferences and continuity across sessions.
Key points for the scenario described:
- Built-in persistent memory
- Foundry memory is a managed long-term memory solution.
- It supports persistent storage through memory stores.
- Memory types include:
- User profile memory for durable preferences and personal context.
- Chat summary memory for prior conversation continuity.
- Procedural memory for reusable how-to routines.
- Per-user isolation
- Memory is segmented with the
scopeparameter. - To scope memory to an individual end user, set
scopeto"{{$userId}}"in the memory tool definition and passx-memory-user-id: <user-id>on each response call. - If that header is not passed, scope falls back to the caller’s Microsoft Entra identity.
- For a Teams/Bot Service integration, the practical pattern is to map the Teams/Bot user identity to the value sent in
x-memory-user-id, so each user gets a separate memory partition.
- Memory is segmented with the
- Persistent memory vs session-only context
- Persistent memory should be stored in the memory store.
- Session-only instructions such as “use this source only for this conversation” should remain in the current conversation context and not be written as long-term memory.
- Foundry distinguishes between:
- Static memories injected at the start of a conversation for persistent user context.
- Contextual memories retrieved per turn based on recent messages.
- If direct API control is needed, static memories can be retrieved by calling
search_memorieswithscopeonly, while contextual memories are retrieved by callingsearch_memorieswithitemsset to the latest messages.
- Overriding remembered preferences
- The service supports direct remember-or-forget behavior when a user explicitly asks the agent to remember or forget something.
- It also supports item-level CRUD for memory records, so backend logic can create, inspect, update, or delete individual memory items.
- This supports scenarios where a new instruction replaces an older preference.
- Backend management and deletion
- Yes. Memory can be managed from the backend.
- Supported operations include creating, reading, updating, listing, and deleting individual memory items.
- Store-level retention controls are also available, including default TTL for newly created memory entries.
- Direct remember/forget commands do not override TTL; items can still expire if TTL is configured.
- Implementation choices
- Two supported patterns are documented:
- Attach the memory search tool to the agent so the agent reads and writes memory during conversations.
- Use memory store APIs directly to add memories from conversation content and search memories explicitly.
- For a hosted agent workflow, the quickstart describes wiring a memory store to the agent and using
FoundryMemoryProvider, which retrieves relevant memories before each model call and updates the store after each turn.
- Two supported patterns are documented:
- Recommended implementation path for this scenario
- Create a memory store for the agent.
- Attach the memory search tool to the agent.
- Set per-user
scopeusing"{{$userId}}". - From the Teams/Bot backend, pass
x-memory-user-idfor each user on response calls. - Keep temporary conversation-only instructions in the active thread/request context instead of persisting them.
- Use memory item CRUD or direct remember/forget behavior when preferences must be updated or removed.
- Optionally configure TTL if stored memories should expire automatically.
- Reference samples and architecture guidance in the provided material
- The Foundry quickstart shows a hosted agent with persistent memory backed by a memory store.
- The memory how-to articles cover store creation, agent-tool integration, direct API usage, retention, and item CRUD.