← All guides

Agent Memory Explained: State, Not a Vector Database

Most agent memory is built as search: save past text, embed it, and pull back what looks relevant. That answers one question well. It fails at another: what is true now? A fact you corrected last week is still 'relevant', so the agent keeps using it. In 2026, more builders treat memory as state, not search. This guide explains the difference, the five terms people mix up, the data, and how OpenClaw stores memory.

Bottom Line

  • Retrieval asks: what from the past is relevant to this question?
  • State asks: given everything learned so far, what is true now?
  • A vector store answers the first question. It cannot tell that a fact was replaced, so it can return stale facts.
  • Good memory needs updates, contradictions and expiry, not only search.
  • Memory is also an attack surface. An instruction planted in memory can affect every later session.

The Five Terms People Mix Up

TermWhat it isQuestion it answersExample
ContextWhat the model sees on this callWhat can I use right now?The current chat, files read this session
RAGSearch over outside knowledgeWhat document is relevant?Search the product docs
MemoryWhat the agent keeps over timeWhat do I know about this user or project?”The user deploys with GitHub Actions”
SkillsStored proceduresHow do I do this kind of task?A release checklist in a SKILL.md
ToolsThings the agent can doWhat action can I take?Run a command, call an API

Memory is the one that changes. Docs change rarely, and skills change when you edit them. Memory changes every session, and some of what it holds stops being true.

Retrieval vs State

Jordy Zomer put the split into two questions, in a post from 28 August 2026:

  1. “What information from the past is relevant to this question?”
  2. “Given everything we have learned so far, what is currently true?”

His motivating failure: an agent built a conclusion on an assumption. A later check disproved the assumption. The vector store still returned the old fact, because it was still relevant, and nothing knew which conclusions depended on it.

An example of our own: you tell your agent in March that the app runs on Heroku. In June you move it to Fly.io and say so. Ask “how do I deploy?” and a similarity search may return both notes, or only the March one. A state-based memory marks the March note as replaced.

How state-based systems handle change

SystemHow it handles a changed fact
Zep / GraphitiEach fact has a validity window. “Old facts are invalidated — not deleted.” The newer fact wins
Mem0Has a DELETE step for memories that new information contradicts. Its graph version marks them invalid instead
LangMem profilesOne document per user that “updates the existing document rather than creating a new one”
LemmalogThe model extracts facts, and a Datalog engine works out what follows from them and retracts what no longer holds
LinkedIn’s memory agentFresh information gets priority, with a conflict policy and offline clean-up of stale entries

LinkedIn’s team also moved part of its system off GraphRAG, which they said was “slow and it’s also not cost efficient”, to a tree structure that allows small updates.

What the Benchmarks Show

Two benchmarks test memory over long conversations:

  • LongMemEval (500 questions) tests extraction, multi-session reasoning, time, knowledge updates and knowing when not to answer. Commercial assistants showed about a 30% accuracy drop over long interactions.
  • LoCoMo uses conversations of about 300 turns over up to 35 sessions.

Time-aware memory helps on time questions

From Zep’s paper, LongMemEval, full context against Zep:

CategoryModelFull contextZep
Temporal reasoninggpt-4o45.1%62.4%
Temporal reasoninggpt-4o-mini36.5%54.1%
Knowledge updategpt-4o78.2%83.3%
Knowledge updategpt-4o-mini76.9%74.4%

But memory does not always beat full context

From Mem0’s own paper, LoCoMo, judged by an LLM:

MethodOverallTemporal questions
Full context72.9%Not reported
Mem0 with a graph68.4%58.1%
Mem066.9%55.5%
Zep66.0%49.3%
Best plain RAG61.0%Not reported
OpenAI memory52.9%21.7%

Read both tables together. If the whole history fits in the context, full context can be the most accurate. Memory systems win on cost and speed: Mem0 reports more than 90% lower token cost. On time questions, structured memory beats plain chunk search by a wide margin.

Lemmalog’s author reports that his system used about 2,700 tokens per LongMemEval question against about 104,000 for full context. He also says the test used only 17 questions per category, and answers his own question of whether it proves anything with “Not quite yet.”

Memory Poisoning

Memory that survives sessions also keeps attacks alive.

StudyFinding
”Bad Memory” (July 2026)Tested Claude Code and Codex. Getting an agent to overwrite its own memory files was hard. But payloads already planted there “can successfully attack current and future sessions”
MINJA (2025, updated 2026)An attacker can add malicious records to an agent’s memory only by sending it queries
”Poison Once, Exploit Forever” (April 2026)One poisoned observation on one site activated later on other sites. Attack success reached 32.5% on GPT-5-mini

The Bad Memory authors say persistent memory “changes the threat model for prompt injection”. What to do:

  • Read your memory files. In OpenClaw they are plain Markdown, so you can.
  • Do not let untrusted content write to memory. Keep a reader agent with no write access for web pages and email.
  • Expire old notes. Anthropic’s memory tool docs suggest you periodically delete memory files that nobody has opened.

Our local LLM prompt injection guide covers the rest of the defense.

How OpenClaw Memory Works

OpenClaw memory is plain Markdown in the workspace (default ~/.openclaw/workspace). The docs say the model remembers only what is saved to disk.

FileRoleLoaded
MEMORY.mdCurated long-term facts and decisionsAt session start. Cut if over the bootstrap budget
USER.mdPreferences and profile factsAt session start, with a small budget
memory/YYYY-MM-DD.mdDaily notesToday’s and yesterday’s on /new or /reset. The rest by search
DREAMS.mdThe Dream DiaryOptional

In state and retrieval terms (our framing): MEMORY.md and USER.md are the state. The daily notes are the retrieval layer.

The settings

SettingDefaultWhat it does
memory.search.enabledtruememory_search over notes, hybrid vector and keyword
memory.search.provider"openai"Embeddings provider. "none" gives keyword-only search
memory.search.query.maxResults6Results per search
memory.search.query.minScore0.35Lowest match score returned
agents.defaults.compaction.memoryFlush.enabledtrueA silent turn writes notes before compaction
agents.defaults.compaction.memoryFlush.softThresholdTokens4000How early the flush starts
plugins.entries.memory-core.config.dreaming.enabledtruePromotes strong notes into MEMORY.md
plugins.entries.memory-core.config.dreaming.frequency"0 3 * * *"Runs at 03:00 daily

Two built-in state behaviors:

  • Dated notes decay. OpenClaw ranks daily notes with a 30-day half-life. MEMORY.md and USER.md never decay.
  • Dreaming promotes, with gates. Only the deep phase writes to MEMORY.md, and untrusted content is excluded from promotion. Check what it would promote with openclaw memory promote-explain "<query>".

Useful commands: openclaw memory status, openclaw memory search "query" and openclaw memory index --force.

Make OpenClaw memory act like state

  1. Keep MEMORY.md as current facts only. When a fact changes, edit the line. Do not add a second line.
  2. Date your decisions: “2026-11-01: deploy moved to Fly.io (was Heroku).”
  3. Let daily notes hold history. They decay and stay searchable.
  4. Read MEMORY.md after Dreaming runs, and remove anything wrong.

For memory plugins (Hipocampus, ClawVault, mem0, Letta), see OpenClaw memory systems compared. For a fully local setup, see a local memory stack for Hermes and OpenClaw.

Honest Caveats

  1. Vendors run their own benchmarks. Zep, Mem0 and Lemmalog each publish results where their system does well.
  2. The “OpenClaw” scores in third-party comparisons (0.244 on LongMemEval, 0.557 on LoCoMo in Lemmalog’s post) do not say which OpenClaw memory setup was tested.
  3. The Heroku to Fly.io example is ours. It shows the pattern; it is not from a study.
  4. We did not run these memory systems for this guide.

Sources

See Also

Read next

Context Rot Explained: Why Agents Get Worse Over Time
Context rot is the drop in model accuracy as the input grows, long before the context window is full. The benchmark data, why a 1M window is not 1M useful tokens, what compaction loses, and the fixes in Claude Code, the Claude API and OpenClaw.
Harness Engineering Explained: Prompt vs Context vs Harness
Harness engineering is the work around the model: tools, instructions, tests, feedback loops, permissions and memory. What it means, how it differs from prompt and context engineering, the benchmark data that shows why it matters, and where each part lives in OpenClaw.
Hermes Agent Skills: Master /learn Without Bloated Context (2026)
Use Hermes skills and /learn for repeatable workflows, install safely, separate skills from memory, and review self-written changes.
How Much VRAM Does gpt-oss 120B Need at Full 128K Context? About 4.5 GiB of Cache, Not 9
gpt-oss 120B holds its entire 131,072-token window in roughly 4.5 GiB of KV cache, because half its layers only ever attend to 128 tokens. Here is the arithmetic from the model's own config.json, and the machines that fit the ~70GB total.