Running Agents Without the Cloud
Introduction: The Case for Local-First AI
- The Cloud Dependency Problem
- Defining Local-First AI
- What This Book Is and Is Not
- The Reference Project
Chapter 1: Foundations - Hardware, Linux and the Local AI Stack
- The Local AI Hardware Stack
- GPUs and Accelerators
- Hardware Discovery and Monitoring on Linux
- Linux as the AI Operating Foundation
- GPU Drivers and Accelerator Ecosystems
- Practical Hardware Sizing Methodology
- Chapter Summary
Chapter 2: Transformer Inference from First Principles
- Tokenization and Embeddings
- Attention Mechanics and KV Caches
- Prefill Versus Decode: Two Different Computational Regimes
- Batching Strategies
- Sampling and Decoding Controls
- Memory and Compute Accounting
- Chapter Summary
Chapter 3: Model Selection and Formats
- Architecture Families
- Model Roles
- Model Formats and File Layouts
- Repositories and Provenance
- Licensing and Compliance
- Selection Methodology
- Chapter Summary
Chapter 4: Quantization and Inference Optimization
- Numerical Representations
- Quantization Approaches
- GGUF Quantization Families
- CPU/GPU Offloading Strategies
- Advanced Optimizations
- Systematic Benchmarking of Optimizations
- Chapter Summary
Chapter 5: Local Inference Runtimes and Serving
- llama.cpp and the GGUF Ecosystem
- Ollama as a Managed Local Runtime
- vLLM for High-Throughput Local Serving
- Hugging Face Transformers and Related Libraries
- ONNX Runtime and Alternative Backends
- Building the Reference Model Server
- Chapter Summary
Chapter 6: APIs, Interfaces and Interoperability
- API Design for Local Inference
- OpenAI-Compatible API as Interoperability Convention
- Streaming Responses and Backpressure
- Structured Outputs and JSON Schemas
- Tool/Function Calling Interfaces
- Authentication, Rate Limiting and Concurrency Control
- Health Checks, Graceful Shutdown and Service Discovery
- Chapter Summary
Chapter 7: Local Agent Architecture
- What Is an Agent
- The Agent Loop
- Structured Tool Calling
- State Management and Memory
- Planning and Task Decomposition
- Multi-Agent Architectures
- Chapter Summary
Chapter 8: Building Fully Local Agents
- Minimal Local Model Client
- Tool-Using Assistant
- Local Document Analysis System
- Local Coding Assistant
- Research/Knowledge Agents Over Local Corpora
- Background Autonomous Services
- Chapter Summary
Chapter 9: Local RAG, Memory and Knowledge Systems
- Document Ingestion Pipelines
- Embedding Models for Local Use
- Vector Search and Indexes
- Hybrid Retrieval
- Reranking
- Context Assembly and Citations
- Persistent Storage: SQLite and Structured Stores
- Conversation Memory and Episodic Storage
- Indexing Pipelines and Incremental Updates
- Retrieval Evaluation
- Defenses Against Poisoned Content
- Chapter Summary
Chapter 10: Security and Trust Boundaries for Local AI
- The Local Fallacy
- Model Provenance and Artifact Verification
- Software Supply Chain Security
- Prompt Injection Defenses
- Tool Abuse Prevention
- Linux Security Controls
- Network Security
- Authentication and Access Control
- Secrets Management
- Audit Logging
- Human Approval Gates
- Kill Switches
- Chapter Summary
Chapter 11: Offline and Air-Gapped Operation
- Dependency Acquisition Strategy
- Reproducible Package Mirrors
- Model Transfer and Integrity Verification
- Offline Documentation
- Software Updates and Patch Management
- License Tracking and Compliance
- Backup and Recovery
- Time Synchronization
- Secure Data Import/Export
- Maintaining Long-Term Disconnected Deployments
- Chapter Summary
Chapter 12: Performance Engineering and Benchmarking
- Why Benchmarking Matters for Local AI
- Benchmark Metrics Defined
- Building Reproducible Benchmark Harnesses
- Interpreting Benchmark Results
- Establishing Service-Level Objectives
- Capacity Planning
- Chapter Summary
Chapter 13: Reliability Engineering for Autonomous Local Systems
- Process Supervision
- Health Checks
- Retries with Bounded Policies
- Timeouts
- Circuit Breakers
- Queue Management and Backpressure
- Crash Recovery and Checkpointing
- GPU Out-of-Memory Handling
- Degraded-Mode Operation
- Chapter Summary
Chapter 14: Observability and Evaluation
- Structured Logging
- Metrics Collection
- Distributed Tracing
- GPU and Hardware Monitoring
- Local Dashboards
- Alerting
- Behavioral Evaluation
- Testing Strategies
- Continuous Evaluation
- Chapter Summary
Chapter 15: Deployment Patterns and Networking
- Developer Laptop Deployment
- Gaming-Class Workstation Deployment
- Dedicated Linux Inference Server
- Multi-GPU Workstation/Server
- Home Lab Deployment
- Small Office Deployment
- Edge Appliance Deployment
- Air-Gapped Environment Deployment
- Centralized Versus Distributed Inference
- Networking for Local AI Systems
- Chapter Summary
Chapter 16: Integration, Lifecycle Operations and Architecture Decisions
- Integration with Existing Software
- Lifecycle and Operations
- Local Versus Cloud Versus Hybrid: Decision Frameworks
- Chapter Summary
Conclusion: The LocalForge Platform in Practice
- The Complete Architecture
- Getting Started: From Zero to Working System
- Adapting to Your Environment
- Future Directions in Local AI
- Final Thoughts