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.
After this chapter you will be able to
- Agent reliability through task control. Explain how narrowing a task, providing thorough relevant prompts and high-quality data, and using code to detect and remove anomalous outputs can make an AI model's work more reliable. State that software applying these controls is what the section calls an AI agent.
- Recurring agent design patterns. Describe agent design patterns as recurring ways that agents tame imperfect AI models despite differing tasks. Explain that the book classifies, names, and describes these patterns to expose common engineering challenges and their solutions.
- Agent debate and framing questions. Describe the conflicting views of AI agents and state the three questions the chapter raises: what an agent is, why people build agents, and what role agents may play in the software industry.
- AI agent definition. Explain what makes a software system an AI agent in this book: it critically relies on AI models to perform a chosen class of tasks that traditional software would often need significant human help to handle. Describe the typical interaction characteristics of agents, including flexible natural-language input, humanlike text or voice interaction, and iterative refinement through continued user interaction.
- Code and model agency. Describe agents as code–AI hybrids in which control over the next action can alternate between deterministic program code and AI-model outputs. Distinguish code agency, where currently executing code decides what happens next, from model agency, where a model output guides the next action, using the personal-assistant sequence as an example.
- Practical agent boundary. Distinguish the primacy-of-AI-agency view, which requires an AI model to control decision-making primarily, from indispensability-of-AI-capability, which treats AI as sufficient when it is essential to operation even under rigid code orchestration. State that the book adopts indispensability of AI capability and explain why reliability-critical agents may favor deterministic code orchestration while still using AI for situational understanding and adaptable behavior.
- Foundation model reliability risks. Explain why powerful generalist foundation models alone can be unsuitable in business contexts, citing unreliable behaviors such as hallucinated facts, faulty logic, and unsupervised harmful or off-task behavior.
- Disciplined agent reliability. Describe how agents improve reliability by narrowing AI responsibilities, supervising information-source selection, and imposing fixed, interpretable, goal-motivated processes where needed.
- Behavioral scope of ADPs. Explain what qualifies as an agent design pattern (ADP) in this book and distinguish it from broader software or infrastructure patterns. State that an ADP concerns agent-specific operations and improves an important agent quality.
- ADP instantiation and modularity. Describe how an ADP affects an agent only when it is instantiated and applied, and explain the book's view of ADPs as abstract modules that can be inserted largely independently into an existing design. Include the functional and behavioral-guarantee role of this modularity.
- Design and parameter separation. Explain how ADPs disentangle an agent's fixed design decisions from parameter-value decisions and from separate quality-specific decisions. Describe how this separation lets a designer tune performance without redesigning the agent.
- Targeted performance adjustments. Explain how increasing resampling attempts can reduce hallucinated quotations and changing the number of voting beams can change confidence-score granularity. Describe how a Skeptic can be added to catch known logical missteps in an extracting Persona's reasoning traces with minimal design change.
- Predictive performance dimensions. Describe how this book uses performance to mean predictive performance rather than computational inference efficiency, and explain its three major forms: capability, robustness, and reliability.
- Interpretability and alignment benefits. Explain that interpretability-oriented ADPs expose, log, parse, and communicate outcomes of agent routines, while alignment-oriented ADPs reduce misguided outputs or prevent safety incidents, including those encouraged by adversarial inputs.
Section by section
Introduction
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.
- Agent reliability through task control: Explain how narrowing a task, providing thorough relevant prompts and high-quality data, and using code to detect and remove anomalous outputs can make an AI model's work more reliable. State that software applying these controls is what the section calls an AI agent.
Why it matters: This explains why an agent is more than a single prompt sent to a model. - Recurring agent design patterns: Describe agent design patterns as recurring ways that agents tame imperfect AI models despite differing tasks. Explain that the book classifies, names, and describes these patterns to expose common engineering challenges and their solutions.
Why it matters: Named patterns let engineers recognize and reuse solutions instead of rediscovering them for every agent. - Composable ADP benefits: Describe ADPs as composable modules for building transparent, standardized, and automatically testable agentic applications. State that the book presents them to help readers design new agents, improve existing agents, and explain their designs.
Why it matters: Composability and shared design language can make agent systems easier to build, inspect, test, and communicate.
Key terms: AI agent, foundational models, output anomalies, high-quality data, agent design patterns, ADPs, patterns, composable modules, transparent, standardized
1.1 Why build agents?
This introductory section frames the debate around AI agents and motivates asking what agents are, why they are built, and what role they may have in software.
- Agent debate and framing questions: Describe the conflicting views of AI agents and state the three questions the chapter raises: what an agent is, why people build agents, and what role agents may play in the software industry.
Why it matters: These questions provide the frame for evaluating agents beyond either hype or dismissal.
Key terms: AI agents, agentic AI, large language models, SaaS
1.1.1 What is an agent?
This section defines AI agents, explains their code–AI hybrid control model, and positions the book’s practical definition against a stricter autonomy-based view.
- AI agent definition: Explain what makes a software system an AI agent in this book: it critically relies on AI models to perform a chosen class of tasks that traditional software would often need significant human help to handle. Describe the typical interaction characteristics of agents, including flexible natural-language input, humanlike text or voice interaction, and iterative refinement through continued user interaction.
Why it matters: This definition sets the boundary for which systems and design problems the book treats as agentic. - Code and model agency: Describe agents as code–AI hybrids in which control over the next action can alternate between deterministic program code and AI-model outputs. Distinguish code agency, where currently executing code decides what happens next, from model agency, where a model output guides the next action, using the personal-assistant sequence as an example.
Why it matters: Understanding who controls the next step is fundamental to reasoning about an agent’s behavior and reliability. - Practical agent boundary: Distinguish the primacy-of-AI-agency view, which requires an AI model to control decision-making primarily, from indispensability-of-AI-capability, which treats AI as sufficient when it is essential to operation even under rigid code orchestration. State that the book adopts indispensability of AI capability and explain why reliability-critical agents may favor deterministic code orchestration while still using AI for situational understanding and adaptable behavior.
Why it matters: This practical boundary includes reliable real-world agentic applications without requiring them to surrender high-level process control to fallible models. - Agent model diversity: State that agents can combine many kinds of AI models, not only LLMs and vision-language models, and identify examples such as small language models, scene classifiers, object detectors, image segmentation models, and action models. Describe the range of agent examples presented, including personal assistants, coding agents, deep research agents, and profession-specific specialized assistants.
Why it matters: Recognizing this breadth prevents treating agents as chatbots powered only by one kind of language model.
Key terms: AI agent, AI models, continued output refinement, repeated user interactions, code-AI hybrid, program control, code agency, model agency, speech-to-text model, LLM
1.1.2 Why do we design agents?
This section explains why agents are engineered around foundation models: to reduce unreliable behavior while adding practical capabilities, transparency, and sometimes lower cost.
- Foundation model reliability risks: Explain why powerful generalist foundation models alone can be unsuitable in business contexts, citing unreliable behaviors such as hallucinated facts, faulty logic, and unsupervised harmful or off-task behavior.
Why it matters: Recognizing these failure modes clarifies why an agent needs more than a capable underlying model. - Disciplined agent reliability: Describe how agents improve reliability by narrowing AI responsibilities, supervising information-source selection, and imposing fixed, interpretable, goal-motivated processes where needed.
Why it matters: A disciplined system can retain useful AI capabilities while reducing the chance of bad outcomes. - Agent utility and efficiency: Describe the added benefits agents can provide beyond a plain model: access to curated information and specialized tools, awareness of relevant context, greater interpretability, and sometimes lower cost through efficient resource access.
Why it matters: These benefits show that agents are not only safety wrappers but also a way to make AI more useful and economical.
Key terms: foundation models, LLMs, VLMs, world models, hallucinating, narrowing the AI's responsibilities, supervising the choice of information sources, fixed processes, interpretable processes, goal-motivated processes
1.2 AI’s problems already have solutions
This section defines agent design patterns as reusable behavioral abstractions and explains how they help developers compose, discuss, and revise agent designs.
- Behavioral scope of ADPs: Explain what qualifies as an agent design pattern (ADP) in this book and distinguish it from broader software or infrastructure patterns. State that an ADP concerns agent-specific operations and improves an important agent quality.
Why it matters: This scope helps you recognize which reusable design choices the book treats as agent design patterns. - ADP instantiation and modularity: Describe how an ADP affects an agent only when it is instantiated and applied, and explain the book's view of ADPs as abstract modules that can be inserted largely independently into an existing design. Include the functional and behavioral-guarantee role of this modularity.
Why it matters: Thinking of ADPs as composable modules makes it easier to add targeted behavior without redesigning an entire agent. - Design and communication benefits: Explain how knowing ADPs can simplify iterative agent design and provide a shared vocabulary for discussing design choices. Give examples from the section of matching a problem or need to patterns such as Resampler, Voter, Refiner, or Memory.
Why it matters: A shared pattern vocabulary lets a team discuss and adjust agent behavior more quickly and precisely.
Key terms: agent design pattern, ADP, behavioral patterns, instantiated, applied, introduced, implemented, abstract modules, functional LEGO bricks, Resampler
1.2.1 What can we do with ADPs?
This section shows how ADPs separate stable agent design from tunable performance parameters and allow targeted pattern additions to fix specific problems.
- Design and parameter separation: Explain how ADPs disentangle an agent's fixed design decisions from parameter-value decisions and from separate quality-specific decisions. Describe how this separation lets a designer tune performance without redesigning the agent.
Why it matters: This separation makes agents easier to tune and evolve without disturbing their overall structure. - Layered quote-extraction composition: Describe the example composition of a specialized extracting Persona, a Resampler, and a Voter for extracting verbatim quotes. Explain that the composition provides source-present candidate answers and reasoning-justified confidence scores.
Why it matters: The example illustrates how multiple patterns can combine to deliver distinct reliability and confidence properties. - Targeted performance adjustments: Explain how increasing resampling attempts can reduce hallucinated quotations and changing the number of voting beams can change confidence-score granularity. Describe how a Skeptic can be added to catch known logical missteps in an extracting Persona's reasoning traces with minimal design change.
Why it matters: ADPs let designers make surgical changes for a specific weakness instead of rebuilding an entire agent.
Key terms: ADPs, design decisions, parameter values, quality-specific design decisions, parameter tuning, Voter, Resampler, Persona, extracting Persona, voting beams
1.2.2 Using ADPs can pay off in multiple ways
This section explains how agent design patterns can improve agents through predictive performance, interpretability, alignment, and cost, and why specialized agent design is likely to remain valuable.
- Predictive performance dimensions: Describe how this book uses performance to mean predictive performance rather than computational inference efficiency, and explain its three major forms: capability, robustness, and reliability.
Why it matters: This distinction lets you evaluate whether a pattern makes an agent better at its job rather than merely cheaper or faster to run. - Performance measurement approaches: Explain how capability, robustness, and reliability are evaluated: capability on designed or user-collected data, robustness on synthetic variations seeded by capability data, and reliability by logging internal failures in tests or real use.
Why it matters: Different performance improvements need different evidence, so one benchmark score cannot show every kind of improvement. - Interpretability and alignment benefits: Explain that interpretability-oriented ADPs expose, log, parse, and communicate outcomes of agent routines, while alignment-oriented ADPs reduce misguided outputs or prevent safety incidents, including those encouraged by adversarial inputs.
Why it matters: Agents need to be understandable to their developers and safe for their users, not merely capable of producing outputs. - Agent-level cost accounting: Describe why the book treats inference efficiency as cost and evaluates an ADP's agent-level cost mainly through token use, standard query count, and sometimes approximate dollar charges.
Why it matters: This gives a practical way to compare pattern benefits against the usage charges that agent developers actually face. - Continued value of specialized agents: Summarize the arguments against agent replacement theory: frontier-model progress may not continue in dramatic leaps, local agents can offer confidentiality and proximity, specialized agents embody proprietary tested processes, and users often need more control and customization than broad models provide.
Why it matters: These arguments explain why deliberate agent design can remain worthwhile even as general frontier models improve.
Key terms: performance, predictive performance, inference performance, capability, robustness, reliability, benchmarking dataset, metric, accuracy, interpretability
1.3 Summary
This summary explains why agents and agent design patterns make AI systems more reliable, structured, adaptable, and likely to remain useful.
Where this is used later
- Runtime and orchestration (chapter 2) · Runtime and orchestration put controlled, iterative model calls into practice.
- Agent Flow Diagrams (chapter 2) · Agent Flow Diagrams provide a way to represent agent designs built from patterns.
- How the Errand pattern works (chapter 3) · The Errand pattern is presented as one named solution to a recurring agent problem.
- Mortgage analysts as children of the ReAct abstraction (chapter 2) · The ReAct abstraction involves model-directed actions within an implemented agent structure.
- How Guardrail works with other patterns (chapter 4) · Combining Guardrail with other patterns requires understanding where control and model outputs occur in a flow.
- Ensuring compliance with guardrails (chapter 2) · Compliance guardrails reflect the need to make reliability-critical agent behavior tractable.
- The pain point: Unsafe or inappropriate output (chapter 4) · Guardrails address unsafe or inappropriate outputs, a key reason not to leave all decisions to model agency.
- Image generation guardrailing (chapter 4) · Image-generation guardrailing applies the patterns beyond a text-only assistant setting.
Concepts explained in this chapter
- AI agentA software system that uses an AI model, together with prompts, data, and programmatic control, to perform tasks.
- reliabilityReliability is the degree to which a system consistently produces correct and dependable results under expected conditions.
- interpretabilityInterpretability is the extent to which an agent's internal routines and outcomes can be understood by a developer or user.
- costCost is the expenditure associated with operating an AI agent, summarized here primarily by resource usage or monetary charges.
- agentic applicationA software application whose operation relies on AI capabilities for essential functions while combining model-driven behavior with traditional software.
- ai agencyDecision-making authority exercised by an AI model over how a software system handles inputs and selects actions.
- code agencyThe form of agency in which currently executing program code determines what happens next.
- code orchestrationCode orchestration is the coordination of AI models and traditional software through a predetermined, rigid, and tractable program process.
- model agencyModel agency is the form of agency in which AI-model outputs guide the selection of the next action.
- ResamplerAn agent design pattern that repeats stochastic model attempts and assesses their outputs to find an acceptable result.
- VoterVoter is an agent design pattern that aggregates outputs from multiple invocations to provide a robust result or confidence information.
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.
