> ## Documentation Index
> Fetch the complete documentation index at: https://docs.open4rena.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Memory

> What o4 remembers between sessions, where it's stored, and how to clear it.

o4 can remember things between sessions, such as your preferences, project
conventions, and decisions you made together. The next time you start o4 in
the same project, the model gets those memories as part of its context, so
you don't have to repeat yourself.

Memory is on by default. To have the model remember something, ask for it:

```text theme={null}
Remember that this project uses pnpm, not npm, and that we never auto-commit.
```

To make it forget something, ask for that too:

```text theme={null}
Forget what you saved about auto-commit.
```

o4 has two kinds of memory: memory files that the model edits like any other
file, and a memory database that the model reads and writes with memory
tools.

## Memory files

Each project has a memory directory in your home directory:

```text theme={null}
~/.o4/projects/<project-id>/memory/
```

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

The model writes these files with its normal `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](/configuration/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](#the-memory-database), because those take its
place.

## The memory database

o4 also keeps memories in SQLite databases:

| Scope | Location |
| - | - |
| Project | `.o4/memory/memory.db` in your project |
| Global | `~/.o4/memory/global.db` |

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:

| Tool | What it does |
| - | - |
| `memory_save` | Save a memory with a type, optional tags, and a scope. A near-duplicate updates the existing memory instead of adding a new one. |
| `memory_search` | Full-text search in one scope. |
| `memory_list` | List memories in one scope, optionally filtered by type. |
| `memory_forget` | Delete a memory by its ID. |

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.

<Note>
  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](/safety/workspace-trust).
</Note>

### Session summaries

When you quit a session that had at least one exchange, o4 saves a short
`session_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`, or `not 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.

To delete every file in the project's memory directory, run:

```text theme={null}
/memory clear
```

o4 reports how many files it removed and updates the model's context.

<Warning>
  `/memory clear` deletes the memory files, including `MEMORY.md`, and there's
  no undo. It doesn't touch the memory databases. To remove entries from a
  database, ask the model to forget them, or delete `.o4/memory/memory.db` or
  `~/.o4/memory/global.db` yourself.
</Warning>

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

```json theme={null}
{
  "memory_enabled": false
}
```

With memory off, o4 doesn't load `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:

```text theme={null}
/remember deploy-cmd=make release
```

o4 saves it in `.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:

| Command | What it does |
| - | - |
| `/memdir [query]` | List the Markdown files in the project's `.o4/memory/` and in `~/.o4/memory/`. With a query, list only the files that match it, best match first. |
| `/extract-mem <text>` | Show which lines of some text look like facts worth remembering, such as lines with "always", "never", or "prefer". It saves nothing. |

## Agent memory

A custom agent can have its own memory. Set `memory` in the agent's front
matter to one of these scopes:

| `memory` | Directory |
| - | - |
| `user` | `~/.o4/agent-memory/<agent-name>/` |
| `project` | `.o4/agent-memory/<agent-name>/` in your project |
| `local` | `.o4/agent-memory-local/<agent-name>/` in your project |

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](/guides/subagents#custom-agents).

## Related pages

* [Project instructions](/configuration/project-instructions): shared, checked-in guidance for the model.
* [Context and cost](/guides/context-and-cost): how memory adds to the context window.
* [Telemetry and privacy](/help/telemetry-and-privacy): what o4 stores and sends.
