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 persisted and enriched with recalled context under a hard budget (default 1.2s), and every outgoing reply is persisted — through AG2’s own hook system, with zero extra code per turn. The injected context feeds the LLM only; the original text is what persists, so recalled memories can never re-enter storage. A process-wide dedup registry plus deterministic idempotency seeds fix 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 — ours stores once, 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.0.0 (PyPI)
- Last setup review
- 2026-08-24
- 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
- Both-side capture with deterministic idempotency seeds
- 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 stored transcript
- 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 per-turn analyzer-LLM cost with zero-LLM memory
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.