← back
00 · opening
Last updated May 29, 2026

The Agent Harness.

Two programs that turn a language model into an agent. We know how Claude Code works because people reverse-engineered it. We know how OpenClaw works because its code is open.

CLAUDE CODE closed · in your terminal one loop, one task MODEL used by both OPENCLAW open · in your chats always-on daemon · same model, two harnesses ·
A model on its own only reads text and writes text back. A harness is the program around it. It gives the model its instructions and history, runs the tools the model asks for, and keeps the loop going. Here are two harnesses, taken apart side by side.
scroll
01 · the loop

Claude Code runs one loop per task. OpenClaw runs one loop that never stops.

Every agent needs a loop: the model asks for a tool, the harness runs it, and the result goes back to the model. Claude Code starts a fresh loop for each task and ends it when the model replies with end_turn. OpenClaw runs a single daemon that stays up for days and wakes whenever a message arrives. Step through the same five steps for both harnesses and see where they differ.

turn cycle
01 INPUT arrives 02 MODEL decides 03 TOOL executes 04 RESULT injected 05 NEXT step · loop until stop · END_TURN
01 / input arrives
Something wakes the agent.
Pick a harness and step through the cycle.
in essence
# Claude Code: one ephemeral loop per task
def run_task(prompt):
    messages = [user(prompt)]
    while True:
        reply = model(messages)           # think
        messages.append(reply)
        if not reply.tool_calls:          # text only -> done
            return reply                  # stop_reason: "end_turn"
        for call in reply.tool_calls:     # act
            messages.append(run_tool(call))  # observe, then repeat
# OpenClaw: one daemon, never sleeps
while True:                     # the Gateway
    event = inbox.get()        # a message, cron tick, or webhook
    agent = route(event)       # pick the per-channel agent
    agent.handle(event)        # runs its own loop, then waits
the contrast: Claude Code runs one ephemeral loop per task in your terminal. It is a ReAct while-loop: think, call a tool, read the result, repeat. In the reverse-engineered source that loop is nO, an async generator, and it stops when the model replies with end_turn. OpenClaw is a persistent Gateway daemon. This one background process takes in many chats at once, sends each chat to a session run by the right agent, and keeps running until you stop it.
02 · context & memory

Claude Code shrinks its history to fit. OpenClaw writes its memory to disk.

Claude Code works inside a fixed window: the model can only see so many tokens at once. Before each model call it tries five compaction steps, called shapers, cheapest first, and stops as soon as the history fits. There is no single fill level that sets this off, and writing a summary is the last resort. OpenClaw mostly avoids the problem, because its memory lives on disk as plain Markdown and YAML files that last longer than any one session.

claude code · staged compaction (cheapest first)
used 128,000 / 200,000 tok healthy
system claude.md user model tool result summary
A full window, before any shaping. The system prompt and CLAUDE.md are pinned, so no stage removes them. Press run next shaper to apply the stages one at a time, cheapest first.
in essence
# Claude Code: shrink history cheapest-first, stop once it fits
SHAPERS = [budget_reduction, snip, microcompact,
           context_collapse, auto_compact]

def fit(messages, limit):
    for shape in SHAPERS:
        if tokens(messages) <= limit:
            break              # fits now, stop early
        messages = shape(messages)
    return messages
the contrast: Claude Code shrinks its history in stages: Budget Reduction, Snip, Microcompact, Context Collapse (which folds content when it is read and deletes nothing), and finally Auto-Compact, where a model writes a summary as the last resort. All of this keeps one long task inside an ephemeral window that disappears when the session ends. OpenClaw keeps durable memory on disk at ~/.openclaw/workspace, and it lasts across days and channels. The same folder holds prompt files like AGENTS.md and SOUL.md.
03 · tools & skills

Both use one skill format. Claude Code's tools work on code. OpenClaw's work on your life.

Both harnesses package skills the same way: a SKILL.md file with a YAML header (frontmatter), loaded by progressive disclosure. Both use MCP to plug in any other tool. The difference is what the tools act on. Claude Code's tools work on a codebase. OpenClaw's tools work on the rest of your life: your browser, your schedule, your chat apps. OpenClaw can also install skills from a public marketplace.

claude code · built-ins
openclaw · first-class tools
the contrast: Both use SKILL.md files and MCP. Claude Code's tools work on a codebase (Read, Edit, Bash, Grep), and its skills can be set at four scopes: enterprise, personal, project, or plugin. OpenClaw's tools work on your life (browser, canvas, cron, Discord, Slack), and it installs skills from the ClawHub registry at clawhub.ai. Be careful there: an audit found that roughly 26% of 31,000+ community skills had at least one vulnerability.
04 · subagents

Claude Code's subagents are short-lived helpers. OpenClaw's agents run side by side for days.

Claude Code starts a subagent in a fresh, separate context window, lets it do the work that uses up lots of tokens, and keeps only its summary. That way the main conversation does not fill up. OpenClaw runs many agents at once, one per channel or per peer (the person or group on the other end). Each one is long-lived and sandboxed. Press spawn to watch Claude Code's version.

claude code · isolated context
main conversation
3 lines · 4.5k tokens
task
summary
subagent · explore
idle
The subagent reads, searches, and reasons in its own window. Only its summary comes back to the main conversation. Reverse-engineered analyses of the source also describe an async message queue (h2A).
the contrast: Claude Code spawns short-lived subagents through the Task/Agent tool so the main conversation's context stays small. Each one runs in its own window with its own separate permissions, and only its summary comes back. OpenClaw runs many long-lived agents, one per channel or peer. Each has its own workspace and can optionally be sandboxed (Docker by default, or SSH and OpenShell backends) with per-tool allowlists.
05 · hooks vs triggers

Claude Code's hooks react to events inside a session. OpenClaw's triggers come from outside.

Claude Code's hooks are shell commands you attach to named events in a single session, such as the moment before a tool runs. They run every time their event happens, whatever the model wants. OpenClaw's triggers come from the outside world and wake the agent up: a cron schedule, a webhook, or a new message.

CLAUDE CODE · LIFECYCLE HOOKS

Fire inside one session.

where
the hooks key in settings.json, reloaded as soon as the file changes
events
SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop, plus SubagentStart/Stop, SessionEnd, PermissionRequest, and more
can block
a PreToolUse hook can return allow, deny, or ask. Or it can exit with code 2, which blocks the call and sends the hook's stderr back to the model
trigger
the session's own lifecycle
OPENCLAW · PROACTIVE TRIGGERS

Wake the agent from outside.

cron
scheduled jobs (maxConcurrentRuns default 8, sessionRetention default '24h')
webhooks
authenticated, set under hooks, default path /hooks; Gmail Pub/Sub works too
heartbeat
each agent wakes itself, by default every '30m' (0m turns it off)
channels
are where messages come in and replies go out. A new message wakes the agent, and the reply goes back the same way
the contrast: Claude Code's hooks run at set points inside one session. OpenClaw's triggers wake the agent from the outside: cron, webhooks, heartbeats, and the channels themselves. OpenClaw is always running, waiting for any of them.
06 · permissions & sandboxing

Claude Code checks every tool call. OpenClaw checks who is allowed to talk to it.

Before a tool call runs, Claude Code checks it against your rules. In auto mode, a separate classifier model checks it too. OpenClaw starts one step earlier. It first decides who is allowed to talk to it at all, then puts everyone who is not you in a sandbox.

CLAUDE CODE · RULES + CLASSIFIER

Check the tool call.

rules
Tool or Tool(specifier), e.g. Bash(npm run test *), Read(./.env)
order
deny → ask → allow; the first matching rule wins, and rules from all scopes are merged
modes
default, acceptEdits, plan, auto, dontAsk, bypassPermissions
classifier
in auto mode, a separate model blocks risky actions (curl|bash, prod deploys, force-push, push to main)
floors
protected paths (.git, .claude, shell rc) are never approved automatically. Even bypass mode blocks rm -rf / and refuses to run as root unless sandboxed
OPENCLAW · WHO CAN TALK

Check who is talking.

DM policy
pairing | allowlist | open | disabled, default pairing
pairing
a one-time code: openclaw pairing approve <channel> <code>
main session
belongs to the single owner and runs tools on the host with full access
everyone else
all other sessions are sandboxed (Docker by default) with per-tool allowlists
the contrast: Claude Code checks each tool call against your rules, plus a classifier in auto mode. OpenClaw checks who is allowed to talk to it, then sandboxes everyone who is not you.
07 · config & files

Claude Code keeps its config in your repo. OpenClaw keeps it on the machine that runs it.

Both are configured with plain files. Neither uses a database. Claude Code's config lives in .claude/ inside the repo, where it is committed and shared with your team. OpenClaw's lives in ~/.openclaw on whichever machine runs the always-on daemon.

CLAUDE CODE · IN THE REPO

Committed to git, shared with the team.

memory
CLAUDE.md at ~/.claude/, ./, ./.claude/, plus CLAUDE.local.md
settings
settings.json + settings.local.json; when settings conflict, the priority order is managed > CLI > local > project > user (permission rules are merged instead)
agents
.claude/agents/
mcp
.mcp.json / ~/.claude.json
skills
SKILL.md files
OPENCLAW · WITH THE DAEMON

Lives in ~/.openclaw.

config
one ~/.openclaw/openclaw.json (JSON5: comments + trailing commas; override via OPENCLAW_CONFIG_PATH)
workspace
~/.openclaw/workspace with .agents/, extensions/, skills/
channels
under channels.<provider>.*
models
per agent via agents.defaults.models (catalog + allowlist)
the contrast: Claude Code's config lives in your repo, committed next to the code it controls. OpenClaw's lives next to the always-on daemon, in ~/.openclaw on whichever machine runs it.
08 · surfaces

Claude Code runs where you write code. OpenClaw runs in your chat apps.

Claude Code is one harness that runs in three places in your dev environment: your terminal, your editor, and a cloud container on the web. OpenClaw is one Gateway that you host yourself, and it connects to the messaging apps you already use every day.

CLAUDE CODE · CLI

Your shell

runs in
your terminal, in your current directory
speed
fastest, no cold start
persistence
sessions under ~/.claude/
CLAUDE CODE · IDE

Inside the editor

runs in
VS Code / JetBrains
extras
sees your selected text and open files
diffs
shown in the editor's own diff view
CLAUDE CODE · WEB

Cloud container

runs in
a temporary VM, deleted when the session ends
setup
install deps in SessionStart
persistence
commit & push or it's gone
OPENCLAW · THE GATEWAY

Self-hosted bridge

runs on
a VPS or your own machine
nodes
a macOS menu bar, plus iOS and Android nodes
shape
one daemon, many channels at once
OPENCLAW · 20+ CHANNELS

The apps you already use

messaging
WhatsApp, Telegram, Slack, Discord, Signal, iMessage, Matrix, Teams
more
Google Chat, Feishu, LINE, WeChat, QQ, IRC, Nostr, Twitch, WebChat
idea
the agent shows up where you already are
the contrast: Claude Code runs in your dev environment: the CLI, your IDE, or a short-lived web container. OpenClaw runs in the chat apps you already use, connected through one Gateway that you host yourself.
09 · openness & provenance

Claude Code had to be decompiled. OpenClaw publishes its source almost every day.

We know how these two harnesses work for very different reasons. We know Claude Code's internals only because its source leaked. We know OpenClaw's because its code has been open from day one.

CLAUDE CODE · CLOSED

Known by decompilation.

shape
one ~12MB minified, obfuscated cli.js (vars like X6, K8, b6)
the leak
the .js.map source maps in the npm package included a sourcesContent field holding the original TypeScript, which made deobfuscation possible
coverage
reported as a "source leak" by InfoQ and The Register (Apr 2026)
analysis
VILA-Lab studied v2.1.88: ~1,884 TS files, ~512K lines of code. Only ~1.6% is AI decision logic; the other ~98.4% is ordinary deterministic infrastructure
OPENCLAW · MIT, OPEN

Known by reading it.

license
MIT, public from day one
releases
CalVer vYYYY.M.D, almost every day; latest stable v2026.5.27
lineage
Clawdbot → Moltbot → OpenClaw, by Peter Steinberger (@steipete)
scale
hundreds of thousands of GitHub stars (~375K); its mascot is Molty, a space lobster
steward
its creator was hired by OpenAI (Feb 2026), and a stewardship foundation now runs it
the contrast: Claude Code had to be decompiled to be understood. OpenClaw publishes its source almost every day. To take Claude Code apart, people needed a leaked source map. To take OpenClaw apart, you only need a git clone.
10 · closing

The harness is what turns a model into an agent.

A language model on its own is a function: text goes in, text comes out. The code around it is what makes it an agent. That code runs the loop, keeps the context small enough to fit, provides the tools, checks permissions, and connects to the places where you use it. Claude Code and OpenClaw make almost opposite choices at every one of these layers, and both work.

Claude Code is a closed, single-task loop that you run in your terminal, and we know its insides from a leaked source map. OpenClaw is an open, always-on daemon that talks to you through your chat apps, and you can read all of its code on GitHub. Both can run the same model. What differs is the harness.

Claude Code facts come from official docs plus reverse-engineering of the leaked source maps. OpenClaw facts come from its open repo and docs.