How OpenClaw memory works, and why it inflates token bills
OpenClaw memory lives in Markdown files and a session that never resets by default. What loads into every prompt, how to prune it, and what scoped memory fixes.

On this page
Part of AI agent with persistent memory: how it works and what to demand
OpenClaw memory is a set of Markdown files in the agent's workspace, plus a conversation that, by default, never resets. MEMORY.md holds curated long-term facts, USER.md your preferences, and daily notes collect in memory/YYYY-MM-DD.md. It's simple and you can open every file in a text editor, which is its real strength. It's also why bills creep up: the memory file and the rest of the workspace are sent with every turn, and the session history keeps growing until compaction kicks in near the model's context limit.
Here is how each piece works, what actually inflates the bill, and how to trim it safely. Everything below is from OpenClaw's docs as of 28 November 2026.
How OpenClaw stores long-term memory and session transcripts
There are two layers, and they behave very differently.
Memory files, in the agent workspace (memory docs):
MEMORY.md: curated long-term facts and standing decisions. The docs say it is "not a raw transcript, daily log, or exhaustive archive." It loads at session start and, on most setups, with every turn.USER.md: your stable preferences, written as directives.memory/YYYY-MM-DD.md: daily notes. Indexed for search, not injected every turn. Today's and yesterday's load on a fresh/newor/reset.DREAMS.md: optional summaries from "dreaming", a background sweep that promotes recurring facts intoMEMORY.md. Dreaming is on by default and runs as a cron job.
Agents reach the rest through two tools: memory_search, a hybrid of semantic and keyword search, and memory_get, which reads a file or line range. Semantic search uses OpenAI embeddings by default, so your notes go to OpenAI for indexing unless you set memory.search.provider to another provider or "none" for keyword-only search.
Session history, kept apart from memory (sessions): rows and transcripts live in ~/.openclaw/agents/<agentId>/agent/openclaw-agent.sqlite, with archived transcripts in that agent's sessions/ folder. The default reset mode is "none". The same conversation carries on for days or weeks unless you opt into a daily or idle reset.
- 1Every turnAGENTS.md, SOUL.md, USER.md, MEMORY.md
- 2PlusThe session's history so far
- 3On demandDaily notes via memory_search
- 4Near the limitCompaction summarises old turns
Why unpruned memory turns cheap heartbeats into $18+ nights
A model has no memory of its own. Each turn, OpenClaw rebuilds the prompt: tools, skills, workspace files and then the conversation. All of it is billed as input tokens, every time (token use).
Three things push that number up.
1. The workspace files. Each injected file is truncated at 20,000 characters (agents.defaults.bootstrapMaxChars), and the whole set at 60,000 (bootstrapTotalMaxChars). On the usual rule of thumb of about four characters per token, a full set is around 15,000 tokens before you've said a word. A MEMORY.md that has grown into a diary is paid for on every message.
2. The session that never resets. With the default no-reset mode, history accumulates. Auto-compaction starts at the smaller of 85% of the window and the window minus its reserve. The docs' own example: on a 1,000,000-token window with a 20,000-token reserve, that's 850,000 tokens (compaction). Until then, every turn resends the lot. Prompt caching softens it, but only inside the cache's time window.
3. Heartbeats run in that same conversation. OpenClaw's proactive check "uses the agent's main conversation" (heartbeat docs). So a check that only asks "anything new?" carries the full weight of a long session.
That's how the best-known bill happened. Notebookcheck reported each heartbeat "sending 120,000 tokens of context for a trivial check" to Claude Opus, about $0.75 a request, and "$18.75 gone in a single night." Memory files were one part of that context. The growing conversation was the rest.
To be fair: current OpenClaw releases create the heartbeat switched off, cap the workspace files, and compact automatically. The defaults are better than they were. The bloat comes from leaving a long-lived session and a growing MEMORY.md alone for weeks.
How to audit and compact OpenClaw memory safely
Measure first, then cut. Our OpenClaw token usage guide covers the wider bill; these steps are just memory and context.
- See what each turn sends. Run
/context detailin chat. It breaks down every injected file, the tools, skills and system prompt size.openclaw doctorcompares each file's size on disk with what's actually injected. - Turn on the cost footer.
/usage tokensshows input and cache tokens per reply;/usage costgives a local cost summary from your session logs. - Edit
MEMORY.mdby hand. Keep standing decisions and durable facts. Move logs, meeting notes and anything dated into daily notes, where they're searchable but not sent every turn. If the file is over the cap, the copy on disk stays whole but the injected copy is cut off, so the facts at the bottom silently stop reaching the model. - Start fresh sessions on purpose.
/newstarts a new conversation without rewriting the old one. Or setsession.resettodaily(it rolls at 4am gateway time by default) oridle. - Compact long sessions with a focus.
/compact Focus on the open orders and supplier decisionssummarises older turns while keeping the most recent ones. The full history stays on disk; only what the model sees changes. Before compaction, OpenClaw prompts the agent to save important notes to the daily file. - Check what dreaming promotes. Review
DREAMS.mdnow and then. If a promotion is wrong,openclaw memory rem-backfill --rollbackundoes it. - Keep checks out of the main conversation. Use an isolated session for scheduled checks where you can, restrict them with
activeHours, and put them on a small model.
Back up the workspace folder before a big edit. Memory files are plain text, so version them with git if you like; that's one of the nicest things about OpenClaw's design.
How Fluf isolates memory per business and lets you edit it directly
Fluf is a desktop app for Mac, Windows and Linux where you hire AI agents, each a named character with persistent memory. Its memory is built from separate entries rather than one file, and every entry has an owner (memory docs).
- Scoped on purpose. Each memory has a Who reads it setting: about you, everyone in a business, a team, or only one agent. A business never reads another business's memory unless you grant it. Your store's refund policy doesn't leak into a client's business.
- You approve what's kept. After work, Fluf picks out candidate facts and decisions, merges duplicates and flags contradictions. Anything risky lands in To review, where you Keep, Edit or choose Don't keep.
- Edit, pin, forget, restore. Pin what agents should read first. Forget stops agents using a memory at once, with 30 days to bring it back. Every memory keeps its history of earlier versions.
- It cleans up after itself. Memories unused for over 90 days with low confidence fade; shared ones come to you for review first. Text that looks like an API key or token is never stored.
- Long chats are summarised, not dropped. When a conversation outgrows what the model can see, older parts are summarised and the agent can search past conversations. If required instructions can't fit, nothing is sent and the agent says so.
- Memory belongs to the agent, not the model. Switch an agent from Claude to GPT or a local model and its memory comes along (switching models).

What it doesn't do: let you open the memory in a text editor and grep it. Export covers that: Export as Markdown to read it, or a Fluf file to import elsewhere. Passwords, keys and private reasoning never go into an export. For the wider picture, read AI agent with persistent memory.
Memory hygiene rules for any persistent AI agent
These apply whether you run OpenClaw, Fluf or something else.
- Separate facts from logs. Durable facts go in long-term memory. Dated events go somewhere searchable, not into every prompt.
- Scope by business. One agent's notes about client A should never reach client B's work.
- Review what gets promoted. Automatic memory is useful and occasionally wrong. Look at what's added each week.
- Reset conversations deliberately. A fresh session with good memory beats a month-long one with everything in it.
- Never store secrets in memory. Keys belong in a secrets store or the app's key settings, not in a Markdown file the model reads every turn.
- Put a dollar limit next to the memory. Context grows quietly. A daily cap per agent turns a surprise bill into a held job (usage and budgets).
Tired of paying to resend last month's notes? Download Fluf and give your agents memory you can manage.
Questions people ask
- Where does OpenClaw store memory?
- In Markdown files in the agent's workspace: MEMORY.md for curated long-term facts, USER.md for your preferences, and daily notes in memory/YYYY-MM-DD.md. Conversation history lives separately in a per-agent SQLite database under ~/.openclaw/agents/, with archived transcripts in its sessions folder.
- Does OpenClaw send MEMORY.md with every message?
- Yes, when the file exists, as part of the workspace files injected into the system prompt. Each file is capped at 20,000 characters and all of them together at 60,000 by default. Daily notes are not injected every turn; the agent searches them when needed.
- How do I reduce OpenClaw context bloat?
- Run /context detail to see what each turn sends, keep MEMORY.md short and current, start fresh sessions with /new or a daily reset, and run /compact on long ones. Put frequent checks on a small model.
- How does OpenClaw memory compare with Fluf?
- OpenClaw memory is files you edit in a text editor, shared by everything in that agent's workspace. Fluf keeps memories as separate entries you review, pin, edit or forget in the Library, each scoped to you, a business, a team or one agent.
- Can I run either one locally with my own AI providers?
- Yes. Both run on your own computer with your own Claude Code or Codex login, an API key, or a local model through Ollama or LM Studio. OpenClaw uses OpenAI embeddings for memory search by default; you can switch provider or use keyword-only search.
Sources
- OpenClaw docs: Memory, checked 28 November 2026
- OpenClaw docs: Token use and costs, checked 28 November 2026
- OpenClaw docs: Sessions, checked 28 November 2026
- OpenClaw docs: Compaction, checked 28 November 2026
- OpenClaw docs: Heartbeat, checked 28 November 2026
- Notebookcheck: $18.75 overnight to ask 'Is it daytime yet?', checked 28 November 2026
- openclaw/openclaw on GitHub, checked 28 November 2026



