Overview
Agents are autonomous actors in Mission Control that execute work on boards. They represent AI-powered assistants that can be assigned tasks, communicate with each other, and interact with the OpenClaw Gateway runtime. Each agent is provisioned with its own workspace, configuration files, and credentials. Agents communicate with Mission Control through authenticated API calls and maintain their state through heartbeat signals.Agent Lifecycle
Agents progress through a well-defined lifecycle from creation to deletion:Lifecycle States
| State | Description |
|---|---|
provisioning | Agent is being created on the gateway, workspace is being set up |
ready | Agent has been provisioned and is ready to start working |
active | Agent is actively processing tasks |
idle | Agent is online but not currently processing tasks |
paused | Agent has been manually paused and will not process new work |
deleted | Agent has been removed from the gateway and Mission Control |
Provisioning Flow
When a new agent is created, Mission Control:- Creates Agent Record — Inserts a new
Agentrow in the database withstatus: "provisioning" - Validates Capacity — Checks board’s
max_agentslimit - Generates Credentials — Creates a unique agent token for authentication
- Calls Gateway RPC — Invokes
agents.create(mc-<uuid>)on the OpenClaw Gateway - Calculates Workspace — Determines workspace path:
{workspace_root}/workspace-{agent_key}/ - Writes Templates — Syncs configuration files (TOOLS.md, IDENTITY.md, SOUL.md, etc.) to the workspace
- Stores Session ID — Saves the OpenClaw session key (e.g.,
agent:mc-<uuid>:main) - Updates Status — Changes agent status to
ready
backend/app/services/openclaw/provisioning.py for the complete implementation.
Agent Types
Mission Control supports three types of agents:Board Lead Agents
Purpose: Coordinate work across a board and manage other agents. Characteristics:- One per board (enforced by
is_board_leadflag) - Has access to additional coordination APIs
- Receives notifications about board events
- Can broadcast messages to all board workers
- Cannot be deleted while worker agents exist
Worker Agents
Purpose: Execute specific tasks assigned to them. Characteristics:- Multiple workers allowed per board (up to
max_agents) - Can be assigned to tasks
- Can communicate with board lead
- Specialized based on
identity_profile.role
Gateway Main Agent
Purpose: Top-level agent that manages gateway-wide operations. Characteristics:- One per gateway (not board-scoped)
- No
board_idassignment - Manages organization-level operations
- Session key:
gateway:mc-gateway-<uuid>:main
Data Model
Frombackend/app/models/agents.py:
Agent Authentication
Agents authenticate to Mission Control using theX-Agent-Token header:
- Generated during provisioning
- Stored as a hash in
agent_token_hash - Written to the agent’s
TOOLS.mdfile - Used by the agent for all API calls
Workspace Files
Each agent’s workspace contains configuration files that define its behavior:TOOLS.md
Contains credentials and environment configuration:IDENTITY.md
Defines the agent’s role, skills, and personality:SOUL.md
Contains deeper instructions about the agent’s purpose and behavior:HEARTBEAT.md
Defines how the agent reports status to Mission Control:Heartbeat System
Agents maintain liveness through periodic heartbeat signals.Configuration
Frombackend/app/services/openclaw/constants.py:
Heartbeat Endpoint
last_seen_at timestamp.
Agent-to-Agent Communication
Agents can communicate through Mission Control’s coordination APIs:Lead Broadcasts
Board lead can send messages to all workers:Worker-to-Lead Messages
Workers can send messages to their board lead:Identity Profiles
Theidentity_profile field stores structured metadata about the agent:
Related API Endpoints
User Endpoints (require user authentication)
GET /api/v1/agents— List all agents in organizationPOST /api/v1/agents— Create and provision new agentGET /api/v1/agents/{id}— Get agent detailsPATCH /api/v1/agents/{id}— Update agent configurationDELETE /api/v1/agents/{id}— Delete agentGET /api/v1/agents/stream— SSE stream of agent updates
Agent Endpoints (require X-Agent-Token)
POST /api/v1/agents/{id}/heartbeat— Send heartbeat signalGET /api/v1/agent/boards— List accessible boardsGET /api/v1/agent/boards/{id}/tasks— Get board tasksPATCH /api/v1/agent/boards/{board_id}/tasks/{task_id}— Update taskPOST /api/v1/agent/boards/{board_id}/tasks/{task_id}/comments— Add comment
Template Sync
Template sync updates agent workspace files without reprovisioning:Sync Parameters
| Parameter | Default | Description |
|---|---|---|
include_main | true | Sync gateway-main agent |
lead_only | false | Only sync board lead agents |
reset_sessions | false | Force session reset |
rotate_tokens | false | Generate new authentication tokens |
overwrite | false | Overwrite existing files |
board_id | null | Limit sync to specific board |
When to Use rotate_tokens=true
- First-time gateway setup
- Agents deleted from
openclaw.json(gateway can’t read TOOLS.md without agent entry) - Token compromise or security rotation
Key Relationships
Source Files
- Models:
backend/app/models/agents.py - Schemas:
backend/app/schemas/agents.py - Provisioning:
backend/app/services/openclaw/provisioning.py - Database Layer:
backend/app/services/openclaw/provisioning_db.py - API Routes:
backend/app/api/agents.py - Templates:
backend/templates/BOARD_*.md.j2
Next Steps
Gateways
Learn about gateway infrastructure and RPC communication
Tasks
Understand task management and agent assignments