Files
obsidian-vault/Summaries/OpenClaw Multi-Agent Workflows - 4 Levels Explained.md

106 lines
2.8 KiB
Markdown

# OpenClaw Multi-Agent Workflows - 4 Levels Explained
**Source:** https://www.reddit.com/r/openclaw/comments/1r2euvp/this_is_how_ive_learned_to_create_multiagent/
**Summarized:** 2026-02-23
---
## TL;DR
OpenClaw has **4 levels of multi-agent support** built-in, from simple persistent agents to full A2A Protocol orchestration. No Docker required for levels 1-3—they all run in a single gateway process.
---
## Level 1: Multiple Persistent Agents (Built-in)
Define isolated agents in config, each with their own workspace, system prompt, model, and tools:
```yaml
agents:
list:
- id: researcher
default: true
workspace: ~/.openclaw/workspace-research
- id: coder
workspace: ~/.openclaw/workspace-code
bindings:
- agentId: researcher
match: { channel: telegram, accountId: research-bot }
- agentId: coder
match: { channel: discord, guildId: "123456" }
```
Each agent has **full isolation**: separate session history, model config, tool permissions.
---
## Level 2: Agent-to-Agent Communication (Built-in)
Enable `tools.agentToAgent` for agents to talk via `sessions_send`:
```yaml
tools:
agentToAgent:
enabled: true
allow: ["researcher", "coder", "writer"]
```
- Ping-pong conversations (up to 5 turns by default)
- `sessions_spawn` for background sub-agents that report back
- Closest to "orchestrator delegates to specialist" pattern
---
## Level 3: Cross-Agent Delegation (3-Level Hierarchy)
Work around single-level limits:
```
Orchestrator (main agent)
├─ sessions_send → Specialist A (sibling main agent)
│ ├─ sessions_spawn → subagent A1
│ └─ sessions_spawn → subagent A2
└─ sessions_send → Specialist B (sibling main agent)
├─ sessions_spawn → subagent B1
└─ sessions_spawn → subagent B2
```
Config uses `subagents.allowAgents` for cross-agent spawning.
---
## Level 4: True Multi-Agent Orchestration (A2A Protocol)
For advanced use cases with intelligent routing, review, retries, synthesis:
- **a2a-adapter**: Wraps OpenClaw agents as A2A Protocol servers
- Mix-and-match: OpenClaw + CrewAI + LangChain + n8n
- Can run as local Python processes or remote agents
Example:
```python
from a2a_adapter import load_a2a_agent, serve_agent
adapter = await load_a2a_agent({
"adapter": "openclaw",
"agent_id": "researcher",
"thinking": "low",
"async_mode": True,
})
serve_agent(agent_card=agent_card, adapter=adapter, port=9001)
```
---
## Key Takeaways
| Level | Complexity | Setup |
|-------|-----------|-------|
| 1 | Low | Config only |
| 2 | Low-Medium | Config + enable tool |
| 3 | Medium | Config + cross-agent permissions |
| 4 | High | A2A Protocol + external orchestrator |
**Bottom line:** OpenClaw's built-in multi-agent (levels 1-3) requires only `~/.openclaw/config.yaml` changes—no additional infrastructure needed.