liveBook · Manning

What you will learn in Designing AI Agents

Principles, patterns, and best practices

by Jia Huang · Manning Early Access Program (MEAP)

Chapter by chapter

Chapter 1: The agent paradigm shift

The chapter introduction uses a coding-agent failure to explain why model-directed decisions require agent design patterns, while connecting those patterns to established engineering practice.

1.1 What exactly is an agent? · 1.2 From fixed control flow to model-directed control · 1.2.1 What breaks and why · 1.2.2 Uncertainties of agent systems · 1.3 What makes agent patterns fundamentally different · 1.3.1 What this changes for developers · 1.4 Designing agents through cognitive functions · 1.4.1 Argus reviews a pull request · 1.4.2 How this book turns design choices into evidence · 1.5 Summary · 1.6 References

What you learn in chapter 1 →

Chapter 2: Turn a task into an agent architecture

The introduction frames agent architecture as a set of choices driven by a business task and its constraints, rather than by a preferred pattern.

2.1 Choose the capabilities the task requires · 2.1.1 The agent capability stack · 2.1.2 Design the cognitive engine: The Perception-Reasoning-Action loop · 2.2 Turn capabilities into a system architecture · 2.2.1 How information flows through cognitive modules · 2.2.2 Runtime virtual machine · 2.2.3 The external world boundary · 2.2.4 How production systems instantiate the architecture · 2.3 Use the two-axis map to compare pattern choices · 2.3.1 The execution topology axis · 2.3.2 Why you need both dimensions · 2.3.3 The complete pattern map · 2.3.4 Scope and limitations of the map · 2.3.5 The pattern selection card · 2.3.6 How to read the rest of this book · 2.4 Decide when to scale beyond one agent · 2.4.1 Start with the single-agent default · 2.4.2 Scale only after hitting a structural wall · 2.4.3 What multi-agent costs you · 2.5 Set trust boundaries before granting autonomy · 2.6 Apply the decisions: The Argus skeleton · 2.6.1 The PRA loop in 50 lines · 2.6.2 Try it yourself · 2.6.3 The same pattern, different frameworks · 2.7 Summary · 2.8 References

What you learn in chapter 2 →

Chapter 3: Perception: What your agent sees determines what it does

The chapter introduction shows why an agent can fail despite having the right evidence: perception depends on how useful information is selected and presented, not merely on how much context is supplied.

3.1 The context window as a treatment budget · 3.1.1 How attention varies by position · 3.1.2 The three-way squeeze · 3.1.3 How production agents solve this · 3.1.4 Measuring perception quality · 3.2 Pattern: Context triage · 3.2.1 The emergency room · 3.2.2 The four tiers · 3.2.3 Context triage in Claude Code · 3.2.4 Building it · 3.2.5 When it breaks · 3.3 Pattern: Semantic compaction · 3.3.1 The moment the window fills · 3.3.2 Three levels of compression · 3.3.3 Protect decision-critical evidence · 3.3.4 Building it · 3.3.5 When it breaks · 3.4 Pattern: Progressive discovery · 3.4.1 From an entry point to working context · 3.4.2 Forage, then focus, then deepen · 3.4.3 The production spectrum · 3.4.4 Building it · 3.4.5 The progressive disclosure connection · 3.4.6 When it breaks · 3.5 Pattern: Multi-modal fusion · 3.5.1 When text is not enough · 3.5.2 The representation decision · 3.5.3 Building it · 3.5.4 When it breaks · 3.6 Putting it all together: The perception pipeline · 3.6.1 Claude Code's perception cycle in action · 3.7 Upgrading Argus: From blind reviewer to context-aware analyst · 3.8 Summary · 3.9 References

What you learn in chapter 3 →

Chapter 4: Memory: What your agent remembers shapes what it becomes

The introduction defines agent memory as a policy for carrying information across boundaries, using a decision ledger to show why stored history must be separated from current authority.

4.1 What is memory? State, persistence, and knowledge across sessions · 4.1.1 The memory hierarchy analogy · 4.1.2 The memory lifecycle · 4.1.3 How production agents handle memory today · 4.1.4 Measuring memory quality · 4.2 Pattern: Hierarchical Retention · 4.2.1 Three tiers and the eviction question · 4.2.2 In production: Claude Code's scoped memory sources · 4.2.3 Building it · 4.2.4 Before and after: What eviction looks like · 4.2.5 Argus integration · 4.2.6 When it breaks · 4.3 Pattern: RAG Pipeline · 4.3.1 Two governed paths: Compile and assemble · 4.3.2 In production: Claude Code's tool-based retrieval · 4.3.3 Building it · 4.3.4 When it breaks · 4.4 Pattern: Progress tracking · 4.4.1 The checkpoint chain · 4.4.2 In Production: Three approaches compared · 4.4.3 Building it · 4.4.4 When it breaks · 4.5 Pattern: Failure journals · 4.5.1 Failure fact, candidate lesson, published lesson · 4.5.2 In production: Model-written notes as candidate memory · 4.5.3 Building it · 4.5.4 When it breaks · 4.6 Composing memory patterns · 4.7 Memory and collaboration: A boundary · 4.8 Argus checkpoint: What Argus can do now · 4.9 Summary · 4.10 References

What you learn in chapter 4 →

Chapter 5: Reasoning: How your agent decides what to do next

This introduction defines reasoning as producing an inspectable decision from clearly represented state and evidence, then frames how to choose an appropriate reasoning approach.

5.1 What is reasoning? From represented state to an inspectable decision · 5.1.1 Private reasoning, decision records, and execution traces · 5.1.2 How the reasoning landscape changed · 5.1.3 What remains an architectural decision · 5.1.4 The reasoning patterns at a glance · 5.1.5 Testing and observing reasoning · 5.2 Pattern: Chain-of-Thought · 5.2.1 Making the decision path explicit · 5.2.2 In production: Separate the decision record from the action trace · 5.2.3 Building it · 5.2.4 Argus integration · 5.2.5 When it breaks · 5.3 Pattern: Complexity-Based Routing · 5.3.1 Route on difficulty, override on consequence · 5.3.2 In production: Route the decision, not only the model · 5.3.3 Building it · 5.3.4 Argus integration · 5.3.5 When it breaks · 5.4 Pattern: Parallel Exploration · 5.4.1 A concrete branch decision: Independence before concurrency · 5.4.2 Branching, scoring, and pruning · 5.4.3 Building it · 5.4.4 When it breaks · 5.5 Pattern: Iterative Hypothesis Testing · 5.5.1 The hypothesis-experiment loop · 5.5.2 In Production: How coding agents actually debug · 5.5.3 Building it · 5.5.4 Argus integration · 5.5.5 When it breaks · 5.6 Composing reasoning patterns around the decision · 5.7 Reasoning branches and collaboration · 5.8 Argus checkpoint: What the agent can do now · 5.9 Summary · 5.10 References

What you learn in chapter 5 →

Chapter 6: Action: How your agent acts is where strategy meets consequences

The introduction shows why a state-changing agent action must be judged by its bounded, verified real-world effect rather than by a successful tool response.

6.1 What is action? · 6.1.1 Success has layers · 6.1.2 The action gap · 6.1.3 Risk follows the effect · 6.1.4 Four ways to constrain action · 6.2 Pattern: Prompt Chaining · 6.2.1 The seam is the design surface · 6.2.2 Build artifacts before retries · 6.2.3 Retry only when something changes · 6.2.4 When Prompt Chaining breaks · 6.3 Pattern: Tool Dispatch · 6.3.1 Eligibility comes before selection · 6.3.2 Reveal capability in layers · 6.3.3 Build the executable surface · 6.3.4 When Tool Dispatch breaks · 6.4 Pattern: Plan-and-Execute · 6.4.1 The interruption test · 6.4.2 Make the plan an execution record · 6.4.3 Persist before asking the model to remember · 6.4.4 Recover effects before retrying calls · 6.4.5 Keep replanning local · 6.4.6 When Plan-and-Execute breaks · 6.5 Pattern: Guardrail Sandwich · 6.5.1 Return to the payroll result · 6.5.2 Admission, containment, and verification · 6.5.3 Build a fail-closed guarded path · 6.5.4 Verify the effect, not the story · 6.5.5 When the Guardrail Sandwich breaks · 6.6 Composing action patterns · 6.7 Testing the Action boundary · 6.8 Argus checkpoint: Action · 6.9 Summary · 6.10 References

What you learn in chapter 6 →

Chapter 7: Reflection and evaluation: How your agent audits and learns from itself

The chapter introduction shows why useful fixes to individual agent failures need evaluation across runs to determine whether the system is improving.

7.1 What is reflection? · 7.1.1 Why another pass is not enough · 7.2 Pattern: Generator-Critic · 7.2.1 One artifact, a different line of inquiry · 7.2.2 Design the Critic before adding iterations · 7.2.3 Building Generator-Critic · 7.2.4 When Generator-Critic breaks · 7.3 Pattern: Self-Heal Loop · 7.3.1 Recovery requires permission and responsibility · 7.3.2 The fail-diagnose-fix-verify loop · 7.3.3 Building Self-Heal Loop · 7.3.4 When Self-Heal Loop breaks · 7.4 Pattern: Skill Package · 7.4.1 A successful run creates a candidate · 7.4.2 One active Skill or conditional coexistence · 7.4.3 Route in layers · 7.4.4 Building Skill Package · 7.4.5 Maintain the library from operating evidence · 7.4.6 When Skill Package breaks · 7.5 Pattern: Experience Replay · 7.5.1 From an execution trace to a replayable lesson · 7.5.2 Feedback latency changes the admission test · 7.5.3 Record, admit, and recall · 7.5.4 Building Experience Replay · 7.5.5 When Experience Replay breaks · 7.6 Composing reflection patterns · 7.6.1 A current-task coordinator · 7.7 Evaluation belongs beside the change · 7.7.1 Build and protect the evaluation set · 7.8 Argus checkpoint: Reflection · 7.9 Summary · 7.10 References

What you learn in chapter 7 →

Chapter 8: Collaboration: When one agent is not enough

This introduction explains why collaboration helps when work can be divided, but adds costs that a single agent may avoid.

8.1 What collaboration changes · 8.2 Pattern: Handoff Chain · 8.2.1 Walking through an airline-support handoff · 8.2.2 A chain in a coding agent · 8.2.3 When Handoff Chain breaks · 8.3 Pattern: Fan-Out/Gather · 8.3.1 When apparent parallelism collapses · 8.3.2 Gathering without hiding the minority · 8.3.3 Parallel work in coding agents · 8.3.4 When Fan-Out/Gather breaks · 8.4 Pattern: Adversarial Review · 8.4.1 Three mechanisms that look like review · 8.4.2 Evidence from code review systems · 8.4.3 Running a bounded review · 8.4.4 When Adversarial Review breaks · 8.5 Pattern: Hierarchical Delegation · 8.5.1 What the manager and workers need from each other · 8.5.2 Hierarchical delegation in coding agents · 8.5.3 When Hierarchical Delegation breaks · 8.6 Testing and observing collaboration · 8.7 Composing collaboration patterns · 8.8 The implementation layers: Where control lives · 8.8.1 Three communication channels · 8.8.2 MCP and A2A are the plumbing · 8.9 Argus checkpoint: Collaboration · 8.10 Summary · 8.11 References

What you learn in chapter 8 →

Chapter 9: Governance: Constraints that enable freedom

The introduction explains why agents with consequential capabilities need governance and how clear boundaries can make delegation possible.

9.1 What is governance? Autonomy without accountability is a liability · 9.1.1 The governance spectrum · 9.1.2 Constraints enable freedom · 9.2 Pattern: Approval Gate · 9.2.1 Risk classification and the approval ladder · 9.2.2 Classifying action risk · 9.2.3 In production: Claude Code's permission modes · 9.2.4 Approval is a contract across time · 9.2.5 Building it · 9.2.6 When it breaks · 9.3 Pattern: Blast Radius Control · 9.3.1 Nested containment: Sandbox inside sandbox · 9.3.2 Layer 1: Capability restriction (least privilege) · 9.3.3 Layer 2: Execution isolation (sandboxing) · 9.3.4 Layer 3: Damage limitation · 9.3.5 Building it · 9.3.6 When it breaks · 9.4 Pattern: Progressive Commitment · 9.4.1 Earning trust through evidence · 9.4.2 Human sovereignty triggers · 9.4.3 Enforcing the current trust boundary · 9.4.4 A configured baseline and an earned trust level · 9.4.5 Building it · 9.4.6 When it breaks · 9.5 Pattern: Observability Harness · 9.5.1 Making the invisible visible · 9.5.2 The observability platform landscape · 9.5.3 What to observe: Metrics locate the problem; trajectories explain the path · 9.5.4 In production: Claude Code's observability stack · 9.5.5 Building it · 9.5.6 From evidence to improvement · 9.5.7 When it breaks · 9.6 Composing governance patterns · 9.7 Governance standards and the regulatory landscape · 9.7.1 The emerging governance ecosystem · 9.8 The Argus checkpoint: From code reviewer to governed system · 9.9 Summary · 9.10 References

What you learn in chapter 9 →

Chapter 10: Composing patterns: From map to terrain

Introduces pattern composition through an identifier handoff failure and the need to preserve continuity across consequential interfaces.

10.1 The evidence-driven six-step method · 10.1.1 Step 1: Bound completion · 10.1.2 Step 2: Run the smallest end-to-end baseline · 10.1.3 Step 3: Diagnose the binding deficit · 10.1.4 Step 4: Generate a small candidate set from the map · 10.1.5 Step 5: Specify consequential seams and define the experiment · 10.1.6 Step 6: Compare, decide, and reopen · 10.2 From pattern map to task terrain · 10.2.1 What the map can suggest · 10.2.2 What the terrain adds · 10.3 Model the complete task before selecting patterns · 10.3.1 The Task Completion Contract · 10.3.2 Draw the task spine and four continuity lines · 10.3.3 Locate the first deviation · 10.4 Make consequential interfaces explicit · 10.5 Do general-purpose agents make composition obsolete? · 10.6 The pattern selection card and evaluation receipt · 10.7 Selecting and connecting patterns for a salary-template task · 10.7.1 From observed failure to a candidate composition · 10.7.2 Reuse the mechanisms and supply the adapters · 10.7.3 Compare on the same workload before accepting · 10.8 Three field pressure tests · 10.8.1 GIS publication: An internal receipt is not the delivered result · 10.8.2 Learned routing: A valid training set can still misrepresent the workload · 10.8.3 DeerFlow guardrails: Authorize tool visibility and execution · 10.9 The composition record · 10.10 Argus as a composition self-test · 10.11 Summary · 10.12 References

What you learn in chapter 10 →

Chapter 11: Patterns in the wild: Three end-to-end case studies

The introduction illustrates evidence-driven architecture changes and the need for exact rules at agent system boundaries.

11.1 How to read an architecture case · 11.1.1 Five evidence classes · 11.1.2 Five architecture actions · 11.1.3 A zero-pattern control: When evidence says stop · 11.2 Case 1: From tool calls to a state-preserving execution chain · 11.2.1 Bound the completed task · 11.2.2 The smallest plausible baseline · 11.2.3 Failure one: Fixed steps drift · 11.2.4 Failure two: A valid argument loses its origin · 11.2.5 The trace localizes the handoff · 11.2.6 Three runtime structures for three kinds of truth · 11.2.7 Replay the task with the new ownership · 11.2.8 Evidence, decision, and reopen conditions · 11.3 Case 2: Deciding what a modeling agent should judge · 11.3.1 Start with the model behind the picture · 11.3.2 Separate the work at its dependencies · 11.3.3 Remove a review loop when the check can be computed · 11.3.4 Make the write and its result observable · 11.3.5 Reuse the division of responsibility · 11.4 Case 3: Operating evidence reopens the architecture · 11.4.1 One question crosses several boundaries · 11.4.2 Two operating mismatches changed the design · 11.4.3 Evals make drift visible · 11.4.4 Decision and reopen condition · 11.5 Cross-case analysis · 11.5.1 What the cases teach us · 11.6 A failure taxonomy for composed agents · 11.6.1 Layer 1: Problem and contract · 11.6.2 Layer 2: Task-pattern fit · 11.6.3 Layer 3: Pattern seam · 11.6.4 Layer 4: Parameter and model · 11.6.5 Layer 5: Workload and scale · 11.7 How much evidence is enough · 11.8 The architecture decision ledger · 11.9 Taking the patterns into your own work · 11.10 Summary · 11.11 References

What you learn in chapter 11 →

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.