Making OpenClaw Actually Remember Things
Overview
Ray Fernando shows how to improve OpenClaw’s long-term recall by enabling its local QMD search backend, which combines keyword and vector retrieval with reranking to find relevant information across Markdown files and imported chat archives. He pairs searchable memory with a three-tier organization system and a nightly dream-cycle optimizer, reporting that AGENTS.md shrank from 7,869 to 1,354 characters while preserving details for on-demand retrieval.
Key takeaways
- Enabling QMD gives OpenClaw local retrieval across Markdown memories and imported chat archives, using BM25, vector search, and reranking to find relevant notes without loading every archive into each prompt.
- Keep AGENTS.md and other always-injected files limited to information that affects every interaction; move episodic details into searchable files and use MEMORY.md as an index.
- Ray’s optimizer reduced AGENTS.md from 7,869 characters to 1,354 and MEMORY.md from roughly 7,000 characters to about 1,000, while keeping details available through QMD.
- A useful nightly memory workflow can run silently as a cron job, review recent logs for patterns, draft changes for approval, and send a separate morning brief.
- Search tools such as Exa.ai can filter results and reduce exposure to low-quality or malicious content, but they do not eliminate prompt injection; trusted sources and human review remain important.
- Local model serving through MLX or LM Studio, combined with a Tailscale tunnel, can connect an on-device model to remote agents, but throughput and latency need to be considered.
Chapters
- Ray Fernando found that OpenClaw sometimes lost track of earlier conversations after sessions compacted.
- He identifies two related problems: weak retrieval of older notes and workspace files that grow large enough to consume thousands of tokens on every turn.
- The proposed fix combines QMD search with a memory optimizer that keeps frequently loaded context concise.
- OpenClaw stores workspace information in plain Markdown, including daily logs, MEMORY.md, AGENTS.md, and archived chat imports.
- AGENTS.md and other injected files are loaded repeatedly, while daily logs focus on recent sessions and older entries require targeted retrieval.
- Before context compaction, an automatic memory flush prompts the agent to write lasting notes; Ray cites a 20,000-token reserve floor and a 4,000-token threshold.
- QMD is a local command-line search engine for documentation and Markdown knowledge bases, intended to retrieve relevant notes from a query.
- Its retrieval flow expands queries, uses BM25 keyword search and vector search, then ranks results for relevance.
- Ray’s example is asking for a 2023 Italy trip plan or packing list and retrieving it from archived conversations rather than keeping it all in active context.
- Ray recommends updating OpenClaw before requesting QMD, noting that the experimental backend was available in the 2.13 release and he updated his own setup to 2.15.
- He describes asking the agent to update itself and then enable QMD as the memory backend, allowing it to install and configure the sidecar.
- After enabling Telegram streaming, he restarted the app and tested retrieval by asking about the Italy trip.
- Ray’s memory optimizer skill checks files such as AGENTS.md and MEMORY.md for duplicated or overly detailed content that is injected on every turn.
- In his audit, AGENTS.md was reduced from more than 2,000 tokens to about 600, while information moved out of always-loaded files remained searchable through QMD.
- He recommends asking the agent to draft a plan and reviewing proposed edits before applying them, rather than deleting memory indiscriminately.
- Ray asks OpenClaw to create two scheduled jobs: a silent overnight dream cycle and a conversational morning brief.
- The dream job reviews daily files and session transcripts, connects recurring patterns, and cleans up memory in relation to Ray’s goals.
- His example optimization reduced AGENTS.md from 7,869 characters to 1,354 and MEMORY.md from roughly 7,000 characters to about 1,000.
- The dream cycle can run as an isolated cron task with delivery set to none, while the morning brief is designed to send a user-facing update.
- Ray’s optimizer instructions say never to delete information, to move it into searchable Markdown files, and to create drafts for review before applying changes.
- The skill protects SOUL.md from optimization and stores the rationale for memory conventions in files that QMD can search on demand.
- Tier one contains only identity, orientation, and instructions that genuinely affect every interaction, such as essential AGENTS.md and SOUL.md content.
- Tier two holds searchable notes, daily logs, project details, and preferences that QMD retrieves only when relevant, so they cost no prompt tokens until searched.
- Tier three is full-file access: the agent reads other on-disk information when a task requires it, instead of loading it into every context.
- MEMORY.md can act as a lightweight table of contents that points the agent toward nested folders and specific files.
- Ray recommends running OpenClaw’s doctor command after QMD setup to check for configuration or installation errors.
- He says QMD can index imported ChatGPT and Claude histories, including summaries dating back to 2023, so a single query can combine relevant details from multiple archives.
- For web research, Ray prefers Exa.ai and ExaCode over Brave, and recommends limiting sources to trusted documentation because search filtering reduces, but does not eliminate, prompt-injection risk.
- Ray demonstrates a separate skill that checks a news article against multiple sources and distinguishes confirmed facts, anonymous claims, and unsupported assertions.
- The analysis of an Anthropic-Pentagon dispute highlights the article’s framing, evidence gaps, emotional appeals, and missing context about Claude’s reported use through Palantir.
- He shares the Rhetorical Analyzer skill with his Discord community and describes it as a way to examine claims without being swept up by an article’s emotional framing.
- Ray discusses sharing the memory optimizer and other agent skills through Discord while continuing to refine them before wider release.
- For safety, he recommends getting QMD details from official OpenClaw documentation and reviewing third-party skill files rather than installing them blindly.
- He suggests using planning conversations with an agent to define a skill’s requirements before implementation, especially when correctness matters.
- Ray describes serving local models from a Mac or NVIDIA DGX Spark with tools such as MLX or LM Studio, then connecting remote agents through a Tailscale tunnel.
- He warns that local inference can introduce throughput and response-latency limits when multiple users or agents send requests.
- The discussion turns to open models, privacy, government access, and the risks of giving any single company or agency unrestricted access to sensitive systems.
- Ray considers connecting OpenClaw to Notion for databases, Kanban views, and reports that sync across devices, drawing on workflows he already uses there.
- He also wants to explore an iOS assistant that could replace Siri and a locally served Qwen text-to-speech model connected to HomePods.
- For users concerned about Telegram chat logging, he notes that an alternative app can communicate with the OpenClaw gateway directly.
Transcript excerpt
0:00 Aloha and welcome. Today we're going to fix long-term memory. So I actually have OpenClaw installed on this Mac Mini right here. And so this thing is actually running my whole entire life. And I noticed when I was chatting yesterday that my memory stuff wasn't really working. After things compacted, it says like, hey, I didn't really know what was going on. And so what I found out was that there's this thing called QMD. And this is a new thing that came as part of the update that we're going to go ahead and talk about. We're also going to talk about here about OpenClaw. Basically, OpenClaw has now become in the hands of OpenAI, which is pretty amazing. So Pete Steinberger is now joining the OpenAI team, and he's going to be basically helping them. Like, I think they've set up a whole new foundation and everything like that, and a lot of people are really concerned that this may
0:46 actually tank the project or something like that, and it's actually not. I'm also the belief of Alex Finn where he's also saying that it's very bullish and we're going to talk a little bit more about that. So we're also going to talk a little bit about the memory optimizer skills. So I made a skill around this whole thing and it's a little script that's going to check to make sure that your memory is pretty much compact. Because what most people don't realize is that certain files inside of your memory can get really bloated. So that every time you start to actually prompt your OpenClaw agent, it'll start to like maybe use 2,000 tokens right now. A week from now, it could be 6,000 tokens, it could be 20,000 tokens, because sometimes you'll say, hey, can you
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Ray Fernando.