Overview

1 When and why to use agent design patterns

The chapter opens by showing a familiar failure mode of language models: even with careful prompting, they can ignore instructions, wander off-task, or produce incomplete results. The practical response is not simply to ask the model harder, but to narrow the task, supervise it more closely, and add code that can detect problems and steer the process. From this perspective, an AI agent is software that combines AI models with structured control logic so the system can reliably complete a chosen class of tasks.

Agents are presented as code-model hybrids in which decision-making shifts between deterministic software and model-driven behavior. The chapter explains that while models provide flexible understanding, generation, and planning, they are also unreliable on their own, so agents are built to constrain that freedom where necessary. This can improve utility, reliability, interpretability, and sometimes cost, because the system can be designed to use curated data, specialized tools, fixed workflows, and repeated checks instead of depending entirely on open-ended model reasoning.

The chapter also introduces agent design patterns as reusable behavioral modules that capture common solutions to recurring engineering problems in agent design. These patterns help standardize how agents are built, make design choices easier to explain, and separate structural decisions from parameter tuning. By treating patterns as composable building blocks, the book aims to support the creation of more capable, robust, and testable agentic systems while offering a practical framework for improving existing ones.

Summary

  • The widespread challenges of AI models, specifically their notorious unreliability and tendency to disregard instructions, led to the development of AI agents, which can enable autonomous, multi-step workflows that incorporate planning, tool usage, and self-correction. By integrating AI into structured, transparent processes, agents deliver increased utility, reliability, and interpretability compared to direct model usage.
  • Agent design patterns (ADPs) are recurring behavioral abstractions that make AI models more useful and reliable within agentic systems. ADPs address common design challenges, enabling systematic improvements in agent capability, robustness, reliability, interpretability, alignment, and cost.
  • By applying these patterns, agent designers can disentangle complex quality concerns and make targeted enhancements to their agents. The ADPs in this book are common functional blocks for building agents that deliver these qualities. ADPs also help designers standardize approaches and quickly adapt agents to specific constraints.
  • Despite speculation that agents will become obsolete, several factors—including access to private information sources, process-based design advantages, and user preference for observable, easily controlled systems—suggest that agents will remain relevant.

FAQ

What is an AI agent in the context of this chapter?An AI agent is a software system whose core functionality depends critically on AI models and that performs a chosen class of tasks, often tasks that traditional software cannot handle well without significant human input. It typically combines flexible user interaction, repeated refinement, and model-driven reasoning with code that orchestrates the overall process.
Why do people build agents instead of using foundation models directly?People build agents to make AI systems more useful, reliable, and controllable. By narrowing the task, curating inputs, supervising tool use, and imposing fixed processes where needed, agents can reduce model mistakes while still benefiting from the power of foundation models.
What problems with language models motivate the use of agents?Foundation models, especially LLMs, can hallucinate facts, ignore instructions, go off on tangents, and behave unpredictably if left unsupervised. Agents are designed to constrain these weaknesses through code, better prompts, selective tool use, and output checking.
How do agents improve reliability?Agents improve reliability by limiting what the model is responsible for, supervising the choice of information sources, and using deterministic code to enforce a predictable process. They can also detect and handle internal failures, such as invalid model outputs or failed tool calls.
What is meant by code agency and model agency?Code agency refers to moments when program logic decides what happens next, while model agency refers to moments when the AI model’s output determines the next action. In many agents, control shifts back and forth between code and model depending on the stage of the task.
What are agent design patterns (ADPs)?ADPs are reusable behavioral patterns that capture common engineering decisions in agent design. They are like modular building blocks that can be instantiated within an agent to improve qualities such as capability, reliability, robustness, or interpretability.
How do ADPs help simplify agent development?ADPs give developers standardized modules they can combine, adjust, and explain more easily. Instead of redesigning an agent from scratch, developers can apply known patterns to solve recurring problems such as bad output formats, low confidence, or flawed reasoning.
What kinds of benefits can ADPs provide?ADPs can improve performance, interpretability, alignment, and cost. They may help agents handle more input types, better withstand noisy or unusual inputs, explain their behavior more clearly, reduce harmful outputs, and avoid unnecessary computational expense.
How are capability, robustness, and reliability different?Capability means the agent can handle a new class of inputs or do more useful work. Robustness means the agent performs well even when inputs or task structure vary. Reliability means the agent’s internal process succeeds more consistently, with fewer technical failures like malformed outputs or failed searches.
Will agents become obsolete as frontier models improve?The chapter argues that agents are still likely to remain important. Specialized agents often rely on private processes, local or on-premises information, and close user control that frontier models alone cannot easily replace, and many users prefer constrained, practical systems over broader but less controllable models.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Agent Design Patterns ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Agent Design Patterns ebook for free