---
title: "Memory for the OpenAI Agents SDK"
description: "The OpenAI Agents SDK persists conversation history through sessions. Add durable temporal memory with dated evidence through the past.dev API."
canonical: https://past.dev/integrations/openai-agents-sdk
last-updated: 2026-09-02
---
# Add memory to the OpenAI Agents SDK

Source: https://past.dev/integrations/openai-agents-sdk

The OpenAI Agents SDK persists conversation history through sessions: a session stores the items of one conversation and prepends them to the next run's input. Handoffs pass that history between agents. The SDK does not document a cross-session fact model. A function tool that calls past.dev over HTTP adds durable memory with event dates, supersession and an explicit status on every recall.

## OpenAI Agents SDK memory scope

The [OpenAI Agents SDK](https://openai.github.io/openai-agents-python/) ships session memory: a [session](https://openai.github.io/openai-agents-python/sessions/) stores the items of one conversation (user messages, assistant responses, tool calls), prepends them to the next run's input and appends what the run produced. Backends include `SQLiteSession`, `RedisSession`, `SQLAlchemySession` and `OpenAIConversationsSession`, which keeps the history server-side through the [Conversations API](https://developers.openai.com/api/docs/guides/conversation-state).

A [handoff](https://openai.github.io/openai-agents-python/handoffs/) delegates the conversation to another agent. By default the receiving agent sees the entire previous conversation history; an `input_filter` can trim what it receives.

- Scope is one conversation. A new session id starts empty, and the SDK documents no cross-session or cross-user fact model.
- Sessions store raw conversation items. There is no entity resolution, no fact validity dates and no change query over what they hold.
- Server-side storage has retention rules: [response objects are saved for 30 days by default](https://developers.openai.com/api/docs/guides/conversation-state), while conversation objects carry no 30-day TTL. Either way the stored unit is a transcript rather than structured facts.

## The integration: two function tools, two endpoints

Define two function tools that call past.dev over HTTP. Store observations with their original timestamps, and recall before answering questions that depend on history. All four endpoints are documented in the [API reference](/docs/memory-api/api-reference).

```python
import os, requests
from agents.decorators import tool

BASE = "https://api.past.dev/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['PAST_API_KEY']}"}

@tool
def remember(text: str, happened_at: str) -> dict:
    """Store a durable fact with the time it actually happened (ISO 8601)."""
    return requests.post(f"{BASE}/ingest", headers=HEADERS, json={
        "content": text,
        "timestamp": happened_at,
    }).json()

@tool
def recall(question: str) -> dict:
    """Return ranked, dated evidence and a status value for a question."""
    return requests.post(f"{BASE}/recall", headers=HEADERS, json={
        "query": question,
    }).json()
```

Add both to the agent's `tools` list. The SDK builds each schema from the function signature and takes the descriptions from the docstring ([tools documentation](https://openai.github.io/openai-agents-python/tools/)). Tell the agent in its instructions when to use them: remember durable facts about people and decisions, recall before answering questions about history.

## How an agent uses recall status

Applications can route on `status`. `Supported` means the evidence establishes the answer. `Conflicted` returns evidence from credible sources that disagree. `NoKnownSupport` means the stored evidence does not establish an answer. `UnknownBecauseDegraded` means retrieval could not complete and should be treated as an unknown result.

Define behavior for each status value. For `Supported`, answer with the date and the citation. For `Conflicted`, present both sides with their sources. For `NoKnownSupport`, say the stored history does not establish an answer. For `UnknownBecauseDegraded`, retry the recall or answer without memory and say so.

## Sessions and past.dev side by side

| Requirement | Sessions | past.dev via tool |
| --- | --- | --- |
| Continue one conversation across runs | Yes | No |
| Facts shared across sessions, users and agents | No | Yes |
| Current value after a fact changes | The model rereads the transcript | Supersession with both values queryable |
| What was true on a date | No query for it | [Point-in-time recall](/glossary/point-in-time-recall) |
| Insufficient evidence distinguished from a miss | No | Status value on every recall |

The two layers run together: the session carries the current conversation while the API holds durable facts any agent or session can query. The [quickstart](/docs/memory-api/quickstart) reaches a first recall in four calls, and the [benchmarks](/benchmarks) document how recall quality is measured.

## Frequently asked questions

### Do OpenAI Agents SDK sessions remember users across conversations?

A session replays the conversation items stored under its session id. A new session id starts empty, so memory across conversations requires the application to load history itself or to query an external memory service.

### Can I keep using sessions if I add a memory API?

Yes. Sessions handle the transcript of the current conversation. The memory API keeps durable facts with dates and sources that any session, agent or application can query.

### What happens to memory during a handoff?

By default the receiving agent sees the entire previous conversation for that run. Facts stored through the memory tools are independent of handoffs: any agent with the same key can recall them, during the run or after it.

## Related

- [Memory for the Vercel AI SDK](https://past.dev/integrations/vercel-ai-sdk)
- [Memory for the Claude Agent SDK](https://past.dev/integrations/claude-agent-sdk)
- [Memory for LangGraph](https://past.dev/integrations/langgraph)
- [Session memory](https://past.dev/glossary/session-memory)
- [Quickstart](https://past.dev/docs/memory-api/quickstart)