Add persistent memory to OpenAI Agents SDK applications.

OpenAI Agents SDK Integration

CortexDB integrates with the OpenAI Agents SDK to provide persistent memory tools for AI agents.

Installation

pip install cortexdb[openai-agents]

Setup

from openai import agents
from cortexdb.integrations.openai_agents import cortex_memory_tools

# Create CortexDB memory tools
memory_tools = cortex_memory_tools(
    api_key="your-cortex-api-key",
    tenant_id="my-app",
    namespace="openai-agent",
)

# Create an agent with memory tools
agent = agents.Agent(
    name="Memory Assistant",
    instructions="You are a helpful assistant with long-term memory. Use the memory tools to store and recall information.",
    model="gpt-4o",
    tools=memory_tools,  # Adds remember, recall, and forget tools
)

# Run the agent
result = agents.run(
    agent,
    messages=[{"role": "user", "content": "Remember that our API key rotates every 90 days."}],
)

Available Tools

The integration provides three tools:

| Tool | Description | |---|---| | cortex_remember | Store information in long-term memory | | cortex_recall | Retrieve relevant memories by query | | cortex_forget | Remove specific memories |

Configuration

| Parameter | Default | Description | |---|---|---| | api_key | $CORTEX_API_KEY | CortexDB API key | | tenant_id | Required | Tenant identifier | | namespace | None | Memory namespace | | top_k | 10 | Results per recall |