|
| 1 | +--- |
| 2 | +sidebar_position: 3 |
| 3 | +title: Brain & Hands |
| 4 | +description: How OpenClaw separates reasoning (LLM) from execution (shell, files, browser) |
| 5 | +--- |
| 6 | + |
| 7 | +# Brain & Hands |
| 8 | + |
| 9 | +OpenClaw separates AI reasoning from system execution into two distinct layers. |
| 10 | + |
| 11 | +## The Brain (Reasoning Engine) |
| 12 | + |
| 13 | +The Brain is the LLM that interprets requests and decides what to do. |
| 14 | + |
| 15 | +### Supported Providers |
| 16 | + |
| 17 | +| Provider | Models | Config Key | |
| 18 | +|----------|--------|------------| |
| 19 | +| **Anthropic** | Claude Opus 4.6, Sonnet 4.5, Haiku 4.5 | `anthropic` | |
| 20 | +| **OpenAI** | GPT-5.3-Codex, GPT-4o | `openai` | |
| 21 | +| **xAI** | Grok | `xai` | |
| 22 | +| **Local** | Any model via Ollama or vLLM | `local` | |
| 23 | + |
| 24 | +### Configuration |
| 25 | + |
| 26 | +```yaml title="~/.openclaw/config.yml" |
| 27 | +brain: |
| 28 | + provider: "anthropic" |
| 29 | + model: "claude-opus-4-6" |
| 30 | + api_key: "${ANTHROPIC_API_KEY}" # Or set env var |
| 31 | + temperature: 0.7 |
| 32 | + max_tokens: 4096 |
| 33 | + |
| 34 | + # Fallback if primary provider is down |
| 35 | + fallback: |
| 36 | + provider: "openai" |
| 37 | + model: "gpt-4o" |
| 38 | +``` |
| 39 | +
|
| 40 | +### How the Brain Works |
| 41 | +
|
| 42 | +1. Receives a message (from user, channel, or heartbeat) |
| 43 | +2. Loads relevant memory context |
| 44 | +3. Applies active skill instructions |
| 45 | +4. Generates a plan (internal chain-of-thought) |
| 46 | +5. Outputs either a response, a tool call, or both |
| 47 | +
|
| 48 | +The Brain never directly touches the filesystem or network — it requests actions from the Hands. |
| 49 | +
|
| 50 | +## The Hands (Execution Environment) |
| 51 | +
|
| 52 | +The Hands execute what the Brain decides to do. |
| 53 | +
|
| 54 | +### Capabilities |
| 55 | +
|
| 56 | +| Hand | Description | Examples | |
| 57 | +|------|-------------|---------| |
| 58 | +| **Shell** | Execute terminal commands | `ls`, `git`, `python`, `curl` | |
| 59 | +| **Filesystem** | Read/write/modify files | Create configs, edit code, manage logs | |
| 60 | +| **Browser** | Chromium automation | Fill forms, scrape pages, take screenshots | |
| 61 | +| **HTTP** | Make API requests | REST calls, webhook delivery | |
| 62 | + |
| 63 | +### Shell Execution |
| 64 | + |
| 65 | +By default, commands run with the same permissions as the user who started OpenClaw: |
| 66 | + |
| 67 | +```yaml title="~/.openclaw/config.yml" |
| 68 | +hands: |
| 69 | + shell: |
| 70 | + enabled: true |
| 71 | + timeout: 30000 # ms, per command |
| 72 | + allowed_commands: [] # Empty = all allowed |
| 73 | + blocked_commands: |
| 74 | + - "rm -rf /" |
| 75 | + - "shutdown" |
| 76 | + - "reboot" |
| 77 | +``` |
| 78 | + |
| 79 | +### Browser Automation |
| 80 | + |
| 81 | +OpenClaw includes a headless Chromium instance for web tasks: |
| 82 | + |
| 83 | +```yaml title="~/.openclaw/config.yml" |
| 84 | +hands: |
| 85 | + browser: |
| 86 | + enabled: true |
| 87 | + headless: true |
| 88 | + timeout: 60000 |
| 89 | + allowed_domains: [] # Empty = all allowed |
| 90 | +``` |
| 91 | + |
| 92 | +:::tip |
| 93 | +Set `headless: false` during development to watch the browser in action. |
| 94 | +::: |
| 95 | + |
| 96 | +### Sandboxing |
| 97 | + |
| 98 | +For production deployments, you can isolate the Hands: |
| 99 | + |
| 100 | +```yaml title="~/.openclaw/config.yml" |
| 101 | +hands: |
| 102 | + sandbox: |
| 103 | + enabled: true |
| 104 | + type: "docker" # or "firejail" on Linux |
| 105 | + image: "openclaw/sandbox:latest" |
| 106 | + network: false # Disable network in sandbox |
| 107 | + writable_paths: |
| 108 | + - "~/.openclaw/memory" |
| 109 | + - "/tmp/openclaw" |
| 110 | +``` |
| 111 | + |
| 112 | +## Brain-Hands Communication |
| 113 | + |
| 114 | +The Brain and Hands communicate through a structured tool-call protocol: |
| 115 | + |
| 116 | +```json |
| 117 | +// Brain requests action |
| 118 | +{ |
| 119 | + "type": "tool_call", |
| 120 | + "tool": "shell", |
| 121 | + "args": { |
| 122 | + "command": "git status", |
| 123 | + "cwd": "/home/user/project" |
| 124 | + } |
| 125 | +} |
| 126 | +
|
| 127 | +// Hands return result |
| 128 | +{ |
| 129 | + "type": "tool_result", |
| 130 | + "tool": "shell", |
| 131 | + "output": "On branch main\nnothing to commit, working tree clean", |
| 132 | + "exit_code": 0 |
| 133 | +} |
| 134 | +``` |
| 135 | + |
| 136 | +The Brain can chain multiple tool calls in sequence, analyzing each result before deciding the next step. |
| 137 | + |
| 138 | +## Cost Considerations |
| 139 | + |
| 140 | +OpenClaw's token consumption is a commonly cited concern: |
| 141 | + |
| 142 | +- **Average daily cost**: $5–50 depending on usage and model |
| 143 | +- **Heartbeat alone**: ~$1–5/day (varies by interval and task count) |
| 144 | +- **Heavy automation**: Can spike significantly with complex skills |
| 145 | + |
| 146 | +To manage costs: |
| 147 | +- Use cheaper models for simple tasks (`haiku` for heartbeat, `opus` for complex work) |
| 148 | +- Increase heartbeat interval |
| 149 | +- Use [local models](/guides/local-models) to eliminate API costs entirely |
| 150 | + |
| 151 | +## See Also |
| 152 | + |
| 153 | +- [Local Models Guide](/guides/local-models) — Run without API costs |
| 154 | +- [Configuration Reference](/reference/configuration) — All brain/hands settings |
| 155 | +- [Security Hardening](/security/hardening) — Restricting execution capabilities |
0 commit comments