Build a custom multi-agent collaboration team on OpenClaw — step by step, with correct
architecture, workspace files, routing config, and collaboration rules.
> Important: This skill is based on verified OpenClaw documentation (docs.openclaw.ai)
> and the official GitHub repo (github.com/openclaw/openclaw). All configuration patterns,
> file names, and architecture decisions reflect the actual OpenClaw system as of early 2026.
This is an interactive, guided workflow. You walk the user through 8 phases:
At each phase, ask the user questions, validate their choices, then generate the
corresponding configuration and workspace files.
Help the user define their agent team composition.
id: short lowercase identifier (e.g., planner, coder, writer)name: display name (e.g., "🧠 Planner")role: one-sentence description of what this agent doesmode: Does it lead (orchestrator) or follow (specialist)?Recommended team templates (user can customize):
Dev Team (4 agents):
planner — Task decomposition, prioritization, project trackingcoder — Code implementation, debugging, technical executionreviewer — Code review, quality assurance, testingwriter — Documentation, commit messages, technical writingContent Team (3 agents):
strategist — Content strategy, audience analysis, topic planningcreator — Writing, editing, creative outputcritic — Quality review, fact-checking, style consistencyBusiness Team (4 agents):
chief — Overall coordination, decision synthesisanalyst — Data analysis, market research, risk assessmentbuilder — Technical implementation, automationcommunicator — External communication, reports, presentationsSolo+ (2 agents):
main — General-purpose assistant (default agent)research — Deep research, analysis, background tasksExplain these to the user clearly:
openclaw gateway process hosts ALL agentsagents.list[] in ~/.openclaw/openclaw.jsonagentDir for auth/state, session transcripts under ~/.openclaw/agents//sessions/ , memory index databaseagentDir across agents — causes auth/session collisionsAsk the user which channels they want to use:
For each agent, the user should run:
openclaw agents add <agent-id>
Or define them in ~/.openclaw/openclaw.json:
{
agents: {
list: [
{ id: "planner", workspace: "~/.openclaw/workspace-planner" },
{ id: "coder", workspace: "~/.openclaw/workspace-coder" },
{ id: "reviewer", workspace: "~/.openclaw/workspace-reviewer" },
],
},
}
Each agent's workspace follows this standard structure (per official docs):
| File | Purpose | Loaded When |
|---|---|---|
| ------ | --------- | ------------- |
AGENTS.md | Operating instructions, memory rules, behavior priorities | Every session |
SOUL.md | Persona, tone, boundaries | Every session |
USER.md | Who the user is, how to address them | Every session |
IDENTITY.md | Agent name, vibe, emoji (created during bootstrap) | Every session |
TOOLS.md | Notes about local tools/conventions (guidance only, does NOT control tool access) | Every session |
HEARTBEAT.md | Optional tiny checklist for heartbeat runs | Heartbeat only |
BOOT.md | Optional startup checklist on gateway restart | Gateway start |
BOOTSTRAP.md | One-time first-run ritual, deleted after completion | First run only |
memory/YYYY-MM-DD*.md | Daily memory logs (append-only) | On demand |
MEMORY.md | Curated long-term memory | Private sessions only |
> Critical correction: The official workspace does NOT include files named
> ROLE-COLLAB-RULES.md, TEAM-RULEBOOK.md, TEAM-DIRECTORY.md, or
> GROUP_MEMORY.md as standard OpenClaw files. These are custom additions.
> If the user wants collaboration rules, they should be embedded in AGENTS.md
> and SOUL.md, which are the files OpenClaw actually loads every session.
For each agent, generate these files based on the user's team design.
SOUL.md template — Customize per agent:
# Soul of [Agent Name]
## Identity
- Name: [Display Name]
- Role: [One-line role description]
- Emoji: [Emoji identifier]
## Personality
[2-3 sentences describing tone, communication style]
## Responsibilities
[Bullet list of what this agent owns]
## Boundaries
- [What this agent should NOT do]
- [When to defer to other agents]
## Private Chat Mode
[How to behave in 1:1 conversations — act as full-service expert]
## Group Chat Mode
[How to behave in group — follow team protocol, incremental contributions only]
AGENTS.md template — Customize per agent:
# Operating Manual for [Agent Name]
## Core Behavior
- Always read IDENTITY.md and USER.md at session start
- In group chats, only respond when @-mentioned (unless you are the orchestrator)
- Write important decisions to memory/YYYY-MM-DD.md
## Memory Protocol
- Read today's and yesterday's daily log at session start
- Use memory_search for semantic recall before answering complex questions
- Write durable facts to MEMORY.md only in private sessions
- Never load MEMORY.md in group contexts
## Collaboration Protocol
- When your task is done, summarize your output clearly
- If a task is outside your role, say so and suggest which agent to @
- Never engage in back-and-forth with other agents without user involvement
## Quality Standards
[Role-specific quality requirements]
IDENTITY.md template:
# [Agent Name]
- id: [agent-id]
- name: [Display Name]
- emoji: [Emoji]
- role: [Role description]
- capabilities: [What this agent can do]
Bindings route inbound messages to agents. They are evaluated in order — first match wins.
More specific bindings should come before general ones.
Each binding matches on: channel, accountId, chatType, peer, guild/team IDs.
Each Discord bot = one accountId. Bind each to an agent:
{
bindings: [
{ agentId: "planner", match: { channel: "discord", accountId: "planner-bot" } },
{ agentId: "coder", match: { channel: "discord", accountId: "coder-bot" } },
{ agentId: "reviewer", match: { channel: "discord", accountId: "reviewer-bot" } },
],
channels: {
discord: {
accounts: {
"planner-bot": {
token: "${DISCORD_TOKEN_PLANNER}",
guilds: {
"<guild-id>": {
channels: {
"<collab-channel-id>": { allow: true },
},
},
},
},
"coder-bot": {
token: "${DISCORD_TOKEN_CODER}",
// ... similar guild/channel config
},
// ... other bots
},
},
},
}
Each Telegram bot = one accountId:
{
bindings: [
{ agentId: "planner", match: { channel: "telegram", accountId: "default" } },
{ agentId: "coder", match: { channel: "telegram", accountId: "coder" } },
],
channels: {
telegram: {
accounts: {
default: { botToken: "${TELEGRAM_TOKEN_PLANNER}" },
coder: { botToken: "${TELEGRAM_TOKEN_CODER}" },
},
},
},
}
The recommended pattern for multi-agent group collaboration:
Orchestrator agent: requireMention: false (sees all messages)
Specialist agents: requireMention: true (only responds when @-mentioned)
mentionPatterns for reliable triggering// In the orchestrator's account config:
guilds: {
"<guild-id>": {
channels: {
"<channel-id>": { allow: true, requireMention: false },
},
},
},
// In specialist accounts:
guilds: {
"<guild-id>": {
channels: {
"<channel-id>": { allow: true, requireMention: true },
},
},
},
Configure per-agent mention patterns so users can reliably summon agents:
// Per agent in agents.list[]:
{
id: "coder",
groupChat: {
mentionPatterns: ["@coder", "@engineer", "@Coder Bot"],
},
}
In group chat, you also want to prevent agents from endlessly replying to each other.
This is controlled by session.agentToAgent.maxPingPongTurns (range 0–5).
For group chat safety, set to 0 or 1. Full agent communication setup is in Phase 6.
{
session: {
agentToAgent: {
maxPingPongTurns: 1, // 0 = no reply-back, 1 = one exchange max
},
},
}
// Per channel:
channels: {
discord: {
groupPolicy: "allowlist", // recommended: explicit control
// or "open" for more permissive setups
},
},
OpenClaw provides two primitives for inter-agent communication, both disabled by default.
Read references/agent-communication.md for full configuration details and patterns.
1. Enable the master switch (global, not per-agent):
{ tools: { agentToAgent: { enabled: true, allow: ["planner", "coder", "reviewer", "writer"] } } }
2. Two communication primitives:
| Primitive | Use Case | Behavior |
|---|---|---|
| ----------- | ---------- | ---------- |
sessions_send | Direct agent-to-agent conversation | Synchronous, supports ping-pong (0–5 turns) |
sessions_spawn | Delegate task to another agent | Async, isolated session, announces result back |
3. Per-agent allowlists for sessions_spawn:
{ id: "planner", subagents: { allowAgents: ["coder", "reviewer", "writer"] } }
4. Session visibility — orchestrator needs "all", specialists use default "tree":
{ tools: { sessions: { visibility: "all" } } } // For orchestrator only
5. Loop detection — always enable as safety net:
{ tools: { loopDetection: { enabled: true, detectors: { pingPong: true, genericRepeat: true } } } }
sessions_send) or async delegation (sessions_spawn)?Each agent has its own isolated workspace and memory. There is **no built-in
cross-agent shared memory**. Read references/team-shared-memory.md for full
implementation details, setup scripts, and file templates.
Create a shared directory symlinked into every agent's workspace:
~/.openclaw/team-shared/ ← Single source of truth
├── TEAM-KNOWLEDGE.md ← Durable facts, preferences, quality standards
├── TEAM-DECISIONS.md ← Decision log with date/context/rationale
├── TEAM-STATUS.md ← Current priorities, active tasks, blockers
├── TEAM-DIRECTORY.md ← Agent IDs, session keys, mention patterns
└── projects/
├── INDEX.md ← Registry of all active projects
└── <project-name>.md ← Per-project context doc
~/.openclaw/workspace-planner/team-shared → symlink to above
~/.openclaw/workspace-coder/team-shared → symlink to above
~/.openclaw/workspace-reviewer/team-shared → symlink to above
mkdir -p ~/.openclaw/team-shared/projects
# Create shared files (see references/team-shared-memory.md for templates)
# Then symlink into each workspace:
for agent in planner coder reviewer writer; do
ln -s ~/.openclaw/team-shared ~/.openclaw/workspace-$agent/team-shared
done
memory_get and file tools — no special API needed## Team Shared Memory Protocol
- Before significant tasks: read team-shared/TEAM-STATUS.md
- After completing tasks: update TEAM-STATUS.md with outcome
- For team decisions: append to TEAM-DECISIONS.md with date + rationale
- For project work: read/update team-shared/projects/<project>.md
- NEVER write private user information to team-shared files
memory_search only indexes the current agent's workspace. Symlinked dirs may not
be indexed. Use memory_get (targeted file read) for shared files — it always works.
OpenClaw's memory is file-based Markdown with semantic search.
Two standard layers (per official docs):
memory/YYYY-MM-DD.md) — append-only, day-to-day decisions and contextMEMORY.md) — curated durable facts, only loaded in private sessionsMemory tools available to agents:
memory_search — semantic recall over indexed snippets (hybrid BM25 + vector search)memory_get — targeted read of a specific file/line range> Critical correction: The article mentions GROUP_MEMORY.md as a standard file.
> This is NOT a standard OpenClaw workspace file. The official approach is:
> - MEMORY.md loads only in private/main sessions (never in groups)
> - Group chats have their own isolated session state
> - For cross-session context sharing, use a projects/ directory pattern
> with self-contained docs readable from any session
{
agents: {
defaults: {
compaction: {
reserveTokensFloor: 20000,
memoryFlush: {
enabled: true,
softThresholdTokens: 4000,
},
},
memorySearch: {
enabled: true,
// Auto-selects: local → OpenAI → Gemini → BM25 fallback
},
},
},
}
bootstrapMaxChars: 20000 per file, bootstrapTotalMaxChars: 150000 total{
agents: {
list: [
{
id: "planner",
model: { primary: "anthropic/claude-sonnet-4-20250514" },
},
{
id: "coder",
model: { primary: "anthropic/claude-sonnet-4-20250514" },
},
],
},
}
Each agent can have its own tool allow/deny list:
{
id: "coder",
tools: {
allow: ["exec", "read", "write", "edit", "apply_patch", "browser"],
deny: ["cron"],
},
sandbox: {
mode: "all",
scope: "agent",
},
}
After collecting all information, generate:
openclaw.json — Complete configuration (see references/openclaw-team-example.json5 for full template)team-shared/ symlinks in every workspace# List all agents and their bindings
openclaw agents list --bindings
# Check channel connectivity
openclaw channels status --probe
# Validate configuration
openclaw doctor
# Restart gateway to apply changes
openclaw gateway restart
When guiding users, proactively correct these common misconceptions:
Multiple agents share the same server process and config file.
locations via absolute paths unless sandbox is explicitly enabled per-agent.
Actual tool access is controlled by agents.list[].tools.allow/deny in config.
ROLE-COLLAB-RULES.md, TEAM-RULEBOOK.md, GROUP_MEMORY.md → These are NOT standard OpenClaw files. Put collaboration rules in AGENTS.md
and SOUL.md which are loaded every session. Custom files won't auto-load.
sessions, never in group contexts. This is a privacy protection.
channel + accountId → agentId" → Partially correct butoversimplified. Bindings can match on channel, accountId, chatType, peer (kind + id),
and guild/team IDs. They are evaluated in order, first match wins.
use channel-wide defaults and only add specific bindings for exceptions.
agents can't do reply-back ping-pong via sessions_send. They can still use
sessions_spawn for sub-agent tasks, and the orchestrator can still @-mention
others in group chats.
Discord is convenient because each bot has visible identity and @mention is natural.
Feishu, Slack, and others support similar patterns.
From docs.openclaw.ai/concepts/agent-workspace:
AGENTS.md — Operating instructions (loaded every session)SOUL.md — Persona, tone, boundaries (loaded every session)USER.md — User profile (loaded every session)IDENTITY.md — Agent name/emoji (created during bootstrap)TOOLS.md — Tool notes, guidance only (loaded every session)HEARTBEAT.md — Heartbeat checklist (optional)BOOT.md — Startup checklist (optional)BOOTSTRAP.md — First-run ritual (deleted after completion)memory/YYYY-MM-DD*.md — Daily memory logsMEMORY.md — Long-term memory (private sessions only)skills/ — Workspace-specific skillsFor the complete multi-agent reference, read:
references/architecture-corrections.md — Common misconceptions and correctionsreferences/openclaw-team-example.json5 — Full example configuration file共 1 个版本