Overview
A single AI agent can write a function, fix a bug, or draft a test. But real software engineering is a team sport: someone gathers requirements, someone designs the architecture, someone writes the code, someone reviews it, and someone verifies that it works. Multi-agent software teams replicate this division of labor with specialized AI agents, each carrying a distinct role, system prompt, and tool set.
This chapter teaches you how to design, coordinate, and supervise these teams. You will learn how to define agent roles (product manager, architect, developer, tester, reviewer), connect them through workflow graphs (sequential, parallel, conditional), manage shared state and message passing, implement debate patterns for design decisions, and insert human approval gates at critical junctures. The result is a system where AI agents collaborate on software tasks from issue triage to pull request, with humans retaining control over high-stakes decisions.
Where Chapter 16 focused on a single agent operating at repository scale, this chapter scales from one agent to many. The coordination patterns you learn here reappear in Chapter 54 (multi-agent discovery systems), where the "team" is not building software but running scientific experiments. The MCP servers from Chapter 12 become the tools these agents call, and the context engineering techniques from Chapter 11 determine how much of the codebase each agent can see.
Prerequisites
You should have read Chapter 10: Prompting to Programming for the basics of tool calling and agent loops, Chapter 11: Context Engineering for how to feed relevant context to agents, and Chapter 12: Building MCP Servers for the protocol that agents use to interact with tools. Familiarity with directed graphs (from Chapter 3) helps for understanding workflow topologies.
Learning Outcomes
- Define specialized agent roles with distinct system prompts, tool sets, and output schemas for software engineering tasks.
- Construct workflow graphs (sequential, parallel, conditional, cyclic) that route tasks between agents.
- Implement shared state management and structured message passing between agents using typed channels.
- Design debate and critique patterns that improve code quality through adversarial agent interaction.
- Insert human approval gates at security-critical, cost-critical, and quality-critical decision points.
- Build multi-agent teams using OpenAI Agents SDK, LangGraph, AutoGen, and CrewAI.
- Integrate a complete multi-agent pipeline that takes a GitHub issue and produces a reviewed pull request.
Sections
17.1 Agent Roles and Workflows
Defining the five canonical software agent roles: product manager, architect, developer, tester, reviewer. Workflow graphs as directed graphs over agent nodes: sequential pipelines, parallel fan-out/fan-in, conditional branching, and cyclic refinement loops. Formalizing workflows with state machines and graph properties.
17.2 Coordination and Human Gates
Shared state and message passing: blackboard architectures, typed channels, and event-driven coordination. Debate and critique patterns for design review. Human-in-the-loop approval gates: when to block, what to surface, and how to design the approval interface. Trust calibration and progressive autonomy.
17.3 Building a Software Agent Team
Recipe: a complete multi-agent team that takes a GitHub issue and produces a reviewed pull request. Implementation with four frameworks (OpenAI Agents SDK, LangGraph, AutoGen, CrewAI). Testing, observability, and cost control for multi-agent pipelines. Integration with the Discovery Workbench.
Bibliography
Foundational Papers
Introduces the idea of LLM-powered agents assuming distinct software development roles (CEO, CTO, programmer, tester) and collaborating through natural language. The original multi-agent software team paper that inspired much of this chapter.
Formalizes multi-agent workflows using Standard Operating Procedures (SOPs) where each agent produces structured artifacts (PRDs, system designs, code). Demonstrates that structured outputs outperform free-form chat between agents.
Shows that having multiple LLM agents debate and critique each other's outputs improves accuracy on reasoning tasks. The theoretical foundation for the debate patterns in Section 17.2.
Tools & Frameworks
A lightweight Python framework for building multi-agent workflows with handoffs, guardrails, and tracing. Used in Section 17.3 for the sequential pipeline implementation.
A graph-based framework for building agent workflows as state machines with typed state, conditional edges, and persistence. The primary framework used in Section 17.3 for complex workflows.
Microsoft's framework for multi-agent conversations with support for human-in-the-loop patterns, code execution, and group chat. Demonstrates flexible conversation topologies beyond sequential pipelines.
A high-level framework that models agents as crew members with roles, goals, and backstories. Focuses on ease of use and hierarchical delegation patterns.
Architecture & Patterns
A comprehensive survey covering agent architectures, memory, planning, and multi-agent interaction. Provides the taxonomy used in Section 17.1 for classifying agent roles.
Analyzes collaboration patterns in multi-agent systems: cooperative, competitive, and mixed-motive. Useful background for understanding when debate helps and when it wastes tokens.
Models multi-agent workflows as computational graphs and optimizes the graph structure itself. Relevant to Section 17.1's discussion of workflow graph topologies and their properties.
Evaluation & Benchmarks
The standard benchmark for evaluating AI agents on real-world software engineering tasks. Multi-agent teams are evaluated against the same issues used in Section 17.3's recipe.
Demonstrates the importance of agent-computer interfaces for software engineering tasks. The single-agent baseline that multi-agent teams aim to surpass.