Long-term memory for AI coding agents
Coding agents are good at the task in front of them and forgetful about everything else. This page explains what agent memory is, why agents forget by default, and what to look for when you add durable recall.
Why coding agents forget
A model reasons over a context window — a finite buffer of tokens. When a session ends, that buffer is discarded. Nothing persists by default. The next session starts cold: the decisions you made, the approaches you ruled out, and the conventions you settled on are simply gone. You re-explain them, and the agent repeats mistakes it already learned to avoid.
What “agent memory” is
Agent memory is an external layer that runs a loop: capture → recall → consolidation. Capture reads what happened and writes down what is worth keeping. Recall surfaces the relevant subset at the start of, or during, a later session. Consolidation dedups and reconciles facts so the store stays coherent over time.
This is distinct from a bigger context window. A larger window lets the model see more at once; memory lets durable facts outlive the window and return only when they are relevant — without paying to re-load the whole history every time.
Two architectures
Memory systems mostly fall into two camps, and both are reasonable choices depending on what you value.
A cloud memory database keeps your memories in a hosted store. The service handles persistence, indexing, and retrieval; you read and write through its API. This centralizes operations and can scale across machines and teams without local setup.
A local-first vault keeps memory as files on your own machine — typically Markdown you can open, edit, and move. Retrieval runs against a local index. This keeps the data under your control and portable, at the cost of running the index locally.
What to look for
Whichever architecture you pick, a few properties separate a memory layer you can trust from one you cannot:
- Data ownership and portability. Can you read, edit, and move your memory, or is it locked inside a proprietary store?
- Recall quality. Hybrid retrieval — keyword (BM25) plus semantic (vector) search — generally beats either alone for surfacing the right fact.
- Non-lossiness. Originals should be retained. Summarization that throws away the source text is hard to audit and impossible to recover.
- Secret redaction. Tokens, keys, and credentials should be scrubbed before anything is written to storage.
How agentcairn approaches it
agentcairn is local-first. Memory is distilled into a local Markdown vault that is the source of truth — not a one-way export from a database. A rebuildable DuckDB index gives fast hybrid retrieval (BM25 + vector, fused with RRF, with an optional reranker). The index is a cache; the Markdown is the truth, so it survives model upgrades, index rebuilds, and uninstalling the tool.
It works across coding agents: Claude Code and Codex as plugins, Cursor and other MCP hosts via the bundled server, all sharing one global vault.
FAQ
What is agent memory?
Agent memory is durable storage and recall of the facts, decisions, and conventions an AI agent accumulates across sessions — surfaced when relevant, beyond what fits in a single context window.
Why do AI coding agents forget between sessions?
A context window is ephemeral: it is discarded when the session ends. Without an external memory layer, each new session starts cold and the agent has no record of earlier work.
How is a local-first memory vault different from a cloud memory database?
A local-first vault stores memory as files on your machine that you can read, edit, and move. A cloud memory database keeps that memory in a hosted database accessed over the network. The data model and where it lives are the main differences.
Does agentcairn memory survive uninstalling the tool?
Yes. Memory is plain Markdown in your vault, and the DuckDB index is a rebuildable cache. Uninstalling the tool leaves the Markdown intact, so nothing is trapped in a database.
Which AI agents work with agentcairn?
Claude Code and Codex install as plugins. Cursor and other MCP hosts connect through the bundled MCP server, sharing one global vault.
Get started
Install agentcairn into your agent in one command:
cairn install --all