Skip to main content

Memory

Runs with the same session_id share a conversation. By the end of this page that conversation survives a restart, lives in the database you choose, and stays small however long it grows.

A conversation the agent remembers

Every agent has memory; with no memory_router, it is kept in the process:
A different session_id starts with an empty history. Leave session_id out and each run gets a new one (it is in result["session_id"]).

Keep it across restarts

In memory, the history ends with the process. To keep it, give the agent a MemoryRouter backed by a database. SQLite needs no server:
The postgres extra installs SQLAlchemy, which the SQL backend uses for SQLite too. Save this as remember.py:
Run it twice — two separate processes:
The second process had never seen the first message: it read it from memory.db. The model’s wording will differ on your run.

The backends

DATABASE_URL is a SQLAlchemy URL. The postgres extra brings SQLAlchemy and the PostgreSQL driver. SQLite needs it too, though Python has SQLite built in: every "sql" store goes through SQLAlchemy, and the postgres extra is the one that ships it. Another database SQLAlchemy supports needs its own driver installed. A router you create keeps its connections open until you close it. Build one per process and share it across agents; if you build one per request, close it when the request is done:
The memory store also holds your runs. A run that pauses for an approval or a budget is saved in the memory store, and resumed from it. To pause in one process and resume in another, both need a store they can reach: sql, redis or mongodb (durable runs). Finished run records are removed after run_retention_days (30 by default).

Read, clear, switch

History is kept per agent: two agents with different names sharing one store and one session_id each see only their own messages. Switching backends does not copy anything: the new store starts with what it already holds.

Long conversations: windows and summaries

A session’s full history is kept; memory_config decides how much of it each run is given. By default a run gets the last 10,000 messages, which in practice is the whole history; context_management then keeps each model call under its token budget (Context engineering). A long-lived session is better served by a window of its own. A smaller window, with the part that falls out of it summarized:
The project’s name had left the window by the last question, and the agent still knew it: the older messages became one [CONVERSATION SUMMARY] message. How it works: when a run loads a session whose history is larger than the window, the older messages are summarized by the agent’s own model (one extra model call), the summary takes one slot of the window, and the most recent messages fill the rest. A tool call and its result are kept together. Without summary, the older messages are simply left out of the run. memory_config is merged with the defaults one level deep: a key you leave out keeps its default, so {"value": 50} still counts in messages. A summary you give replaces the default summary as a whole, and a key left out of it takes the summarizer’s own default (retention_policy falls back to "keep"). Within one run, the context is kept under the model’s limit separately, by context_management (context engineering).

Options

The full lists: agent settings and the OmniCoreAgent reference.

When things go wrong

The agent logs to the omnicoreagent logger and prints nothing on its own. To see warnings, turn logging on:
The URL variable was not set when the MemoryRouter was created. Building the router raises rather than keeping history in process memory, where a restart would lose it:
"redis" without REDIS_URL and "mongodb" without MONGODB_URI raise the same way. Set the variable before building the router.
Install the extra the message names. Redis and MongoDB name theirs the same way.
PostgreSQL, MySQL and SQLite are all "sql"; the URL picks the database.
Raised when the agent starts, from a memory_config with an unknown mode:
Use sliding_window or token_budget. A partial memory_config is merged with the defaults, so a key you leave out, such as value, keeps its default.

Next

Durable runs

Pause a run, resume it later — in another process — from the memory store.

Context engineering

Keeping one run’s context under the model’s limit.

Workspace files

The agent’s files: notes, plans, generated work.

Serve it

Sessions over REST and SSE.