What OpenAI Agents SDK already keeps
Sessions store the conversation items of a run so the next run continues the thread. They don’t reconcile facts across threads or systems.
Where Auld fits
Add @function_tool wrappers for recall and remember, and use run context to carry the authenticated user id. Sessions keep the thread; Auld keeps the facts.
| Concern | OpenAI Agents SDK | Auld |
|---|---|---|
| Current conversation | Yes | Not needed |
| Facts across sessions and channels | Your code | Yes |
| Which fact is current after a change | Your code | Yes, with history |
| What was true on a date | Your code | Yes (asOf) |
| Who may see a memory | Your code | Identities and audiences |
| Source for each statement | Your code | Returned with every memory |
Implementation sequence
Define a context type
Carry user id in the run context.
Write function tools
Decorate with
@function_tool; read the id from the context wrapper.Attach to the agent
Add tools and an instruction about when to recall.
Ingest after runs
Send stated facts with their time.
Example
import os, requests
AULD = os.environ["AULD_API_BASE"] # e.g. https://YOUR-AULD-HOST
HEADERS = {"Authorization": f"Bearer {os.environ['AULD_API_KEY']}"}
def auld_post(path: str, body: dict) -> dict:
r = requests.post(f"{AULD}/v1/{path}", json=body, headers=HEADERS, timeout=30)
r.raise_for_status()
return r.json()
def remember(text: str, user_id: str, source_id: str, occurred_at: str) -> str:
"""Store a dated record for one user. Returns the job id."""
return auld_post("records", {"sourceId": source_id, "text": text,
"occurredAt": occurred_at, "author": user_id,
"visibility": f"user:{user_id}"})["jobId"]
def recall(query: str, user_id: str, max_tokens: int = 2000) -> str:
"""Current memories with sources, formatted for a prompt."""
res = auld_post("recall", {"query": query, "viewer": user_id, "maxTokens": max_tokens})
return "\n".join(f"- {m['text']} ({m['sources'][0]['title']}, {m['sources'][0]['occurredAt'][:10]})"
for m in res["memories"]) or "No relevant memory."from dataclasses import dataclass
from agents import Agent, Runner, RunContextWrapper, function_tool
from memory_client import recall
@dataclass
class UserCtx:
user_id: str
@function_tool
def recall_memory(ctx: RunContextWrapper[UserCtx], query: str) -> str:
"""Recall the user's history with dates and sources."""
return recall(query, ctx.context.user_id)
agent = Agent(name="Assistant", tools=[recall_memory],
instructions="Before answering about previous work, call recall_memory.")
# result = await Runner.run(agent, "Where did we land on the budget?", context=UserCtx("user_42"))Illustrative example · standard HTTP · check the framework’s current docs for exact signatures
Or connect the MCP server
If your OpenAI Agents SDK setup can use MCP tools, point it at the Auld MCP endpoint instead of writing wrappers. The model gets remember, recall, forget and memory_status. Use wrappers when you need to inject the user id yourself or post-process results; use MCP for speed of setup.
Custom integration recipe using standard HTTP/MCP tools
- This recipe wires OpenAI Agents SDK’s own tool interface to the Auld REST API or MCP server; there is nothing Auld-specific to install.
- Bind the viewer id from your authentication layer, not from model output.
- Ingestion is asynchronous — poll the job before depending on a just-sent fact in tests.
- Recall returns up to your plan’s token limit (8,000 on Pay as you go and Flex).
Frequently asked questions
Can memory be a guardrail input?
Yes — a guardrail can recall policy-relevant facts (for example, an account’s region) before a tool runs.
Hosted MCP?
You can also connect the Auld MCP server instead of writing tools.