Inside OpenClaw's LCM: How Long Context Memory Makes Agents Remember
What makes a good memory system? The user shouldn't have to explain who they are, what they just said, or what they want — every single time. OpenClaw achieves this with LCM (Long Context Memory), a memory management system designed specifically for AI agents operating across multiple sessions.
The architecture works on three layers. Short-term memory handles the current conversation session. When context approaches 80% of the window limit, OpenClaw automatically compresses earlier messages into structured summaries and injects them into the system prompt — preserving decision logic and key information while discarding filler content.
Mid-term memory — the LCM Summaries layer — is where things get interesting. As conversations accumulate beyond what fits in a single context window, LCM compresses conversation history into searchable, structured summaries stored in persistent memory. When you discuss a technical architecture with your agent and return to the topic a week later, LCM retrieves the relevant summary automatically. The compression algorithm is the secret sauce: it preserves decision logic and key inflection points while discarding small talk and redundant exchanges.
Long-term memory lives in actual files on disk. Each agent can write to dedicated memory files — soul.md, user.md, or custom paths. This is fundamentally different from cloud LLM memory. You can open the files, read what the agent remembered, edit mistakes, or delete things you don't want stored. This transparency is the defining advantage of local AI: you control what's remembered and what's forgotten.
A few practical pitfalls to watch for. The compression threshold defaults to 80% of context window, but if you're processing long documents, raise it — otherwise the agent might compress the document you're still analyzing. Memory writes are asynchronous, so if the agent process crashes, the last conversation may not be saved. And in multi-agent scenarios, memory isolation means Agent A's memory files aren't accessible to Agent B by default — you need to explicitly share paths.
The bottom line: LCM turns "memory" from a black box into a white box. You can see, edit, and control exactly what your agent remembers. Cloud LLMs cannot offer this.