AG2 + MemorySync
An automatic memory loop for AG2’s ConversableAgent — one attach call, duplicate-proof multi-agent capture, and a deadlock-free bridge.
Overview
Install ag2-memorysync and one attach call gives a classic AutoGen ConversableAgent long-term memory: every incoming user message is sent to MemorySync, which extracts the durable facts it contains, and is enriched with recalled context under a hard budget (default 1.2s) — through AG2’s own hook system, with zero extra code per turn. The agent’s own replies are not sent (assistant replies are not stored as memories); an outgoing message is sent only when its sender speaks for a person. The injected context feeds the LLM only; the original text is what is sent, so recalled memories can never re-enter memory. A process-wide dedup registry plus deterministic idempotency seeds avoid the double-store bug Zep documents in their own zep-ag2 adapter (two attached agents in one session store every utterance twice with conflicting roles — here each utterance is handled once, and an agent’s reply is never sent as the person’s words, by test). All async work rides one persistent background event loop that never touches the caller’s loop, so chats driven from inside asyncio work — zep-ag2 documents a deadlock caveat there. The package has zero framework dependencies: it duck-types against the agent, so it works with whichever classic distribution you installed and cannot version-conflict (zep-ag2 pins ag2<1).
Setup status and requirements
- Supported version
- ag2-memorysync 1.1.0 (PyPI)
- Last setup review
- 2026-09-03
- Permissions
- A MemorySync API key with read and write scopes.
- Limits
- Targets the classic ConversableAgent framework (pip install autogen, Python 3.10+). The rewritten pip install ag2 v1 has no hook system yet — a future adapter target.
Capabilities
- One attach call — the whole integration
- Hard recall budget (default 1.2s) — the reply is never late
- User-turn capture with deterministic idempotency seeds; replies are not sent
- Multi-agent double-store bug (documented in zep-ag2) fixed by design, with a reproduction test
- Deadlock-free: one persistent bridge loop, never the caller’s (asyncio-driven chats pass, by test)
- Zero framework dependencies — no ag2<1 pin trap
- Injected context reaches the LLM but never the memory store
- search_memory + save_memory tools via register_memory_tools
Quick Start
from autogen import ConversableAgentfrom ag2_memorysync import MemorySyncCapabilityassistant = ConversableAgent("assistant", llm_config=...)memory = MemorySyncCapability(api_key="ms_...",user_id="customer-42",session_id="support")memory.add_to_agent(assistant) # that’s the whole integration
Use Cases
ConversableAgent chats that remember users across sessions
Multi-agent GroupChat workflows with duplicate-proof shared capture
Replacing Teachability’s in-process analyzer LLM with server-side fact extraction
Explore More
Built for production AI systems
Build AI systems that remember
MemorySync provides the infrastructure layer for persistent memory, adaptive retrieval, and enterprise AI intelligence.
Start free. No credit card required.