🦞 OpenClaw Bootcamp
DAY 09 / 16
📜
OpenClaw Bootcamp · Day 9

AGENTS.md:
The Operating Manual

Your agent has a voice and a memory. Now it needs a rulebook. AGENTS.md defines how your agent operates — priorities, tool policies, delegation patterns, and the guardrails that make autonomy safe.

Operating Rules Sub-Agents Tool Policies Security
🦞 OpenClaw Bootcamp
DAY 09 / 16
Where We Are & Where We’re Going

Day 9 Goals

Day 8 Checkpoint
  • Three-file memory system: MEMORY.md, daily notes, DREAMS.md
  • Hybrid search with vector + BM25 keyword matching
  • Curated MEMORY.md with lean token footprint
01
Understand what AGENTS.md is and how it differs from SOUL.md
02
Master sub-agents: spawning, managing, nesting depth, and concurrency
03
Understand tool policies and three independent security mechanisms
04
Write your own operating rules and test them in a live session
🦞 OpenClaw Bootcamp
DAY 09 / 16
The Foundation

What Is AGENTS.md?

AGENTS.md is described in the docs as “operating instructions for the agent and how it should use memory.” The key word is operating — this file governs mechanics, not personality.

Operating Rules

Priorities, workflows, escalation procedures, and how the agent handles specific situations.

🛡

Safety Defaults

Guardrails that prevent destructive actions without explicit confirmation from the user.

🧠

Memory Guidance

How to read memory at startup, what order to check files, and what’s worth remembering.

The Docs Say

“Keep AGENTS.md for operating rules. Keep SOUL.md for voice, stance, and style.” If it’s about how the agent sounds, it goes in SOUL.md. If it’s about how the agent behaves, it goes in AGENTS.md.

🦞 OpenClaw Bootcamp
DAY 09 / 16
File Location & Loading

Where It Lives & Bootstrap Order

File Path
# Default workspace ~/.openclaw/workspace/AGENTS.md # Named profile ~/.openclaw/workspace-<profile>/AGENTS.md
First In Line

AGENTS.md is the first file your agent reads at session start. It sets the behavioral frame before personality, identity, or memory.

Bootstrap Injection Order
  • 1AGENTS.md — Operating rules (loaded first)
  • 2SOUL.md — Personality & tone
  • 3TOOLS.md — Available tool definitions
  • 4IDENTITY.md — Agent identity
  • 5USER.md — User preferences
  • 6HEARTBEAT.md — Proactive tasks
  • 7BOOTSTRAP.md — Extra context
  • 8MEMORY.md — Long-term memory (last)
🦞 OpenClaw Bootcamp
DAY 09 / 16
The Critical Distinction

AGENTS.md vs SOUL.md

AGENTS.mdSOUL.md
PurposeOperating instructions, rules, memory guidancePersona, tone, voice, boundaries
Content TypeMechanical: workflows, priorities, tool usageExpressive: short beats long, sharp beats vague
Loaded InAll sessions + sub-agentsNormal sessions only
Sub-Agents See It?Yes — alwaysNo — filtered out
Example“Always confirm before sending emails”“Be concise and direct”
Why This Matters

Sub-agents only receive AGENTS.md and TOOLS.md — all other bootstrap files are filtered out to keep sub-agent context small. Your operating rules reach everywhere. Your personality stays in the main session.

🦞 OpenClaw Bootcamp
DAY 09 / 16
The Starting Point

The Default Template

Three Safety Defaults
🚫

Don’t Dump Secrets

Never paste file trees or credentials into a conversation. Directories and secrets stay out of chat.

Don’t Run Destructive Commands

No deleting files, overwriting data, or irreversible operations without explicit user confirmation.

💬

Don’t Send Partial Replies

When composing for Telegram, WhatsApp, or Discord, send the complete message — never stream fragments to external surfaces.

Startup Read Order

When a session begins, the agent reads context in this order:

  • 1SOUL.md — personality first
  • 2USER.md — user preferences
  • 3Today & yesterday’s daily notes — recent activity
  • 4MEMORY.md — long-term memory
Customize It

The default template is described as a “personal assistant variant.” You don’t have to use it as-is — it’s the baseline your agent starts from. Today you’ll make it yours.

🦞 OpenClaw Bootcamp
DAY 09 / 16
Delegation

What Are Sub-Agents?

A sub-agent is a background agent run spawned from an existing agent run. Think of it like delegating a task to an assistant who works independently and reports back when done.

🔌

Isolated Context

Each sub-agent gets its own context window and token usage. It only receives AGENTS.md and TOOLS.md — no personality, no identity, no full conversation history.

Non-Blocking

Spawning is non-blocking — you get a run ID back immediately and the main agent keeps working. No waiting around for the sub-agent to finish.

📣

Announce Results

When a sub-agent finishes, it announces a summary or result message back to the requester’s chat channel automatically.

📚

Only Operating Rules

Sub-agents inherit AGENTS.md and TOOLS.md only. SOUL.md, IDENTITY.md, USER.md, HEARTBEAT.md, and BOOTSTRAP.md are all filtered out.

🦞 OpenClaw Bootcamp
DAY 09 / 16
Hands-On

Spawning & Managing Sub-Agents

Spawning
# From chat /subagents spawn main "Summarize my last 3 daily memory files" # Programmatically (agent calls) sessions_spawn task: "Research topic X"
Emergency Stop

Running /stop in the requester chat cascades to abort all sub-agents and their nested children. One command stops the entire delegation tree.

Management Commands
  • /subagents list — Show all current runs
  • /subagents kill — Terminate a specific run or all
  • 📄/subagents log — View output (filterable)
  • /subagents info — Metadata: model, runtime, tokens
  • /subagents send — Message a running sub-agent
  • 🎯/subagents steer — Give direct guidance to change course
🦞 OpenClaw Bootcamp
DAY 09 / 16
Limits & Architecture

Nesting Depth & Concurrency

Nesting Levels
  • 0Main Agent — Can always spawn sub-agents
  • 1Sub-Agents — Can only spawn if maxSpawnDepth ≥ 2
  • 2Workers — Can never spawn further sub-agents

Maximum nesting depth is 5, but the docs recommend 2.

Orchestrator Pattern

Set maxSpawnDepth: 2 to enable a coordinator that spawns workers. Main agent → coordinator → workers. This is the recommended pattern for complex multi-step tasks.

Default Concurrency Limits
SettingDefault
maxSpawnDepth1
maxChildrenPerAgent5
maxConcurrent8
archiveAfterMinutes60
// openclaw.json "agents": { "defaults": { "subagents": { "maxSpawnDepth": 1, "maxChildrenPerAgent": 5, "maxConcurrent": 8, "archiveAfterMinutes": 60 } } }
🦞 OpenClaw Bootcamp
DAY 09 / 16
Access Control

Tool Policies

The Fundamental Rule

Deny always wins. If a tool appears in both an allow list and a deny list, it’s denied. No exceptions. No overrides.

Cascading Model
  • 1. Base profiles
  • 2. Provider-specific profiles
  • 3. Global allow / deny lists
  • 4. Per-agent lists
  • 5. Provider-level lists
  • 6. Sandbox-specific restrictions

Each layer can tighten what’s available. Deny at any layer blocks the tool everywhere below.

Tool Groups
GroupCovers
group:runtimeexec, process, code execution
group:fsread, write, edit, apply_patch
group:sessionssession management
group:memorysearch and retrieval
group:webweb operations

Allow or deny entire groups instead of listing individual tools.

// Restricted agent: read-only "tools": { "allow": ["group:fs", "group:memory"], "deny": ["write", "edit", "exec"] }
🦞 OpenClaw Bootcamp
DAY 09 / 16
Defense in Depth

Three Security Mechanisms

📦

Sandbox — Where

Determines where tools execute. Modes:

  • off — no sandboxing
  • non-main — sandbox everything except main agent
  • all — sandbox everything

Configurable globally or per-agent in openclaw.json.

🛡

Tool Policy — Which

Determines which tools are available. The allow/deny cascading system.

  • Hard stop — denied = denied
  • /exec cannot bypass a denied tool
  • Non-empty allow list auto-blocks unlisted tools
🔐

Elevated — Who

The escape hatch. Determines who can override.

  • /elevated on — exec outside sandbox
  • /elevated full — skip exec approval
  • Configurable globally and per-agent via sender allowlists
Three Dimensions, Zero Conflicts

Sandbox = where. Tool Policy = which. Elevated = who can override. They operate independently because they control different dimensions. No conflicts.

🦞 OpenClaw Bootcamp
DAY 09 / 16
Advanced Architecture

Multi-Agent Architecture

Three Isolated Components
  • 1Workspace — Own AGENTS.md, SOUL.md, and other files
  • 2agentDir — Auth profiles, model registry, and agent-specific state
  • 3Session store~/.openclaw/agents/<id>/sessions
Critical Rule

Never reuse agentDir across agents. Shared agentDir causes auth and session collisions. Each agent must have its own isolated state directory.

Routing Precedence

Routing determines which agent handles which conversation:

  • 1. peer (direct user mapping)
  • 2. parentPeer
  • 3. guildId + roles
  • 4. guildId
  • 5. teamId
  • 6. accountId
  • 7. channel-level
  • 8. fallback (default agent)

If multiple bindings match in the same tier, first in config order wins.

🦞 OpenClaw Bootcamp
DAY 09 / 16
Keep It Lean

Token Costs & Context Inspection

Why AGENTS.md Size Matters More

AGENTS.md is injected in every session type — main sessions and sub-agent sessions. A bloated AGENTS.md taxes every interaction and every delegation spawn.

Hard Limits
  • Per-file: 20,000 chars (bootstrapMaxChars)
  • Total bootstrap: 150,000 chars (bootstrapTotalMaxChars)
  • Truncation warning: once (default), always, or off
Inspection Commands
  • /status — Quick context window fullness check
  • 📄/context list — Every injected file with raw vs injected sizes, truncation status
  • 🔍/context detail — Per-file and per-tool breakdowns for full audit
Sub-Agent Savings

Sub-agents already skip SOUL.md, IDENTITY.md, USER.md, HEARTBEAT.md, and BOOTSTRAP.md. AGENTS.md is one of only two files they receive, so keeping it concise benefits delegation costs disproportionately.

🦞 OpenClaw Bootcamp
DAY 09 / 16
Before Day 10

Day 9 Homework

  • 01

    Review Your AGENTS.md

    Open ~/.openclaw/workspace/AGENTS.md and read through what’s there. Identify the three safety defaults and the startup read order. This is your baseline.

  • 02

    Spawn Your First Sub-Agent

    Run /subagents spawn main "Summarize my last 3 daily memory files" in chat. Then use /subagents list and /subagents log to see the result.

  • 03

    Inspect Your Context

    Run /context list and /context detail to see how much each bootstrap file contributes. Pay attention to AGENTS.md specifically.

  • 04

    Add One Custom Operating Rule

    Something specific to your workflow: “always write code in TypeScript,” “summarize articles before responding,” or “never use exec without confirmation.” Test it in a new session.

🦞 OpenClaw Bootcamp
DAY 09 / 16
🦞
Coming Up

Day 10: Tools & Skills
Extend What Your Agent Can Do

Your agent has rules, guardrails, and the ability to delegate. Day 10 is where you extend its capabilities — built-in tools, custom Skills, ClawHub marketplace, and building your own integrations. From consumer to creator.

Built-in Tools Custom Skills ClawHub Security