liveBook · Manning

What you will learn in Agent Design Patterns

Elements, components, and architecture

by Peter Belcak · Manning Early Access Program (MEAP)

Chapter by chapter

Chapter 1: When and why to use agent design patterns

This introduction frames agents as software that makes imperfect AI models more reliable and introduces agent design patterns as reusable solutions to common agent-design challenges.

1.1 Why build agents? · 1.1.1 What is an agent? · 1.1.2 Why do we design agents? · 1.2 AI’s problems already have solutions · 1.2.1 What can we do with ADPs? · 1.2.2 Using ADPs can pay off in multiple ways · 1.3 Summary

What you learn in chapter 1 →

Chapter 2: Working with ADPs: Building a mortgage advisor tool

This introduction frames a reliable mortgage-advisor agent as a case study and outlines its information-gathering, analysis, reporting, and compliance workflow using agent design patterns.

2.1 Agent Flow Diagrams · 2.2 Runtime and orchestration · 2.3 Gathering information with the Interlocutor · 2.4 Dispatching a team of analysts to produce advice · 2.4.1 Mortgage analysts as children of the ReAct abstraction · 2.4.2 Bundling analysts into a supervised team · 2.5 The report-writing errand · 2.6 Ensuring compliance with guardrails · 2.7 Spotting the refinement loop · 2.8 Summary

What you learn in chapter 2 →

Chapter 3: Errand: Breaking complex workflows into units

This introduction frames Errand as a pattern for decomposing complex agent workflows into small intelligent pipelines that control context, improve maintainability, and enable parallel execution.

3.1 The pain point: Limits on context length · 3.2 How the Errand pattern works · 3.2.1 Tradeoffs · 3.2.2 When and where to use Errand · 3.3 Errand pattern variants · 3.3.1 Persona errands · 3.3.2 Reflection errands · 3.3.3 Compaction errands · 3.3.4 Structured extraction errands · 3.3.5 Editing errands · 3.4 Applying the Errand pattern: Use-case examples · 3.4.1 Speaker stance identification errand · 3.4.2 Call summarization errand · 3.5 Summary

What you learn in chapter 3 →

Chapter 4: Guardrail: A gating mechanism to boost reliability

This chapter introduces Guardrail as a pattern that uses specialized gating models to make agentic systems safer, more reliable, and more trustworthy.

4.1 The pain point: Unsafe or inappropriate output · 4.2 How the Guardrail pattern works · 4.2.1 Tradeoffs · 4.2.2 When and where to use Guardrail · 4.2.3 How Guardrail works with other patterns · 4.3 Guardrail pattern variants · 4.3.1 Sequential and parallel guardrails · 4.3.2 Buffered and stream guardrails · 4.3.3 Resampling guardrails · 4.4 Applying the Guardrail pattern: Example use cases · 4.4.1 Image generation guardrailing · 4.4.2 Internal guardrailing in ideation · 4.4.3 research agent tools · 4.5 Summary

What you learn in chapter 4 →

Chapter 5: Resampler: Reliability through repeated sampling

This introduction frames stochastic model output as a reliability risk at code–AI interfaces and introduces Resampler as a retry-and-check loop that can both constrain and exploit variation.

5.1 The problem: Random, unreliable, constraint-violating outputs · 5.2 How the Resampler pattern works · 5.2.1 Tradeoffs · 5.2.2 When and where to use Resampler · 5.2.3 How Resampler works with other patterns · 5.3.1 Resampling guardrails · 5.3.2 Input-stochastic resamplers · 5.4.1 Regex-powered reasoning reliability resampler · 5.4.2 Style enforcement resampler · 5.4.3 Chemical reaction chain discovery · 5.5 Summary

What you learn in chapter 5 →

Chapter 6: Voter: Leveraging stochasticity for improved outputs

This introduction shows how the Voter pattern turns variable model outputs into a more robust answer and a signal of uncertainty.

6.1 To quickly summarize the above: By running an ensemble of probabilistic model instances on the same problem, one can arrive at a distribution of outcomes or results. This distribution can then be leveraged to explore the set of possible answers, find the most favored answer, or to estimate the confidence one should place in any given answer. This approach is captured by the Voter pattern. The pain point: Stochastic inference producing variable outputs · 6.2 How the Voter pattern works · 6.2.1 Tradeoffs · 6.2.2 Implementation sketch · 6.2.3 When and where to use the Voter pattern · 6.2.4 How Voter works with other patterns · 6.3.1 Committee · 6.3.2 Divergent Committee (“Loose Ensemble”) · 6.4.1 Simple test-time compute scaling (TTCS) of mathematical reasoning · 6.4.2 Committee of judges · 6.4.3 Automatic travel safety assessment · 6.5 Summary

What you learn in chapter 6 →

Chapter 7: Retriever: Returning more relevant results

Introduces the Retriever pattern as a way to search large information sources cheaply, then give an agent a small, relevant context for reasoning.

7.1 The pain point: · 7.2 How the Retriever pattern works · 7.2.1 Tradeoffs · 7.2.2 Implementation sketch · 7.2.3 When and where to use Retriever · 7.2.4 How Retriever works with other patterns · 7.3 Retriever pattern variants · 7.3.1 Resampling retriever · 7.4 Illustrative Applying the Retriever pattern: use-case examples · 7.4.1 Context-aware assistant · 7.4.2 Hybrid RAG for technical support · 7.4.3 Dynamic few-shot exemplar selection · 7.4.4 Semantic tool selection · 7.5 Summary

What you learn in chapter 7 →

Chapter 8: Decompose-Process-Recompose: Handling large inputs with accuracy

This introduction explains why large inputs degrade model performance and how Decompose-Process-Recompose (DPR) produces one reliable answer by analyzing smaller fragments and combining the results.

8.1 The pain point: Large inputs creating inaccurate, unreliable, and fragmented output · 8.2 How the DPR pattern works · 8.2.1 Tradeoffs · 8.2.2 Implementation sketch · 8.2.3 When and where to use DPR · 8.2.4 How DPR works with other patterns · 8.3 DPR pattern Variants · 8.3.1 Decompose-Voter · 8.3.2 Decompose-Retriever · 8.3.3 Retriever-Process-Recompose · 8.4 DPR in action: Use-case examples · 8.4.1 Map-reduce document summarization · 8.4.2 Multi-modal content extraction · 8.4.3 Smoothened sequential translation · 8.5 Summary

What you learn in chapter 8 →

Chapter 9: Router: Classifying and dispatching

The introduction explains why a single general-purpose agent can struggle with specialized tasks and presents Router as a unified interface that classifies requests and dispatches them to suitable specialists.

9.1 The pain point: Too many specialized components to choose from · 9.2 How the Router pattern works · 9.2.1 Tradeoffs · 9.2.2 Implementation sketch · 9.2.3 When and where to use Router · 9.2.4 How Router works with other patterns · 9.3.1 Ensemble router · 9.3.2 Multi-layered router · 9.3.3 Proximity router · 9.4.1 Specialized jurisdiction-aware tax advisor · 9.4.2 Complexity-driven inference budget optimizer · 9.4.3 Ensemble-based medical symptom triage · 9.5 Summary

What you learn in chapter 9 →

Concepts explained in this book

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.