OpenAI has added memory and history to its Agents API. Memory is a store of editable text notes an agent can search, read and write. History is a searchable record of past conversations. Kevin Whinnery, who works on developer experience at OpenAI, put it this way: your agents learn and improve over time. I ran both on the live API, and the agent kept the notes tidy, found them in a fresh session and answered from them.
What it adds
The Agents API went into public beta in September with a managed Codex harness, durable sessions and context compaction. Each session keeps its own conversation, so until now a new session started cold. Memory and history are the two ways to carry something across. They’re tools on the agent, and each one points at a store you create in your project.

A memory store holds notes. Each has a path like preferences.md, some text and a revision number. The agent can list, search, read, write and append to them, and your own code can do the same through the API. A history store holds the conversations from every session attached to it. The agent can search them and read the original messages, and your code can list the sessions in the store.
You can use either tool, both, or neither. A tool set on the saved agent is inherited by each new session, and a session can override the list when it’s created. Leave out store_id on a tool and the API makes a new store for that session. The guide also lets you put your own instructions on the memory tool to say what’s worth saving, and those replace the default guidance for the session.
Setting it up
Two POSTs make the stores, and the agent lists them as tools. This is OpenAI’s own quickstart.
history_store_id=$(curl -fsS https://api.openai.com/v1/agents/history_stores \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H 'OpenAI-Beta: agents=v1' \
--json '{}' | jq -er '.id')
memory_store_id=$(curl -fsS https://api.openai.com/v1/agents/memory_stores \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H 'OpenAI-Beta: agents=v1' \
--json '{}' | jq -er '.id')
curl -fsS https://api.openai.com/v1/agents \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H 'OpenAI-Beta: agents=v1' \
--json @- <<JSON
{
"model": "gpt-6.2-astra",
"tools": [
{ "type": "history", "store_id": "$history_store_id" },
{ "type": "memory", "store_id": "$memory_store_id" }
]
}
JSON
The Python SDK covers the same ground from release 3.64.0, which lists “add memory and history to beta agents”. I ran this against it, and it created both stores, seeded a note and returned the agent with both tools attached.
from openai import OpenAI
client = OpenAI()
agents = client.beta.agents
memory = agents.memory_stores.create(name="trip-notes")
history = agents.history_stores.create(name="trip-history")
agents.memory_stores.notes.create(memory.id, path="preferences.md", content="Prefers aisle seats.")
agent = agents.create(
model="gpt-6.2-astra",
instructions="You are a concise travel assistant.",
tools=[
{"type": "memory", "store_id": memory.id},
{"type": "history", "store_id": history.id},
],
)
print("agent tools:", [(t.type, t.store_id) for t in agent.tools])
for note in agents.memory_stores.notes.list(memory.id):
print(note.path, "rev", note.revision)
What I ran
Every run used GPT-6.2 Astra, the model in OpenAI’s examples, at its default medium reasoning effort, with no sandbox. The calls came from a cloud VM with 4 cores, 15 GB RAM and Ubuntu 24. I read each session’s items back afterwards to see which tools the agent called.
OpenAI’s own example
First the guide’s example, to check it behaves as written. One session had told the agent a booking code. A note in the memory store said the user prefers aisle seats. A third session got this prompt, verbatim.
Use my saved seat preference to pick 12A (window) or 12C (aisle). Find my Paris booking code in session history and include it in your answer.
The turn took 11 seconds. The agent searched notes for “seat”, searched history for “Paris” and answered 12C with the code ZX721, exactly as the guide shows.

Letting the agent write its own notes
Next, the agent does the saving. With an empty memory store and no special instructions, I sent this, verbatim.
I'm vegetarian, I live in Wellington, I use metric units, and my side project deploys to Cloudflare Workers. Please remember that for next time.
The agent listed the store, found it empty and wrote two notes by topic: preferences.md for the diet, city and units, and side-project.md for the deploy target. Then I opened a new session with these tools attached and asked, verbatim:
Suggest a Friday dinner idea and give me the deploy command for my side project.
It searched the notes for “deploy”, listed the store, read both files and answered with black bean tacos and npx wrangler deploy. Nothing in the prompt mentioned diet or hosting.


Changing a fact works the same way. In a third session I sent this, verbatim.
Update: I've moved to Auckland now. Everything else is the same.
The agent read preferences.md first, then rewrote it with Auckland and kept the diet and units. Reading it back through the API showed revision 2, and the deploy note was untouched at revision 1.
Telling it when to save
The memory tool takes an instructions field. I set it to a single sentence, verbatim.
Save details only when the user explicitly asks you to remember them.
Then I sent a casual remark with a question, verbatim: “I think pineapple on pizza is fine, honestly. Anyway, what’s a good name for a cat?” The agent suggested “Pip” and the store stayed empty. Next I sent “Please remember that my cat is called Biscuit.” It appended one line to a new pets.md and confirmed it.

Edits from your own code
Your app can edit the same notes, and the revision number stops two writers overwriting each other. I updated the deploy note with revision 1 and got a 200 and revision 2. A second write that still claimed revision 1 came back as a 409 with conflict_error, and a read afterwards showed the note exactly as the first edit left it.


What history keeps
History follows the session, not the agent. I saved an agent with both tools and started a session from it, and the session showed both stores as inherited. Its chat appeared in the history store’s session list. Then I started a session that overrode the tools to keep only memory and told it a code word, “ORCHARD-9”. That chat never reached the store: the list stayed at one session. A later session from the saved agent, asked for the code word, searched history and said it found none.

An empty store works too. I asked for the Paris booking code with a fresh history store and tried several search terms. It found only my question, said it couldn’t find the code and asked me to paste the confirmation rather than guess one.
Speed and tokens
The guide’s two-tool turn took 11 seconds. A small recall turn, the dinner and deploy question above, showed 45K input tokens on the session, and 44.7K of those were cached, with 246 output tokens. Most of that input is the agent harness and tool definitions, which the cache absorbs, so the notes themselves add little. The session’s usage field reports it, so you can check your own turns.
Where it fits
Before this, the Agents API had no built-in way to carry anything across sessions. OpenAI’s own training lesson on the topic has your app save notes in its database, hand them to a function tool and add them to the next session’s input. That still works and suits data you already own. The new stores move the same job into the API: the agent reads and writes notes itself, and your app gets endpoints to list, edit and delete them.
It’s also a different thing from the open-source Agents SDK’s sessions, which keep one conversation’s items in storage you control, such as SQLite. Those are client-side history for a single run loop. The hosted stores are shared across sessions and live in your OpenAI project. I covered earlier Agents API additions in the pieces on the 12-hour prompt cache and Daybreak sessions.
The split between a store of conversations and a store of distilled facts is becoming common. Databricks’s agent memory, now in beta, uses the same two-part design: a session store for transcripts and a memory store for durable facts, with the store as the security boundary. OpenAI’s version keeps both inside the Agents API and gives the notes a revision number you can rely on.
What I’d do
I’d use memory for durable facts such as preferences, decisions and project settings, and history for the exact wording of what was said. I’d set instructions on the memory tool so the agent saves only what matters, and I’d give each user or customer their own memory store, since a store is the unit you attach. That last point is my design choice, not something the guide requires. Because notes are plain text with paths, I’d also have my app list them now and then, which is an easy way to see what an agent has learned.
My sample is small: one model, short sessions and made-up users. Inside it, the agent saved when asked, searched before answering, updated instead of duplicating and said so when it found nothing. I’d build a support or assistant agent on that.
Sources
- Kevin Whinnery on X
- Reuse memory and history across sessions, OpenAI API guide
- Carry context across sessions, OpenAI Agents API training
- Configuring Agents, OpenAI API guide
- Changelog, OpenAI API
- openai-python changelog, 3.64.0
- Add sessions and memory to an existing agent, Databricks
Disclosure: I’m an OpenAI, Firecrawl and Devin ambassador.




