Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build and deploy AI applications on Azure AI Foundry using Microsoft's model catalog and AI services
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
foundry-agent/create/references/tool-memory.md
1# Agent Memory23Managed long-term memory for Foundry agents. Enables agent continuity across sessions, devices, and workflows. Agents retain user preferences, conversation history, and deliver personalized experiences. Memory is stored in your project's owned storage.45## Prerequisites67- A [Foundry project](https://learn.microsoft.com/azure/ai-foundry/how-to/create-projects) with authorization configured8- A **chat model deployment** (e.g., `gpt-5.2`)9- An **embedding model deployment** (e.g., `text-embedding-3-small`) — see [Check Embedding Model](#check-embedding-model) below10- Python packages: `pip install azure-ai-projects azure-identity`1112### Check Embedding Model1314An embedding model is **required** before enabling memory. Check if one is already deployed:1516Use `foundry_models_list` MCP tool to list all deployments and look for an embedding model (e.g., `text-embedding-3-small`, `text-embedding-3-large`, `text-embedding-ada-002`).1718| Result | Action |19|--------|--------|20| ✅ Embedding model found | Note the deployment name and proceed |21| ❌ No embedding model | Deploy one before enabling memory — see below |2223### Deploy Embedding Model2425If no embedding model exists, use `foundry_models_deploy` MCP tool with:26- `deploymentName`: `text-embedding-3-small` (or preferred name)27- `modelName`: `text-embedding-3-small`28- `modelFormat`: `OpenAI`2930## Authorization and Permissions3132| Role | Scope | Purpose |33|------|-------|---------|34| **Azure AI User** | AI Services resource | Assigned to project managed identity |35| **System-assigned managed identity** | Project | Must be enabled on the project |3637**Setup steps:**381. In Azure portal → project → **Resource Management** → **Identity** → enable system-assigned managed identity392. On the AI Services resource → **Access control (IAM)** → assign **Azure AI User** to the project managed identity4041## Workflow4243```44User wants agent memory45│46▼47Step 1: Check for embedding model deployment48│ ├─ ✅ Found → Continue49│ └─ ❌ Not found → Deploy one (ask user)50│51▼52Step 2: Create memory store53│54▼55Step 3: Attach memory tool to agent56│57▼58Step 4: Test with conversation59```6061## Key Concepts6263### Memory Store Options6465| Option | Description |66|--------|-------------|67| `chat_summary_enabled` | Summarize conversations for memory |68| `user_profile_enabled` | Build and maintain user profile |69| `user_profile_details` | Control what data gets stored (e.g., `"Avoid sensitive data such as age, financials, location, credentials"`) |7071> 💡 **Tip:** Use `user_profile_details` to control what the agent stores — e.g., `"flight carrier preference and dietary restrictions"` for a travel agent, or exclude sensitive data.7273### Scope7475The `scope` parameter partitions memory per user:7677| Scope Value | Behavior |78|-------------|----------|79| `{{$userId}}` | Auto-extracts TID+OID from auth token (recommended) |80| `"user_123"` | Static identifier — you manage user mapping |8182### Memory Store Operations8384| Operation | Description |85|-----------|-------------|86| Create | Initialize a memory store with chat/embedding models and options |87| List | List all memory stores in the project |88| Update | Update memory store description or configuration |89| Delete scope | Delete memories for a specific user scope |90| Delete store | Delete entire memory store (irreversible — all scopes lost) |9192> ⚠️ **Warning:** Deleting a memory store removes all memories across all scopes. Agents with attached memory stores lose access to historical context.9394## Troubleshooting9596| Issue | Cause | Resolution |97|-------|-------|------------|98| Auth/authorization error | Identity or managed identity lacks required roles | Verify roles in Authorization section; refresh access token for REST |99| Memories don't appear after conversation | Updates are debounced or still processing | Increase wait time or call update API with `update_delay=0` |100| Memory search returns no results | Scope mismatch between update and search | Use same scope value for storing and retrieving memories |101| Agent response ignores stored memory | Agent not configured with memory search tool | Confirm agent definition includes `MemorySearchTool` with correct store name |102| No embedding model available | Embedding deployment missing | Deploy an embedding model — see Check Embedding Model section |103104## References105106- [Memory tool documentation](https://learn.microsoft.com/azure/ai-foundry/agents/how-to/memory-usage?view=foundry)107- [Memory Concepts](https://learn.microsoft.com/azure/ai-foundry/agents/concepts/what-is-memory)108- [Tool Catalog](https://learn.microsoft.com/azure/ai-foundry/agents/concepts/tool-catalog?view=foundry)109- [Python Samples](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/ai/azure-ai-projects/samples/memories)110