Integration
Long-term memory for the OpenAI Agents SDK
The official OpenAI Agents SDK is the cleanest path to OpenAI's agent loop: typed schemas, `@function_tool`, `Runner.run`. Memory between runs is the gap. `engram_tools(bucket=...)` returns two pre-decorated `@function_tool` callables that you add to any `Agent`'s `tools=[...]`.
Install
Three steps: sign up for an Engram API key, paste a BYOK LLM-provider key on /models, then drop the snippet below into OpenAI Agents.
Three steps to memory in your agent
- Sign up. Free, no card. You'll land on a Getting Started page that walks the next two steps.
- Add your LLM key. Engram is BYOK. Paste an OpenAI / Anthropic / Groq / Together / Fireworks key and we'll route every extraction and query call through your provider. You pay your provider directly. We never see your inference.
- Paste the snippet below into your agent and restart it. Use
Authorization: Bearer <api-key>with the API key from your portal.
engram-openai-agents: durable memory for the official OpenAI Agents SDK
Two pre-decorated @function_tool callables bound to one Engram bucket. Pass them as tools=[...] to any Agent. Source: github.com/lumetra-io/engram-openai-agents.
- Install:
- Vendor
engram_openai_agents.py(~45 LOC) and export your API key: - Wire the tools into your
Agent:
pip install lumetra-engram openai-agentscurl -fsSL https://raw.githubusercontent.com/lumetra-io/engram-openai-agents/main/engram_openai_agents.py -o engram_openai_agents.py
export ENGRAM_API_KEY="<api-key>"from agents import Agent, Runner
from engram_openai_agents import engram_tools
store, query = engram_tools(bucket="my-agent")
agent = Agent(
name="assistant",
instructions=(
"You have durable memory. Before answering questions about prior "
"context, call engram_query_memory. When the user shares a fact "
"worth remembering, call engram_store_memory."
),
tools=[store, query],
)
result = await Runner.run(agent, "My name is Jacob, please remember that.")What you can do once memory's wired in
- Add memory to an Agent without writing a custom `Tool` class; the SDK's `@function_tool` decorator already wraps the functions
- Per-user buckets per request via `engram_tools(bucket=f'user-{user_id}')`
- Use with OpenAI's structured-output mode to extract specific Pydantic-like schemas before storing
- Combine with the SDK's tracing so every tool call is logged alongside the model's reasoning
FAQ
Does this register with the SDK's `params_json_schema` correctly?
Yes. `@function_tool` introspects the function signatures and docstrings to build the schema, and the Engram tools are written for that to work cleanly.
Async or sync?
Both. The SDK accepts async tools and runs them in the agent loop. Engram's underlying client is sync, and the tools wrap appropriately for both modes.
What model should I run the agent on?
Any OpenAI model with tool-calling: gpt-4o, gpt-4.1, gpt-5. The OpenAI Agents SDK supports the full lineup. Engram's BYOK provider (for extraction and synthesis inside Engram) is separate.
Related integrations
Ship durable memory in OpenAI Agents today
Free tier: 10K memories and 50K retrievals per month. No credit card. Same Engram backend powers all 41 integrations, so memories you write from one client are immediately queryable from the rest.