Inside OpenClaw: Gateway, Brain, Memory, Heartbeat, and Skills
Five components that turn an LLM into a persistent agent. Here is what each one does, how they interact, and where the architecture shines and struggles.
In my last article, I described how OpenClaw agents produce behavior that surprises people — remembering corrections, acting autonomously, explaining their reasoning. I promised a deeper look at the architecture behind that behavior. This is that article.
I want to be clear about my perspective. I am not an OpenClaw contributor. I am a product leader who has built agents with the framework and studied its design because it solves problems that matter to my work. What follows is my understanding of the architecture as a practitioner, informed by the documentation, the source code, and conversations with teams that have deployed OpenClaw in production.
OpenClaw is built around five core components: Gateway, Brain, Memory, Heartbeat, and Skills. Each serves a distinct purpose, and the way they interact is what gives OpenClaw agents their persistent, adaptive character. A sixth element — SOUL.md — defines the agent's identity and personality, and I will cover it alongside the components it touches.
Gateway: The Nervous System
The Gateway is the central control plane of an OpenClaw agent. It is a single long-lived daemon process that manages all connections, sessions, routing, and events. If you think of an OpenClaw agent as an organism, the Gateway is the nervous system — everything passes through it.
At a technical level, the Gateway runs a WebSocket server on the local machine. Control clients (the macOS app, CLI, or web UI) connect to it. Messaging platform integrations — and OpenClaw supports over twenty, including Slack, WhatsApp, Telegram, Discord, iMessage, and Teams — connect through it. Every message, every tool invocation, every heartbeat pulse flows through the Gateway.
What makes the Gateway architecturally significant is that it creates a persistent runtime for the agent. In most frameworks, the agent exists only during the execution of a request. The Gateway keeps the agent alive between requests. It maintains session state, manages authentication, routes messages to the right handler, and serves the web-based Canvas UI.
In practice, the Gateway is what allows you to message an OpenClaw agent on Slack at 9 AM, have it remember that conversation when you check in via the macOS app at 2 PM, and then watch it take autonomous action at 3 PM when the Heartbeat fires. The session continuity that the Gateway provides is foundational to everything else the framework does.
Where the Gateway creates risk: The January 2026 security audit revealed a critical vulnerability — the Gateway's WebSocket server did not validate origin headers, meaning any website could silently connect to a running agent. This has been patched, but it illustrates a broader tension in OpenClaw's design: the same persistent daemon that makes agents feel alive also creates a significant attack surface. In enterprise deployments, the Gateway needs to be treated as security-critical infrastructure.
Brain: The Reasoning Engine
The Brain is where the language model lives, and it follows the ReAct (Reasoning + Acting) pattern — a loop that alternates between thinking and doing.
Here is how it works in practice:
- The Brain loads context — conversation history, relevant memories, the list of available tools
- It compiles a system prompt that includes the agent's SOUL.md (identity), available skills, and the current context
- It sends everything to the LLM
- The LLM responds with either a text answer or a tool call
- If it is a tool call, the Brain executes the tool, adds the result to the context, and loops back to step 3
- This continues until the LLM produces a final text response
The Brain is model-agnostic. OpenClaw supports Claude, GPT-4, Gemini, Mistral, Ollama, and local models. You can switch the underlying LLM without changing the agent's skills, memory, or identity. This is a practical advantage — you can start with a powerful model for complex tasks and drop to a cheaper model for routine heartbeat checks.
Thinking levels are a feature I find particularly well-designed. OpenClaw supports seven reasoning intensities, from "off" (no chain-of-thought) to "xhigh" (extended deliberation). You can control this per-message with a /t directive. For routine status checks, low thinking saves tokens. For complex planning decisions, high thinking produces notably better output.
Where the Brain struggles: The ReAct loop can wander. I have seen agents enter reasoning spirals where they invoke tools repeatedly without making progress — pulling data they already have, reconsidering decisions they already made. This is a known limitation of ReAct-based architectures, not specific to OpenClaw, but it is more visible here because the agent runs autonomously. A wandering agent that is responding to a prompt is annoying. A wandering agent that is executing during a Heartbeat cycle is burning tokens with no one watching.
Memory: The Continuity Engine
Memory is what separates OpenClaw from frameworks where every interaction starts from scratch. It is also the component I find most cleverly designed.
OpenClaw's Memory operates across two tiers, plus a search layer:
Short-term memory is an append-only daily log stored as a markdown file — one file per day, named by date. When the agent starts a session, it loads today's log and yesterday's log. This gives it continuity across conversations within a short window. If you told the agent something this morning, it knows about it this afternoon.
Long-term memory lives in MEMORY.md — a curated file of durable facts, decisions, preferences, and lessons. This file is loaded into the agent's context at the start of every private session. It survives restarts, updates, and even model changes. If short-term memory is the agent's working memory, MEMORY.md is its institutional knowledge.
The bridge between them is automatic memory compaction. When a conversation grows long and the context approaches its token limit, OpenClaw triggers a silent agentic turn. It prompts the model: "Before this conversation compresses, what is worth remembering?" The model reviews the context and writes anything durable to MEMORY.md. This means the agent does not lose important context when conversations compress — it distills the essence and carries it forward.
Semantic search is the third piece. The agent can search its entire memory archive using hybrid retrieval — BM25 keyword matching plus vector embeddings with MMR re-ranking and temporal decay. When the agent encounters an unfamiliar situation, it can retrieve relevant past experiences even if they happened weeks ago and are no longer in the active context.
A practical example: I deployed a customer reporting agent that interacted with six account managers. Over three weeks, the agent accumulated memory about each manager's preferences — one wanted detailed notes on every interaction, another wanted only escalation summaries, a third preferred weekly digests grouped by account tier. Nobody configured these preferences explicitly. The daily logs captured the patterns, compaction distilled them into MEMORY.md, and semantic search surfaced them in the right contexts.
Where Memory falls short: The community has noted that Memory's effectiveness depends heavily on the quality of the compaction prompts and the underlying model's judgment about what is worth remembering. Some developers have reported that the built-in memory system loses important details during compaction, leading to third-party alternatives like mem0 and vector-store integrations with Milvus. Memory is also entirely local — there is no built-in mechanism for sharing memories across agents or syncing across devices.
Heartbeat: The Autonomy Engine
The Heartbeat is the component that makes OpenClaw agents proactive rather than purely reactive. It is, at its core, a periodic timer — but what it enables is more significant than the mechanism suggests.
How it works: The Gateway fires a heartbeat prompt at a configurable interval — thirty minutes by default, one hour on some provider tiers. The prompt is sent as a user message into the agent's main session. The agent reads its HEARTBEAT.md file — a workspace-level checklist of standing instructions — and evaluates whether anything needs attention. If nothing does, it responds with HEARTBEAT_OK. If something needs action, it acts.
HEARTBEAT.md is where the design gets interesting. It is a plain markdown file that defines what the agent should check during each heartbeat. For a project management agent, it might say: check the sprint board for stale tasks, review any pending pull requests, summarize overnight messages. For a monitoring agent: check system dashboards, compare metrics against baselines, alert if anything is anomalous.
The Heartbeat turns an LLM from a tool you invoke into an assistant that is always watching. The sprint planning agent I described in my previous article checks the board every thirty minutes. It does not need to be asked. It notices when a task has been stuck for a day, it notices when a deadline is approaching, and it surfaces these observations proactively.
Where the Heartbeat has real limitations: Cost is the most obvious. Each heartbeat run loads context, compiles the system prompt, and makes an LLM call. Without the isolatedSession optimization — which runs the heartbeat in a stripped-down session consuming only a few thousand tokens — costs compound quickly. An agent running every thirty minutes with full context can consume over 100,000 tokens per run. Over a month, that adds up.
The Heartbeat is also not adaptive — it fires at a fixed interval regardless of what is happening. A quiet Sunday and a critical launch day get the same cadence. You can configure active hours (so the agent sleeps overnight), but there is no built-in mechanism for the agent to adjust its own monitoring frequency based on urgency. If you need adaptive cadence, you configure it manually or build it into the HEARTBEAT.md instructions.
Skills: The Capability Layer
Skills are how OpenClaw agents learn to do things. Each skill is a markdown file — a SKILL.md — that teaches the agent how to use a specific tool or follow a specific procedure.
The structure is simple and elegant. A SKILL.md file has YAML frontmatter (name, description, requirements) and a markdown body that contains the instructions. The description field acts as a trigger phrase — it is included in the system prompt so the LLM knows what skills are available and when to use them.
Loading precedence matters: Skills are loaded from workspace-level directories first, then from the user's managed skills, then from bundled defaults. This means you can customize or override any skill at the project level without modifying global configuration.
ClawHub is the public skills registry — over 5,400 skills as of early 2026, covering everything from browser automation to email management to code generation. You can install skills with a single command.
What makes skills powerful in practice is that they are composable. A customer success agent might combine a CRM skill (to query account data), an email skill (to draft messages), a calendar skill (to check availability), and a reporting skill (to generate summaries). Each skill is independent and self-contained, but the Brain orchestrates them together based on the agent's goals.
Where skills create real risk: Skills run with the full privileges of the user who installed them. There is no sandboxing, no code signing, and no verification process on ClawHub. A security review in early 2026 found over 340 malicious skills on the registry, traced to coordinated campaigns. If you are using OpenClaw in a professional context, you need to audit every skill you install — or restrict your agents to skills you have written yourself.
SOUL.md: The Identity Layer
SOUL.md is not a component in the architectural sense — it is a configuration file. But it deserves discussion because it is what makes each OpenClaw agent feel distinct.
SOUL.md is a plain markdown file that defines the agent's identity, worldview, values, and communication style. It is injected into the system prompt every time the agent wakes — effectively, the agent reads itself into being at the start of every session.
The elegance is in the simplicity. You do not fine-tune the model. You do not train a custom adapter. You write a markdown file that says who the agent is, what it cares about, and how it communicates. Change the file, change the personality instantly.
A SOUL.md for a customer success agent might emphasize empathy, precision in account details, and a preference for proactive communication. A SOUL.md for a DevOps monitoring agent might emphasize brevity, technical accuracy, and a bias toward early alerting.
In combination with MEMORY.md (what the agent knows) and HEARTBEAT.md (what the agent monitors), SOUL.md creates a surprisingly complete picture of an agent's role. I have found that teams who invest time in writing thoughtful SOUL.md files get dramatically better results than teams who leave it generic.
How the Components Interact
The power of OpenClaw's architecture is not in any individual component. It is in how they work together. Consider what happens when an OpenClaw agent receives a Slack message from a team lead saying "we might need to push the launch date."
-
Gateway receives the message via the Slack integration and routes it to the agent's session
-
Brain activates. It loads the current context, including today's Memory log, the agent's SOUL.md, and the list of available Skills
-
Brain uses the
memory_searchtool to retrieve relevant context — it finds entries about the current project timeline, the downstream marketing campaign, and a note from two weeks ago that the last launch delay cost a week of rework -
Brain formulates a response through the ReAct loop: acknowledge the concern, summarize the downstream implications based on retrieved memories, and offer to pull together an impact analysis using the project management and calendar skills
-
Memory captures the interaction in today's daily log — the concern, the agent's response, and the context that informed it
-
The next time Heartbeat fires, the agent checks the project board with heightened attention to this project, because Memory now contains a note that the launch date may be at risk
This entire flow takes seconds. No human configured the specific response. The behavior emerges from the interaction of five components, each doing their job — Gateway routing, Brain reasoning, Memory providing context, Skills providing capability, and Heartbeat ensuring follow-up.
Practical Guidance for Getting Started
If you are considering OpenClaw, here is what I have learned from deploying it:
Start with one agent, one domain. Do not try to build a multi-agent system on day one. Deploy a single agent for a specific role — project management, content scheduling, customer reporting — and let the Memory system build context over two to four weeks.
Write a real SOUL.md. The default is generic and produces generic behavior. Spend an hour writing a SOUL.md that captures the agent's role, communication style, and priorities. This single investment produces the highest return of anything you can configure.
Audit every skill. Do not install skills from ClawHub without reviewing their code. The security track record of the public registry is poor. For enterprise use, write your own skills or fork and audit existing ones.
Optimize Heartbeat costs early. Enable isolatedSession for heartbeat runs. Configure active hours so the agent is not burning tokens overnight. Start with a longer interval (one hour) and shorten it only for workflows that genuinely need faster response.
Be patient through the cold start. The first two weeks will feel underwhelming. Memory is empty. The agent does not know your preferences, your team's rhythms, or your project context. By week four, the accumulated context begins to compound. The agent starts surfacing observations you did not ask for — and they are useful.
Monitor token consumption. OpenClaw can be expensive if you are not careful. The Brain's ReAct loop, the Heartbeat's periodic runs, and the Memory system's search operations all consume tokens. Set up cost tracking from day one.
The Bigger Picture
OpenClaw's architecture represents a specific bet about the future of agent technology: that the most useful agents will be the ones that persist, remember, and act autonomously over time. Not the ones that are smartest on any single interaction, but the ones that become more valuable the longer they operate.
After deploying the framework across several use cases, I believe this bet is directionally correct — with significant caveats. The security model needs to mature. The cost structure needs optimization. The autonomy needs better guardrails. These are not minor issues. They are the difference between a framework that impresses in demos and one that operates reliably in production.
But the architectural insight — that agents need identity, memory, autonomy, and skills as first-class components — is sound. Whether OpenClaw specifically becomes the dominant framework or whether its ideas get adopted by competitors, the patterns it has established will shape how agents are built for years to come.
For product leaders evaluating how to invest in agent technology, understanding these components is not just technical trivia. It is the basis for predicting which agent investments will compound over time and which will plateau.
What do you think? I would love to hear your perspective — feel free to reach out.
Related Articles

Founder, BusinessOfAI.com
Product management executive with 15+ years building enterprise software. Created 8 major products generating $2B+ in incremental revenue.