Microsoft Agent Framework memory
A ContextProvider with budgeted instruction-layer recall, per-run identity, and capture that can never crash the agent.
Overview
Install agent-framework-memorysync and Microsoft Agent Framework agents remember users across sessions. MemorySyncContextProvider rides the framework’s ContextProvider seam: before every run, relevant memories are recalled under a hard budget (default 1.2s) and injected into the instructions layer — the system prompt, where context belongs (the first-party Mem0 provider fabricates a role="user" message instead). After every run the user’s messages are sent to fact extraction automatically with deterministic idempotency seeds, once per user turn even in tool loops, and entirely fail-open — the Mem0 provider’s after_run errors crash the agent after a successful run. The agent’s replies are not sent: assistant replies are not stored as memories. One user_id drives storage AND retrieval (Mem0 splits them; forget the search scope and your agent is silently memoryless), and a per-run identity ladder — agent.run options, a resolver callable, then the constructor — solves the construction-bound identity limitation both Mem0 and Zep document. Python 3.10+, matching the framework itself (Zep requires 3.11).
Setup status and requirements
- Supported version
- agent-framework-memorysync 1.1.0 (PyPI)
- Last setup review
- 2026-10-01
- Permissions
- A MemorySync API key with read and write scopes.
- Limits
- Requires agent-framework-core 1.8+ (Python 3.10+).
Capabilities
- Instructions-layer injection — never a fabricated user message
- Hard recall budget (default 1.2s) — a run is never stalled
- Capture is entirely fail-open — a memory outage can never crash the agent
- Per-run identity: agent.run options → resolver → constructor
- One user_id drives storage and retrieval — no silent memoryless agents
- once-per-turn capture in tool loops; deterministic idempotency seeds
- Session state stays JSON-native — AgentSession serialization keeps working
- Optional search_memory + save_memory tools via extend_tools
Quick Start
from agent_framework import Agentfrom agent_framework_memorysync import MemorySyncContextProviderprovider = MemorySyncContextProvider(api_key="ms_...",user_id="customer-42",session_id="support",)agent = Agent(client=..., context_providers=[provider])result = await agent.run("which seat should I book?")# per-run identity (neither Mem0 nor Zep supports this):await agent.run("...", options={"memorysync_user_id": "other-user"})
Use Cases
Azure-stack agents that greet returning users with context
Multi-tenant services resolving identity per request, not per provider
Migrating off the beta Mem0 provider and its crash-on-capture behaviour
Guides and related pages
Related integrations
Explore More
Add long-term memory to Microsoft Agent Framework
Start free with 10,000 add requests a month and no credit card. Memory is stored per end user and comes back in every later session.
