DocsStart

Persistent memory in AI agents

A technical primer on persistent memory in agentic AI: what it is, how it differs from a context window, and why local-first storage matters.

3 min read·docs/persistent-memory.md· Edit on GitHub

What is persistent memory in AI agents?

Persistent memory is the layer of an AI agent that survives beyond a single prompt or session. Without it, every conversation starts from scratch: the agent has no record of what it read yesterday, what it decided last week, or what the user already told it. With it, the agent can act consistently over weeks or months and reference specific past events.

This page is a technical primer on what persistent memory means in agentic AI, how it differs from an LLM context window, and why local-first storage matters when memory is the substrate an agent makes decisions on.

Memory vs context window

A context window is the block of tokens the model sees for one call. It is lost the moment the call returns. Memory in an agentic system is external: it lives in a database or file the runtime writes to and reads from across calls. The context window is the working set; memory is the store.

Practically, an agent with memory does three things a stateless prompt cannot:

  • Recall specific past events by content, not by turn index.
  • Detect and resolve contradictions between what it believed and what it now observes.
  • Forget — remove a fact permanently when the user or policy requires it.

What "persistent" really requires

For memory to be persistent in a useful sense, it must survive:

  • Process restarts — the agent binary can be killed and restarted without the store dissolving.
  • Model swaps — moving from one LLM to another does not require rebuilding history.
  • Runtime swaps — the same memory should be readable by a LangGraph agent, an MCP client, or a custom loop.
  • Machine moves — the store is a portable artifact you can ship with the agent (a single file, or a small database).

If any of these forces a rebuild, the memory is not persistent — it is a cache.

Why local-first storage matters

Memory is not neutral data. It carries facts the agent will condition future decisions on: user preferences, unresolved commitments, private observations, sometimes credentials. That makes memory a security surface as much as a performance one.

Local-first storage — a single SQLite file, on the user's machine or inside their VPC — has three concrete advantages for agent memory:

  1. Data does not leave the environment. No hosted API sits between the agent and its own history. Private observations stay private.
  2. Ingest is free. With no LLM call per write, the cost of remembering collapses to whatever your embedder costs — often zero on CPU.
  3. Failure modes are simple. A file on disk either exists or does not. There is no hosted control plane to fall over, no shared multi-tenant DB to reason about.

The cost is that local-first memory does not automatically synchronize across devices — a deliberate tradeoff, made explicit rather than hidden.

The three operations

Every practical memory system for AI agents exposes some form of:

  • remember(text, kind, importance) — write a memory with enough metadata that later reads can filter it by time, source, or trust level.
  • recall(query, filters) — retrieve the memories most relevant to the current task, ranked, with the source span that produced each result.
  • forget(id) — remove a memory permanently, returning proof of erasure.

Anything more elaborate (temporal tiers, consolidation, contradiction resolution) is layered on top of these three.

What good memory returns

The signature of a well-designed memory system is not the fact it stores; it is what recall returns. Two properties matter:

  • Source-traceable. Every returned memory points back to the exact input span it came from. The agent can quote the source, and a human auditor can verify it.
  • Budgeted. Recall returns as much relevant context as fits in a token budget the caller sets, not an arbitrary top-k with no notion of prompt size.

Systems that return LLM-summarized "facts" without span references are lossy: the agent can no longer answer "why do you think that?" with anything better than "the memory said so."

Where Midas fits

Midas is a memory primitive for AI agents built around these constraints: persistent, local-first, LLM-free at ingest, and source-traceable at recall. It is a small Python facade (remember / recall / assemble) plus an MCP server, backed by a single SQLite file.

If you are building an agent that has to be trusted to act on what it remembers, start with:

  • Install — one-line setup, first run, MCP server.
  • Long-horizon memory — how Midas keeps context useful across weeks of sessions.
  • Benchmarks — reader-independent recall and cost numbers, reproducible from the repo.