Docs
Memory for OpenAI Agents SDK agents
Give every OpenAI Agents SDK agent the same memory. The agent saves what it learns with remember, and any agent in your workspace finds it later with recall. Each memory is a receipt you can check. The connection is the agentics.you MCP server, so there is no extra package to install from us.
Before you start
- Create an account at agentics.you/signup.
- In the console, open API keys. Under Agent keys, choose Create agent key, pick the agent this code acts as, and copy the key. It starts
agk_mcp_and is shown once. - Keep it in an environment variable, never in code:
export AGENTICS_AGENT_KEY="agk_mcp_..."Install
pip install openai-agentsThe code
MCPServerStreamableHttp connects from your process with the key in headers. call_tool runs one tool, and passing the server in mcp_servers gives the agent every tool it lists.
import asyncio
import os
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp
AGENTICS_MCP_URL = os.environ.get("AGENTICS_MCP_URL", "https://agentics.you/mcp")
async def main():
async with MCPServerStreamableHttp(
name="agentics",
params={
"url": AGENTICS_MCP_URL,
"headers": {"Authorization": f"Bearer {os.environ['AGENTICS_AGENT_KEY']}"},
},
) as agentics:
# Save a memory, then find it again. Any agent in the workspace can recall it.
await agentics.call_tool("remember", {"content": "The customer prefers email over phone calls."})
found = await agentics.call_tool("recall", {"query": "How does the customer like to be contacted?"})
print(found.content[0].text)
# Give the server to an agent. It recalls before it answers and remembers what it learns.
if os.environ.get("OPENAI_API_KEY"):
agent = Agent(
name="Assistant",
instructions="Call recall before you answer. Call remember to save anything worth keeping.",
mcp_servers=[agentics],
)
result = await Runner.run(agent, "How should we contact the customer?")
print(result.final_output)
asyncio.run(main())Run it
python openai_agents_memory.pyIt prints the memory recall found, with its receipt_hash and a verify_url anyone can open. With OPENAI_API_KEY set, it then asks an agent the same question, and the agent can call recall itself.
Next
- MCP tool reference: every argument
rememberandrecalltake, and the other memory tools. - Scoping: which memories an agent key can read.
- Lifecycle: how a newer memory replaces an older one.
This code runs in CI on every change, against a stand-in for the MCP server (examples/guides/ in the repository).