SSD Nodes Learn Hosting plans →
How to do am Matt ConnorBy Matt Connor · Updated 2026-08-28

How to Build Your Own OpenClaw AI Agent

Learn how to build a self-hosted AI agent like OpenClaw, piece by piece, and why hardening matters after 9 security flaws surfaced in 4 days.

Wetín OpenClaw really be

OpenClaw na personal AI agent wey you self-host. You run am for your own server, connect am to the chat apps wey you already dey use, and e fit run shell commands, control browser, read and write your files, and act on the messages wey you send am. MIT license cover am, e dey local-first, and e get more than 380,000 GitHub stars as of middle of 2026. This make am one of the projects wey get the most stars for the platform. Under all the noise, na fairly small set of parts wey dem wire together in sensible way. This post go explain those parts so you go understand how tool like this dey built, and where the dangerous edges dey.

Make I give you one warning first, because e affect every design choice wey follow. For March 2026, dem disclose nine security issues for OpenClaw within four days. One of dem na critical privilege-escalation flaw wey get rating of 9.9 out of 10 (CVE-2026-32922). The project expect say you, the operator, go harden am. Agent wey fit run any command only dey as safe as the box wey e dey run on and the limits wey you put around am. Remember this as you dey read.

The gateway daemon: one process, keep am private

For the center na one process wey dey run continuously, and dem usually dey call am gateway. Na the control plane be this. E dey receive messages, decide wetin to do, run the tools, then send replies back. Everything else dey connect to am.

The most important thing about the gateway na where e dey listen. By default, OpenClaw dey bind am to the loopback address, 127.0.0.1, so internet no fit reach am unless you deliberately expose am. Leave am there. Na this single process dey run commands, so if you expose the gateway, anybody wey find am fit get remote foothold into your server. When you need reach am from your laptop, use VPN or SSH tunnel instead of opening a port. Nobody fit attack port wey dem no fit reach.

Channel connectors: message go in, reply go out

Personal agent go only useful if you fit talk to am through the apps wey you already dey use. Na channel connectors dey make this possible. Each one dey connect to one platform, like Telegram, WhatsApp, Slack, or Discord, through the platform bot API or webhooks.

The process dey almost the same for all of dem. The connector registers bot with the platform. E receives your incoming message, either by polling the platform or by receiving webhook wey the platform push give am. Then e hands the message to the gateway and posts the gateway reply back through the same API. Connector na thin translation layer. E converts "Telegram message don arrive" to "here be text for the agent", then converts the reply back again. If you wan build your own, mostly na to read one platform bot documentation and map the platform message format to the gateway format.

The brain and the tool loop

Inside the gateway dey the part wey make am be agent instead of chatbot. Na loop be this.

Message go arrive. Gateway go send am to language model together with list of tools wey model get permission to use. Model go read the message and decide: e go answer directly, or e go call tool. If e call tool, gateway go run the tool, collect the result, then send the result back to model. Model go check the result and decide again. This go repeat until model no get anything else to do and e produce final reply.

Na this loop be the main idea behind agent, and na the same loop whether the agent dey inside chat app or terminal. To see how tools dey connect to this loop for standard way, connect tools through the Model Context Protocol na good next read. For the model side, run the model itself for your own hardware go complete the other half.

Na tools be the main thing, and na dem still carry the danger

Na tools dey make OpenClaw powerful. One tool fit run shell command, another fit control browser, and another fit read and write files. If you give the loop above access to these tools, e fit do almost anything wey you fit do with keyboard. Na this reach be the whole product, and na also the whole risk.

Agent wey fit run any command based on instruction wey come from chat app get large attack surface. Bad instruction, prompt-injection attack wey hide inside web page wey browser tool visit, or bug like the March 2026 flaws fit change "read my calendar" to "delete my files." So these limits no be optional extras. Run the agent as dedicated, unprivileged user wey no get sudo, so compromise no go escalate. Put dangerous tools behind approval step, so agent go ask before e do anything destructive. Sandbox tool execution, so runaway command go remain contained. Isolate model's API key, so leak no go hand attacker your account.

Before you expose anything wey dey run shell commands, go through the basic steps carefully. Generate checklist for your own box here, then follow am from top to bottom:

ToolVPS hardening checklist

The unprivileged-user part dey explained well for running services as unprivileged user, and the complete safe-setup walkthrough for the real project dey for running OpenClaw safely on VPS.

Memory as plain files

Most people expect say agent memory go dey inside database. OpenClaw own no be like that. E dey store memory as plain Markdown files for disk, and that choice worth copying.

Files simple. No schema to migrate, no service to keep running, and no query language to learn. You fit inspect dem: open the folder and read exactly wetin agent believe about you, correct wrong note by editing file, or delete memory by removing the file. Dem portable too, because moving agent go new server na just to copy one directory. For one-user personal agent, folder wey get text files dey enough, and e keep the whole system easy to understand.

Skills: portable tare wey you fit use add abilities

Apart from the tools wey dey inside am, OpenClaw dey use portable skill format so community fit extend wetin e fit do without changing the core. Skill na self-contained bundle of instructions and, sometimes, code wey dey teach the agent new task. Agent go load skill when task need am. Web search na the common first skill wey people dey add, and pointing that skill to your own SearXNG instance go keep your queries away from commercial search API. E also make am clear where the skill trust boundary dey, because everything wey e return na text wey stranger write.

The value of format like this na say abilities fit dey shared. Person fit write skill for specific job, publish am, and other people fit drop am in. If you build your own agent, defining small, clear extension format early go save you from hard-coding every capability inside the core later.

Bring your own model

OpenClaw no dey depend on any particular model. E no release im own language model. Instead, e dey connect to the one wey you choose, wey fit be hosted API or model wey you dey run by yourself.

This separation matter for cost, privacy, and control. Hosted API go give you the strongest models without hardware wey you need manage, but you go pay per token and your prompts go leave your server. Self-hosted model, wey you serve with something like Ollama, keep every message for your own box and cost only hardware and power. But you go need manage smaller or slower model. Plenty people dey use both options. If you want keep agent fully private, self-hosting the model for your VPS na the part wey close the last gap, and Hermes Agent na another self-hosted agent wey worth comparing with.

You go build one?

You fit build all of this. The parts no be exotic: one daemon, some chat connectors, one model-and-tools loop, one folder of Markdown, and one plugin format. To understand dem dey useful well, because e remove mystery from every agent wey you go use, and e show you exactly where the danger dey.

But for most people, the honest answer na to run the real thing and harden am instead of rebuilding am from scratch. OpenClaw don already solve the connectors, the loop, and the skill format, and e don pass through real security review. Your effort better go the part wey na your own responsibility to get right: the setup and hardening for your own server. If you really want use the learning route first, work through the concepts step by step better pass reading agent source code cold, because every stage go leave you with one thing wey you don actually build. Build small one to learn. Run and lock down the real one to use.

The general foundations dey for building your own AI agent on a VPS, and building an agent with Claude show the same ideas with one specific model as the brain.

FAQ

E hard to build agent like OpenClaw?

The individual parts no hard. A gateway process, chat connector, model-and-tools loop, and folder of files each dey straightforward on their own. The hard part na to do am safely. Agent wey dey run shell commands from chat messages na serious security surface, and to set sandboxing, permissions, and unprivileged-user setup correctly na more work than to connect the features together.

Why OpenClaw dey store memory as Markdown files instead of database?

Because for single-user personal agent, files dey enough and much simpler. No database service dey to run, memory easy to read and correct by hand, and moving the agent go another server na just to copy one directory. Database dey make sense for larger scale, but no be for here.

Which part of personal AI agent dey most dangerous?

Na the tools wey let am act: running shell commands, controlling browser, and writing files. Na those things be the reason to build am and the reason e fit harm you. OpenClaw's March 2026 security event, nine issues for four days including one 9.9-rated critical issue, na the clearest reason to handle the tool layer carefully: run am as unprivileged user, gate destructive actions, and sandbox execution.

I need my own language model to build one?

No. Agents like OpenClaw dey model-agnostic, so you connect the one wey you choose. E fit be hosted API for the strongest models, or model wey you run by yourself for full privacy. Self-hosting with Ollama keep every message for your own server, but you go need run smaller model.