# How does OpenClaw work? Its architecture explained

One program, the Gateway, takes your chat messages, gives them to an AI model with tools, and sends the reply. Below: each part in plain words.

Tool: OpenClaw. By Julien Lieben. Updated 2026-12-05. Source: https://coldiq.com/university/openclaw/how-openclaw-works

## In short

- OpenClaw has one central program per machine, the Gateway. It owns the chat channels, the conversations and the connections.
- The AI model is not part of OpenClaw. You connect one, in the cloud or local, and OpenClaw builds what it reads.
- For each message, the agent loop prepares the context, asks the model, runs tools, and repeats until the answer is ready.
- Memory is plain text files on your disk, which you can open and correct.
- Pairing, tool rules and command approvals decide what the assistant may do, and the default lets it run commands on its host.

## Steps

1. Picture one Gateway: it links your chat apps, your files and an AI model.
2. Follow one message through the loop, from your phone to the reply.
3. Check the three controls: who may write, which tools, which approvals.

## What are the main parts of OpenClaw?

Think of a small office. The Gateway is the reception, the model is the brain you hire, the tools are its hands, and the workspace is its desk.

- Gateway: one program that stays on, at port 18789 of your machine. There is one per host.
- Channels: WhatsApp, Telegram, Slack, Discord, Signal, iMessage and others. The Gateway is the only part that connects to them.
- Clients: the web dashboard, the terminal and the Mac app. They connect to the Gateway so you can talk and change settings.
- Nodes: phones or computers that lend an ability, such as the camera, a screen recording or the location.
- Agent: the assistant itself, which uses an AI model and tools.
- Workspace: a folder with its instructions, memory and skills.


## What happens when you send a message?

This is called the agent loop. It is the same for a chat message and for a scheduled task.

1. Intake: the Gateway receives the message and checks that the sender is allowed.
2. Session: it finds the conversation this message belongs to.
3. Context: it prepares what the model reads, with instructions, memory, available tools and recent messages.
4. Model: the AI reads all of it and decides to answer or to use a tool.
5. Tools: OpenClaw runs the tool and gives the result back to the model. This can repeat many times.
6. Reply: the answer is sent to the same channel.
7. Save: the conversation and the results are stored on your machine.

Tip: Runs in one conversation go one at a time. A message you send while it works is normally added to the current task, so you can correct it on the way. Send /stop to end it.


## What does the model read each time?

OpenClaw writes the system prompt (the instructions the model gets before your message) for every run. It lists the tools, the skills and the workspace files.

The files are short and in plain text. AGENTS.md holds the working rules. SOUL.md holds the tone and limits. USER.md describes you. IDENTITY.md holds its name. By default each file is cut at 20,000 characters, and all of them together at 60,000.

This is why a good setup costs little. A clear page of rules in AGENTS.md does more than a long speech repeated in each chat.

Tip: Send /context to see how the context is built, and how much room each part takes.


## How does OpenClaw remember things?

Memory is Markdown (plain text with simple marks) on your disk. The docs say the model has no hidden state. If you ask it to remember something, it writes a note in a file.

- MEMORY.md: facts and decisions to keep. It loads in your private conversation and not in groups.
- memory/ with a date: the detailed notes of each day.
- USER.md: your stable preferences.
- Search: the assistant can search its notes by words, and by meaning once a search provider is set.
- Dreaming: a scheduled pass that moves useful short-term notes into MEMORY.md. It is on by default.


## What are sessions, tools, skills and plugins?

A session is one conversation. By default, all your private chats share one session, each group has its own, and each scheduled run starts fresh. If several people write to the assistant, separate their sessions with the dmScope setting, or they will share context.

The other three words are easy to mix up.

- Tool: an action the agent can take, such as reading a file, running a command, searching the web, using the browser or sending a message.
- Skill: a text file that teaches a method. It adds no new power by itself.
- Plugin: an add-on that brings new tools, channels or model providers.
- MCP server: an outside service connected through a shared standard. For example, ColdIQ’s MCP server brings company and contact data from 40+ providers into an assistant.
- Subagent: a helper that the agent starts for a part of the work.


## What keeps it under control?

Three gates matter, and you set each one.

The first is who may write: pairing for strangers, and lists of allowed people for groups. The second is which tools the agent has. The third is command approval, with the modes deny, allowlist, ask, auto and full.

Know the default. On the host machine, command execution is set to full with no question asked, unless you tighten it. When two rules conflict, OpenClaw applies the stricter one. The workspace is also a starting folder and not a locked room: files elsewhere on the machine can be reached unless you turn on sandboxing (a closed environment).

Tip: For a business, start with ask mode, a separate user account or machine, and one channel that only you can use.


## What does this design mean in practice?

The Gateway must run for the assistant to answer. A laptop that sleeps is an assistant that sleeps, which is why people use a small computer or a rented server.

Your data lives in ~/.openclaw on that machine: settings, conversations, credentials and workspace. Back up the workspace in a private place, and never store passwords in it.

Your messages still go to the model provider you chose, unless the model is local. “It runs on my machine” is true for OpenClaw and not for a cloud model.


## What to say

> Explain how you are set up right now, in plain words: which chat channels are connected, which model answers, which tools you may use, where your memory files are, and which actions need my approval. Do not change anything.

## Sources

- [OpenClaw docs: architecture](https://docs.openclaw.ai/concepts/architecture)
- [OpenClaw docs: agent loop](https://docs.openclaw.ai/concepts/agent-loop)
- [OpenClaw docs: system prompt](https://docs.openclaw.ai/concepts/system-prompt)
- [OpenClaw docs: agent workspace](https://docs.openclaw.ai/concepts/agent-workspace)
- [OpenClaw docs: memory](https://docs.openclaw.ai/concepts/memory)
- [OpenClaw docs: sessions](https://docs.openclaw.ai/concepts/session)
- [OpenClaw docs: queue](https://docs.openclaw.ai/concepts/queue)
- [OpenClaw docs: tools](https://docs.openclaw.ai/tools)
- [OpenClaw docs: exec approvals](https://docs.openclaw.ai/tools/exec-approvals)
- [OpenClaw docs: Gateway](https://docs.openclaw.ai/gateway)

## Questions

**What is the OpenClaw Gateway?** The always-on program at the center. It holds the chat connections, the sessions and the dashboard, on port 18789 by default.

**Does OpenClaw include an AI model?** No. You connect a provider such as Anthropic or OpenAI, or a local model.

**Where does OpenClaw store my data?** In the ~/.openclaw folder of the machine that runs it. The workspace is ~/.openclaw/workspace by default.

**Can I run several agents?** Yes. One Gateway can hold several agents, each with its own workspace and settings.

**Is OpenClaw a chatbot or an agent?** An agent. It answers in chat, and it can use tools to read, write, search, run commands and send messages.


## Related

- [What is OpenClaw?](https://coldiq.com/university/openclaw/what-is-openclaw)
- [What happened to the OpenClaw heartbeat, and how do scheduled tasks work now?](https://coldiq.com/university/openclaw/openclaw-heartbeat)

## Try ColdIQ free

ColdIQ gives new accounts up to 1,450 free credits as they get started, no credit card required.
One subscription covers 40+ B2B data providers for finding, enriching and verifying
contacts and companies, through the web app, the API or the MCP server for AI agents.

1. Create an account: https://coldiq.com/marketplace/sign-up?utm_source=ai-assistant&utm_medium=markdown&utm_content=university
2. Run a first search on your own market with the free credits.
3. Connect the MCP server to Claude, ChatGPT or Cursor: https://coldiq.com/mcp
