autogen-memorysync
MemorySync for Microsoft AutoGen
(autogen-agentchat 0.4+): agents that remember users across sessions —
without ever stalling a turn.
pip install autogen-memorysync
Quick start
from autogen_agentchat.agents import AssistantAgent
from autogen_memorysync import MemorySyncMemory
memory = MemorySyncMemory(
api_key="ms_...", # or MEMORYSYNC_API_KEY
user_id="customer-42", # required — who these memories belong to
session_id="support-chat", # scopes the transcript
)
agent = AssistantAgent("assistant", model_client=..., memory=[memory])
result = await agent.run(task=user_text)
# AutoGen never persists automatically — capture the exchange in one call:
await memory.add_turn_pair(user_text, result.messages[-1].content)
update_context runs automatically before every model call: relevant
memories are recalled and injected as a SystemMessage, and the
retrieval surfaces to observers as a MemoryQueryEvent.
Why this one
Mem0 (autogen-ext[mem0]) |
Zep (zep-autogen) |
MemorySync | |
|---|---|---|---|
| Async correctness | ✗ sync client inside async def — blocks the event loop |
✓ | ✓ httpx.AsyncClient throughout |
| Recall latency budget | ✗ none | ✗ none | ✓ hard 1.2s default — a slow backend means an unenriched turn, never a late one |
| Retrieval query | ✗ messages[-1] even when it's assistant/tool text |
last context message | ✓ last user message, role-aware |
| Query errors | ✗ swallowed — outage looks like amnesia | logged | ✓ explicit query() raises; only the hot path fails open |
clear() blast radius |
✗ entire user | ✗ entire user | ✓ session-scoped by default; whole-user wipe is an explicit opt-in |
| Retry safety | ✗ | ✗ | ✓ deterministic idempotency seeds — retries converge on one row |
| Caller's metadata dict | ✗ mutated (pop) |
— | ✓ copied, never touched |
close() |
pass |
✓ | ✓ releases the HTTP client |
Semantics worth knowing
- The turn is never stalled and never broken. Recall waits at most
recall_timeout(default 1.2s); on timeout, outage, or quota exhaustion the agent simply answers without memories. user_idis required. No silent auto-generated UUID namespaces where stored memories can never be found again.- Turns store verbatim under the
autogen::<session>transcript scope — separate history, same shared user memories as every other MemorySync surface. - Free-tier quota exhaustion is silent by design (adds accepted-without-
storing, reads empty); evaluation keys surface strict
429s. create_memory_tools(memory)returnssearch_memory+save_memoryFunctionTools for tool-equipped agents.
Configuration
| Parameter | Default | Meaning |
|---|---|---|
user_id |
— (required) | End user the memories belong to |
session_id |
"default" |
Transcript scope |
top_k |
5 |
Memories considered per turn |
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 |
clear_scope |
"session" |
clear() blast radius; "user" opt-in wipes everything |
Development
pip install -e . autogen-agentchat autogen-ext pytest pytest-asyncio
python -m pytest tests -q # 33 tests incl. a REAL AssistantAgent drive
Note: autogen-agentchat is in maintenance mode (Microsoft's successor
is the Microsoft Agent Framework — a separate MemorySync adapter target).
Maintenance mode means the Memory protocol this package implements is
frozen and stable.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autogen_memorysync-1.0.0.tar.gz.
File metadata
- Download URL: autogen_memorysync-1.0.0.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e742292ddccae9026c33f777915ca42b393755ee6e56c0e19be71f42c02ff19
|
|
| MD5 |
393f2d1a085980863cd00e5b5cd90875
|
|
| BLAKE2b-256 |
b891a97efdcbd013682975015d97fc21c04ced5271129f1cf75ee4da4c9f63ee
|
File details
Details for the file autogen_memorysync-1.0.0-py3-none-any.whl.
File metadata
- Download URL: autogen_memorysync-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06ff23331a24cdc967e7ef4f2fd95858a3e7ad42ffc83b5e3c7f915d32555abd
|
|
| MD5 |
1ae13b68a01f0eb340d84c113c0a6afc
|
|
| BLAKE2b-256 |
e232077e706e90ca074456ef24c4c25c40cc4303f627afdfaeaba22b20230bf5
|