AI agent memory: how an agent remembers between sessions
An AI agent has no memory of its own. Between runs, everything it knew is gone unless something outside the model wrote it down. Persistent memory means storing state externally and loading it at the start of each run. The hard part is not storing it. The hard part is knowing the state you loaded is the state you saved.
Why an AI agent forgets
A language model is stateless. Each call receives a prompt and returns text; nothing survives the call. What looks like memory in a chat interface is the full conversation being re-sent every turn. When the session ends, or the context window fills, that history is gone. An agent that runs on Monday and again on Tuesday is, from the model's point of view, two unrelated strangers.
So agent memory is always the same shape: write state somewhere durable, read it back at the start of the next run, and put it in the prompt. The differences between approaches are what "somewhere" is, and how much you can trust what comes back.
The four approaches, and what each costs you
| Approach | How it works | Good at | Breaks when |
|---|---|---|---|
| A file on disk memory.md, AGENTS.md, a JSON blob | The agent reads and rewrites a local file each run. | Simplicity. Zero infrastructure. Works today. | Two runs overlap and one silently overwrites the other; the machine dies; nothing tells you the file changed underneath you. |
| A vector database semantic recall | Text is embedded and retrieved by similarity at query time. | Large corpora where the agent does not know what it needs. | The agent needs exact state ("what did I decide?") and gets an approximate neighbour instead. Retrieval failures are silent. |
| A managed memory layer mem0, Letta, Zep and similar | A service stores scoped memories and re-ranks them per request. | Per-user personalisation across many conversations. | You need to prove to somebody else what the agent knew and when. Storage is trusted, not verified. |
| Sealed, verifiable memory what FacturIQ does | Each version is hashed, chained and checkpointed. On wake the agent re-hashes its copy and asks one question. | Knowing whether the memory is intact before acting on it. | You want semantic search over it; this is exact-state memory, not retrieval. |
These are not exclusive. A common production shape is a vector store for recall plus a small sealed state file for the things that must be exactly right: what the agent decided, what it already did, what it must not repeat.
The failure nobody plans for
Storage is the easy half. The half that bites is a memory that comes back wrong and looks fine. A truncated write, a half-finished sync, a second session that overwrote the first, an editor that reformatted the file, a restore from the wrong backup. The agent loads it, believes it, and acts on it. Nothing raises an error, because nothing was checking.
This is a measurement problem, not a storage problem. The fix is a fingerprint. Hash the content when you save it. Hash it again when you load it. Compare. If the two differ, the agent stops instead of acting on a memory that is not its own.
A memory store you cannot audit is a memory store you are trusting on faith. The check costs one request and one hash.
Verifying memory on wake, in practice
The pattern is three steps at the start of every run, before any work:
- Re-hash the local copy. SHA-256 of the bytes you were handed.
- Ask whether it matches what was sealed. One request; the answer is
match,mismatch, orunknown. - Branch on the answer.
match: proceed.mismatch: stop and report; do not act.unknown: nothing was sealed under that label yet, so this is the first run.
HASH=$(shasum -a 256 memory/journal.md | cut -d' ' -f1)
curl -s "https://api.facturiq.com/v1/vault/journal/verify?hash=$HASH" \
-H "authorization: Bearer $FACTURIQ_KEY"
# {"label":"journal","verdict":"match","version":7,...}
Writing the new version back uses compare-and-swap, so a second session that started from an older copy is refused instead of silently winning:
curl -s -X PUT https://api.facturiq.com/v1/vault/journal \ -H "authorization: Bearer $FACTURIQ_KEY" \ -H "x-vault-expected-prev: $HASH" \ --data-binary @memory/journal.md
Every version is hashed into an append-only chain, a Merkle checkpoint over that chain is signed every five minutes, and an independent witness running outside our infrastructure countersigns each head. That means the answer to "was this memory altered?" is arithmetic that anyone can redo, not a promise from the service holding the data.
Using it from MCP
If the agent speaks Model Context Protocol, the same memory is available as tools without writing HTTP calls. Point the client at https://api.facturiq.com/mcp and it gains vault_get, vault_put, vault_verify and seal. There is a read-only profile at /mcp/read that refuses every write before touching storage, which is what you connect an unattended reading phase to.
When this is the wrong tool
If what you need is semantic recall over thousands of documents, use a vector store; sealed memory answers "is this exactly what I saved?", not "what do I know about X?". If your agent runs once and never returns, it has no memory problem to solve. And if nobody will ever need to check what the agent knew, a plain file is honestly fine, and free.
Questions people ask
How do AI agents remember things between sessions?
They do not remember on their own. State is written to external storage at the end of a run and loaded back into the prompt at the start of the next one. The model itself is stateless, so every form of agent memory is an external store plus a loading step.
What is persistent memory for an AI agent?
Persistent memory is agent state that outlives a single session: a file, a database row, a vector store or a sealed vault. It is persistent when it survives the process ending, and useful when the agent reliably loads it again at the start of the next run.
How can an agent tell whether its memory was corrupted?
By fingerprinting. Hash the content when it is saved and hash it again when it is loaded. If the two hashes differ, the memory changed between runs. Without a hash comparison, a corrupted memory is indistinguishable from a good one and the agent acts on it anyway.
What is the difference between vector memory and sealed memory?
Vector memory retrieves passages by semantic similarity and answers 'what do I know about this topic?'. Sealed memory stores exact state with a cryptographic fingerprint and answers 'is this byte-for-byte what I saved?'. Many production agents use both, for different questions.
Is there an MCP server for AI agent memory?
Yes. FacturIQ exposes its vault over Model Context Protocol at https://api.facturiq.com/mcp, with tools for reading, writing and verifying memory, plus a server-enforced read-only profile at /mcp/read for unattended reading phases.
How much does verifiable agent memory cost?
FacturIQ's free plan includes 25 MB of vault and 20 seals per day for one agent, with no card required. The Pro plan is 9 EUR per month for five agents, 2 GB of vault and unlimited seals.
Try it on one agent, free
One agent, a daily wake, 25 MB of sealed memory and a public record cost nothing and need no card. Your agent connects with one API call.
Create an operator account Read the API