Sulat.com / Writing on AISunday, December 6, 2026
Enter →
Agent Engineering/6 December 2026

OpenAI adds memory and history to the Agents API

OpenAI's Agents API now lets an agent keep editable notes and search its past chats. I ran both on the live API, and a new session used a note the agent wrote itself.

Glossy 3D OpenAI logo floating above a desk with a stack of note cards and a drawer of rolled chat transcripts
Illustration: Sulat, featuring the OpenAI logo

At a glance

  • OpenAI's Agents API now has two stores an agent can attach: memory, which holds editable text notes, and history, which holds searchable past conversations.
  • In my runs an agent saved its own notes from one message, and a brand-new session used them without being reminded.
  • Every note carries a revision, so an edit based on a stale read bounces with a 409 instead of overwriting.
  • A session only lands in a history store if it carries the history tool, and a store with no matching chat returns a plain not-found.
  • The Python SDK added the endpoints in 3.64.0, and a recall turn on GPT-6.2 Astra showed 45K input tokens, nearly all cached.

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.

Kevin Whinnery’s announcement on X.

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.

Memory holds editable notes both agent and app can edit. History holds past chats you can search and read in full
Memory is what the agent learned. History is what was said. Illustration: Sulat

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.

Code
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.

Code
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.

Code
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.

Terminal output: notes.search finds aisle preference, history.search finds Paris booking code ZX721, answer is 12C and ZX721
One turn used both tools: a note for the seat, the old chat for the code. Output from my run, trimmed.

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.

Code
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:

Code
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.

Terminal output: agent calls notes.write_file twice, then a new session searches notes and answers with tacos and npx wrangler deploy
The first session writes two notes. The second finds them and uses both. Output from my run, trimmed to the calls that matter.
Three steps: user states preferences, agent saves a note by itself, a new chat already knows them. No reminders needed.
Say it once and a later chat already knows. Illustration: Sulat

Changing a fact works the same way. In a third session I sent this, verbatim.

Code
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.

Code
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.

Contrast: a passing remark about pineapple pizza saves no note, asking to remember the cat Biscuit saves a note
One line of instructions on the memory tool sets when the agent saves. Illustration: Sulat

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.

Terminal output: update with revision 1 returns 200 and revision 2, a second write with revision 1 returns 409 conflict_error
The second write used an old revision, got a 409, and the note stayed as it was. Output from my run, trimmed.
Flow: read note at revision 1, app edits to revision 2, second edit citing revision 1 gets a 409 conflict, nothing saved
An edit has to name the revision it read, or it bounces. Illustration: Sulat

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.

Session A inherits memory and history from the agent. Session B drops history, so its chat is not saved to the store
A session only lands in a history store if it carries the history tool. Illustration: Sulat

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

Disclosure: I’m an OpenAI, Firecrawl and Devin ambassador.