liveBook · Manning

Chapter 4: Architecting and building multi-agent systems

What you will learn in chapter 4 of AI Agents in Action, Second Edition

The chapter introduction explains why multi-agent design shifted from simply adding agents toward structuring their roles, while noting the tradeoff between single-agent simplicity and capability.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduction explains why multi-agent design shifted from simply adding agents toward structuring their roles, while noting the tradeoff between single-agent simplicity and capability.

Key terms: unconstrained loops, role-based teams, defined responsibilities, communication channels, single-agent systems, multi-agent coordination, tool use, reasoning and planning

4.1 Architecting multi-agent systems

This section introduces three multi-agent architecture patterns and shows how decision-making, control, and communication distinguish them.

Key terms: decision-making, control, context, communication, common context, orchestrator, context bloat, flow pattern, orchestrator pattern, collaboration pattern

4.1.1 Decision-making and control patterns

This section compares where decisions and control reside in three multi-agent patterns and offers a rule of thumb for choosing among them.

Key terms: agent flow, agent orchestration, manager-worker pattern, decision-making, control, DM/Control/Communication, delegation patterns, flow pattern

4.1.2 Communicating with shared memory, message passing, and MCP

The section explains why multi-agent systems should limit shared context and compares ways agents can communicate.

Key terms: shared context, selection accuracy, context dilution, lost in the middle, research orchestrator, research subagents, synthesis subagent, communication boundary, rubric, output schema

4.1.3 Channeling multi-agent coordination strategies

This section explains how to choose and combine multi-agent coordination patterns while balancing agent autonomy against the control a reliable system needs.

Key terms: agency, constraint, flow pattern, human-in-the-loop checkpoints, sequential pipeline, agent-to-agent pipeline, parallel flow, output schema, retry-with-backoff, hierarchical coordination

4.2 Balancing agents with agentic flows

Introduces agent flows as a way to make an agent’s actions easier to break down and understand, even when a single agent is otherwise preferred.

Key terms: single agent, monolithic agent, agent flow

4.2.1 Transforming agents to agent flows

This section explains when and why to turn a single agent into a flow of specialized agents, focusing on overload, tool selection, and per-call cost.

Key terms: single agent, agent-to-agent flow, specialized roles, responsibilities, overload, attention overload, tool descriptions, selection accuracy, cost/latency, context

4.2.2 Building an agent-to-agent flow

This section explains how to turn a single agent into an agent-to-agent flow by assigning specialized roles and tools to separate agents.

Key terms: agent-to-agent flows, prompt chaining, tool use, roles, specializing agents, ownership, MCP server, agent flow, MCP tools, deterministic

4.2.3 Agency and decision-making in agent flows

This section shows how to make an agent-to-agent flow more predictable by moving a decision into code, constraining research output, and passing focused inputs between agents.

Key terms: agency, deterministic, decision point, guardrail, ResearchSourcesModel, structured output, constrained list of strings, search sources, static string, thinking agent

4.3 Understanding handoffs in agent flows

This section compares three agent-flow communication patterns by how they share context, control interactions, and handle overhead or failures.

Key terms: conversational flow, conversation thread, context, overhead, pass-off communication system, typing, formatting, code complexity, enhanced agent handoff, guardrail

4.3.1 Agent-to-agent flow with handoffs

Explains how agent-to-agent handoffs transfer control without coded transitions, while making agents’ connections less explicit.

Key terms: handoff pattern, agent instructions, orchestration code, dependencies, agentic system

4.3.2 Visualizing agent flows

This section shows how to visualize agent handoffs and inspect their traces, then explains why agent naming matters as systems grow.

Key terms: handoff pattern, flow graph, draw_graph, Traces page, MCP servers, agent names, handoff routing, naming convention, agent registry, hardcoded agent imports

4.3.3 Monitoring the handoff

This section explains how to observe data at an agent handoff and why guardrails, rather than callbacks, should handle bad data.

Key terms: agent handoff, handoff wrapper function, callback function, callbacks, guardrails, handoff point

4.4 Validating agent flows with guardrails

This section explains why agent flows need guardrails and how to choose and layer validation methods according to risk, cost, and the kind of judgment required.

Key terms: guardrails, agent flows, agent-to-agent transfers, semantic circuit breaker, LLM-based guardrails, regex, schema validation, classifier models, code-based validation, semantic

4.4.1 Implementing input and output guardrails

This section explains why agent systems need input and output guardrails and shows how simple checks can flag invalid data.

Key terms: guardrails, input, output, agent to agent, input guardrail, output guardrail, tripwire flag, string comparisons, length checks

4.4.2 Using agents as guardrails

This section shows how an agent can replace simple input and output checks as a guardrail, while noting the added complexity and the Agents SDK’s handoff limitation.

Key terms: guardrail agent, validation rules, string matching, length checks, Agents SDK, guardrails, handoffs, agent-to-agent communication

4.4.3 Adding guardrails for pass-off agent flows

This section explains how to protect agent handoffs with guardrails and bounded retries, then weighs orchestration against simpler agent flows.

Key terms: shape failure, context leakage, instruction injection, guardrails, high-stakes handoffs, pass-off agent flow, filesystem agent, retry mechanism, recovery and retry loops, exponential backoff with jitter

4.5 Exercises

Five exercises guide the reader through building a two-agent flow, adding a typed decision, switching to SDK handoffs, inspecting the agent graph, and protecting plans with an output guardrail and retries.

4.6 Summary

The section summarizes how to structure multi-agent flows and make their coordination, handoffs, and operation reliable.

Where this is used later

Concepts explained in this chapter

← Chapter 3: Actions with Model Context Protocol for AI agents Chapter 5: Agent reasoning and planning →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.