Agent memory
Long-term memory for agents in the database: memory_add, memory_search and the rest, scopes, scores, history, recall as of a time, and memories behind review.
Chronos DB is one binary you run yourself. Releases and install script. To put agents on a database you already run, with approvals: Chronos Gateway
Which release
What it is
Long-term memory for AI agents, built into the database. An agent stores facts (“Alice is vegetarian”, “deploys go through staging first”), finds them again in later sessions, and corrects or forgets them when they change. Memories are rows of a table, agent_memory, searched with the engine’s own text and vector search and versioned like any other row.
The database makes no model or embedding calls:
- Your agent’s model decides what is worth remembering, whether a new fact replaces an old one, and ranks what it reads back.
- Your app embeds memory text with the embedding model it already uses and sends the vectors. Without vectors, memories are still stored and found by their words.
- Chronos stores memories, keeps scopes apart, versions every change, and returns scored candidates with the reasons for each score.
What comes from memories being rows in worlds:
- History per memory.
memory_historylists every version: when, in which world, by which agent, and what changed (added, updated, forgotten, restored, deleted). - Recall as of a time.
as_ofsearches memory as it was: what did the agent know before Tuesday’s bad session? - Undo. A forgotten memory comes back with
memory_updateandrestore: true. A bad batch is undone withrestoreorundo_mergeon its world. - Memories behind review. An agent writes memories in its own world, and merge rules or a person decide what reaches the shared memory in
main. See below. - Just a table. Query
agent_memorywith SQL, join it with your data, diff it, back it up.
Tools and endpoints
The same operations are MCP tools (memory_add, ...), HTTP endpoints (POST /v1/memory_add, ...) and, for search, a SQL function. Each takes branch (default main) and table (default agent_memory).
| Operation | Arguments | Answer |
|---|---|---|
| memory_add | content (one self-contained sentence), the scope, vector, kind, source, tags, entities, importance (0 to 1, default 0.5), dry_run, on_conflict (add or skip) | id, written, near (similar memories of the scope), suggestion: add, update:<id> or duplicate:<id> |
| memory_search | the scope, query and/or vector, k (10), tags (all required), entities (lift), kind, since_ms, until_ms, min_importance, include_forgotten, as_of, weights | memories, best first, each with score and signals |
| memory_update | id, any of content, vector, tags, entities, importance, kind, source, restore | vector_dropped: new content without a new vector drops the old vector |
| memory_forget | id, reason, hard | hidden from search and profiles, kept in history; hard deletes the row |
| memory_get | id, as_of, with_vector | the memory, or null |
| memory_profile | the scope, limit (50), kind, as_of | the scope’s active memories, most important first: load it at the start of a session |
| memory_history | id, limit (50) | versions, newest first |
as_of is a time (2026-11-20 10:00, UTC unless it says), a time ago (-2 days) or milliseconds since 1970. History and as_of reach back as far as the database keeps history (history_retention, 1 hour for a new database); a database in memory keeps none.
Scopes
Every call names a scope: at least one of user_id, agent_id, session_id and app_id, at the top level or in scope. A search sees only the memories whose scope matches every key it gives, so {"user_id": "alice"} finds Alice’s memories from every agent and session, and {"user_id": "alice", "agent_id": "support"} only those the support agent wrote.
Duplicates, decided by your model
memory_add first searches the scope for the new memory’s words and vector. It suggests duplicate:<id> when a memory has the same words, and update:<id> when one is close: a cosine similarity of 0.92 or more, or 80% of the words shared. Nothing is decided for you.
- With
dry_runnothing is written: your model readsnear, then callsmemory_updateon the old memory ormemory_addagain. - With
on_conflict: skipthe memory is written only when the suggestion isadd.
Scores
Text candidates come from the table’s BM25 index (with typo tolerance), vector candidates from its vector index, each over-fetched and filtered by scope in the index. One score per memory:
1/(60 + text rank) + 1/(60 + vector rank) reciprocal rank fusion+ w_recency * 2^(-age / half_life_days) w_recency 0.005, half_life_days 30+ w_importance * importance w_importance 0.005+ w_entity * entities named in the search w_entity 0.003Each memory comes back with its signals: text_rank, vector_rank, similarity (cosine), recency, importance and entities_matched. Rank the top few again with your model for the question at hand.
Vectors
- One embedding model per table. Every vector must have the same length; others are left out of vector search.
- Vectors are stored normalized, so similarity is cosine.
- Without vectors memories are found by their words only: “likes pasta” does not find “enjoys Italian food”. Send vectors for recall by meaning.
An example
{"name": "memory_add", "arguments": {"user_id": "alice", "content": "Alice is vegetarian", "kind": "preference", "tags": ["food"], "vector": [0.012, -0.044, ...]}}{"name": "memory_search", "arguments": {"user_id": "alice", "query": "what can I cook for Alice?", "vector": [0.009, -0.051, ...], "k": 5}}curl -s localhost:7070/v1/memory_add -H "Authorization: Bearer $BOT_TOKEN" -H 'Content-Type: application/json' \ -d '{"user_id":"alice","content":"Alice is vegetarian","kind":"preference","tags":["food"]}'curl -s localhost:7070/v1/memory_search -H "Authorization: Bearer $BOT_TOKEN" -H 'Content-Type: application/json' \ -d '{"user_id":"alice","query":"what can I cook for Alice?","k":5}'From SQL
select id, score, contentfrom memory_search('what can I cook for Alice?', '{"user_id": "alice"}', 5, '{"vector": [0.009, -0.051]}');select * from agent_memory where scope->>'user_id' = 'alice'; -- the rows themselvesmemory_search(query, scope [, k [, options]])runs in the statement’s world, soAS OFand a transaction’s own writes count.optionstakes the search’s other arguments.- Write memories through the tools or the API, so they get ids, timestamps and normalized vectors.
Memory behind review
- The agent forks its own world (
fork) and passes it asbranchto the memory tools. - A merge policy for the agent decides what reaches
main: for exampletables = [agent_memory]andreview_columns = [agent_memory.content], so a person approves each shared fact. Forgetting is an update, somax_deletes = 0still lets it through. - A bad merge is undone with
undo_merge.memory_historyshows which world each version came from.
Rights and limits
- The same rights as any write.
memory_add,memory_updateandmemory_forgetneed the right to change the world named; reads need the right to read it. In MCP’s safe mode the agent writes memories in worlds it forked. - An agent’s own memories only (from 0.9.0): the memory tools keep an agent to the memories it may see, not every row of the table.
- Not a model: no embedding or summarizing happens in the database. Recall by meaning needs your vectors.
The tools are listed with the rest in Serve and The chronos command.