openclaw

Research notes describing OpenClaw, a multi-provider AI-agent system that runs through a long-lived gateway service. The gateway communicates over WebSocket and HTTP and keeps session information.

In plain words
What is it for?
Use them to understand OpenClaw's gateway, sessions, APIs, agent execution, and automation patterns when building an integration.
Why use it?
They provide a reference for connecting sandbox-agent to OpenClaw without relying on an official SDK, which OpenClaw does not provide.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/rivet-dev/sandbox-agent/openclaw
Clone the repo
git clone --depth 1 https://github.com/rivet-dev/sandbox-agent
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,834 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 2 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.03834
Opus 5 $0.00000 $0.01917
Sonnet 5 $0.00000 $0.00767
Haiku 4.5 $0.00000 $0.00383

Measured 2d ago against content hash 800c98faa64f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

openclaw scanned grade B with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Sends data to an external URLmediumData exfiltration

A POST to an outside endpoint may be telemetry or may be exfiltration; either way the mod talks to somewhere, and you should know where.

const response = await fetch("http://127.0.0.1:18789/v1/chat/completions", { method: "POST",

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

curl -X POST http://127.0.0.1:18789/v1/chat/completions \
research/agents/openclaw.md · 554 lines

How it starts

The opening of the file, as written. The whole thing — 554 lines — stays where its author put it; the contents beside it link to each section on GitHub.

OpenClaw (formerly Clawdbot) Research

Research notes on OpenClaw's architecture, API, and automation patterns for integration with sandbox-agent.

Overview

  • Provider: Multi-provider (Anthropic, OpenAI, etc. via Pi agent)
  • Execution Method: WebSocket Gateway + HTTP APIs
  • Session Persistence: Session Key (string) + Session ID (UUID)
  • SDK: No official SDK - uses WebSocket/HTTP protocol directly
  • Binary: clawdbot (npm global install or local)
  • Default Port: 18789 (WebSocket + HTTP multiplex)

Architecture

OpenClaw is architected differently from other coding agents (Claude Code, Codex, OpenCode, Amp):

┌─────────────────────────────────────┐
│           Gateway Service           │  ws://127.0.0.1:18789
│      (long-running daemon)          │  http://127.0.0.1:18789
│                                     │
│  ┌─────────────────────────────┐    │
│  │ Pi Agent (embedded RPC)     │    │
│  │ - Tool execution            │    │
│  │ - Model routing             │    │
│  │ - Session management        │    │
│  └─────────────────────────────┘    │
└─────────────────────────────────────┘
         │
         ├── WebSocket (full control plane)
         ├── HTTP /v1/chat/completions (OpenAI-compatible)
         ├── HTTP /v1/responses (OpenResponses-compatible)
         ├── HTTP /tools/invoke (single tool invocation)
         └── HTTP /hooks/agent (webhook triggers)

Key Difference: OpenClaw runs as a daemon that owns the agent runtime. Other agents (Claude, Codex, Amp) spawn a subprocess per turn. OpenClaw is more similar to OpenCode's server model but with a persistent gateway.

Automation Methods (Priority Order)

1. WebSocket Gateway Protocol (Recommended)

Full-featured bidirectional control with streaming events.

Connection Handshake
// Connect to Gateway
const ws = new WebSocket("ws://127.0.0.1:18789");

// First frame MUST be connect request
ws.send(JSON.stringify({
  type: "req",
  id: "1",
  method: "connect",
  params: {
    minProtocol: 3,
    maxProtocol: 3,
    client: {
      id: "gateway-client",  // or custom client id
      version: "1.0.0",
      platform: "linux",
      mode: "backend"
    },
    role: "operator",
    scopes: ["operator.admin"],
    caps: [],
    auth: { token: "YOUR_GATEWAY_TOKEN" }
  }
}));

// Expect hello-ok response
// { type: "res", id: "1", ok: true, payload: { type: "hello-ok", ... } }

Read the full file on GitHub · 554 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 554 lines · 0 tokens per session scan B 800c98faa64f

Subscribe to this mod's changes

openclaw is an agent published in the GitHub repository rivet-dev/sandbox-agent (1,551 stars, last pushed 2mo ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 3,834 tokens. A static security scan graded it B with 2 findings (sends data to an external url, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.