agent-framework-memorysync
MemorySync for the Microsoft Agent Framework: agents that remember users across sessions — without ever stalling a run.
pip install agent-framework-memorysync
Quick start
from agent_framework import Agent
from agent_framework_memorysync import MemorySyncContextProvider
provider = MemorySyncContextProvider(
api_key="ms_...", # or MEMORYSYNC_API_KEY
user_id="customer-42", # required — who these memories belong to
session_id="support", # tags the facts from this conversation
)
agent = Agent(client=..., context_providers=[provider])
result = await agent.run("which seat should I book?")
Every run recalls relevant memories into the instructions layer under a hard budget, and after the run the user's messages are sent to MemorySync, which extracts the durable facts they contain — no extra code per turn. The agent's replies are not sent: assistant replies are not stored as memories.
Why this one
Mem0 (agent-framework-mem0, in-repo) |
Zep (zep-ms-agent-framework) |
MemorySync | |
|---|---|---|---|
| Injection layer | ✗ fabricates a role="user" message |
✓ instructions | ✓ instructions |
| Recall latency budget | ✗ none | ✗ none | ✓ hard 1.2s default — a slow backend means an unenriched run, never a late one |
| Capture failure behaviour | ✗ after_run errors crash the agent |
swallowed | ✓ entirely fail-open, logged |
| Scope model | ✗ storage ≠ retrieval scopes — forget search_user_id and the agent is silently memoryless |
single | ✓ one user_id drives both — the bug cannot exist |
| Per-run identity | ✗ construction-only | ✗ construction-only (documented) | ✓ agent.run(..., options={"memorysync_user_id": ...}) or a user_id_resolver |
| Write dedup | ✗ re-adds every turn | ✗ | ✓ deterministic idempotency seeds — a retried turn is recognised and not extracted twice |
| Tool-loop double-capture | ✗ | — | ✓ after_run_once_per_turn = True |
| Release status | beta (1.0.0b…) |
0.2.1 | ✓ stable 1.1.0 |
| Python | ≥3.10 | ✗ ≥3.11 only | ✓ ≥3.10 (matches the framework) |
Semantics worth knowing
- User messages are sent to fact extraction; only durable facts are
stored. After each run, every user input message goes to MemorySync
as plain text with
role: "user"under theagent-framework::<session>session scope. The server extracts the durable facts it contains and stores only those, tagged withsession_id: "agent-framework::<session>"— the same shared user memories as every other MemorySync surface. Filler such as "ok" or "thanks" yields none, and the message text itself is not stored. The agent's replies are not sent: assistant replies are not stored as memories. - The resolved run identity is pinned in the provider's session-state
slice, so recall and capture can never diverge within a run — and the
slice stays JSON-native, so
AgentSessionserialization keeps working. expose_search_tool=Trueaddssearch_memory+save_memorytools viacontext.extend_tools.- Free-tier quota exhaustion is silent by design (adds accepted-without-
storing, reads empty); evaluation keys surface strict
429s.
Configuration
| Parameter | Default | Meaning |
|---|---|---|
user_id |
— (required) | End user the memories belong to |
session_id |
"default" |
Session scope: the session_id (agent-framework::<session>) carried by the facts from this conversation |
top_k |
5 |
Memories considered per run |
recall_timeout |
1.2 |
Hard recall budget, seconds |
min_prompt_chars |
8 |
Skip recall for trivial prompts |
context_template |
built-in | {context} placeholder, brace-safe .replace rendering |
capture |
True |
Send the run's user messages for fact extraction after each run |
expose_search_tool |
False |
Register memory tools on every run |
user_id_resolver |
None |
Callable[[AgentSession], str] for dynamic identity |
Development
pip install -e . agent-framework-core pytest pytest-asyncio "httpx>=0.25,<1"
python -m pytest tests -q # 26 tests incl. a REAL Agent run (stub chat client)
License
MIT
Metadata
Release files for agent-framework-memorysync 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| agent_framework_memorysync-1.1.0.tar.gz | 17.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agent_framework_memorysync-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.4 kB
Release files / agent_framework_memorysync-1.1.0.tar.gz
| Download URL | agent_framework_memorysync-1.1.0.tar.gz |
|---|---|
| Size | 17.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
698c547fd02d46227c165038c0a09b65fc0c33807f8beee5ec75c9e23edf6722
|
|
BLAKE2b-256 checksum How to use checksums |
dbbb03294bedfcc0cbb2d5e1fa8fc4eff22b65aa537a43ebb4ae6d6c4c8f5db1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.5
|
Release files / agent_framework_memorysync-1.1.0-py3-none-any.whl
| Download URL | agent_framework_memorysync-1.1.0-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eed4d127cef929db654a593c496ff0f7f7de520be0ebe4c237b3837200b87f3a
|
|
BLAKE2b-256 checksum How to use checksums |
aaa65fe7b70355fbd56b9d78c89e99cfde8d33e9fb5c7c03bc5e432ff8305f65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.5
|