Skip to content

AutoGen

Add Suprflo long-term memory to AutoGen agents. Ships in the Python SDK.

Install

bash
pip install "suprflo[autogen]"

Version support

Targets AutoGen 0.4+ — the autogen-agentchat / autogen-core rewrite — and its autogen_core.memory.Memory protocol. It is not compatible with the old pyautogen 0.2 line, whose agent and memory APIs are fundamentally different. Written against the autogen_core.memory source; not verified against a live install.

What you get

Built on the Python SDK MemoryClient:

  • SuprfloMemory — a full Memory implementation (add, query, update_context, clear, close). Pass it to any agent that accepts memory= and it recalls relevant facts on every turn.

Memory for an assistant

python
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
from suprflo import MemoryClient
from suprflo.integrations.autogen import SuprfloMemory

client = MemoryClient(api_key="YOUR_API_KEY")
memory = SuprfloMemory(client, user_id="alice", top_k=5)

agent = AssistantAgent(
    name="assistant",
    model_client=OpenAIChatCompletionClient(model="gpt-4o"),
    memory=[memory],
)

On each turn update_context searches on the last message and injects the hits as a single SystemMessage — the same shape AutoGen's own ListMemory and ChromaDBVectorMemory use.

Writing and reading directly

python
from autogen_core.memory import MemoryContent, MemoryMimeType

await memory.add(
    MemoryContent(
        content="Alice is allergic to peanuts",
        mime_type=MemoryMimeType.TEXT,
        metadata={"topic": "diet"},
    )
)

results = await memory.query("dietary restrictions")
for hit in results.results:
    print(hit.content, hit.metadata["score"])

Query hits come back as MemoryContent with metadata carrying the memory id, its score when the API returns one, and any metadata you stored.

Scoping

SuprfloMemory(client, user_id=..., agent_id=..., top_k=...) — the scope is applied to every add, query and clear.

Notes and caveats

  • MemoryClient is synchronous. Every call is offloaded with asyncio.to_thread rather than being natively async.
  • cancellation_token is ignored. It's accepted for protocol compatibility, but an in-flight HTTP request won't be interrupted.
  • Text only. Non-text mime_type content is coerced with str(), not rejected.
  • close() is a no-op — you own the MemoryClient lifecycle, so close it yourself.
  • clear() needs a scope. With no user_id / agent_id it would wipe every memory in the workspace, so it raises ValueError instead.

If autogen-core isn't installed, importing this module raises a clear ImportError telling you to pip install "suprflo[autogen]".

The memory layer for AI agents.