Add persistent memory to Microsoft AutoGen agents.
AutoGen Integration
CortexDB provides persistent memory for Microsoft AutoGen agents, enabling multi-agent conversations that remember context across sessions.
Installation
pip install cortexdbai[autogen]
Setup
from autogen import AssistantAgent, UserProxyAgent
from cortexdb.integrations.autogen import CortexMemoryAgent
# Create a memory-augmented assistant
assistant = CortexMemoryAgent(
name="assistant",
system_message="You are a helpful AI assistant with long-term memory.",
llm_config={"model": "gpt-4o"},
cortex_config={
"api_key": "your-cortex-api-key",
"tenant_id": "my-app",
},
)
user = UserProxyAgent(
name="user",
human_input_mode="ALWAYS",
)
# Conversations are automatically stored and recalled
user.initiate_chat(assistant, message="What do you remember about our project?")
Teachable Agent Pattern
from cortexdb.integrations.autogen import CortexTeachableAgent
agent = CortexTeachableAgent(
name="teachable_assistant",
llm_config={"model": "gpt-4o"},
cortex_config={
"api_key": "your-cortex-api-key",
"tenant_id": "my-app",
},
)
# Teach the agent
user.initiate_chat(agent, message="Remember: our deploy window is Tuesdays 2-4pm EST.")
# Later sessions...
user.initiate_chat(agent, message="When can we deploy?")
# "Based on what you told me, your deploy window is Tuesdays 2-4pm EST."
Under the Hood
The integration wraps CortexDB's REST API. Here are the equivalent calls:
# remember() — store a conversation turn
curl -X POST https://api.cortexdb.ai/v1/remember \
-H "Authorization: Bearer your-cortex-api-key" \
-H "Content-Type: application/json" \
-d '{
"content": "Our deploy window is Tuesdays 2-4pm EST.",
"tenant_id": "my-app"
}'
# Returns: { "event_id": "evt_abc123" }
# recall() — retrieve relevant context
curl -X POST https://api.cortexdb.ai/v1/recall \
-H "Authorization: Bearer your-cortex-api-key" \
-H "Content-Type: application/json" \
-d '{
"query": "When can we deploy?",
"tenant_id": "my-app"
}'
# Returns: { "context": "...", "confidence": 0.94, "latency_ms": 10 }
Configuration
| Parameter | Default | Description |
|---|---|---|
| api_key | $CORTEX_API_KEY | CortexDB API key |
| tenant_id | Required | Tenant identifier |
| auto_remember | True | Auto-store conversation turns |