Agentic AI for Engineers Architecting Goal-Driven Systems — Dhivya Nagasubramanian
Agentic AI for Engineers Architecting Goal-Driven Systems Dhivya Nagasubramanian
Agentic AI for Engineers: Architecting Goal-Driven Systems ISBN-13 (pbk): 979-8-8688-2360-2 ISBN-13 (electronic): 979-8-8688-2361-9 https://doi.org/10.1007/979-8-8688-2361-9 Copyright © 2026 by Dhivya Nagasubramanian This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Celestin Suresh John Desk Editor: James Markham Editorial Assistant: Gryffin Winkler Cover designed by eStudioCalamar Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza, New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a Delaware LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail booktranslations@springernature.com; for reprint, paperback, or audio rights, please e-mail bookpermissions@springernature.com. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub https://github.com/Apress/Agentic-AI-for-Engineers. For more detailed information, please visit https://www.apress.com/gp/services/source-code. If disposing of this product, please recycle the paper Dhivya Nagasubramanian Minneapolis, Minnesota
To my family, whose patience and belief made this book possible—and to every engineer who dares to build what doesn’t yet exist.
v Table of Contents About the Author ����������������������������������������������������������������������������������������������������xxi About the Technical Reviewer ������������������������������������������������������������������������������xxiii Acknowledgments �������������������������������������������������������������������������������������������������xxv Foreword �������������������������������������������������������������������������������������������������������������xxvii Introduction ����������������������������������������������������������������������������������������������������������xxix Part I: Artificial Intelligence-Foundation �������������������������������������������������������� 1 Chapter 1: Introduction: AI and Evolution of Agentic AI ������������������������������������������� 3 The Many Minds of AI—Exploring Its Key Branches ��������������������������������������������������������������������� 4 Machine Learning—The Learner of Patterns ������������������������������������������������������������������������������� 5 Supervised Learning: The Flashcard Learner �������������������������������������������������������������������������������� 6 Unsupervised Learning: The Curious Explorer ������������������������������������������������������������������������������ 7 Reinforcement Learning: The Trial- and-Error Learner ������������������������������������������������������������������ 8 Natural Language Processing—The Language Interpreter ���������������������������������������������������������� 9 Speech and Audio—Giving Voice to AI ���������������������������������������������������������������������������������������� 10 Computer Vision—The Eyes of AI ����������������������������������������������������������������������������������������������� 10 Deep Learning—The Architect of Complexity ����������������������������������������������������������������������������� 12 Why It Matters for Agentic AI������������������������������������������������������������������������������������������������������� 12 Transformers: A New Language for Machines ���������������������������������������������������������������������������� 13 Generative AI: Machines That Create ������������������������������������������������������������������������������������������ 13 Agentic AI—The Doers and Deciders ������������������������������������������������������������������������������������������ 14 The Shift: From Static to Strategic ���������������������������������������������������������������������������������������������� 14 The Agentic AI Engine: A Four-Step Intelligence Cycle ���������������������������������������������������������� 15 From Tools to Teammates ����������������������������������������������������������������������������������������������������������� 16 Engineering the Future ��������������������������������������������������������������������������������������������������������������� 16
vi Where Does Generative AI Fit in the Hierarchy of AI? ����������������������������������������������������������������� 17 The Parallel Path: A History of Automation ���������������������������������������������������������������������������������� 18 From Rules to Routines: The Early Days of Automation (2000 and Prior) ������������������������������������ 18 RPA: Software That Mimicked Us (Early 2000s) �������������������������������������������������������������������������� 18 Intelligent Automation: The Merge of Automation and AI (Mid-2010s–2020) ������������������������������ 19 Autonomy at Last: Enter Agentic AI (2023 and Beyond) �������������������������������������������������������������� 19 A Shift in Philosophy ������������������������������������������������������������������������������������������������������������������� 20 The Evolution of Agentic AI: From Concept to Reality ����������������������������������������������������������������� 20 Scenario �������������������������������������������������������������������������������������������������������������������������������������� 21 AI Agents—A Digital Coworker - Sneak Peek into Real-World Applications ������������������������������� 22 Key Takeaways ���������������������������������������������������������������������������������������������������������������������������� 23 Bibliography �������������������������������������������������������������������������������������������������������������������������������� 25 Chapter 2: Automation to Autonomy: A New Engineering Mindshift ���������������������� 27 AI Agents Leading to an Autonomous System Is a Progression �������������������������������������������������� 28 The Engineering Mindset for Automation: Rule- Based and Deterministic ���������������������������������� 29 Efficiency Through Explicit Logic ������������������������������������������������������������������������������������������������ 29 Reliability, Traceability, and Timing���������������������������������������������������������������������������������������������� 30 Real-World Examples ������������������������������������������������������������������������������������������������������������������ 30 The Common Thread ������������������������������������������������������������������������������������������������������������������� 31 Engineering Mindset for Autonomy ��������������������������������������������������������������������������������������������� 31 Autonomy As Goal-Directed Behavior ����������������������������������������������������������������������������������������� 32 Embracing Uncertainty As a Design Principle ����������������������������������������������������������������������������� 32 Automation vs� Autonomy: Two Mindsets, Same Problem ���������������������������������������������������������� 34 Example 1: Warehouse Inventory Robot �������������������������������������������������������������������������������� 34 Example 2: Retail Order Fulfillment ��������������������������������������������������������������������������������������� 35 Enabling Technologies Behind the Shift �������������������������������������������������������������������������������������� 36 Large Language Models and the Transformer Revolution ����������������������������������������������������� 36 Instruction Tuning: From Text Generation to Goal Following �������������������������������������������������� 37 Perception-Action Loops: Closing the Sense-Act Gap ����������������������������������������������������������� 37 Table of ConTenTs
vii Memory Systems: Enabling Continuity and Learning ������������������������������������������������������������ 38 Tool Use and Orchestration Frameworks ������������������������������������������������������������������������������� 38 The Convergence ������������������������������������������������������������������������������������������������������������������������ 38 More Than Just Building: The Responsibility of Agentic AI���������������������������������������������������������� 39 A Manifesto for Responsible Agentic AI Engineering ������������������������������������������������������������������ 40 Call to Action for Engineers ��������������������������������������������������������������������������������������������������������� 41 Choosing RPA vs� Agents by Control and Complexity ������������������������������������������������������������������ 42 Key Takeaways ���������������������������������������������������������������������������������������������������������������������������� 43 Bibliography �������������������������������������������������������������������������������������������������������������������������������� 46 Chapter 3: Transformer Models and LLM Architecture ������������������������������������������� 47 From Sequence Models to Transformers ������������������������������������������������������������������������������������ 47 Unlocking Flexible Cognition ������������������������������������������������������������������������������������������������������� 49 The Agentic Leap: Reasoning, Memory, Planning ������������������������������������������������������������������ 49 Timeline: From RNNs to Transformers to Agentic AI �������������������������������������������������������������� 50 What Makes Up a Transformer and Its Role in Agentic AI ������������������������������������������������������ 55 From Text to Tokens: How Machines Read ���������������������������������������������������������������������������� 58 Why Not Just Use Words? ������������������������������������������������������������������������������������������������������ 58 Why Not Just Use Characters? ���������������������������������������������������������������������������������������������� 59 The Solution: Subword Tokenization �������������������������������������������������������������������������������������� 59 The GPS of Language: How Embeddings Guide Transformers ����������������������������������������������� 59 Why Embeddings Matter ������������������������������������������������������������������������������������������������������� 60 Why Self-Attention and Positional Encoding Matter for Agentic AI ���������������������������������������� 61 Positional Encoding: Sequencing Without Recurrence ���������������������������������������������������������� 61 How Positional Encoding Works �������������������������������������������������������������������������������������������� 61 Different Architectures of Transformers for Different Purposes �������������������������������������������������� 62 Pretraining Strategies for LLMs ��������������������������������������������������������������������������������������������� 63 Scaling Laws and Emergence: When Bigger Becomes Smarter ������������������������������������������������� 64 The Model’s Memory Span: Understanding Context Windows ���������������������������������������������� 65 Pros and Cons of Bigger vs� Smaller Context Windows ��������������������������������������������������������� 66 Advantages of Bigger Context Windows �������������������������������������������������������������������������������� 66 Disadvantages of Bigger Context Windows ��������������������������������������������������������������������������� 67 Table of ConTenTs
viii Emergence: When Bigger Means Different, Not Just Better �������������������������������������������������� 67 Examples of Emergent Capabilities ��������������������������������������������������������������������������������������� 67 Why This Matters for Agentic AI �������������������������������������������������������������������������������������������������� 68 From Transformers to Cognitive Engines ������������������������������������������������������������������������������� 69 From Prediction to Simulation ����������������������������������������������������������������������������������������������� 69 Prompting As the Interface to Cognition �������������������������������������������������������������������������������� 70 Cognitive Engines in Action ��������������������������������������������������������������������������������������������������� 70 Agent Architectures Powered by LLMs ���������������������������������������������������������������������������������� 71 How Transformers Are Embedded in Agents ������������������������������������������������������������������������� 71 The Autonomy Loop: Observe ➤ Reflect ➤ Act �������������������������������������������������������������������� 72 Example: Calendar Scheduling Agent ������������������������������������������������������������������������������������ 74 Common Challenges of Large Language Models ������������������������������������������������������������������������ 74 Looking Ahead ���������������������������������������������������������������������������������������������������������������������������� 75 Key Takeaways ���������������������������������������������������������������������������������������������������������������������������� 76 Bibliography �������������������������������������������������������������������������������������������������������������������������������� 79 Chapter 4: The Agentic AI Fundamentals: Goals, Environments, Actions ��������������� 81 Let’s Get the Definitions Clear ����������������������������������������������������������������������������������������������������� 81 Agency Begins with Intent ����������������������������������������������������������������������������������������������������� 81 What Makes Up an Agentic AI System? �������������������������������������������������������������������������������������� 82 Defining and Structuring Goals: The Compass of Agents ������������������������������������������������������������ 83 What Is a Goal? (Tasks vs� Missions vs� Objectives) �������������������������������������������������������������� 83 Real-World Use Case ������������������������������������������������������������������������������������������������������������� 84 Static vs� Evolving Goals �������������������������������������������������������������������������������������������������������� 85 Hierarchical Goal Structures: From Macro to Micro �������������������������������������������������������������� 85 Reactive vs� Proactive Agents ����������������������������������������������������������������������������������������������� 87 Understanding Environments: Observability and Uncertainty ����������������������������������������������������� 87 Why Environment Understanding Matters ����������������������������������������������������������������������������� 88 Action: From Intent to Impact ������������������������������������������������������������������������������������������������������ 89 So, What Is Action in Agentic AI? ������������������������������������������������������������������������������������������� 90 So, What Exactly Is a Task?—The Small Steps Behind Big Missions ����������������������������������������� 91 “Beyond Language: How Tools Empower Agents” ���������������������������������������������������������������������� 92 Table of ConTenTs
ix The Tool Selection Process ���������������������������������������������������������������������������������������������������� 93 How LLMs Choose Tools �������������������������������������������������������������������������������������������������������� 94 Error Handling When Tools Fail: A Comprehensive Guide ������������������������������������������������������ 94 Failure Categories ����������������������������������������������������������������������������������������������������������������� 95 Tool Composition and Chaining ��������������������������������������������������������������������������������������������� 95 Custom Tool Creation ������������������������������������������������������������������������������������������������������������� 96 Loop Prevention and Recovery ���������������������������������������������������������������������������������������������� 97 Subgoal Conflict Resolution ��������������������������������������������������������������������������������������������������� 98 The Invisible Thread That Holds Everything Together ������������������������������������������������������������ 99 Why Memory Matters ������������������������������������������������������������������������������������������������������������������ 99 Agentic Memory Types with Business Examples ����������������������������������������������������������������� 100 How Agents Use Memory to Adapt �������������������������������������������������������������������������������������� 101 Design Considerations: What to Store and When����������������������������������������������������������������� 101 Beyond Everything, What Enables Agentic AI for What It Is?—The Reasoning ������������������������� 102 Coordination Between Agents ��������������������������������������������������������������������������������������������������� 104 Rule of Thumb: One Agent One Subgoal ������������������������������������������������������������������������������ 105 Stochastic Brains: Embracing Variability in LLMs ���������������������������������������������������������������� 105 Designing Guardrails for Agentic AI������������������������������������������������������������������������������������������� 106 Key Takeaways for Engineers ��������������������������������������������������������������������������������������������������� 108 Bibliography ������������������������������������������������������������������������������������������������������������������������������ 112 Part II: Building Blocks of Agentic Systems ����������������������������������������������� 113 Chapter 5: Architectural Design Patterns for Agentic Systems ���������������������������� 115 Two Levels of Agentic Design ��������������������������������������������������������������������������������������������������� 118 Patterns in Agents ��������������������������������������������������������������������������������������������������������������������� 118 The Single-Agent Loop: Minimalist Autonomy ��������������������������������������������������������������������� 118 The Planner–Executor–Reflector Pattern—“Think Ahead, then Execute�” �������������������������� 121 Tool-Augmented Reasoning Agents = Embedded Reasoning + External Action ����������������� 126 Example: ReAct + Tool Frameworks in Practice ������������������������������������������������������������������ 127 Example of Tool-Augmented Reasoning with RAG �������������������������������������������������������������� 128 Design Topologies in Agentic Architectures—How Multiple Agents Are Wired ������������������������� 129 Table of ConTenTs
x Sequential Example—Retail Support Agent Pipeline ���������������������������������������������������������� 130 Example of Hierarchical Topology—AI Newsletter �������������������������������������������������������������� 131 Example of Hybrid Topology—Universal Enterprise Assistant ��������������������������������������������� 132 Payroll: Structured Change Under Governance ������������������������������������������������������������������� 133 Health: Policy-Driven Precision ������������������������������������������������������������������������������������������� 134 Tech: Autonomous Service with Guardrails ������������������������������������������������������������������������� 134 Controller and Coordination Layer ��������������������������������������������������������������������������������������� 134 Concurrent/Parallel Multi-agent Pattern������������������������������������������������������������������������������ 135 Choosing Between Single Agent, PER, and Multi-agent Architectures ������������������������������������� 136 Decision Tree on Picking the Right Agentic Pattern ������������������������������������������������������������������ 138 Challenges and Considerations ������������������������������������������������������������������������������������������������� 138 Make Tools Contract First—and Enforce the Contract Both Ways ��������������������������������������� 138 Reduce Hallucination at the Two Choke Points: Tool Choice and Arguments ���������������������� 139 Put Guardrails Outside the Model—Least Privilege, Action Limits, and Approvals �������������� 139 Retries Should Be Purposeful: Classify, Back Off, and Avoid Duplicate Side Effects ����������� 140 Bound the Loop and Budget; Detect “Infinite” or Unproductive Iterations �������������������������� 141 Teach the Model to Reflect When Stuck ������������������������������������������������������������������������������ 141 Prefer Smaller, Specialized Models and Selective Tool Use ������������������������������������������������ 141 Harden Untrusted Input and Browsing �������������������������������������������������������������������������������� 142 Operationalizing Guardrails and Scaling Together ��������������������������������������������������������������� 142 Key Takeaways �������������������������������������������������������������������������������������������������������������������������� 143 Bibliography ������������������������������������������������������������������������������������������������������������������������������ 144 Chapter 6: The Art of Prompting ��������������������������������������������������������������������������� 147 Prompting As Agent Programming �������������������������������������������������������������������������������������������� 147 LLMs Don’t Use APIs—They Use Language ������������������������������������������������������������������������������ 147 Analogy: Prompts As Dynamic Control Panels �������������������������������������������������������������������������� 148 Creating Effective Prompts ������������������������������������������������������������������������������������������������������� 149 Prompting Is Agent Programming ��������������������������������������������������������������������������������������������� 150 Why Prompting Is Central to Reasoning, Planning, Safety, and Delegation ������������������������� 151 History of Prompting ����������������������������������������������������������������������������������������������������������������� 151 Table of ConTenTs
xi Prompt Taxonomy: Forms and Functions ���������������������������������������������������������������������������������� 152 Comprehensive Prompt Taxonomy for Agentic AI ���������������������������������������������������������������� 153 Prompt Design As an Engineering Discipline ���������������������������������������������������������������������������� 160 Instruction-Only Prompting: The Minimalist Command ������������������������������������������������������� 161 Few-Shot Prompting: Learning by Demonstration��������������������������������������������������������������� 161 Role Prompting: Wearing the Right Hat ������������������������������������������������������������������������������� 162 Chain of Thought: Thinking Out Loud ����������������������������������������������������������������������������������� 163 Tree of Thought: Exploring the Branches ����������������������������������������������������������������������������� 163 ReAct: Reason, Act, Observe ������������������������������������������������������������������������������������������������ 164 Reflexion: Learning From Itself �������������������������������������������������������������������������������������������� 165 Self-Ask Prompting: Questioning Before Acting ������������������������������������������������������������������ 167 Planning Prompts: From Goal to Road Map ������������������������������������������������������������������������� 167 Delegation Prompts: Assigning the Work ����������������������������������������������������������������������������� 168 Prompt Chaining: Linking Thoughts Together ���������������������������������������������������������������������� 168 Grounded Prompting: Anchoring to Reality �������������������������������������������������������������������������� 169 Evaluation Prompts: The Critic’s Eye ����������������������������������������������������������������������������������� 169 Ensemble Prompting: Many Minds, One Answer ����������������������������������������������������������������� 170 Adaptive Prompting: Changing with the Situation ��������������������������������������������������������������� 170 Context Management Prompts: Staying Focused ���������������������������������������������������������������� 171 Prompt Injection Resistance: Staying Safe �������������������������������������������������������������������������� 171 Tool-Specific Templates: Speaking the API’s Language ������������������������������������������������������ 172 Meta-Prompting: Thinking About Thinking �������������������������������������������������������������������������� 172 Structured Prompts for Consistent Outputs ������������������������������������������������������������������������������ 172 Role Framing and Iteration �������������������������������������������������������������������������������������������������� 175 Prompt Engineering As an Interface Layer �������������������������������������������������������������������������������� 176 Prompt Evaluation in the Agentic AI World �������������������������������������������������������������������������������� 177 Why Testing Is Trickier for Agents ��������������������������������������������������������������������������������������������� 177 How to Test in Practice�������������������������������������������������������������������������������������������������������������� 178 Step 1� Define Scenarios ����������������������������������������������������������������������������������������������������� 178 Step 2� Run the Full Loop ���������������������������������������������������������������������������������������������������� 178 Step 3� Score It �������������������������������������������������������������������������������������������������������������������� 178 Table of ConTenTs
xii Step 4� Build in Self-Critique ����������������������������������������������������������������������������������������������� 178 Step 5� Compare Variations ������������������������������������������������������������������������������������������������� 179 Prompt Caching: Cutting Costs and Latency at Scale ��������������������������������������������������������������� 179 Prompt Libraries: Managing Prompts As Production Artifacts �������������������������������������������������� 180 Key Takeaways �������������������������������������������������������������������������������������������������������������������������� 180 Bibliography ������������������������������������������������������������������������������������������������������������������������������ 185 Chapter 7: Tools and Frameworks for Building Agents ���������������������������������������� 187 The New Ecosystem of Agentic AI Frameworks ������������������������������������������������������������������������ 188 Tool Layer—Hands and Eyes of an Agentic AI System ������������������������������������������������������������� 193 Tool Use: How Agents Reach Beyond Themselves ��������������������������������������������������������������� 196 Why Tool Use Matters ���������������������������������������������������������������������������������������������������������� 198 Practical Scenarios �������������������������������������������������������������������������������������������������������������� 198 Foundation/Cognition Layer—Bedrock of an Agentic AI System ���������������������������������������������� 199 The Orchestration Layer—Where the Agent’s Mind Comes Together ��������������������������������������� 200 Cloud Platforms for Building Agents ������������������������������������������������������������������������������������ 212 Visual Builder Layer—An Arena for Quick Prototyping ������������������������������������������������������������� 213 Key Takeaways �������������������������������������������������������������������������������������������������������������������������� 214 Bibliography ������������������������������������������������������������������������������������������������������������������������������ 216 Chapter 8: Safety, Alignment, and Robustness in Agents ������������������������������������� 219 Hierarchy of Components in an Agentic AI Ecosystem �������������������������������������������������������������� 220 Patterns of Failure and Misalignment ��������������������������������������������������������������������������������������� 221 Adversarial Attacks and Prompt Injection���������������������������������������������������������������������������� 221 Designing Agentic Systems for Safety �������������������������������������������������������������������������������������� 223 Constraints and Guardrails �������������������������������������������������������������������������������������������������� 223 Simulation and Sandboxing ������������������������������������������������������������������������������������������������� 223 Human-in-the-Loop vs� Human-on-the-Loop ���������������������������������������������������������������������� 223 Goal Specification: The “What” and the “How” ������������������������������������������������������������������� 224 Robustness in Real-World Conditions ��������������������������������������������������������������������������������������� 224 Distribution Shifts ���������������������������������������������������������������������������������������������������������������� 225 Stress Testing ���������������������������������������������������������������������������������������������������������������������� 225 Table of ConTenTs
xiii Fail-Safe Mechanisms ��������������������������������������������������������������������������������������������������������� 226 Alignment Strategies ����������������������������������������������������������������������������������������������������������� 226 Value Alignment with Organizational and Human Priorities ������������������������������������������������ 226 Measuring Success: The Agent Evaluation Framework ������������������������������������������������������������ 227 Agents Monitoring Agent ����������������������������������������������������������������������������������������������������� 229 What Monitoring Agents Actually Check For ����������������������������������������������������������������������������� 229 Preventing the Monitor from Being Gamed ������������������������������������������������������������������������������� 230 The Performance and Cost Reality �������������������������������������������������������������������������������������������� 231 Architectures That Work in Practice ������������������������������������������������������������������������������������������ 232 Ethical and Societal Considerations ������������������������������������������������������������������������������������������ 234 Fairness and Bias Mitigation ����������������������������������������������������������������������������������������������� 234 Example: Measuring Fairness in a Resume Screening Agent ��������������������������������������������� 235 Accountability—Who’s Responsible? ���������������������������������������������������������������������������������� 235 Privacy and Data Protection in Autonomous Flows ������������������������������������������������������������� 236 Global Standards: Cultural and Regulatory Variation ����������������������������������������������������������� 236 Practical Techniques and Tooling ���������������������������������������������������������������������������������������������� 236 Guardrails and Validation Pipelines ������������������������������������������������������������������������������������� 236 Observability: Telemetry, Anomaly Detection, and Logs������������������������������������������������������� 237 Adversarial and Stress Testing: PyRIT ��������������������������������������������������������������������������������� 237 Trust, Monitoring, and Responsible AI Platforms ����������������������������������������������������������������� 238 Case Studies Across Industries ������������������������������������������������������������������������������������������������� 238 Designing for Trust �������������������������������������������������������������������������������������������������������������������� 239 Observability Through Structured Logging �������������������������������������������������������������������������� 239 The Principle of Least Privilege ������������������������������������������������������������������������������������������� 240 Modularity and Separation of Concerns ������������������������������������������������������������������������������ 241 Open Challenges ����������������������������������������������������������������������������������������������������������������������� 241 Pre-deployment Safety Checklist ���������������������������������������������������������������������������������������������� 242 The Cost of Safety: Engineering Trade-Offs ������������������������������������������������������������������������������ 243 Key Takeaways �������������������������������������������������������������������������������������������������������������������������� 245 Bibliography ������������������������������������������������������������������������������������������������������������������������������ 250 Table of ConTenTs
xiv Part III: Applications and Engineering Practice ������������������������������������������ 251 Chapter 9: Real-World Domain-Specific Use Cases of Agentic AI ������������������������ 253 Clarifying Terminology: AI Agent vs� Agentic AI ������������������������������������������������������������������������� 254 The Key Difference �������������������������������������������������������������������������������������������������������������� 255 Stacking Multiple Agents: AI Agents vs� Agentic AI �������������������������������������������������������������� 255 Making It Work: Strategy for Smooth Implementation �������������������������������������������������������������� 256 Building the Right Data Infrastructure ��������������������������������������������������������������������������������� 256 Executive Buy-In to the Solution ����������������������������������������������������������������������������������������� 256 Business User’s Alignment �������������������������������������������������������������������������������������������������� 257 FinOps and Cost Optimization Planning ������������������������������������������������������������������������������� 257 Pilot Solution, Measure, and Scale �������������������������������������������������������������������������������������� 257 Real-World, Domain-Specific Wins with Agentic (and Agent-Like) AI ��������������������������������������� 257 Healthcare ��������������������������������������������������������������������������������������������������������������������������� 257 Finance �������������������������������������������������������������������������������������������������������������������������������� 261 Guardrails for the Highly Regulated Industry ���������������������������������������������������������������������������� 264 Manufacturing and Supply Chain ���������������������������������������������������������������������������������������������� 265 Manufacturing: Optimizing for the Wrong Thing ����������������������������������������������������������������������� 266 Customer Experience ���������������������������������������������������������������������������������������������������������������� 266 Customer Service: Trust Is Fragile �������������������������������������������������������������������������������������������� 267 Cybersecurity ���������������������������������������������������������������������������������������������������������������������������� 267 Offensive Security Testing ��������������������������������������������������������������������������������������������������� 268 Smarter Case Management ������������������������������������������������������������������������������������������������� 268 Cybersecurity: False Positives Disrupt Business ���������������������������������������������������������������������� 269 Smart Governance �������������������������������������������������������������������������������������������������������������������� 270 Climate and Sustainability �������������������������������������������������������������������������������������������������������� 270 Public Sector: Bias Has Democratic Consequences������������������������������������������������������������������ 270 How to Identify and Implement Agentic AI Use Cases ��������������������������������������������������������������� 271 Key Takeaways �������������������������������������������������������������������������������������������������������������������������� 273 The Evolution of AI to Agentic Systems ������������������������������������������������������������������������������� 273 Domain-Specific Insights ���������������������������������������������������������������������������������������������������� 274 Risks and Failure Modes ����������������������������������������������������������������������������������������������������� 275 Table of ConTenTs
xv Implementation Strategy ����������������������������������������������������������������������������������������������������� 276 Identifying Where Agentic AI Fits ����������������������������������������������������������������������������������������� 277 The Bigger Picture ��������������������������������������������������������������������������������������������������������������� 278 Bibliography ������������������������������������������������������������������������������������������������������������������������������ 279 Chapter 10: Build Your First AI Agent—Hands-On Coding ������������������������������������ 281 Why Start Small ������������������������������������������������������������������������������������������������������������������������ 281 The Problem We’ll Solve ����������������������������������������������������������������������������������������������������������� 282 Setting Up Your Environment ���������������������������������������������������������������������������������������������������� 283 Prerequisites ����������������������������������������������������������������������������������������������������������������������� 283 Understanding CrewAI: The Core Concepts ������������������������������������������������������������������������������� 285 Agents ��������������������������������������������������������������������������������������������������������������������������������� 285 Tasks ����������������������������������������������������������������������������������������������������������������������������������� 286 Tools ������������������������������������������������������������������������������������������������������������������������������������ 286 Crews ���������������������������������������������������������������������������������������������������������������������������������� 287 Building Our First Agent—Personalized Research Assistant ���������������������������������������������������� 288 Step 1: A Single Research Agent ����������������������������������������������������������������������������������������� 288 Step 2: A Multi-agent Pipeline ��������������������������������������������������������������������������������������������� 290 Step 3: Iterative Refinement with Quality Thresholds ���������������������������������������������������������� 294 Step 4: Adding a Judge LLM ������������������������������������������������������������������������������������������������ 300 Step 4: Human-in-the-Loop Approval ���������������������������������������������������������������������������������� 301 Step 5: Adding Guardrails ���������������������������������������������������������������������������������������������������� 302 Key Takeaways �������������������������������������������������������������������������������������������������������������������������� 303 What’s Next ������������������������������������������������������������������������������������������������������������������������������� 304 Chapter 11: Engineering Agent Feedback Loops �������������������������������������������������� 305 Agents Without Feedback = Static, Brittle Systems ������������������������������������������������������������������ 305 Feedback → Adaptation → Trust ���������������������������������������������������������������������������������������� 306 Balances Autonomy with Accountability ������������������������������������������������������������������������������ 306 Types of Feedback Loops ���������������������������������������������������������������������������������������������������������� 307 Self-Critique ������������������������������������������������������������������������������������������������������������������������ 307 Implicit Task Feedback �������������������������������������������������������������������������������������������������������� 308 Step 1—Define the Feedback Signals �������������������������������������������������������������������������������� 309 Table of ConTenTs
xvi Step 2—Instrument Everything by Building Telemetry Layer ���������������������������������������������� 309 Step 3—Translate Telemetry into Reward Functions ���������������������������������������������������������� 310 Step 4—Build the Feedback Loop ��������������������������������������������������������������������������������������� 310 Step 5—Add Guardrails and an Exploration Budget ����������������������������������������������������������� 310 Mechanisms for Feedback Collection ��������������������������������������������������������������������������������������� 311 Designing Feedback Integration ����������������������������������������������������������������������������������������������� 314 Immediate Correction ���������������������������������������������������������������������������������������������������������� 314 Practical Techniques ����������������������������������������������������������������������������������������������������������������� 315 Example—Research Assistant �������������������������������������������������������������������������������������������������� 317 Challenges and Pitfalls�������������������������������������������������������������������������������������������������������������� 319 Choosing the Right Feedback Mechanisms ������������������������������������������������������������������������� 320 The Core Trade-Offs ������������������������������������������������������������������������������������������������������������������ 321 Decision Framework by Resource Constraints ������������������������������������������������������������������������� 321 Decision Framework by Failure Mode ��������������������������������������������������������������������������������������� 322 Combining Mechanisms: Layered Feedback Architecture �������������������������������������������������������� 323 Monitoring Feedback Loop Health �������������������������������������������������������������������������������������������� 325 Feedback Collection Metrics ����������������������������������������������������������������������������������������������������� 325 Learning Effectiveness Metrics ������������������������������������������������������������������������������������������������� 325 Feedback Loop Latency Metrics ����������������������������������������������������������������������������������������������� 327 Balance and Stability Metrics ��������������������������������������������������������������������������������������������������� 327 Putting It All Together: A Feedback Loop Health Scorecard ������������������������������������������������������ 329 Key Takeaways �������������������������������������������������������������������������������������������������������������������������� 330 Bibliography ������������������������������������������������������������������������������������������������������������������������������ 333 Chapter 12: Collaborative Agents (Multi-agent Systems, Human–AI Teaming) ���� 335 Multi-agent System Patterns ���������������������������������������������������������������������������������������������������� 336 Hands-On Architecture Guide ���������������������������������������������������������������������������������������������������� 337 Architecture 1: Sequential Pipeline ������������������������������������������������������������������������������������� 337 Architecture 2: Parallel Fan-Out/Fan-In ������������������������������������������������������������������������������� 339 Architecture 3: Hierarchical (Manager-Worker) ������������������������������������������������������������������� 341 Architecture 4: Debate/Adversarial �������������������������������������������������������������������������������������� 343 Table of ConTenTs
xvii Architecture 5: Voting/Consensus ���������������������������������������������������������������������������������������� 345 Architecture 6: Blackboard (Shared Memory) ��������������������������������������������������������������������� 347 Architecture 7: Market-Based (Auction) ������������������������������������������������������������������������������ 349 Architecture 8: Supervisor with Dynamic Routing ��������������������������������������������������������������� 351 Communication and Coordination Is Central to Success ����������������������������������������������������� 353 Human–AI Teaming �������������������������������������������������������������������������������������������������������������� 355 Example Use Cases ������������������������������������������������������������������������������������������������������������������� 356 Finance: Trading Desk Copilots �������������������������������������������������������������������������������������������� 357 Healthcare: Diagnostic Support Teams �������������������������������������������������������������������������������� 357 Supply Chain: Negotiation + Routing Agents ����������������������������������������������������������������������� 357 Sustainability: Swarm Agents on the Grid ��������������������������������������������������������������������������� 357 Design Challenges �������������������������������������������������������������������������������������������������������������������� 358 Emergent Behaviors ������������������������������������������������������������������������������������������������������������ 358 Conflict Resolution��������������������������������������������������������������������������������������������������������������� 358 Bottlenecks �������������������������������������������������������������������������������������������������������������������������� 359 Error Cascades �������������������������������������������������������������������������������������������������������������������� 359 Security Risks ���������������������������������������������������������������������������������������������������������������������� 359 Memory Architecture and Context Window Constraints ������������������������������������������������������������ 360 Token Budget Allocation ������������������������������������������������������������������������������������������������������������ 361 Testing Strategies for Multi-agent Systems ������������������������������������������������������������������������������ 363 Testing for Emergent Behaviors ������������������������������������������������������������������������������������������������ 364 Optimization Strategies ������������������������������������������������������������������������������������������������������������� 365 When to Add More Agents ��������������������������������������������������������������������������������������������������������� 365 Key Takeaways �������������������������������������������������������������������������������������������������������������������������� 365 Bibliography ������������������������������������������������������������������������������������������������������������������������������ 370 Chapter 13: Testing, Debugging, Evaluation, and Deployment Considerations ����� 373 Why Agents Aren’t Just Software: A New Mindset for Deployment ������������������������������������������ 374 Testing Dynamic Behavior ��������������������������������������������������������������������������������������������������� 374 Debugging Reasoning, Not Just Code ��������������������������������������������������������������������������������� 374 Deployment As Continuous Evolution ���������������������������������������������������������������������������������� 375 What Can Go Wrong with Agentic Systems—and How to Get Ready ��������������������������������������� 376 Table of ConTenTs
xviii Testing Agent Behavior ������������������������������������������������������������������������������������������������������������� 377 Scenario-Based Tests ���������������������������������������������������������������������������������������������������������� 377 Reasoning Validation ����������������������������������������������������������������������������������������������������������� 377 Prompt Regression Testing �������������������������������������������������������������������������������������������������� 377 Adversarial Testing �������������������������������������������������������������������������������������������������������������� 378 Operational Trust: Observability in Agentic AI���������������������������������������������������������������������������� 378 Telemetry Pipelines ������������������������������������������������������������������������������������������������������������� 378 Dashboards ������������������������������������������������������������������������������������������������������������������������� 378 User Feedback Loops ���������������������������������������������������������������������������������������������������������� 379 Why Evaluation Matters in Agentic AI ���������������������������������������������������������������������������������������� 379 The Dimensions of Evaluation ��������������������������������������������������������������������������������������������������� 380 Current Frameworks and Adaptations �������������������������������������������������������������������������������������� 381 Case Study: Precision Under Pressure—Evaluating Clinical Decision Support Agents ������������ 383 How We Evaluate in Practice ����������������������������������������������������������������������������������������������� 383 Putting It into Practice: A Prompt Evaluation Experiment ��������������������������������������������������������� 391 Experiment Setup ���������������������������������������������������������������������������������������������������������������� 391 Evaluating the Outputs �������������������������������������������������������������������������������������������������������� 392 The Unfinished Science of Evaluating Agents ��������������������������������������������������������������������������� 393 Where Evaluation Is Headed ����������������������������������������������������������������������������������������������������� 394 Deployment Best Practices ������������������������������������������������������������������������������������������������������� 395 Containerization������������������������������������������������������������������������������������������������������������������� 395 Secrets and Configuration Management ����������������������������������������������������������������������������� 396 CI/CD for Agents ������������������������������������������������������������������������������������������������������������������ 396 Canary Releases and A/B Testing ���������������������������������������������������������������������������������������� 396 Failure Planning ������������������������������������������������������������������������������������������������������������������� 397 Lessons from Real-World Deployments ������������������������������������������������������������������������������������ 397 Silent Failures ���������������������������������������������������������������������������������������������������������������������� 397 Prompt Drift Across Model Updates������������������������������������������������������������������������������������� 398 Balancing Observability and Privacy ����������������������������������������������������������������������������������� 398 Operational Cost of Continuous Monitoring ������������������������������������������������������������������������� 398 Key Takeaways �������������������������������������������������������������������������������������������������������������������������� 399 Table of ConTenTs
xix Why Testing, Evaluation, and Deployment Matter ���������������������������������������������������������������� 399 Testing Agent Behavior �������������������������������������������������������������������������������������������������������� 399 Debugging Agents ��������������������������������������������������������������������������������������������������������������� 400 Evaluation Frameworks ������������������������������������������������������������������������������������������������������� 400 Observability and Monitoring����������������������������������������������������������������������������������������������� 401 Deployment Best Practices�������������������������������������������������������������������������������������������������� 401 Pitfalls and Challenges �������������������������������������������������������������������������������������������������������� 402 The Future of Evaluation ������������������������������������������������������������������������������������������������������ 403 Bibliography ������������������������������������������������������������������������������������������������������������������������������ 403 Chapter 14: Conclusion and the Road Ahead: Open Challenges and Responsibility ������������������������������������������������������������������������������������������������������� 405 Grand Technical Hurdles and Open Research Questions ���������������������������������������������������������� 410 Governance and Alignment Challenges ������������������������������������������������������������������������������� 410 Ethical and Societal Questions �������������������������������������������������������������������������������������������� 411 What Comes Next: Emerging Horizons in Agentic AI ����������������������������������������������������������������� 413 Meta-agents ������������������������������������������������������������������������������������������������������������������������ 414 Agent Simulations ��������������������������������������������������������������������������������������������������������������� 414 Neuro-symbolic Hybrids ������������������������������������������������������������������������������������������������������ 414 Human–AI Intent Fusion ������������������������������������������������������������������������������������������������������ 414 A Responsible Path Forward ����������������������������������������������������������������������������������������������� 415 Key Takeaways for Engineers ��������������������������������������������������������������������������������������������������� 416 Key Takeaways �������������������������������������������������������������������������������������������������������������������������� 418 Synthesis of the Journey ����������������������������������������������������������������������������������������������������� 418 Open Technical Challenges �������������������������������������������������������������������������������������������������� 420 Governance and Alignment �������������������������������������������������������������������������������������������������� 420 Ethical Responsibilities�������������������������������������������������������������������������������������������������������� 421 Regulatory Landscape ��������������������������������������������������������������������������������������������������������� 422 Emerging Frontiers �������������������������������������������������������������������������������������������������������������� 423 The Responsible Path Forward �������������������������������������������������������������������������������������������� 424 Bibliography ������������������������������������������������������������������������������������������������������������������������������ 425 Index ��������������������������������������������������������������������������������������������������������������������� 427 Table of ConTenTs
xxi About the Author Dhivya Nagasubramanian is an independent AI/ML researcher and practitioner who has spent over a decade leading digital transformation and automation initiatives at the enterprise level. Her work sits at the intersection of data science, enterprise architecture, and engineering—building AI systems that operate reliably at scale. Beyond her technical work, Dhivya is deeply invested in advancing AI education, mentoring emerging talent, and shaping responsible AI practices. This book distills her hands-on experience into a practical guide for engineers ready to design, build, and deploy agentic AI systems.
Comments 0
Loading comments...
Reply to Comment
Edit Comment