Autogen memory integration
Add persistent memory to Microsoft Autogen agents using the zep-autogen package.
The zep-autogen
package provides seamless integration between Zep and Microsoft Autogen agents. Choose between user-specific conversation memory or structured knowledge graph memory for intelligent context retrieval.
Install dependencies
Environment setup
Set your API keys as environment variables:
Memory types
User Memory: Stores conversation history in user threads with automatic context injection
Knowledge Graph Memory: Maintains structured knowledge with custom entity models
User memory
Automatic Context Injection: ZepUserMemory automatically injects relevant conversation history and context via the update_context()
method. The agent receives up to 10 recent messages plus summarized context from Zep using the specified thread_context_mode
(“basic” or “summary”).
Knowledge graph memory
Tools integration
Zep tools allow agents to search and add data directly to memory storage with manual control and structured responses.
Important: Tools must be bound to either graph_id
OR user_id
, not both. This determines whether they operate on knowledge graphs or user graphs.
Tool function parameters
Search Tool Parameters:
query
: str (required) - Search query textlimit
: int (optional, default 10) - Maximum results to returnscope
: str (optional, default “edges”) - Search scope: “edges”, “nodes”, “episodes”
Add Tool Parameters:
data
: str (required) - Content to storedata_type
: str (optional, default “text”) - Data type: “text”, “json”, “message”
User graph tools
Knowledge graph tools
Query memory
Both memory types support direct querying with different scope parameters.
User memory queries
Graph memory queries
Search result structure
Edge results (facts)
Node results (entities)
Episode results (messages)
Memory vs tools comparison
Memory Objects (ZepUserMemory/ZepGraphMemory):
- Automatic context injection via
update_context()
- Attached to agent’s memory list
- Transparent operation - happens automatically
- Better for consistent memory across interactions
Function Tools (search/add tools):
- Manual control - agent decides when to use
- More explicit and observable operations
- Better for specific search/add operations
- Works with AutoGen’s tool reflection features
- Provides structured return values
Note: Both approaches can be combined - using memory for automatic context and tools for explicit operations.