Black Friday Deals For Authors Are On Now!

Leanpub Header

Skip to main content

AI Agents & Harness Engineering

These books have a total suggested price of $145. Get them now for only $49.00!
About

About

About the Bundle

Books

About the Books

AI Harness Engineering

AI Harness Engineering

For two years, the AI conversation has fixated on models: which one codes cleanest, hallucinates least, or tops the latest benchmark. That debate has produced extraordinary models, but it has obscured a quieter truth: the model is just one input into a running agent. The rest of the system, the harness, matters just as much, and often more.


AI Harness Engineering is the definitive practitioner's guide to designing the scaffolding that turns a raw language model into a reliable, production-grade agent. Written for engineers, technical leads, and architects who already ship with AI tools and want to stop blaming the model for failures they can fix themselves, this book walks the full surface area of a modern agent harness: filesystems and git as durable state, tool design and MCP servers, context engineering and the war on context rot, sandboxes and permissions, the agent loop, planning for long-horizon work, subagent orchestration, verification and evaluation, observability and cost metering, and memory systems that let agents learn from every mistake.

Drawing on architectural patterns from Claude Code, Codex, Cursor, Aider, and the open-source ecosystem, with more than a dozen chapters of runnable code and worked examples, this book teaches the discipline that closes the gap between what today's models can do and what you actually see them doing. The thesis is simple: a decent model with a great harness beats a great model with a bad harness almost every time. Learn to build the scaffolding, and you'll engineer systems where AI agents finish the job, not just start it.

Building AI Harnesses and Reliable Agents

Building AI Harnesses and Reliable Agents

About the Book

Most LLM applications fail in production for reasons that have nothing to do with model quality: an ambiguous tool description, a JSON response that almost matched the schema, a retrieval step that returned the wrong chunk, a prompt injection inside a retrieved document, a retry loop that tripled the token bill overnight. This book treats the model as the least reliable component in the stack and focuses on the *harness* — the scaffolding of code that turns a probabilistic component into a dependable service.

The book is organized in the order you will actually build the system. **Foundations (Ch. 1–3)** cover the real API surface of an LLM application, a five-layer harness architecture (runtime loop, context assembler, tool registry, control plane, observation layer), and prompt design as a program with requirements, rules, and an output contract. **Capability (Ch. 4–8)** covers tool design and registry mechanics, MCP integration, three levels of JSON guarantees with constrained decoding, schema versioning, retrieval with pgvector and hybrid search plus reranking, four kinds of memory (including why the filesystem often beats a memory tool), and workflow-versus-agent selection with a decision matrix and multi-agent patterns. **Assurance (Ch. 9–11)** covers deterministic vs. model-graded assertions, promptfoo eval and red-team configs, indirect prompt-injection defense with tenant isolation and least-privilege tools, OpenTelemetry GenAI conventions, prompt caching, and budget enforcement. **Production (Ch. 12–14)** covers stateless workers, an LLM gateway, autoscaling, data residency, durable execution with pure/step idempotency rules, retries, chaos testing, model and system cards, risk registers, and incident runbooks. **Practice (Ch. 15)** assembles two full walkthroughs: a support agent with human approval on refunds, and a contract-compliance pipeline with eval gates.

Every chapter pairs design rationale with runnable Python, worked request traces, decision matrices, and pitfall lists. Naming specific tooling: OpenAI Agents SDK, Anthropic's Model Context Protocol, LangGraph, AutoGen, CrewAI, LlamaIndex, Haystack, OpenTelemetry, Langfuse, promptfoo, pgvector, Qdrant, LiteLLM.

Who It's For

Software engineers, ML practitioners, and technical leads who know Python and the basics of ML, and who now own an LLM feature that touches real data, real users, and a real budget. No transformer math.

LLM Building Blocks: From Transformers to Production AI Systems

LLM Building Blocks: From Transformers to Production AI Systems

Move from understanding transformer internals to shipping an observable, secure LLM service. This code-first guide connects tokenization, embeddings, attention, pretraining, and fine-tuning to the production systems built on them.

You’ll work with `tiktoken`, Hugging Face tokenizers, and `sentence-transformers`; build RAG pipelines with LlamaIndex, FAISS, HNSW, hybrid search, reranking, and citation verification; add tool calling and MCP-compatible servers; and evaluate outputs with RAGAS and DeepEval. Fine-tuning chapters cover LoRA, QLoRA, TRL, DPO, dataset design, and regression testing. Inference and deployment chapters cover vLLM, llama.cpp, quantization, speculative decoding, streaming, tracing, rate limiting, Docker, and cost controls.

The book also connects prompt engineering, structured outputs, hallucination mitigation, and inference optimization to the surrounding architecture. You’ll compare hosted and local models, choose embedding models and vector stores, reduce latency and token costs, and apply defenses against prompt injection, improper output handling, excessive agency, and supply-chain risks.

The capstone assembles a complete production RAG service: configuration and ingestion, indexing and retrieval, generation with refusal and citation checks, an API, evaluation, testing, and a hardening checklist. Each chapter includes runnable code, worked numbers, architecture comparisons, pitfalls, exercises, and a recap checklist.

AI Accountable Knowledge

AI Accountable Knowledge

*AI Accountable Knowledge* provides an implementation framework for teams building enterprise AI in regulated and high-impact environments. Instead of treating responsible AI as a values statement, the book shows how to design, approve, deploy, and monitor AI systems that produce reliable evidence when decisions are questioned.

You will learn to build an **accountability contract** with testable requirements, conduct layered risk classification and impact assessment, establish data provenance and consent records, select models with documented reasoning, and engineer meaningful human oversight. The book covers fairness, robustness, safety, privacy, security, approval gates, decision records, and balanced assurance reports.

The framework extends into production. You will design governed inference paths for retrieval-augmented generation, implement human-in-the-loop workflows, monitor drift and policy violations, design degraded operation, and prepare incident responses with audit-ready logs and rollback procedures. Separate chapters address third-party model providers, API vendors, version drift, supply-chain risk, and exit planning.

For organizational rollout, the book explains how to scale from pilots to an enterprise AI platform using golden paths, standardized APIs and schemas, governance as code, continuous control testing, a federated operating model, maturity assessment, and a phased adoption roadmap.

Three detailed walkthroughs apply the framework to a **customer-support assistant**, a **hiring decision system**, and a **healthcare operations model**. The book includes sample risk registers, control mappings, decision records, acceptance criteria, exercises, Python and YAML patterns, implementation checklists, and a reusable template pack.

Written for AI architects, technology leaders, governance teams, ML engineers, risk officers, and product managers who need operational accountability rather than an ethics primer.

ImageNet Explained

ImageNet Explained

ImageNet is not one dataset but a family of corpora with different label spaces and evaluation protocols—and choosing the wrong variant can invalidate a benchmark result. This book teaches you to work with ImageNet precisely, from its WordNet synset hierarchy and industrial annotation process to modern training and deployment workflows.

You will learn how ImageNet-1K, ImageNet-21K, ImageNetV2, and ReaL differ, how to obtain and verify ImageNet-1K under its access terms, and how to inspect annotation quality and label noise. Practical PyTorch and torchvision code takes you from decoding and augmentation through ResNet training, mixed precision, checkpointing, and DDP. You will also compare pretrained checkpoints from torchvision, Hugging Face, and timm; decide between fine-tuning, feature extraction, and CLIP zero-shot classification; and perform error analysis for texture bias, spurious cues, and dataset shift.

The evaluation chapters cover ImageNetV2, multi-label ReaL evaluation, confidence intervals, and statistical model comparisons. The final project covers custom dataset annotation, selective prediction with human review, ONNX packaging, TorchServe or Triton serving, and drift monitoring.

Every chapter includes hands-on exercises and a recap checklist. The book assumes Python and basic linear algebra; no prior computer vision experience is required.

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub