Running OpenClaw

A practical operator's guide to installing, configuring, and living with a multi-agent system. From first install to troubleshooting corrupted sessions at 2am.

openclaw agents ~18 min read
Contents
  1. 1.What is OpenClaw
  2. 2.Prerequisites
  3. 3.Install
  4. 4.Config anatomy
  5. 5.Agent file architecture
  6. 6.Your first agent
  7. 7.Model providers
  8. 8.Model tiers
  9. 9.Plugins
  10. 10.Daily workflows
  11. 11.Troubleshooting
  12. 12.Using Claude Code as admin
  13. 13.Rules & pitfalls

1. What is OpenClaw #

OpenClaw is a multi-agent orchestration framework. You define agents as a set of plain Markdown files that describe personality, rules, and behavior. A gateway process routes messages between agents, LLM providers, and channels like Telegram or a local control UI. Every agent is a set of files on disk — not a hosted service, not a SaaS lock-in.

It's a sharp tool. You get real control and low overhead, but you also get a single openclaw.json config that can break the whole system if mishandled. This guide exists because most of the friction is in knowing which file to edit, when to restart, and why a 404 just showed up.

Mental model Think of an agent as (persona files in a workspace) + (runtime config in an agent dir) + (a slot in the global config). The gateway stitches these together and pipes them to the LLM and channels.

2. Prerequisites #

3. Install #

# install OpenClaw globally
npm install -g openclaw

# initialize a default config in ~/.openclaw/
openclaw init

# start the gateway
openclaw gateway

On first start, OpenClaw writes ~/.openclaw/openclaw.json and scaffolds empty directories for agents, sessions, and extensions. The gateway binds to a local port (default 18789) and is ready to accept channel and UI connections.

Protect your config Tools like openclaw doctor --fix will silently remove unknown keys. Once your config is tuned, set the macOS immutable flag: chflags uchg ~/.openclaw/openclaw.json. On Linux, use chattr +i. Unlock before editing, re-lock after.

4. Config anatomy #

Everything the gateway needs is in a single JSON file. Here's the map:

Top-level keyWhat it does
agents.listArray of agent definitions: id, workspace path, model routing, channel membership
agents.defaultsFallback values applied to each agent unless overridden
models.providersLLM providers (anthropic, ollama, openai-compatible) with baseUrl, apiKey, api format
plugins.entriesMap of plugin id → {enabled, source, version}
channels.telegramTelegram bot tokens and per-agent bindings
controlUiGateway bind mode (localhost / lan / tailnet), allowed origins, token
cronScheduled heartbeats — each job references an agentId

Safe edit workflow

# unlock
chflags nouchg ~/.openclaw/openclaw.json

# edit — jq, a text editor, or scripted edits
vim ~/.openclaw/openclaw.json

# re-lock
chflags uchg ~/.openclaw/openclaw.json

# restart gateway to apply config changes
openclaw gateway stop && openclaw gateway
Never run openclaw doctor with the config unlocked It will silently rewrite your file, dropping keys it doesn't recognize and flattening custom overrides. Always diff against a known-good backup before accepting doctor's changes.

5. Agent file architecture #

Every agent has files in two locations with very different purposes. Confusing them is the #1 reason new users can't figure out why a persona change doesn't stick.

Workspace root — the agent's identity and rules

These files are injected into LLM context on every turn. They are plain Markdown. Edit them with any text editor — no restart needed; changes take effect on the next turn.

FilePurposeWhen to edit
SOUL.mdPersona, personality, tone, values, boundariesChanging who the agent is
AGENTS.mdOperating rules, SOPs, workflows, tool usageChanging what the agent does
IDENTITY.mdDisplay name, emoji, short descriptionChanging display identity
USER.mdInfo about the human ownerUpdating user context
MEMORY.mdCurated long-term memoriesAgent self-manages
HEARTBEAT.mdCron / proactive behavior rulesChanging proactive behavior
TOOLS.mdLearned tool patternsAgent self-manages
SOCIAL-RULES.mdGroup chat behaviorChanging social interaction rules
Rule of thumb SOUL.md is identity. AGENTS.md is operations. A behavioral SOP like "always use the vault_write tool for knowledge docs" belongs in AGENTS.md, not SOUL.md. Keep them separate or you'll end up rewriting both to fix one rule.

Agent dir — runtime config (not injected)

Located at ~/.openclaw/agents/<agent-id>/agent/. Managed by the gateway; rarely edited by hand.

FilePurpose
models.jsonPer-agent model provider override (beyond openclaw.json)
auth-profiles.jsonAPI keys, auth tokens, usage stats
auth.jsonAdditional auth config (some agents only)
Gotcha: stray CLAUDE.md A leftover CLAUDE.md in an agent dir is not read by OpenClaw. Only workspace-root Markdown files are injected. If you want context in the agent's prompt, put it in the workspace, not in ~/.openclaw/agents/<id>/agent/.

Change propagation

What changedTakes effectRestart needed?
Workspace Markdown (SOUL, AGENTS, etc.)Next turnNo
~/.openclaw/openclaw.jsonGateway startupYes
Plugin code (TypeScript)Gateway startupYes
Agent-dir models.jsonNext turnNo

6. Your first agent #

The shortest path from nothing to a working agent.

Step 1 — create a workspace directory

mkdir -p ~/clawd-example
cd ~/clawd-example

Step 2 — write the persona

Create SOUL.md:

# You are Example

You are a focused, direct assistant. You prefer terse,
concrete answers over long explanations. You flag uncertainty
instead of guessing. You have a mild aversion to emojis.

## Values
- Clarity over politeness
- Short answers unless depth is requested
- Never fabricate file paths, commands, or API shapes

Step 3 — write operating rules

Create AGENTS.md. This is where you tell the agent where to get context — without these rules, it will hallucinate file paths or write notes nobody can find.

# Operating Rules

## Context & Vault Access

Before answering or acting, search the vault for relevant context.
Tools (provided by the vault-obsidian plugin):

- `vault_context` — quick-reference files from `10-AI-Context/`.
  **Check this first** for any lookup — it's fact-dense and cheap.
- `vault_search "keyword"` — keyword search across all notes.
- `vault_read "path/to/note.md"` — read a specific note.
- `vault_list "folder"` — browse a folder by recency.
- `vault_structure` — show the vault folder layout.

Rules:
- Search before reading — don't dump whole folders.
- Max 3-5 notes per turn unless the user says otherwise.
- Never fabricate paths. If `vault_read` fails, the file doesn't exist.
- If information isn't in the vault, say so explicitly.

## Writing to the Vault

Use `vault_write` for any knowledge the user should find later:
decisions, research notes, meeting minutes, project updates.

- Never write knowledge docs to the agent workspace
  (`~/clawd-example/`) — the user will never find them there.
- Follow the vault's note conventions (frontmatter, headings, tags).
- Always include backlinks to related notes.

## Tool Usage

- If a tool fails twice, stop and report — don't retry blindly.
- If a tool is missing, say so; don't simulate its output.

## Response Format

- Default to 3-5 sentences.
- Use bullet lists for anything enumerable.
- Wrap shell commands in fenced code blocks.
Why this matters The vault-obsidian plugin gives every agent native vault tools. But the agent won't use them unless you tell it to — in AGENTS.md. Without the "Context & Vault Access" section, the agent makes up file paths, forgets what's in the vault, or writes "notes" to its own workspace directory where no human will ever see them.

Step 4 — register the agent in openclaw.json

Unlock the config and add an entry to agents.list:

{
  "id": "example",
  "workspace": "~/clawd-example",
  "model": {
    "primary": "ollama/glm-5.1:cloud",
    "fallbacks": ["anthropic/claude-sonnet-4-6"]
  },
  "channels": []
}

Re-lock the config and restart the gateway. Send the agent a message via the control UI — or attach a Telegram bot token via channels.telegram and message it from your phone.

7. Model providers #

Providers live in models.providers. The two most common:

Ollama cloud

"ollama": {
  "baseUrl": "https://ollama.com",
  "apiKey": "<your ollama key>",
  "api": "ollama"
}

Cloud-tagged models use the :cloud suffix. Use full tags — for example gemma4:31b-cloud, not gemma4:cloud. Shorthand tags that don't exist will appear to work at startup but fail at first request.

Anthropic

"anthropic": {
  "baseUrl": "https://api.anthropic.com",
  "apiKey": "<your anthropic key>",
  "api": "anthropic-messages"
}

OpenAI-compatible endpoints

Any endpoint that speaks the OpenAI /v1/chat/completions shape can be registered as a provider. Useful for local inference servers (vLLM, LM Studio) or third-party gateways.

"local-llm": {
  "baseUrl": "http://localhost:8000",
  "apiKey": "<key or placeholder>",
  "api": "openai-completions"
}
Match api to the endpoint shape api must match what the server actually speaks. anthropic-messages for Anthropic's API, openai-completions for OpenAI-shaped endpoints, ollama for Ollama. A mismatch produces HTTP 404 on every turn — the single most common setup bug.

8. Model tiers #

A workable default: assign different primaries by agent role, with graceful fallback chains.

TierAgent rolePrimaryFallback chain
HeavyCoding, infra, data analysis, reasoningLarge reasoning modelmid-tier open → Anthropic Opus
GeneralCommunication, strategy, user-facing chatBalanced chat modellarge → mid → Anthropic Sonnet
CreativeContent, marketing, brand, socialStrong instruction-following creative modelbalanced → mid → Anthropic Sonnet
HeartbeatsAll agents, for cron-driven background turnsCheap fast model(none; skip if unavailable)

Pick primaries you can afford to hit thousands of times per day. Reserve Anthropic for the last slot in each chain so you don't burn quota on routine turns.

9. Plugins #

Plugins live in ~/.openclaw/extensions/ and are toggled in plugins.entries. Common ones:

PluginPurpose
vault-obsidianNine tools for scoped Obsidian vault read/write. See the deep-dive below.
memory-lancedbVector memory backed by LanceDB + nomic-embed-text
telegramPer-agent Telegram bot channel
openclaw-web-searchWeb search tool (provider-pluggable)
acpxAgent-to-agent communication protocol
aight-utilsMisc utility tools (date, math, string helpers)
vault-obsidian: the killer plugin Without vault_write, agents that want to persist knowledge fall back to writing files in their own workspace directory. The result is "notes" scattered across ~/clawd-<agent>/ that no human ever reads. Enable vault-obsidian, point it at your real vault, and instruct agents (in AGENTS.md) to use vault_write for anything they expect a human to see.

The nine vault-obsidian tools

Agents that write to a knowledge vault all the time end up with three recurring problems: they blow their context window reading whole files when they only need one section, they overwrite notes that had content worth preserving, and they file things in the wrong folder. The plugin's tool set is designed around those three failure modes.

ToolWhen to use
vault_searchKeyword search across the vault. Returns line-numbered snippets around each match (not full files). On zero results, auto-retries with a looser OR-match across query terms and suggests folder scopes. Pass full:true only when you genuinely need the whole file.
vault_outlineReturns just the heading hierarchy of a note with line numbers. Cheap recon. Call this before vault_read on a long note to decide which section to fetch.
vault_readRead a note. Supports section:"## 3. Results" (case-insensitive, partial match) and lines:"100-150" modes so you can pull one slice instead of the whole file. Hard max_chars cap prevents runaway reads.
vault_frontmatterReturn only the YAML frontmatter of a note. Use when you need to check status, tags, or updated without loading the body.
vault_listList notes in a folder sorted by recency. Discovery before read.
vault_contextPull a quick-reference file from 09-AI-Context/. Small, fact-dense. Check here before doing a full search.
vault_structureReturn the vault folder layout with filing-rule reminders. Call when unsure where to write.
vault_writeCreate a new note. Warns on missing frontmatter (auto-injects a minimal block), missing wikilinks on >400-char notes, or writes to an unknown top-level folder. Tool description embeds the filing decision tree.
vault_upsertSafe update of an existing note. Modes: append (adds content under a dated ## Updates YYYY-MM-DD section, preserves everything above), replace (full overwrite), diff (preview the change without writing). Prefer this over vault_write when the file might already exist.
The context-efficient read pattern Teach your agents one workflow: vault_search to find candidate files → vault_outline to see the structure → vault_read with section: to fetch the one part that matters. In practice this cuts tokens per vault lookup by 5x or more versus "search then read full file". The tool descriptions nudge agents toward this pattern, but you get the most mileage by repeating it in AGENTS.md.
Filing decision tree in the tool description The vault_write description ships with a one-paragraph filing rule: colocate with the subject, not by note-type. A project research note goes under 02-Projects/<Project>/, hardware troubleshooting goes under 05-Infrastructure/, a person under 03-People/. Reserve a generic Reference/ folder for genuinely cross-cutting material only. Every agent sees this hint every time it considers writing, which prevents the most common filing mistake: dumping project research in a generic bucket that no one ever reads.

Plugin code changes require a gateway restart. They are not hot-reloaded.

10. Daily workflows #

Check status

pgrep -fl openclaw | grep -v "Chrome\|node"
# expected: openclaw, openclaw-gateway, openclaw-tui

Edit agent instructions

Instructions are plain Markdown in the workspace root. No unlock. No restart. Changes take effect on the agent's next turn.

vim ~/clawd-example/AGENTS.md

Propagate a rule to all agents

When you add a rule that applies to all agents (for example: "always use vault_write for knowledge docs"), add it to the appropriate section of each agent's AGENTS.md. Don't blindly append — each agent's AGENTS.md usually has a tailored structure.

Restart the gateway cleanly

openclaw gateway stop
# give it a beat to release lock files
sleep 2
openclaw gateway

A robust wrapper script — call it openclaw-restart — should:

  1. Stop the gateway.
  2. Kill any leftover openclaw processes.
  3. Delete stale *.jsonl.lock files in session directories.
  4. Detect corrupted sessions (consecutive user turns, "stopReason": "error") and archive them.
  5. Start the gateway.
  6. Verify gateway + proxy + bot connections. Report pass/warn/fail.

Switch a model for a single agent

Use the safe edit workflow. In agents.list, find the agent by id and update model.primary. Use the provider-prefixed form: anthropic/<id> or ollama/<id>.

Open the control UI

openclaw dashboard --no-open   # prints the URL

The URL uses a hash fragment for the token — http://127.0.0.1:18789/#token=<TOKEN>, not a query string. Hash fragments aren't sent to the server, which keeps the token out of access logs.

The controlUi.allowedOrigins list must include every origin you'll connect from — including any Tailscale IPs if you access the UI remotely.

Mobile app pairing

The official mobile app connects via Settings → Manual Host, not QR scan. After the WebSocket is established, the app requests device pairing. Approve it on the host:

openclaw devices list
openclaw devices approve <requestId>

Pending pairing requests expire after 5 minutes. Gateway token + device pairing form a two-layer auth model.

Cron jobs

Cron jobs live in ~/.openclaw/cron/jobs.json. Reference agents by their id from agents.list, not by Telegram handle. Mixing those up silently breaks the job.

11. Troubleshooting #

Agent receives messages but never replies

Symptom: the typing indicator appears on Telegram but no response arrives. Logs show Removed orphaned user message to prevent consecutive user turns or typing TTL reached.

Cause: the session journal has consecutive user turns — usually from a proxy outage that wrote an empty or error-stop assistant message, corrupting the conversation state.

Fix:

# identify the session
openclaw logs --max-bytes 50000 2>&1 | grep "orphan" | grep -o 'sessionId=[^ ]*'

# delete session + its lock
rm ~/.openclaw/agents/<agent>/sessions/<session-id>.jsonl.lock
rm ~/.openclaw/agents/<agent>/sessions/<session-id>.jsonl

# restart
openclaw gateway stop && openclaw gateway

This clears the conversation history with that channel; a fresh session starts on the next inbound message.

404 not_found_error on every turn

The api field of a provider doesn't match the endpoint shape it's pointing at. Inspect the config:

jq '.models.providers' ~/.openclaw/openclaw.json

Verify each provider's api matches its baseUrl: anthropic-messages for Anthropic, openai-completions for OpenAI-shaped endpoints, ollama for Ollama.

Config won't load after editing

The gateway refuses to start and logs a schema error. Most common offenders:

Known crash: network interface flapping

Symptom: gateway dies with AssertionError: Reached illegal state! IPv4 address changed from undefined to defined.

Cause: a USB ethernet adapter or mobile hotspot briefly loses IPv4; the embedded mDNS library crashes on the undefined→defined transition.

Fix: restart the gateway. A good openclaw-restart wrapper handles this cleanly. If it recurs hourly, pin the adapter (disable USB power management) or switch to Wi-Fi.

12. Using Claude Code as admin #

Claude Code — the CLI — is a good fit for OpenClaw admin because most of the work is file editing, config diffing, and log tailing. A few patterns pay back fast:

Write a skill for OpenClaw operations

Claude Code's skills feature lets you package common OpenClaw tasks into an invokable capability: status checks, config edits with unlock/relock, restart workflows, session cleanup. One skill means every conversation that touches OpenClaw inherits the same safety rails.

A skill file should document:

Ask the CLI to do full workflows

Instead of editing files manually, describe the intent: "add a rule to every core agent's AGENTS.md that says to use vault_write for knowledge docs, restart the gateway, and verify the restart succeeded." Claude Code walks the roster, makes the edits, runs the restart script, and reports pass/fail against each step.

Diff before you restart

Before re-locking the config, ask the CLI to show the diff against a known-good backup. A 3-line change in openclaw.json can accidentally delete a whole providers block if jq output is pasted wrong. Diffs surface that before you restart the gateway into a broken state.

13. Rules & pitfalls #

The operator's mindset Most OpenClaw pain comes from editing the wrong file or restarting at the wrong moment. Internalize "workspace Markdown = next turn, openclaw.json = gateway restart, plugin code = gateway restart, models.json = next turn" and 80% of surprises disappear.