Why Your OpenClaw Agent Keeps Forgetting Things and How to Fix It for Good

If you’ve been using OpenClaw for a while, you’ve probably hit this moment: you told your agent something two weeks ago — a preference, a project detail, a decision you made together — and now it’s just… gone. You’re explaining it again from scratch, wondering if something broke.

Why Your OpenClaw Agent Keeps Forgetting Things and How to Fix It for Good

Nothing broke. What you’re experiencing is a fundamental limitation of how large language models handle long conversations. According to Anthropic’s documentation on Claude’s architecture, every LLM operates within a fixed context window — a hard ceiling on how much text the model can hold in working memory at once. When that ceiling gets close, something has to give.

The good news? This is a solved problem. Not with a hack or a workaround, but with a deliberate memory strategy that takes about five minutes to set up. Here’s exactly how it works, why it matters, and three approaches ranked from simple to bulletproof.

A Quick Summary / TL;DR

Short on time? Here’s what you need to know:

ProblemSolutionTime to Set UpDifficulty
Agent forgets preferences after long conversationsCreate a MEMORY.md file for persistent storage2 minutesEasy
Daily session context disappears between restartsEnable daily notes (memory/YYYY-MM-DD.md)3 minutesEasy
Agent repeats the same mistakes after correctionsInstall the Self-Improving Agent skill from ClaWHub5 minutesEasy
Memory files get lost on local machinesHost on xCloud for persistent VPS storage with systemd10 minutesMedium

Best for beginners: MEMORY.md — one file, immediate improvement, zero complexity.

Best for power users: Full self-improving system with hot memory, correction logs, and pattern tracking.

Best for teams and production: xCloud-hosted OpenClaw with persistent disk, managed systemd service, and automatic crash recovery.

Why you need this: the real cost of a forgetful agent

Think about the last time you had to re-explain something to your OpenClaw agent. Maybe it forgot your coding style preferences. Maybe it lost track of which project uses which deployment pipeline. Maybe it forgot the name of your co-founder.

Each re-explanation costs you time. But the higher cost is trust erosion. According to a 2025 McKinsey report on AI agent adoption, 68% of users who abandon AI assistants cite “lack of continuity” as their primary frustration — not capability, not accuracy, but the feeling that the AI doesn’t actually know them.

In 2026, with Claude operating on a 200,000-token context window and GPT-4o supporting 128,000 tokens, these windows are larger than ever. Google’s Gemini 2.0 pushes past 1 million tokens. But even a million tokens have a limit. And when you’re running an always-on agent through OpenClaw — one that handles your emails, manages your projects, monitors your infrastructure — that context fills up fast.

The question isn’t whether your agent will forget. It’s whether you’ve built a system to catch what matters before it disappears.

How context windows actually work (and why they’re not memory)

Here’s the analogy that makes this click: a context window is like a whiteboard in a meeting room. Everything discussed in the current meeting gets written on the board. Everyone can see it, reference it, and build on it. But the whiteboard has a fixed size.

When the board fills up, someone has to erase the oldest notes to make room for new ones. That’s compaction.

What compaction actually does

OpenClaw uses a memory-compaction mechanism. When the context window approaches its token limit — say, 180,000 out of 200,000 tokens for Claude – OpenClaw takes the older portion of the conversation and summarizes it. Thousands of tokens of detailed conversation get compressed into a compact summary, sometimes just a few hundred tokens.

This is smart engineering. Without compaction, the agent would simply hit the wall and stop functioning. Compaction keeps the conversation going.

But the side effect is information loss. And it’s not random — it’s predictable:

What gets preserved in compactionWhat gets lost
Major decisions and conclusionsSpecific wording of preferences
Overall project directionEdge cases and exceptions you flagged
Recent conversation (last few turns)Usernames, file paths, URLs mentioned in passing
High-level goals and objectivesPrecise instructions (“always use tabs, not spaces”)
Active task contextHistorical context from earlier sessions

A summary is, by definition, less detailed than the original. The specific wording of a preference you gave three weeks ago gets reduced to a general description. An edge case you flagged might not survive. A file path mentioned once — gone.

The numbers behind the problem

To understand the scale, consider what fills a context window during typical OpenClaw usage:

ActivityApproximate token cost
System prompt + workspace files5,000–15,000 tokens
Single tool call + response500–3,000 tokens
Reading a file (500 lines)2,000–5,000 tokens
Web search results1,000–3,000 tokens
Code generation (single function)300–1,500 tokens
One hour of active conversation10,000–30,000 tokens

At those rates, an active OpenClaw session can burn through 200,000 tokens in a single workday. A session that runs continuously (as many xCloud-hosted agents do) hits compaction multiple times per week.

Each compaction cycle is another opportunity for details to slip through the cracks.

The three memory approaches: from simple to bulletproof

Compaction isn’t the enemy. A lack of a deliberate save strategy is. Here are three approaches, ranked by complexity and effectiveness.

Approach 1: MEMORY.md — the foundation

Best for: Everyone. This is the starting point, regardless of what else you add later.

MEMORY.md is a single markdown file in your OpenClaw workspace that acts as your agent’s long-term memory. Think of it as the difference between working memory and a notebook: the context window holds what you’re thinking about right now, and MEMORY.md is where you write things down so you don’t lose them when the whiteboard gets erased.

How to set it up

Tell your agent:

“Before any compaction happens, save the most important things from our conversation to a memory file. Include: key decisions we’ve made, my preferences, project details, people and context I’ve mentioned, and anything you’d want to know if starting fresh. Save it to MEMORY.md in the workspace.”

That’s it. One prompt. Your agent creates the file, and from that point forward, it reads MEMORY.md at the start of every session and updates it when important information changes.

What goes in MEMORY.md

A well-structured MEMORY.md typically covers your coding style, communication tone, and formatting rules; active projects with their tech stacks and deployment targets; team members, their roles, and who handles what; architectural choices and workflow decisions; and key dates like launch milestones or review cycles.

What does not go in MEMORY.md

Raw API keys, passwords, session tokens, or any sensitive credentials. Use environment variables or .env files for secrets. MEMORY.md is a knowledge file, not a vault.

Pros and cons

ProsCons
✅ Takes 2 minutes to set up❌ Requires manual curation over time
✅ Works immediately with any model❌ Single file can get unwieldy at scale
✅ Agent reads it automatically each session❌ No structured correction tracking
✅ Human-readable and editable❌ Doesn’t capture task-specific patterns

Approach 2: MEMORY.md + daily notes — high fidelity

Best for: Users who want both curated knowledge and detailed session history.

Daily notes add a second layer: raw, timestamped session logs that capture everything that happened on a given day.

How to set it up

Tell your agent:

“At the end of each day or session, save a summary of what we worked on today to memory/YYYY-MM-DD.md. Include tasks completed, decisions made, problems encountered, and anything notable. Keep MEMORY.md for the curated long-term stuff.”

This creates two complementary systems. MEMORY.md holds the long-term, curated facts your agent needs across all sessions — think of it as an identity document. The daily notes in memory/YYYY-MM-DD.md are raw session logs, high fidelity and chronological, closer to a work journal than a reference sheet.

Why both matter

MEMORY.md tells your agent who you are. Daily notes tell it what happened. When your agent wakes up fresh, it reads MEMORY.md for context and yesterday’s daily note for recency. The combination gives it both depth and continuity.

On xCloud, both files persist on the VPS disk between sessions, server reboots, and OpenClaw updates. Nothing gets lost. On a local machine, a crash or restart could wipe the unsaved state — more on that in the hosting section below.

Pros and cons

ProsCons
✅ Complete daily history, nothing lost❌ Accumulates files over time (needs periodic cleanup)
✅ Easy to search past sessions❌ Agent must read multiple files at session start
✅ Great for debugging “what happened when”❌ Still no structured correction or improvement tracking
✅ Human-reviewable work log❌ Slightly higher token cost at session start

Approach 3: Full self-improving memory system — the bulletproof setup

Best for: Power users running production agents who want their agent to get better over time, not just remember things.

This is where it gets interesting. Instead of just storing information, this approach creates a feedback loop: your agent tracks its own mistakes, learns from your corrections, and adapts its behavior over time. On ClaWHub, there’s a community skill called Self-Improving Agent. When you install it, it creates three specialized memory files.

Hot memory (hot-memory.md) holds frequently accessed facts and patterns — your name, your tech stack, your communication preferences. Things the agent needs almost every session. Think of it as the fast-access cache.

The correction log (correction-log.md) records every mistake you correct, with full context: what the agent did wrong, what the right behavior is, and when it happened. That’s the feedback mechanism.

Pattern memory (patterns.md) stores learned preferences tied to specific task types: “When writing Python, use type hints.” “When drafting emails to clients, keep it under 200 words.” “When deploying to production, always run tests first.” These are behavioral rules the agent extracts from your corrections over time.

To install it, follow the ClaWHub skills guide — it’s a one-command setup.

The loop is simple but effective:

  1. You correct the agent. (“No, don’t use var in TypeScript — always use const or let.”)
  2. The agent logs the correction to correction-log.md with the date, the context, and the corrected behavior.
  3. Next session, the agent reads the correction log. It sees the entry about TypeScript variable declarations.
  4. A similar situation arises. The agent encounters TypeScript code. It checks its patterns and correction log.
  5. The agent avoids repeating the mistake. It uses const without being told.
  6. Over time, the correction log becomes a personalized reference. Not in the machine learning sense (the model weights don’t change), but in the practical sense: the agent reads its own history of mistakes and adjusts its behavior. According to research on in-context learning from Stanford’s Human-Centered AI Institute (HAI), LLMs demonstrate significantly improved task performance when provided with examples of correct behavior in their context window — a finding that directly supports this correction-log approach.

If you prefer building it yourself (or want to customize the structure), give your agent this prompt:

“Build me a self-improving memory system. Create a folder in my workspace called ‘self-improving’ with three files: hot-memory.md for frequently needed context, correction-log.md for logging any mistakes I correct, and patterns.md for task-specific preferences. At the start of each session, read all three files. Whenever I correct you, log the correction to correction-log.md with the date and context. Update hot-memory.md when something important changes.”

Your agent handles the rest. It creates the folder structure, sets up the files, and starts logging. You can also set up proactive workflows so your agent periodically reviews and consolidates its memory files without being asked.

Pros and cons

ProsCons
✅ Agent improves over time automatically❌ More complex setup (5-10 minutes)
✅ Tracks and prevents repeated mistakes❌ Higher token cost reading 3+ files each session
✅ Task-specific pattern learning❌ Correction log grows and needs periodic pruning
✅ Transparent — you can read and edit every log❌ Requires consistent correction behavior from the user

Master comparison: memory approaches at a glance

FeatureNo memory system🥇 MEMORY.md only🥈 MEMORY.md + daily notes🥉 Full self-improving system
Preferences preservedNoYesYesYes, categorized
Session historyNoOnly curated highlightsFull daily logsFull daily logs + corrections
Mistake trackingNoNoNoYes, with context
Behavioral improvementNoNoNoYes, learns from corrections
Setup time0 minutes2 minutes5 minutes10 minutes
Token overhead per session0~1,000–3,000~2,000–5,000~3,000–8,000
ComplexityNoneLowLow-MediumMedium
Best forTesting / casual useMost usersUsers who want full historyPower users / production agents

Memory on xCloud: why the hosting layer matters

Here’s something that trips up a lot of people: you can build the most sophisticated memory system in the world, and it means nothing if the files don’t persist.

Running OpenClaw on your laptop means your agent’s memory lives on your local disk. Close your laptop, and the agent goes to sleep. Crash, and you might lose the unsaved state. Reformat, and it’s all gone.

On xCloud, the equation changes:

FeatureLocal machinexCloud VPS
File persistenceDepends on uptimePersistent disk — survives reboots, crashes, updates
Agent uptimeOnly when your machine is onAlways running (managed systemd service on Linux)
Crash recoveryManual restartAutomatic (systemd auto-restarts the agent)
Memory file accessLocal onlyAccessible via SSH, SFTP, or the agent itself
Background tasksStop when laptop sleepsRun 24/7 — heartbeats, cron, proactive work
Multi-agent setupsResource-constrainedDedicated resources for sub-agents

The difference is architectural. systemd — the service manager built into every modern Linux distribution — manages the OpenClaw process on xCloud. If the process crashes, systemd restarts it automatically. If the server reboots, systemd brings the agent back online. Your memory files sit on the VPS disk, untouched.

This is why the self-improving memory system works best on xCloud: the agent needs to be always running to accumulate corrections, update patterns, and consolidate memory. An agent that only runs when your laptop is open doesn’t get enough cycles to meaningfully self-improve.

Implementation Guide: Set It Up in 15 Minutes

Here’s the step-by-step. Start with Approach 1 and layer on the others when you’re ready.

Step 1: Create MEMORY.md (2 Minutes)

Send this to your OpenClaw agent:

“Create a MEMORY.md file in the workspace. Add the following sections: My Preferences, Active Projects, People & Roles, Key Decisions, and Important Dates. Fill in what you already know about me from our conversations. Going forward, update this file whenever important context changes or before compaction happens.”

Step 2: Enable Daily Notes (3 Minutes)

“At the end of each session or day, save a summary to memory/YYYY-MM-DD.md. Include: tasks completed, decisions made, problems encountered, and anything I’d want to reference later. Create the memory/ folder if it doesn’t exist.”

Step 3: Install or Build The Self-Improving System (5-10 Minutes)

Option A — install from ClaWHub: Follow the ClaWHub skills guide and install the Self-Improving Agent skill.

Option B — build it manually: Use the prompt from the “Build it without a community skill” section above.

Step 4: Let It Run

This is the part people miss. The system gets better with time. The first week, your correction log will have five entries. After a month, it’ll have fifty. After three months, your agent will anticipate your preferences before you state them.

The key behavior from you: correct consistently. When your agent does something wrong, don’t just fix it yourself — tell the agent what was wrong and what the correct approach is. That feedback is the fuel.

Common Mistakes to Avoid

MistakeWhy it happensWhat to do instead
Storing secrets in MEMORY.md“MEMORY.md is enough.”Use .env files or environment variables for credentials
Never curating MEMORY.mdLetting the file grow uncheckedReview and trim monthly — remove outdated info
Expecting instant improvementSelf-improving takes cyclesGive it 2-4 weeks of consistent corrections
Not hosting persistentlyRunning on a laptop that sleepsUse xCloud or another always-on VPS for production agents
Skipping daily notes“MEMORY.md is enough”Daily notes provide the raw material for memory curation
Overloading the correction logLogging every tiny issueFocus corrections on behavioral patterns, not one-off typos

Video resources and tutorials

TopicWhat to searchGetting started with the OpenClaw workspace structure
LLM context windows explained“How LLM context windows work” on YouTubeVisual explanation of the token limit problem
Building an AI agent’s memory“AI agent memory systems tutorial” on YouTubePractical walkthroughs of memory file approaches
OpenClaw setup and configuration“OpenClaw agent setup guide” on YouTubeGetting started with OpenClaw workspace structure
Self-improving AI agents“self-improving AI agent prompt engineering” on YouTubeAdvanced techniques for correction-based learning
Linux systemd service management“systemd service management Linux” on YouTubeUnderstanding how xCloud keeps your agent running

According to Ahrefs research (2026), YouTube mentions are the strongest predictor of AI visibility, with a 0.737 correlation — higher than domain rating, backlinks, or any traditional SEO factor. Content referenced in YouTube videos is significantly more likely to surface in AI search results from Google AI Mode, ChatGPT, and Perplexity.

Frequently asked questions

Do I need all three approaches, or can I just use MEMORY.md?

Start with MEMORY.md alone — it solves 80% of the forgetting problem for most users. Add daily notes when you want session history, and layer on the self-improving system when you’re ready for your agent to actively learn from mistakes. Each approach builds on the previous one.

How much does the memory system cost in tokens?

MEMORY.md adds roughly 1,000–3,000 tokens to each session start, depending on file size. The full self-improving system (three files) adds 3,000–8,000 tokens. On Claude’s 200,000-token context window, that’s 1.5–4% of capacity — a small price for persistent memory.

Will this work with any LLM, or only Claude?

The memory file approach works with any model that OpenClaw supports, including Claude (Anthropic), GPT-4o (OpenAI), and Gemini (Google). The underlying principle — reading files into context at session start — is model-agnostic. The self-improving system works best with models that follow instructions precisely, which is where Claude and GPT-4o excel.

What happens to my memory files if I switch models?

Nothing — they’re plain markdown files on disk. Switch from Claude to GPT-4o and back again; your MEMORY.md, daily notes, and correction logs remain exactly where they are. The agent reads them fresh regardless of which model is running.

How often should I review and curate MEMORY.md?

Monthly is a good cadence for most users. Remove outdated project details, update preferences that have changed, and consolidate any entries that have become redundant. Some users set up a proactive workflow that has the agent do this automatically during heartbeat checks.

Can my agent update MEMORY.md on its own, or do I have to do it manually?

Your agent can and should update MEMORY.md autonomously. The initial prompt instructs it to save important context before compaction. You can also ask it to update specific sections anytime. The key is that you review the file periodically to ensure accuracy — the agent captures what it thinks is important, but you’re the authority on what actually matters.

Is the self-improving system just retrieval-augmented generation (RAG)?

Not exactly. RAG systems typically search large document stores for relevant context. The self-improving system is simpler and more targeted: three small files read in full at session start. There’s no vector database, no embedding search, no retrieval pipeline. It’s closer to “structured prompt context” than RAG. The advantage is simplicity and transparency — you can read every file and understand exactly what your agent knows.

What if my correction log gets too large?

Trim it quarterly. Keep the most useful corrections (behavioral patterns that come up repeatedly) and archive or delete one-off fixes. A correction log with 30–50 high-quality entries is more useful than one with 500 entries, including every minor typo fix. Your agent can help with this consolidation.

Do I need xCloud, or can I run this on my own server?

You can run OpenClaw and this memory system on any Linux server with systemd. xCloud simplifies the setup — managed installation, automatic updates, pre-configured systemd service, and support — but the underlying technology is standard Linux infrastructure. If you’re comfortable managing your own VPS, the memory system works identically.

How is this different from ChatGPT’s built-in memory feature?

ChatGPT’s memory stores short facts about you (preferences, personal details) and applies them globally across conversations. OpenClaw’s memory system is more detailed: full markdown files with structured sections, daily session logs, correction tracking, and pattern learning. It’s also fully transparent and editable — you own the files, you can read them, and you control exactly what’s stored. ChatGPT’s memory is a black box managed by OpenAI.

Can I use sub-agents to manage memory consolidation?

Yes. You can configure a sub-agent for memory maintenance — reviewing daily notes, updating MEMORY.md, pruning the correction log, and consolidating patterns. This keeps your main agent focused on tasks while a background process handles memory hygiene.

Your 2026 OpenClaw memory roadmap

The forgetting problem isn’t going away. As context windows grow — Claude now supports 200,000 tokens, up from 100,000 two years ago — the temptation is to assume bigger windows solve everything. They don’t. Bigger windows just mean it takes longer to hit the wall. The wall is still there.

What does solve it is a deliberate memory strategy: files that persist, logs that accumulate, and a feedback loop that turns corrections into improvements.

Action steps by goal

Your goalBest approachFirst stepEnable daily notes in the workspace
Stop re-explaining preferencesMEMORY.mdSend the setup prompt to your agent todayImmediate — agent remembers from next session
Full session historyMEMORY.md + Daily NotesAn agent that learns from mistakesComplete recall of past sessions within a week
Agent that learns from mistakesSelf-Improving SystemInstall ClaWHub skill or build manuallyNoticeable improvement within 2-4 weeks
Always-on, crash-proof memoryxCloud HostingDeploy OpenClaw on xCloud VPSPersistent memory, zero downtime, automatic recovery

Start with MEMORY.md. It takes two minutes. Then add layers as your needs grow.

Your agent doesn’t need to forget. It just needs a place to remember.

👉 Host your OpenClaw agent on xCloud →

Join The Waitlist

To Get Early Access to Lifetime Deals

LTD WaitList Access