Files
openclaw/docs/concepts/agent.md

124 lines
5.1 KiB
Markdown
Raw Normal View History

2025-12-17 11:29:12 +01:00
---
summary: "Agent runtime (embedded pi-mono), workspace contract, and session bootstrap"
2025-12-17 11:29:12 +01:00
read_when:
- Changing agent runtime, workspace bootstrap, or session behavior
title: "Agent Runtime"
2025-12-17 11:29:12 +01:00
---
2026-01-31 21:13:13 +09:00
2025-12-17 11:29:12 +01:00
# Agent Runtime 🤖
OpenClaw runs a single embedded agent runtime derived from **pi-mono**.
2025-12-17 11:29:12 +01:00
## Workspace (required)
2026-01-30 03:15:10 +01:00
OpenClaw uses a single agent workspace directory (`agents.defaults.workspace`) as the agents **only** working directory (`cwd`) for tools and context.
2025-12-17 11:29:12 +01:00
2026-01-30 03:15:10 +01:00
Recommended: use `openclaw setup` to create `~/.openclaw/openclaw.json` if missing and initialize the workspace files.
2025-12-17 11:29:12 +01:00
2026-01-10 14:51:21 -06:00
Full workspace layout + backup guide: [Agent workspace](/concepts/agent-workspace)
2026-01-07 00:04:03 +01:00
If `agents.defaults.sandbox` is enabled, non-main sessions can override this with
per-session workspaces under `agents.defaults.sandbox.workspaceRoot` (see
2026-01-10 14:51:21 -06:00
[Gateway configuration](/gateway/configuration)).
2025-12-17 11:29:12 +01:00
## Bootstrap files (injected)
2026-01-30 03:15:10 +01:00
Inside `agents.defaults.workspace`, OpenClaw expects these user-editable files:
2026-01-31 21:13:13 +09:00
2025-12-17 11:29:12 +01:00
- `AGENTS.md` — operating instructions + “memory”
- `SOUL.md` — persona, boundaries, tone
- `TOOLS.md` — user-maintained tool notes (e.g. `imsg`, `sag`, conventions)
- `BOOTSTRAP.md` — one-time first-run ritual (deleted after completion)
- `IDENTITY.md` — agent name/vibe/emoji
- `USER.md` — user profile + preferred address
2025-12-17 11:29:12 +01:00
2026-01-30 03:15:10 +01:00
On the first turn of a new session, OpenClaw injects the contents of these files directly into the agent context.
2025-12-17 11:29:12 +01:00
2026-01-07 10:03:50 +00:00
Blank files are skipped. Large files are trimmed and truncated with a marker so prompts stay lean (read the file for full content).
2026-01-30 03:15:10 +01:00
If a file is missing, OpenClaw injects a single “missing file” marker line (and `openclaw setup` will create a safe default template).
2025-12-17 11:29:12 +01:00
`BOOTSTRAP.md` is only created for a **brand new workspace** (no other bootstrap files present). If you delete it after completing the ritual, it should not be recreated on later restarts.
To disable bootstrap file creation entirely (for pre-seeded workspaces), set:
```json5
{ agent: { skipBootstrap: true } }
```
2026-01-08 23:06:56 +01:00
## Built-in tools
2025-12-17 11:29:12 +01:00
Core tools (read/exec/edit/write and related system tools) are always available,
subject to tool policy. `apply_patch` is optional and gated by
`tools.exec.applyPatch`. `TOOLS.md` does **not** control which tools exist; its
2026-01-31 21:13:13 +09:00
guidance for how _you_ want them used.
2025-12-17 11:29:12 +01:00
2025-12-20 12:22:15 +01:00
## Skills
2026-01-30 03:15:10 +01:00
OpenClaw loads skills from three locations (workspace wins on name conflict):
2026-01-31 21:13:13 +09:00
2025-12-20 12:23:53 +00:00
- Bundled (shipped with the install)
2026-01-30 03:15:10 +01:00
- Managed/local: `~/.openclaw/skills`
2025-12-20 12:22:15 +01:00
- Workspace: `<workspace>/skills`
2026-01-10 14:51:21 -06:00
Skills can be gated by config/env (see `skills` in [Gateway configuration](/gateway/configuration)).
2025-12-20 12:22:15 +01:00
## pi-mono integration
2025-12-22 18:05:44 +01:00
OpenClaw reuses pieces of the pi-mono codebase (models/tools), but **session management, discovery, and tool wiring are OpenClaw-owned**.
- No pi-coding agent runtime.
- No `~/.pi/agent` or `<workspace>/.pi` settings are consulted.
2025-12-22 18:05:44 +01:00
2025-12-17 11:29:12 +01:00
## Sessions
Session transcripts are stored as JSONL at:
2026-01-31 21:13:13 +09:00
2026-01-30 03:15:10 +01:00
- `~/.openclaw/agents/<agentId>/sessions/<SessionId>.jsonl`
2025-12-17 11:29:12 +01:00
2026-01-30 03:15:10 +01:00
The session ID is stable and chosen by OpenClaw.
Legacy Pi/Tau session folders are **not** read.
2025-12-17 11:29:12 +01:00
## Steering while streaming
When queue mode is `steer`, inbound messages are injected into the current run.
The queue is checked **after each tool call**; if a queued message is present,
remaining tool calls from the current assistant message are skipped (error tool
results with "Skipped due to queued user message."), then the queued user
message is injected before the next assistant response.
When queue mode is `followup` or `collect`, inbound messages are held until the
current turn ends, then a new agent turn starts with the queued payloads. See
2026-01-10 14:51:21 -06:00
[Queue](/concepts/queue) for mode + debounce/cap behavior.
Block streaming sends completed assistant blocks as soon as they finish; it is
**off by default** (`agents.defaults.blockStreamingDefault: "off"`).
Tune the boundary via `agents.defaults.blockStreamingBreak` (`text_end` vs `message_end`; defaults to text_end).
Control soft block chunking with `agents.defaults.blockStreamingChunk` (defaults to
2026-01-03 16:45:53 +01:00
8001200 chars; prefers paragraph breaks, then newlines; sentences last).
Coalesce streamed chunks with `agents.defaults.blockStreamingCoalesce` to reduce
2026-01-13 07:15:57 +00:00
single-line spam (idle-based merging before send). Non-Telegram channels require
explicit `*.blockStreaming: true` to enable block replies.
Verbose tool summaries are emitted at tool start (no debounce); Control UI
streams tool output via agent events when available.
2026-01-07 17:15:53 +01:00
More details: [Streaming + chunking](/concepts/streaming).
## Model refs
Model refs in config (for example `agents.defaults.model` and `agents.defaults.models`) are parsed by splitting on the **first** `/`.
- Use `provider/model` when configuring models.
- If the model ID itself contains `/` (OpenRouter-style), include the provider prefix (example: `openrouter/moonshotai/kimi-k2`).
2026-01-30 03:15:10 +01:00
- If you omit the provider, OpenClaw treats the input as an alias or a model for the **default provider** (only works when there is no `/` in the model ID).
2025-12-17 11:29:12 +01:00
## Configuration (minimal)
At minimum, set:
2026-01-31 21:13:13 +09:00
- `agents.defaults.workspace`
- `channels.whatsapp.allowFrom` (strongly recommended)
2025-12-17 11:29:12 +01:00
---
_Next: [Group Chats](/channels/group-messages)_ 🦞