Chapter 11

Multi-Agent Collaboration

Making multiple Agents work like a team

Why Do We Need Multiple Agents?

A single Agent runs into several issues with complex tasks: • Limited context window — one Agent can only hold so much information • Tasks are too complex — multiple aspects need simultaneous attention (code, tests, docs) • Parallel processing — independent subtasks can run concurrently • Specialization — different subtasks may need different prompts and tool configurations Multi-Agent collaboration lets you decompose big tasks into smaller ones, delegating them to specialized Agents.

OpenHarness's Multi-Agent Architecture

OpenHarness implements multi-Agent collaboration through these components: 🤖 Agent Tool The main Agent launches sub-agents via the Agent tool. Each sub-agent has its own independent conversation context and toolset. 📨 SendMessage Tool Send messages to an already-running sub-agent, continuing a previous conversation. 👥 TeamRegistry The team registry manages all active sub-agents and their states. 📋 TaskManager The task manager coordinates sub-agent task assignment and lifecycle.

How to Launch Sub-Agents

System prompt — Agent tool description
1# How to use the Agent tool
2
3# Launch a sub-agent specialized in code search
4Agent(
5 description="Search for auth-related code",
6 prompt="Find all files and functions related to user authentication",
7 subagent_type="Explore" # Exploration agent
8)
9
10# Launch a planning sub-agent
11Agent(
12 description="Design refactoring plan",
13 prompt="Analyze the current auth module architecture and design a refactor plan",
14 subagent_type="Plan" # Planning agent
15)
16
17# Launch in the background (doesn't block the main Agent)
18Agent(
19 description="Run test suite",
20 prompt="Run all tests and report results",
21 run_in_background=True
22)

The main Agent can launch sub-agents like this:

Sub-Agent Types

OpenHarness predefines several sub-agent types: 🔍 Explore Agent Specialized for code search and exploration. Has search-related tools but no edit permissions. Fast and safe. 📐 Plan Agent Specialized for designing plans. Can search and read code but can't modify it. Ideal for planning before implementation. 🔧 General Purpose Agent A full-featured Agent with the complete toolset. For subtasks that require executing operations. Each type has a different toolset and permissions, ensuring sub-agents only do what they're supposed to.

Parallel vs Sequential

A core advantage of multi-Agent is parallel processing. For example: Sequential (slow): Search frontend code → Search backend code → Search test code Parallel (fast): Launch 3 Explore Agents simultaneously, each searching frontend, backend, and test code respectively The main Agent can use run_in_background=True to let sub-agents run in the background while it continues with other work. Sub-agents automatically notify the main Agent when they finish.
📌 Key Takeaway
Divide and Conquer, Each With Their Own Role
The core philosophy of multi-Agent collaboration is "divide and conquer." The main Agent handles understanding and coordination; sub-agents handle specific execution. Each sub-agent has an independent context and toolset, with no interference. This pattern lets Agent systems tackle tasks far beyond any single Agent's capabilities.
🧠 Check Your Understanding
Why not have a single Agent do everything alone?