MemorySync
Getting Started

AutoGen Memory

A real Memory-protocol implementation for Microsoft AutoGen (autogen-agentchat 0.4+): recalled context injected before every model call under a hard latency budget, role-aware retrieval, duplicate-proof persistence, and a clear() that cannot wipe a customer by accident. Install autogen-memorysync from PyPI.

What installs

pip install autogen-memorysync

update_context runs automatically before every model call: relevant memories are recalled, injected as a SystemMessage, and surfaced to observers as a MemoryQueryEvent — the framework’s own eventing, not a side channel.

Mem0 (`autogen-ext[mem0]`)Zep (`zep-autogen`)SupermemoryMemorySync
Async correctness✗ sync client inside async methods — blocks the event loop— no adapter at all✓ async httpx throughout
Recall latency budget✗ none✗ none✓ hard 1.2s default, tested against a slow backend
Retrieval querymessages[-1] — assistant text after a tool resultlast context message✓ last user message, role-aware
Explicit query() on failure✗ silently returns empty — outage looks like amnesialogged✓ raises; only the hot path fails open
clear() blast radius✗ the entire user✗ the entire user✓ session-scoped by default; whole-user wipe is an explicit opt-in
Retry safety✓ deterministic idempotency seeds
Docs for the current API△ docs page shows the old 0.2 recipe✗ integration pages 404✓ this page

The capture loop

By verified design, AutoGen never calls `add()` automatically — retrieval and storage are separated, and storage is the application’s job. add_turn_pair(user_text, assistant_text) reduces that job to one call per exchange: both sides store verbatim under the autogen::<session> transcript scope with deterministic idempotency seeds, so a retried call converges on one stored row instead of a duplicate.

GuaranteeHow
A reply is never lateRecall waits at most recall_timeout (default 1.2s); on a miss the agent answers without memories
An outage never breaks the agentupdate_context catches everything, logs a warning, injects nothing
Retries never duplicateSeeds derived from role + session + content hash
Your metadata dict is safeCopied before reading — never mutated (the Mem0 adapter pops keys out of the dict you handed it)
clear() cannot nuke a customerSession-scoped deletion by default; clear_scope="user" is an explicit, documented opt-in

Memory as agent tools

from autogen_memorysync import create_memory_tools
tools = create_memory_tools(memory) # search_memory + save_memory
agent = AssistantAgent("assistant", model_client=...,
memory=[memory], tools=tools)

save_memory goes through the server’s extraction path, so the server — not the model — decides whether the text is durable enough to keep. Free-tier quota exhaustion stays silent by design (adds accepted-without-storing, reads empty); evaluation keys surface truthful 429s.

Configuration

ParameterDefaultMeaning
user_id— (required)End user the memories belong to — never auto-generated (a random namespace strands data)
session_iddefaultTranscript scope: autogen::<session>
top_k5Memories considered per turn
recall_timeout1.2Hard recall budget in seconds
min_prompt_chars8Skip recall for trivial prompts
context_templatebuilt-in{context} placeholder; brace-safe .replace rendering
clear_scopesessionclear() blast radius; "user" opt-in wipes everything

Supported versions

SurfaceRequiresVerified on
autogen-memorysync 1.0.0autogen-agentchat / autogen-core 0.4+ (Python 3.10+)33 CI checks against the latest autogen-agentchat: a REAL AssistantAgent driven via the official ReplayChatCompletionClient (SystemMessage injection in the true turn order, MemoryQueryEvent emission), the role-aware retrieval regression, the 1.2s budget vs a slow backend, session-scoped clear, seed idempotency, metadata non-mutation, and both monthly-quota server modes

Where to go next

Was this page helpful?