The New Frontier of AI Engineering
Introduction: Why the Harness Matters
- The Model Is Not the Product
- A Concrete Failure
- Defining the Harness
- The Harness as Competitive Advantage
- Beyond Prompt Engineering
- How to Read This Book
Chapter 1: What Is AI Harness Engineering?
- Defining the Harness
- The Architectural View
- What Harness Engineering Is Not
- The Harness as Competitive Advantage
- The Engineering Promise: Reliability from Probability
- How to Read This Book
Chapter 2: Historical Evolution
- From API Wrappers to System Architects
- The Rise of Prompt Engineering and Its Limits
- Function Calling as an Inflection Point
- The Agent Revolution: Chain of Thought and Beyond
- From Single-Model Scripts to Multi-Model Systems
- Lessons from Traditional Software Architecture
Chapter 3: The Harness Architecture Primer
- High-Level Architectural Layers
- The Request Lifecycle End to End
- Control Plane Versus Data Plane
- Synchronous Versus Asynchronous Patterns
- The Minimal Viable Harness
- Scaling Up: From Script to Platform
Chapter 4: Model Interfaces and Abstraction
- Direct API Integration Patterns
- Abstraction Layers: Unification and Its Costs
- Structured Outputs and Schema Enforcement
- Streaming, Chunking and Backpressure
- Model Selection and Routing
- Fallbacks and Degradation Paths
Chapter 5: Context Construction and Management
- System Prompts as Configuration
- Context Assembly: Layers and Templates
- Context Window Economics: Token Budgets and Trade-Offs
- Summarization and Compression Techniques
- Context Drift and Coherence Over Time
- Versioning and Debugging Context
Chapter 6: State and Memory Systems
- Working Memory and Short-Term Context
- Persistent Memory: Vector Stores and Knowledge Bases
- Episodic, Semantic and Procedural Memory Architectures
- Memory Retrieval and Recall Strategies
- State Machines and Conversation State
- Memory Eviction and Lifespan Management
Chapter 7: Control Flow and Execution Loops
- The Agent Loop: Observe, Think, Act
- Planning, Execution and Reflection Cycles
- Deterministic Guardrails Around Probabilistic Steps
- Timeout, Budget and Termination Conditions
- Reentrancy and Idempotency in AI Workflows
- Structuring Complex Interactions as Control Graphs
Chapter 8: Function Calling and Tool Invocation
- Tool Definition and Schema Design
- JSON Schema and Function Spec Formats
- Native Function Calling Versus Prompt-Based Patterns
- Tool Discovery and Registration
- Error Handling and Partial Tool Results
- Security Boundaries in Tool Access
Chapter 9: Agent Execution Models
- ReAct and Its Variants
- Plan-and-Solve and Tree-of-Thought Patterns
- Reflexion and Self-Correction Loops
- Long-Horizon Task Execution
- Human-in-the-Loop Integration Points
- Comparing Agent Architectures: When to Use What
Chapter 10: Multi-Agent Architectures
- Motivations and Anti-Motivations for Multi-Agent Systems
- Hub-and-Spoke and Broker Architectures
- Hierarchical Delegation and Supervision
- Peer Collaboration and Debate Patterns
- Specialization by Role or Capability
- Consensus, Voting and Conflict Resolution
Chapter 11: Inter-Agent Communication and Coordination
- Message Passing and Topic-Based Communication
- Shared Memory and Blackboard Patterns
- Contract and Protocol Design for Agent Interaction
- Scheduling and Concurrency Control
- Deadlock Detection and Liveness Guarantees
- Scaling Communication in Large Agent Systems
Chapter 12: Retrieval-Augmented Generation Systems
- RAG Architectural Patterns: Naive to Advanced
- Document Ingestion and Chunking Strategies
- Embedding Models and Vector Index Design
- Hybrid Retrieval: Dense, Sparse and Graph
- Reranking and Result Fusion
- Evaluating and Optimizing RAG Pipelines
Chapter 13: Planning, Reasoning and Task Decomposition
- Decomposition Patterns: Hierarchical and Flat
- Chain-of-Thought as an Internal Mechanism
- Self-Consistency and Ensemble Reasoning
- Constraint Satisfaction and Validation
- Planning with Partial Observability
- Meta-Reasoning and Strategy Selection
Chapter 14: Workflow Engines and Orchestration
- DAG-Based Workflow Engines for AI
- Conditional Logic and Dynamic Control Flow
- AI as a Step in Larger Workflows
- Integration with Orchestration Platforms
- Long-Running Workflows and Persistence
- Human Approval Gates and Escalation
Chapter 15: Persistent Agent Environments and Computer Use
- Sandboxed Execution Environments
- Browser Automation and Web Interaction
- File System Access and Data Manipulation
- Tool-Use for Code Execution
- Safety Constraints and Action Review
- Stateful Environments and Persistent Context
Chapter 16: Deterministic Control Over Probabilistic Systems
- Probabilistic Outputs and Their Costs
- Structured Outputs as a Reliability Mechanism
- Validation, Sanitization and Fallback Layers
- Temperature, Sampling and Reproducibility
- Contract Testing with AI Components
- Designing for Variability
Chapter 17: Observability, Telemetry and Debugging
- Logging AI System Execution
- Distributed Tracing Across Model and Tool Calls
- Metrics That Matter: Latency, Quality and Cost
- Token-Level Observability
- Debugging Strategies for Non-Deterministic Systems
- Replaying and Simulating Interactions
Chapter 18: Evaluation Frameworks and Quality Assurance
- Defining Quality for AI Systems
- Automated Evaluation Frameworks
- LLM-as-Judge: Capabilities and Pitfalls
- Golden Dataset Construction
- Regression Testing and Guardrail Tests
- Continuous Evaluation in Production
Chapter 19: Performance, Scalability and Cost Optimization
- Latency Optimization Strategies
- Token Economics and Cost Budgeting
- Caching: Prompt, Embedding and Response
- Throughput and Concurrency Design
- Resource Allocation and Auto-Scaling
- Cost-Per-Task Optimization
Chapter 20: Fault Tolerance and Recovery
- Failure Modes in AI Systems
- Retry Strategies and Exponential Backoff
- Checkpointing and State Recovery
- Circuit Breakers and Rate Limiting
- Degradation Modes and Graceful Failure
- Disaster Recovery and Data Loss Prevention
Chapter 21: Security Threat Landscape
- Prompt Injection: Direct and Indirect
- Tool Misuse and Privilege Escalation
- Data Leakage and Privacy Threats
- Supply Chain Risks in Prompt and Model Libraries
- Adversarial Examples and Model Manipulation
- Real-World Incident Analysis
Chapter 22: Defense-in-Depth Architectures
- Input Validation and Sanitization
- Output Filtering and Content Moderation
- Sandbox Isolation and Capability Control
- Secrets Management and Key Rotation
- Network Security and Egress Control
- Layered Defense Design Patterns
Chapter 23: Governance, Compliance and Human Oversight
- Regulatory Landscape and Compliance Needs
- Auditability and Explanation Requirements
- Human-in-the-Loop and Human-on-the-Loop
- Access Control and Authorization
- Policy Enforcement and Guardrails
- Ethical Design Considerations
Chapter 24: Building a Minimal Production Harness
- Project Structure and Dependencies
- Model Interface Layer
- Tool Definition and Registration System
- Agent Loop Implementation
- Configuration and Environment Setup
- Testing the Minimal Harness
Chapter 25: Building a Multi-Agent Orchestration Platform
- System Architecture and Design Decisions
- Agent Registry and Message Bus
- Task Decomposition and Routing
- State Persistence and Recovery
- Observability Integration
- Running and Testing the Platform
Chapter 26: Production Deployment and Operations
- Containerization and Infrastructure
- CI/CD for AI Harness Systems
- Monitoring Dashboards and Alerting
- Evaluation Integration in the Deployment Pipeline
- Incident Response Procedures
- Continuous Improvement and Model Updates
Chapter 27: The Next Generation of AI Harnesses
- Adaptive and Self-Configuring Harnesses
- Increasingly Autonomous Systems
- Model-Agnostic Architecture Design
- Persistent World Simulations
- Human-Agent Collaboration at Scale
- Convergence with Traditional Software Engineering