Skip to main content

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_id is 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) returns search_memory + save_memory FunctionTools 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

autogen_memorysync-1.0.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autogen_memorysync-1.0.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

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

Hashes for autogen_memorysync-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0e742292ddccae9026c33f777915ca42b393755ee6e56c0e19be71f42c02ff19
MD5 393f2d1a085980863cd00e5b5cd90875
BLAKE2b-256 b891a97efdcbd013682975015d97fc21c04ced5271129f1cf75ee4da4c9f63ee

See more details on using hashes here.

File details

Details for the file autogen_memorysync-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for autogen_memorysync-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06ff23331a24cdc967e7ef4f2fd95858a3e7ad42ffc83b5e3c7f915d32555abd
MD5 1ae13b68a01f0eb340d84c113c0a6afc
BLAKE2b-256 e232077e706e90ca074456ef24c4c25c40cc4303f627afdfaeaba22b20230bf5

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.1

2 files

This release

1.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page