AutoGen / AG2 Integration

AutoGen / AG2 + Awareness Memory

Add persistent, cross-session memory to your AutoGen multi-agent conversations. Agents remember prior decisions and context across sessions.


Installation

pip install awareness-memory-cloud[autogen]

Quick Start

from memory_cloud import MemoryCloudClient
from memory_cloud.integrations.autogen import MemoryCloudAutoGen
import openai

# Local mode (no API key needed)
client = MemoryCloudClient(mode="local")
mc = MemoryCloudAutoGen(client=client)  # memory_id auto-managed

# Cloud mode (team collaboration, semantic search, multi-device sync)
client = MemoryCloudClient(base_url="https://awareness.market/api/v1", api_key="YOUR_API_KEY")
mc = MemoryCloudAutoGen(client=client, memory_id="memory_123")

# Hook into agent message processing
mc.wrap_agent(autogen_agent)

# Or inject into an existing agent
mc.inject_into_agent(assistant)

# Or register explicit tools
mc.register_tools(caller=assistant, executor=user_proxy)

Integration Patterns

Pattern 1: Agent Injection

mc.inject_into_agent(assistant)
# The agent now has memory context injected into every message exchange

Pattern 2: Tool Registration

mc.register_tools(caller=assistant, executor=user_proxy)
# Agents can explicitly call memory tools during conversations

Pattern 3: Direct API

result = mc.awareness_recall("What happened in the last review cycle?")
mc.awareness_record("Code review approved. Merging to main branch.")

Use Cases

  • Multi-agent conversations with persistent memory — context survives across conversation rounds
  • Agent group chats that remember prior decisions — no need to re-explain context
  • AutoGen workflows spanning multiple sessions — pick up where you left off
  • Cross-agent knowledge sharing — agents build on each other's discoveries

Multi-User / Multi-Role

mc_assistant = MemoryCloudAutoGen(
    client=client, memory_id="memory_123",
    default_metadata={"agent_role": "assistant"}
)

mc_critic = MemoryCloudAutoGen(
    client=client, memory_id="memory_123",
    default_metadata={"agent_role": "critic"}
)

Example

See examples/e2e_autogen_cloud.py in the SDK repository for a complete end-to-end example.


Next Steps