Memory files
Each project has a memory directory in your home directory:<project-id> is a hash of the project’s path, so each project gets its own
directory. Run /memory to see the exact path.
The main file is MEMORY.md. At the start of each session, o4 adds its
contents to the model’s context, along with the directory path. Only the
first 200 lines, up to 16 KiB of text, are used, so keep the file short. The
model can put details in other files in the same directory, such as
debugging.md, and link to them from MEMORY.md.
While memory is on, o4 gives the model guidelines for these files:
- Save stable facts: conventions, key file paths, architecture decisions, your preferences, and fixes for recurring problems.
- Don’t save details of the current task, unverified guesses, or anything that repeats your project instructions.
- When you ask it to remember something, save it right away. When you ask it to forget something, remove it.
- Update wrong or outdated entries instead of adding duplicates.
write and edit tools, so the
edits go through your usual approvals.
You can also edit MEMORY.md yourself in any editor. For instructions that
belong to the project and should be shared with your team, use
project instructions instead.
If your project has Markdown files in .o4/memory/, o4 can also tell the
model their names at the start of a session, so it can read them with its
read tool when they’re relevant. It doesn’t load their contents. In o4
0.2.74 this list only appears when there are no preference memories to
load from the memory database, because those take its
place.
The memory database
o4 also keeps memories in SQLite databases:
Each memory has a type:
fact, decision, pattern, preference, or
session_summary. At the start of each session, o4 adds up to five of your
most recently updated preference memories to the model’s context, global
ones first.
The model uses these tools with the database:
Every memory tool call asks for your approval in the default approval mode.
The project scope is the default. The model uses the global scope only when
it asks for it explicitly.
The global database holds memories from all your projects. o4 opens it only
in workspaces you trust, so an untrusted repository can’t read or change it.
See workspace trust.
Session summaries
When you quit a session that had at least one exchange, o4 saves a shortsession_summary memory in the project database. It lists the files the
model changed with write or edit and up to five sentences where the model
stated a decision.
See and clear memory
Run/memory to open the Memory pane. It shows:
- the memory directory for the current project,
- whether memory is enabled,
- the number of lines in
MEMORY.md, ornot found, - the other files in the directory and their sizes,
- a Clear memory row that shows the command below. Selecting it does nothing; type the command yourself.
Turn memory off
Open/config, and on the General tab toggle Auto memory. You can
also set memory_enabled in ~/.o4/settings.json, or in
.o4/settings.json for one project:
MEMORY.md or database memories into the
model’s context, doesn’t give the model the memory guidelines, and doesn’t
save session summaries. The memory tools are still available to the model.
Your own notes: /remember and /recall
/remember and /recall keep a small key and value store for you. The model
never sees it, and it has nothing to do with the memory above. Save a value
with = or : between the key and the value:
.o4/session-memory.json in your project, so it’s still there
in later sessions. /recall deploy-cmd shows the value, and /recall on its
own lists the saved keys. These commands aren’t listed in /help.
Two more unlisted commands help you look at memory:
Agent memory
A custom agent can have its own memory. Setmemory in the agent’s front
matter to one of these scopes:
When the agent starts, o4 adds that directory’s
MEMORY.md to its system
prompt. o4 ignores the user scope for agents that come from plugins. See
subagents.
Related pages
- Project instructions: shared, checked-in guidance for the model.
- Context and cost: how memory adds to the context window.
- Telemetry and privacy: what o4 stores and sends.