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.1.tar.gz (17.8 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.1-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file autogen_memorysync-1.0.1.tar.gz.

File metadata

  • Download URL: autogen_memorysync-1.0.1.tar.gz
  • Upload date:
  • Size: 17.8 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.1.tar.gz
Algorithm Hash digest
SHA256 968781fe16e916921944a5570a7f9c88c4b37b8fbc272d8da8427d4de5b5845b
MD5 d489ec2a690c3a81b609a43731f9fa13
BLAKE2b-256 d4c23e1a04826c9e7de6015cdd1bd4594d8e035d54e21c424e367ec793228bee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for autogen_memorysync-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 19800facd11106f24c81ad2919d8235987dc8416e6c6f57c36178f29b308c1fa
MD5 67ca7746e9b59eb6cce78402974cac87
BLAKE2b-256 fd6a96900a96895caa5df940c2e40ef06d58b20fe68374cc88c12f591ba97df9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

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