Executable programs and extensions

agent-memory: making a coding agent remember across sessions

It keeps what used to vanish when a session closed

agent-memory is a runtime1 that keeps a coding agent's memory in Markdown files. The files are the source of truth and the SQLite index is a cache you can delete and rebuild. Recall answers with paths and summaries rather than pasted text, so the agent opens only as much as the task needs.

Requirements and key details
  • It keeps work context that used to disappear when a session ended as Markdown files.
  • Recall answers with paths and summaries, and the text is opened only when needed.
  • In a bounded test it scored 52.9% against 5.8% with no memory.
  • Claude Code, Codex CLI and Hermes share one store.

It keeps what used to vanish when a session closed

An agent forgets what it learned when it closes a session. Which file it changed and why, which attempt failed: none of that is there next time. agent-memory is a runtime that closes that gap.

Memory tools have split into two lines. One is a retrieval engine built on embeddings and a knowledge graph; the other is a filesystem the agent reads directly. The first finds well but is hard to inspect, the second is legible but does not scale as a search surface.

This tool puts both in one store. The files stay as they are and an index sits on top, so the index searches and the files answer.

A memory is not a pasted block of transcript. It records what was done and why in one file, and links related files together.

A person at a laptop with document, spreadsheet and mail windows flowing toward an agent
Turning the document, spreadsheet and mail context of each session into files is where memory starts.

Markdown is the source of truth and the index is a cache

Each memory is a Markdown file. Links inside a file carry relations, and files in the same folder are neighbours, so relations survive without a graph database underneath.

The three paths to a memory
PathWhat happens
Injection at session startReads MEMORY.md as is
Index searchSearches FTS5, optionally fused with vectors
Plain directory walkFinds with ls and grep

The index can be deleted at any time. Removing it and rebuilding loses no knowledge, and that is enforced by a test rather than promised in a document.

Rebuild the index
rm -rf .index/ && mem rebuild

Install it and create a store

It is not on PyPI yet, so you install from a checkout. It needs Python 3.12 or later, and installing builds the mem command, the MCP2 server and the hook binaries.

Install
uv sync --all-packages

After creating the store you attach it to the agent you use. Each host keeps its settings in a different place, so the command takes the host name.

Recall answers with paths and the files do the reading

A search returns a one-line abstract, the file path and a score, not the text itself. The agent looks at that list and opens only the files it needs, at the depth it needs.

What each reading depth costs
StageWhat comes back
ListOne-line abstract, path, score
OutlineHeadings only
AbstractThe file's abstract
Full textThe whole file
Raw traceThe cited raw messages

Pasting text fills the context quickly and makes it hard to see what was read. Answering with paths leaves a record in the transcript of which files were opened and which were not.

A small robot on a box with file, calendar, chat and search cards connected by cables
When there are several ways to reach a memory, a miss on one still leaves another path.

Writes happen at conversation boundaries

It does not wait for the agent to decide to write something down. Distillation starts at the point where a conversation breaks, and it does not hold up the work in progress.

What is worth keeping usually surfaces when a task ends. The choice that was made and what failed get captured then.

The raw trace is copied before distillation. Something the distiller misses is therefore never lost by the system.

There is no model client inside the library. Judgment is borrowed from the host agent's CLI3, and it stays visible in the transcript.

It consolidates and forgets while the agent sleeps

A consolidation pass runs when there is no conversation. It merges what came in and forgets what has low value. It runs on its own cycle instead of waiting for a request.

What the unattended pass may and may not do is separated. It adds and updates on its own, but deletion only arrives as a proposal you confirm.

Forgetting is a feature. The same fact scattered across files duplicates search results, and an old decision can hide the current one.

Updating does not erase the earlier record. Asking as of a date answers with the memory as it stood then, so you can trace what changed when.

At night a person works by a desk lamp beside a monitor checklist and a tidy paper tray
Consolidation runs in the quiet hours, so the next session starts from tidied memory.

It compared memory against no memory

The developer measured a reduced LongMemEval-S with 120 episodes. The haystack was bounded to 12 sessions, the host was Claude Haiku 4.5 and a Sonnet 5 judge scored the answers.

Accuracy compared with no memory
ApproachCorrect
agent-memory52.9% (127/240)
MemCore35.8% (86/240)
No memory5.8% (7/120)

These numbers do not measure writing quality or reasoning. They look only at how accurately facts from earlier sessions come back.

Three hosts share one store

A memory written by Claude Code is found by Codex CLI and picked up again by Hermes. All nine ordered writer/reader pairs across the three hosts passed, with specifics intact.

Memory carries across hosts because the store is files. A store trapped inside one app's database cannot be read by another app.

Compared with starting without memory, correct answers rose from 2 of 36 to 13 of 36. Memory carries over even when the host changes.

It is an early version, so check these points

The version is 0.1.0 and it is not on PyPI yet. Command names and settings can change, so follow the documentation that matches the version you installed.

The measurement bounded the haystack to 12 sessions. That makes it a study of write strategy rather than a comparison at corpus scale.

Switching agents means installing the hooks and settings again. The memory stays as Markdown, but which host writes and when depends on the settings.

Terminology notes

  1. Runtime — The software environment that provides facilities needed while a program runs. In local AI, it can also refer to a model execution engine.

    Back to the text
  2. MCP — A protocol for connecting clients to tools and data sources a model may use. Connectivity and permission to execute a particular tool must still be configured separately.

    Back to the text
  3. CLI — Short for Command-Line Interface: operating a program by entering commands in a terminal.

    Back to the text

Frequently asked questions

What should you check first in this article?
agent-memory is a runtime that keeps a coding agent's memory in Markdown files. The files are the source of truth and the SQLite index is a cache you can delete and rebuild. Recall answers with paths and summaries rather than pasted text, so the agent opens only as much as the task needs.