Introduction
Chapter 1: What We Mean by AI Agents
- From Chatbots to Agents: A Taxonomy
- The Reliability Gap: Why Agent Behavior Is Fundamentally Different
- Deterministic Code Meets Probabilistic Reasoning
- The Core Ingredients of an Agent System
- Common Misconceptions That Cause Real Outages
Chapter 2: Why Agents Fail
- Hallucinations and False Confidence
- Reasoning Errors and Chain-of-Thought Fragility
- Non-Determinism and Unreproducible Behavior
- Tool Misuse: Wrong Tools, Wrong Parameters, Wrong Time
- Infinite Loops, Divergence and Resource Exhaustion
- Cascading Failures and State Corruption
- Security Failures: Prompt Injection, Leakage and Abuse
- Partial Execution and Incomplete Work
Chapter 3: The Reliability Stack: A Layered Model
- The Layers: Control, Reasoning, Tools, State, Observability
- Where Determinism Lives (and Where It Must Not)
- Explicit Contracts and Invariants
- Bounded Autonomy as a Design Principle
- Failure Containment: Blame Lines and Isolation
Chapter 4: Control Architectures: Patterns and Trade-offs
- The Simple Agent Loop: When It Works, When It Breaks
- Deterministic State Machines Around Probabilistic Transitions
- Graph-Based Workflows and DAG Orchestration
- Hierarchical Agents and Subagent Delegation
- The Supervisor Pattern: Meta-Agent Coordination
- Decision Criteria: Choosing an Architecture for Your Constraints
Chapter 5: Planning, Decomposition and Task Management
- Task Decomposition Strategies: Recursive, Iterative and Hybrid
- Plan vs. Execution: Separation of Concerns
- Dynamic Replanning and Adaptation
- Goal Specification: From Vague Intentions to Machine-Checkable Conditions
- Monitoring Plan Health and Detecting Derailment
Chapter 6: Tool Design and Integration
- The Tool Contract: Typed Inputs, Validated Outputs, Explicit Errors
- Idempotency and Safe Retries
- Tool Discovery and Selection Reliability
- Parameter Validation and Sanitization
- Asynchronous Tools and Long-Running Operations
- Tool Observability: Logging, Timing and Metrics
Chapter 7: Context Engineering and Memory Systems
- The Context Window as a Constrained Resource
- Short-Term Memory: Conversation History and Working Context
- Long-Term Memory: Storage, Indexing and Retrieval
- RAG Reliability: Freshness, Accuracy and Citation
- Context Compression and Summarization Risks
- Memory Consistency and Concurrency
Chapter 8: Structured Outputs and Grounding
- Schemas, Grammars and Constrained Decoding
- Output Validation: Pre-flight and Post-flight Checks
- Grounding Outputs in Verifiable Evidence
- Confidence, Uncertainty and When to Fail Open
- Multi-Step Verification and Cross-Check Patterns
Chapter 9: Multi-Agent Systems and Coordination
- When You Actually Need Multiple Agents
- Coordination Patterns: Messaging, Shared State, Hierarchical
- Communication Reliability and Protocol Design
- Conflict Resolution and Deadlock
- Emergent Behavior and Unintended Interactions
- Multi-Agent Security and Isolation
Chapter 10: Building a Reliable Agent: Reference Architecture I (Single Agent)
- System Overview and Design Goals
- Project Structure and Dependencies
- Typed Data Models and Configuration
- Model Integration and Prompt Management
- Tool Definitions with Validation and Error Handling
- State Persistence and Recovery
- The Control Loop: Control Flow Around Probabilistic Reasoning
- Automated Tests and Basic Evaluation
Chapter 11: Reference Architecture II (Workflow-Based Agent)
- When Workflows Beat Pure Autonomy
- Defining the Workflow Graph
- Step Implementations: Mixing Determinism and AI
- Error Handling and Recovery in Workflows
- Human Approval Gates
- Observability Across Workflow Executions
- Testing Workflow Behavior
Chapter 12: Reference Architecture III (Multi-Agent System)
- Architecture Overview: Roles, Responsibilities, Boundaries
- Message Protocol and Communication Layer
- Agent Implementations with Encapsulated Reasoning
- Coordination and Orchestration Logic
- Shared State and Consistency
- Security: Isolation, Authorization, Least Privilege
- End-to-End Observability
- Deployment, Scaling and Operations
- Complete Evaluation and Regression Suite
Chapter 13: Evaluation: Testing Agents Like Real Systems
- The Test Pyramid for Agentic Systems
- Unit Testing: Isolated Components and Tools
- Integration Testing: Agent in a Controlled Environment
- Scenario-Based Testing and Simulations
- Adversarial Testing and Red Teaming
- Deterministic Simulations and Mock Environments
- Regression Testing for Model and Prompt Changes
Chapter 14: Model-Graded Evaluation and Its Limits
- How Model Grading Works
- Designing Effective Grading Prompts
- Calibration and Agreement with Human Judgment
- Limitations: Bias, Fragility and Manipulation
- Combining Model Grading with Deterministic Checks
- When Human Evaluation Is Non-Negotiable
Chapter 15: Observability, Monitoring and Incident Response
- What to Observe: Traces, Logs, Metrics and Audits
- Distributed Tracing for Agent Executions
- Structured Logging: Machine-Readable Narratives
- Key Metrics for Agent Reliability
- Alerting on Agent Behavior: Signals vs. Noise
- Incident Response: Diagnosing Agent Failures
- Postmortems and Continuous Improvement
Chapter 16: Security Engineering for AI Agents
- The Expanded Attack Surface of Agents
- Prompt Injection: Types, Defenses and Residual Risks
- Tool Authorization and Least Privilege
- Data Leakage and Privacy Preservation
- Sandboxing and Execution Isolation
- Input/Output Filtering and Sanitization
- Security Testing for Agent Systems
Chapter 17: Production Deployment and Infrastructure
- Deployment Architectures: Monolith, Microservices, Serverless
- Model Access: Direct API, Proxy and Routing
- Concurrency and Rate Limiting
- Caching Strategies: Prompts, Responses and Tool Results
- Token Economics and Cost Attribution
- Capacity Planning and Load Management
- Graceful Degradation and Fallback
Chapter 18: Governance, Compliance and the Future
- Change Management: Models, Prompts and Tools
- Compliance and Regulatory Considerations
- Documentation and Runbooks for Agent Systems
- Reproducibility and Experimentation Tracking
- Open Problems in Agent Reliability
- Principles for the Next Era of Agent Engineering