Solving OpenClaw's Memory Problem: Context Window, Files, RAG, and the Active Memory Plugin

Solving OpenClaw's Memory Problem: Context Window, Files, RAG, and the Active Memory Plugin
Get in touch or AI consulting Join the AI Community & Comprehensive Online Courses for All Levels

“Why doesn’t my agent remember what I told it last week?” is probably the most common OpenClaw complaint there is. Ariel answers it in layers: first why every AI forgets in the first place, then what OpenClaw does about it out of the box, then the RAG plugin you have to switch on yourself, and finally the new Active Memory plugin, the thing that made him record this video. A clean OpenClaw install, he points out, doesn’t come with most of these solutions turned on.

Layer one: the context window is a boiling pot

Every model works inside a context window, and every piece of text you send gets poured into it. The big models take around a million tokens, the smaller ones around 200,000. Ariel’s rough rule of thumb is about two tokens per word, so that’s somewhere between 100,000 and 500,000 words. Sounds like plenty. So why does the AI still forget?

His explanation, with numbers he openly admits are made up just to show the idea: the AI doesn’t think in words, it thinks in numbers. Ask it about Claude’s models and “Haiku, Sonnet, Opus” become weights inside the model. Then ask about GPT’s models and “Pro, Mini, Nano” come in with their own weights. If nothing else happened, the next question about GPT could get answered with Claude’s models, because that’s how the numbers fell. That’s why there’s a whole branch of math called attention: every new question weakens the old weights and strengthens the new ones, so the model knows the latest questions are what matter.

The side effect: 400 messages later, the weights of that first answer are so small the model can barely give them any attention. And it gets worse. Even if it does look back, the value of the word itself has decayed. It may see “something that started with an H” or not recognize anything at all. In Ariel’s words, it’s like someone asking you two years later “remember what I told you?” and you answer “I think you said something, but I don’t remember what.” Models forget all the time, by design: to focus on what matters, they have to push down what doesn’t.

The enterprise answer: databases

The usual enterprise solution is a database: anything from plain SQL or Mongo to MCP tools. You build the agent so that every time the user asks something, it first searches the database and only then answers. From there came RAG, graph RAG, and ideas like Andrej Karpathy’s wiki-style knowledge base. All good ideas, he says. But OpenClaw starts somewhere simpler.

Layer two: OpenClaw’s files

Before getting into databases and arguments about what goes where, OpenClaw uses markdown files: AGENTS.md, SOUL.md, IDENTITY.md, TOOLS.md, USER.md, MEMORY.md and more. Tell your agent to be calm or grumpy, and that goes into its soul or identity file. Tell it something about yourself and it lands in USER.md. Ariel’s example: he’s Haredi and doesn’t work on Shabbat, so when he tells the agent on Friday “go do all this, I’ll see you in 30 hours”, it answers, “Ah, your Shabbat has arrived.”

MEMORY.md is the most immediate memory, and it’s important to understand it’s just a file. At the start of every session, OpenClaw pours its system prompt in, then all these files, straight into the context window. Which means the same old problem: the agent remembers them well at the start and less well as the conversation grows.

When the context fills up, OpenClaw compacts: it summarizes the conversation into a dated file in the memory folder and starts a fresh session. The system prompt tells it to read roughly the last two days of those files, so after a compaction it’s still fairly up to date. And if you say “we talked about something last week”, it has a long list of dated files to go back and search.

Underneath all that, 100% of the conversation is saved in session files, which grow fast. That’s how you can talk to agent A on WhatsApp, agent B on Telegram, agent A again on Discord, and everyone keeps up. Tell it “search the session file for when we talked about X” and it finds it.

Why does Ariel call this genius? Because it’s super simple, super light, keeps what matters, and it just works. Most people using OpenClaw as a personal assistant are very happy with it.

Ariel’s own trick: a procedures file

His tip from his own setup: a file of procedures with trigger keywords. The example is a “schnitzel” rule: if he says the word schnitzel, the agent must check the procedures file and do exactly what’s written there. It usually catches the keyword and replies “I recognized this is in the procedures file, it says to do these steps, so that’s what I’m doing.” It works in most cases, not 100%, which is where the next layer comes in.

Layer three: the memory-core RAG plugin

OpenClaw ships with a plugin called memory-core, which is basically internal RAG. Quick refresher on RAG (Retrieval Augmented Generation): fetch pieces of information from different places, bundle them together, then let the AI write the answer in human language.

Behind RAG there’s usually a vector database. The difference from plain SQL, in his example: if your tables list 8 buses and 16 cars and you ask “how many vehicles do I have?”, a vector database understands those are related concepts and answers 24. Plain SQL answers zero, because you’d have to search for buses and cars explicitly. Turning words into those weights is done by embedding models, AI models that specialize in exactly that. Documents get cut into chunks (a 1,000-word document becomes pieces of 50 to 120 words or so), and the search brings back the two or three chunks that are relevant to the question.

Once memory search is configured and memory-core is enabled, the agent gets two new tools, memory_search and memory_get, just like it has tools for reading files or searching the web. An AI can’t search, read files, or run commands on its own. It needs tools for all of it. And here’s the catch he stresses: the agent can search its memory, but it doesn’t have to. It has to decide to.

How Ariel set it up

By default it indexes MEMORY.md and the small memory files, and only .md files unless you configure otherwise. Ariel added three more folders:

  • docs: everything he asks the agent to research or save, documents he wants “available and quick to pull”.
  • His internal apps folder: originally named after Jarvis, back when that was the bot’s name. Now it’s Goblin, “because there’s no choice, it’s not the same thing”. Each app has a README written with the memory index in mind.
  • The bot’s own GitHub: a personal repo collection of his OpenClaw with notes, including a whole section on how to maintain OpenClaw.

He went with the cheapest, simplest option: a SQLite-based store. The status shows 165 of 170 files indexed, cut into chunks of about 128 tokens. Instead of re-indexing on every change or every session, which didn’t suit his VPS, he set a daily cron to finish the indexing. For the embedding model, a smaller one didn’t work for him, so he settled on Qwen embedding 0.6B. And a practical warning: it kept crashing on memory errors even though the machine hadn’t run out, so he added a swap file, 16 GB at first, then cut it to 4 GB once he saw it barely used it. After that it worked great.

The orchestration problem

So the layers so far: context window, files, RAG. But OpenClaw has a problem a classic pipeline doesn’t. When you build an orchestrated flow with LangChain or LangGraph, n8n, or other popular orchestration tools, you decide up front which searches run before the question even reaches the AI. In OpenClaw you’re chatting with the AI, and it decides whether to use those memory tools or go straight to the files. Sometimes it simply won’t think of it.

Layer four: the Active Memory plugin

This is the new thing. The Active Memory plugin is built on the RAG layer, not the files, so if you want it to work properly you need RAG set up properly: the index kept fresh with watch on (every change gets picked up immediately) and an interval, say every 30 minutes, plus all your files configured right.

What it does: when you send a question, before it reaches your agent (on WhatsApp, in Ariel’s case), it spins up a sub-agent. The sub-agent runs memory_search on what you asked and injects the results into the main session. Even if the session already knew that information somewhere deep down, now it sits at the top, fresh and strong. Only then do your question and that context reach the agent, and you get your answer. If that sounds fuzzy, Ariel says, go back 20 seconds and listen again, because it’s actually very simple.

The downsides: it loads the system. The index has to stay fresh all the time, which means some AI is always working, and on a VPS that’s CPU and a small amount of RAM. On a Mac with a GPU it’s much easier. And there are extra steps before every answer, so each reply can take two or three times longer.

The upside: every answer becomes “a nugget of gold”. Always accurate, never forgets anything. Even more so with more advanced RAG tools where you can say “put this in memory now” mid-conversation, instead of writing it to an MD file and waiting for the index to catch up.

Who should turn it on

Ariel’s honest take for himself: as a single user with a personal assistant, the procedures file plus memory-core already makes him “happy to the roof”, and he hasn’t turned Active Memory on. But for his clients, organizations where three, five, ten people work with the same OpenClaw and the manager wants to know exactly what’s going on, it’s a different story. Index the whole machine, enable Active Memory only for the manager’s agent, and suddenly the manager gets very precise answers. Same for anyone doing research who needs exact data.

He closes with a love letter to the platform. Yes, OpenClaw is still a startup product and upgrades sometimes break things. He maintains his own fork and has seen everything collapse after an upgrade. But when he digs in, the product got significantly better. He’s convinced it’s still number one, notes that other tools like Hermes ride on its ideas, and says it’s huge in China too. Set up the files properly, configure memory-core properly, use a stronger RAG than his minimal one, turn on Active Memory, and “OpenClaw’s memory problems are simply over.”

๐Ÿ”ฅ Roast Corner

Let’s review the memory architecture of a man who just explained attention decay for twelve minutes. His most reliable long-term memory mechanism is a file of procedures triggered by the word “schnitzel”. Not a vector database. Not a knowledge graph. A schnitzel. Somewhere, a team of PhDs built retrieval augmented generation, and Ariel’s agent snaps to attention the moment it hears breaded chicken.

Then the infrastructure chapter. He gave the indexer a 16 GB swap file “because it kept crashing even though it hadn’t run out of memory”, found it barely used any of it, and shrank it to 4. So the AI with the memory problem was fixed by giving the server more memory it didn’t need. That’s not engineering, that’s buying your goldfish a bigger bowl and calling it therapy.

And the grand finale: after building four layers of memory and explaining exactly why Active Memory makes “every answer gold”, he hasn’t turned it on. The cobbler’s agent goes barefoot, but at least it remembers what schnitzel means.

๐Ÿค– AI for Humans

A video about AI forgetting things deserves a story about AI helping people remember. At Ontario Tech University in Canada, Dr. Winnie Sun and her Wellness Innovation in Neuro-Aging Lab work with people living with dementia and their caregivers on reminiscence therapy: helping people recall past events through photos, videos, music and sounds. Through her VR Memory Project, participants put on a headset and “step inside” places from their own lives, a childhood neighborhood, a favorite trip, family photos, with scent now being added to make it feel more real.

The new part is a conversational AI that encourages participants to talk about meaningful life experiences and keeps the conversation going during sessions, with the aim of strengthening the connection with caregivers and younger family members, since loneliness is a big part of living with dementia. People with dementia help design and test it. One participant, Bea Kraayenhof, said it relaxed her and was “something I had never dreamed could be done.” Source: Ontario Tech University.

Get in touch or AI consulting Join the AI Community & Comprehensive Online Courses for All Levels

๐Ÿ’ฌ Comments