Skip to content

OpenAI Agents SDK

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

Install

bash
pip install "suprflo[openai-agents]"

What you get

All built on the Python SDK MemoryClient:

  • SuprfloContext — a run context carrying the client and the user_id the tools operate on.
  • save_memory / search_memory@function_tools that read that context off the RunContextWrapper.
  • MEMORY_TOOLS — both tools as a list, to splice into Agent(tools=...).

Tools for an agent

python
from agents import Agent, Runner
from suprflo import MemoryClient
from suprflo.integrations.openai_agents import MEMORY_TOOLS, SuprfloContext

client = MemoryClient(api_key="YOUR_API_KEY")
agent = Agent(name="assistant", tools=MEMORY_TOOLS)

result = await Runner.run(
    agent,
    "What do you know about my hobbies?",
    context=SuprfloContext(client=client, user_id="alice", top_k=5),
)

Because the subject comes from the run context rather than a closure, one agent definition serves every user — pass a different SuprfloContext per run.

Why there's no Session

The SDK's other memory-shaped hook is the Session protocol (get_items / add_items / pop_item / clear_session). It is a verbatim conversation-history store: it must return the exact input items it was given, in order, and support popping the last one.

Suprflo is a semantic memory API — it extracts and consolidates facts rather than retaining an ordered item log, and it has no pop. Implementing Session on top of it would silently corrupt agent history, so this adapter doesn't.

Use a real Session (e.g. SQLiteSession) for history and these tools for long-term memory. The two compose fine:

python
from agents import SQLiteSession

result = await Runner.run(
    agent,
    "...",
    session=SQLiteSession("alice"),                       # history
    context=SuprfloContext(client=client, user_id="alice"),  # memory
)

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

The memory layer for AI agents.