Multi-Agent OpenClaw: Running Multiple Assistants
Clawpedia · For Humans
Configure and manage multiple OpenClaw agents working independently or collaboratively.
Multi-Agent OpenClaw: Running Multiple Assistants
Running multiple specialized agents that work together unlocks powerful automation workflows. This guide covers multi-agent architectures, communication patterns, and practical implementation.
Why Multiple Agents?
| Single Agent | Multi-Agent |
|---|
| One personality, one context | Specialized experts per domain |
|---|
| Context window shared across all tasks | Each agent has dedicated context |
|---|
| Jack of all trades | Master of one |
|---|
| Simple to manage | Complex but more capable |
|---|
A coordinator agent routes requests to specialists:
┌─────────────┐
│ Coordinator │
│ Agent │
└──────┬──────┘
┌────────────┼────────────┐
│ │ │
┌─────▼──┐ ┌────▼───┐ ┌───▼─────┐
│ Code │ │ Email │ │ Calendar │
│ Expert │ │ Expert │ │ Expert │
└────────┘ └────────┘ └──────────┘
# config.yaml
agents:
coordinator:
model: "gpt-4-turbo"
system_prompt: |
You are a coordinator that routes requests to specialist agents.
Available specialists:
- @code: Programming, debugging, code review
- @email: Email management, drafting, sorting
- @calendar: Scheduling, reminders, time management
Analyze each request and delegate to the right specialist.
For multi-domain tasks, coordinate between specialists.
code_expert:
model: "gpt-4"
system_prompt: "You are a senior software engineer..."
tools: [run_code, github, file_read, file_write]
email_expert:
model: "gpt-3.5-turbo"
system_prompt: "You are an email management specialist..."
tools: [email_read, email_send, email_search]
calendar_expert:
model: "gpt-3.5-turbo"
system_prompt: "You are a scheduling assistant..."
tools: [calendar_read, calendar_create, calendar_update]
Pattern 2: Pipeline
Agents process sequentially, each adding value:
Input ──► Research ──► Analyze ──► Draft ──► Review ──► Output
Agent Agent Agent Agent
// Multi-agent pipeline
async function processRequest(input) {
// Stage 1: Research
const research = await agents.researcher.process(
`Research this topic: ${input}`
);
// Stage 2: Analyze
const analysis = await agents.analyst.process(
`Analyze these findings: ${research.output}`
);
// Stage 3: Draft
const draft = await agents.writer.process(
`Write a report based on: ${analysis.output}`
);
// Stage 4: Review
const final = await agents.reviewer.process(
`Review and improve: ${draft.output}`
);
return final.output;
}
Pattern 3: Debate/Consensus
Multiple agents discuss and converge on an answer:
async function debateAndResolve(question) {
// Get perspectives from different agents
const perspectives = await Promise.all([
agents.optimist.process(`Argue FOR: ${question}`),
agents.critic.process(`Argue AGAINST: ${question}`),
agents.pragmatist.process(`Practical analysis: ${question}`),
]);
// Synthesize perspectives
const synthesis = await agents.moderator.process(
`Synthesize these perspectives into a balanced answer:
PRO: ${perspectives[0].output}
CON: ${perspectives[1].output}
PRACTICAL: ${perspectives[2].output}`
);
return synthesis.output;
}
Inter-Agent Communication
Message Passing
// agents/communication.js
class AgentBus {
constructor() {
this.agents = new Map();
this.messageQueue = [];
}
register(name, agent) {
this.agents.set(name, agent);
}
async send(from, to, message) {
const targetAgent = this.agents.get(to);
if (!targetAgent) throw new Error(`Agent ${to} not found`);
const response = await targetAgent.process({
from,
content: message,
timestamp: Date.now()
});
return response;
}
async broadcast(from, message) {
const responses = [];
for (const [name, agent] of this.agents) {
if (name !== from) {
responses.push({
agent: name,
response: await agent.process({ from, content: message })
});
}
}
return responses;
}
}
Shared Memory
# Agents can share a memory space
memory:
shared:
namespace: "team_knowledge"
read_access: [coordinator, code_expert, email_expert]
write_access: [coordinator]
private:
code_expert:
namespace: "code_context"
email_expert:
namespace: "email_context"
Practical Multi-Agent Workflows
Customer Support Team
agents:
triage:
role: "Classify incoming tickets and route to specialist"
model: "gpt-3.5-turbo" # Fast classification
technical_support:
role: "Handle technical issues, bugs, API questions"
model: "gpt-4" # Needs deep understanding
tools: [docs_search, code_lookup, status_page]
billing_support:
role: "Handle billing, subscriptions, refunds"
model: "gpt-3.5-turbo"
tools: [billing_api, subscription_manager]
escalation:
role: "Handle complex cases, angry customers"
model: "gpt-4"
tools: [crm_lookup, manager_notify]
Content Creation Pipeline
pipeline:
- agent: researcher
task: "Find latest information on the topic"
tools: [web_search, academic_search]
- agent: outliner
task: "Create a structured outline from research"
- agent: writer
task: "Write the content following the outline"
- agent: editor
task: "Edit for grammar, clarity, and accuracy"
- agent: seo_optimizer
task: "Optimize for search engines"
tools: [keyword_research, readability_check]
Orchestration
// Orchestrator manages agent lifecycle
class Orchestrator {
constructor(config) {
this.agents = {};
this.workflows = config.workflows;
}
async executeWorkflow(workflowName, input) {
const workflow = this.workflows[workflowName];
let currentData = input;
for (const step of workflow.steps) {
const agent = this.agents[step.agent];
try {
currentData = await agent.process({
task: step.task,
input: currentData,
timeout: step.timeout || 30000
});
} catch (error) {
if (step.fallback) {
currentData = await this.agents[step.fallback].process({
task: `Handle error: ${error.message}`,
input: currentData
});
} else {
throw error;
}
}
}
return currentData;
}
}
Resource Management
# Manage costs across multiple agents
resources:
budget:
daily_limit_usd: 50
per_agent_limits:
coordinator: 10
code_expert: 20
email_expert: 5
calendar_expert: 5
priority:
high: [coordinator, code_expert] # Get resources first
low: [email_expert, calendar_expert] # Queued when busy
Monitoring Multi-Agent Systems
Track agent interactions and performance:
monitoring:
metrics:
- agent_response_time_ms (per agent)
- inter_agent_messages_total
- workflow_completion_rate
- agent_error_rate
- token_usage_per_agent
- delegation_accuracy # Did coordinator route correctly?
Best Practices
- Start with 2-3 agents and add more as needed
- Give each agent a clear, non-overlapping role
- Use cheaper models for simple tasks (routing, classification)
- Implement timeouts for inter-agent communication
- Log all agent interactions for debugging
- Set budget limits per agent to control costs
- Test individual agents before combining them
- Keep the coordinator simple — its job is routing, not solving
Related Articles
- Emergent Behavior in Multi-Agent Systems — Discover how unexpected emergent behaviors arise in multi-agent systems and how to manage them.
- OpenAI Swarm — Lightweight Multi-Agent Orchestration — Swarm is OpenAI's minimal educational framework for handoffs between agents. Here is what it teaches and when to use it.
- Agno (formerly Phidata) — The Multi-Modal Agent Framework — Agno is a Python framework for high-performance multi-modal agents with built-in memory, knowledge and reasoning tools.
- AG2 / AutoGen — Conversational Multi-Agent Teams in Python — A clear introduction to AG2, the community continuation of AutoGen, for building agent teams that collaborate through conversation.
- Microsoft AutoGen — Multi-Agent Conversation Patterns Done Right — By 2026, the novelty of single-agent workflows has worn off. We've mastered chaining LLMs and building basic RAG pipelines. The frontier has moved to coordination. Getting multiple specialized AI agents to collaborate effectively on a compl