Leanpub Header

Skip to main content

AI Engineering Visualized: Volumes 1 & 2

From one prompt to an agent you can trust with real tickets. One project across two visual books: Foundations, then Agents.

Bought separately

$48.00

Minimum price

$24.99

$34.99

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

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

About

About the Bundle

Start with one prompt. Finish with an agent you'd trust on real tickets.

These two books follow one project from beginning to end: a support assistant for Northwind Goods, a fictional online store. Volume 1 builds it. Volume 2 makes it reliable. Get both and you never have to restart with a new example, a new codebase or a new set of terms.

What you build

In Volume 1: Foundations (24 chapters), a single prompt answering "Can I get a refund for order #1234?" grows into a working system that:

  • decides refunds with rules in code the model can't argue away
  • counts its tokens and checks its output against a contract
  • calls tools, searches a handbook and answers with citations
  • says "I don't know" when the pages don't cover the question
  • measures itself with evals before every change
  • runs an agent loop with step limits, permissions and human approval
  • retries failed calls, masks personal data and logs every request

In Volume 2: Agents, that assistant gets the harness it needs for real work:

  • tools with schemas, validation and a limited blast radius
  • plans that are checked before they run and repaired when a step fails
  • verification before anything is committed
  • a state machine with checkpoints, so a ticket can resume, and a recorded reason for every stop
  • side effects with idempotency keys and receipts, so a refund is never paid twice
  • tickets that wait on a courier and can be cancelled safely
  • approvals bound to the exact action, so a changed amount needs a fresh sign-off
  • memory you can correct, and context that keeps what each step needs

Still to come in Volume 2: agentic RAG, MCP, tool trust, multi-agent systems, failure engineering, evaluation and reliability.

How the books teach

Every idea is a named mental model drawn as a doodle, with a plain definition, a failure you can trigger and the fix. Every chapter has short Python examples that run on a scripted stand-in model, so they cost nothing to try.

Why the bundle

Bought separately, each book has a $14.99 minimum and a $24 suggested price ($29.98 minimum, $48 suggested for both). The bundle is $24.99 minimum and $34.99 suggested.

Early access, free updates

Volume 1 is about 90% complete: all 24 chapters are in, and the explainer videos are still to come. Volume 2 is in early access, with 10 of 17 planned chapters written. You buy once and get every new chapter and revision of both books free as it lands.

Who it's for

Backend and full-stack developers, data engineers who've been asked to "add AI", and technical founders who need LLM features that hold up after the demo. You need to read Python. You don't need a machine learning background.

Books

About the Books

AI Engineering Visualized, Volume 1: Foundations

AI Engineering Visualized, Volume 1: Foundations

A Visual Guide to Building LLM Apps, RAG and Agents

You got the demo working. Now it has to work on Monday. AI Engineering Visualized is for developers who have to ship features that call a language model. A model is one box; a product is the whole diagram around it. This book draws that diagram, box by box, as hand-drawn doodles you can remember and reuse when you design or debug. Every idea is a named mental model, such as The Context Suitcase, The Citation Gate, The Golden Set or The Trojan Ticket, with a picture, a plain definition, a failure you can trigger and the fix. One assistant, built chapter by chapter. You build a support assistant for Northwind Goods, a fictional online store. It starts as one prompt answering "Can I get a refund for order #1234?" and grows into a system that:

  • decides refunds with rules in code the model cannot argue away
  • counts its tokens and checks its own output against a contract
  • calls tools, then searches a handbook and answers with citations
  • says "I don't know" when the pages don't cover the question
  • measures itself with evals before every change
  • runs an agent loop with step limits, permissions and human approval
  • retries failed calls, masks personal data and logs every request for replay

Real code, no API key. Every chapter has short Python examples from the free companion repository (MIT licence, Python standard library only) and an exercise with a tested solution. The examples run on a scripted stand-in model, so they cost nothing; swap in your provider with one function when you are ready. Who it's for: backend and full-stack developers, data engineers asked to "add AI", and technical founders. You need to read Python. You do not need a machine learning background. Who it's not for: readers who want to train models from scratch, or a catalogue of today's model prices and rankings. Prices and model names change too fast; the book shows you how to measure instead. Early access (about 90% complete). All 24 chapters of Volume 1 are in this edition, fully illustrated. Each chapter's explainer video (QR code and short link in the book) is coming. Buy once and get every update free as the videos land.

Table of contents

Part I: The First Call

  1. AI Engineering Is a System
  2. What an LLM Is: From Text Predictor to Assistant
  3. Talking to a Model: The Chat API
  4. Tokens: What the Model Reads and What You Pay
  5. One Token at a Time: Why Answers Vary

Part II: Making It Dependable

  1. Inside the Context Window: What the Model Pays Attention To
  2. Fluent Is Not True: Hallucination
  3. Evals: Measuring a Probabilistic System
  4. Choosing a Model
  5. Anatomy of a Prompt
  6. Structured Output and Tool Calling

Part III: Giving It Knowledge (RAG)

  1. Embeddings: Meaning as Coordinates
  2. Search and Retrieval: Finding the Right Passage
  3. Chunking: Cutting Documents So the Right Piece Is Found
  4. The RAG Pipeline: Retrieve, Then Answer
  5. Grounded Answers: Citations and "I Don't Know"
  6. Is the RAG Working? Evaluating Retrieval and Answers

Part IV: Giving It Hands (Agents)

  1. Workflows vs Agents: Rails or Steering Wheel
  2. The Agent Loop: Think, Act, Observe
  3. Planning and Multi-Step Tasks
  4. Memory: What the Agent Remembers
  5. Agent Safety: Permissions, Approvals and the Trojan Ticket

Part V: Ship It

  1. Guardrails and Privacy: Checks In, Checks Out
  2. Ship It: Errors, Tracing, Latency and the Complete System

Plus: About This Book (with how to use the code), How to Read the Doodles, How to Use the Videos, a Further Reading appendix, a Glossary and a Mental-Model Index.

AI Engineering Visualized, Volume 2: Agents

AI Engineering Visualized, Volume 2: Agents

A Visual Guide to Designing Agents That Plan, Act and Recover

Your agent worked in the demo. Then it refunded the wrong order, waited forever on a courier, or told a customer "your refund has been processed" when no payment ever went through.

AI Engineering Visualized, Volume 2: Agents is about everything around the model that turns its proposals into safe, finished work. The book calls that the agent harness: the loop, the tool registry, the checks, the state store, the approvals, the memory and the limits. The model is a part you can swap. The harness is what you test, version and ship.

One assistant, carried forward. Volume 1 ended with a support assistant for Northwind Goods, a fictional online store. Volume 2 picks it up and makes it an agent you could trust with real tickets: refunds, damaged items, late deliveries, address changes. Each chapter builds one part of the harness, shows a failure you can trigger, and fixes it.

Visual first. Every idea is a named mental model, such as The Agent Harness, The Identity Chain, Blast Radius, One Operation, One Receipt, The Waiting Ticket or Every Stop Has a Reason, drawn as a doodle with a plain definition next to it.

Real code. Each chapter has short Python examples ("Hands on Keys") and runs on a scripted stand-in model by default, so it costs nothing. Chapters also report what happened when the same code ran against a real local model (llama3.2 through Ollama), including the bugs those runs exposed and how the harness was changed to catch them.

What's inside

Done (in this edition):

  1. The Agent Harness: Everything Around the Model
  2. Tool Engineering: Schemas, Validation and Safe Actions
  3. Planning: Dependencies, Validation and Replanning
  4. Verification Before Commit: Checks, Bounded Revision and Postconditions
  5. State Machines, Checkpoints and Stop Reasons
  6. Side Effects: Idempotency, Transactions and Compensation
  7. Long-Running Tickets: Waits, Progress and Cancellation
  8. Human Oversight: Approvals, Interrupts and Escalations
  9. Agent Memory: Lifetime, Scope and Correction
  10. Context Engineering for Long-Running Agents

Coming (planned; titles may change):

11. Agentic RAG: Retrieval the Agent Chooses

12. MCP: Hosts, Clients, Servers and Discovery

13. Tool Trust: Credentials, Allow-Lists and Untrusted Output

14. Multi-Agent Systems: Handoffs, Coordination and Trade-offs

15. Agent Failure Engineering: Loops, Cascades and Side Effects

16. Agent Evaluation: Outcomes and Trajectories

17. Agent Reliability: Repeat Runs, Scorecards and Gates

Chapters 1-3 are in the free sample.

Who it's for

Developers who have a working LLM feature or a basic agent loop and now need it to behave on real tasks: backend and full-stack engineers, data engineers, and technical founders. You need to read Python. It helps to have read Volume 1 (especially its agent chapters), but the ideas it relies on are recapped where they are used.

Early access

This book is in early access: 10 of 17 planned chapters are written (about 59%). Buy once and get every new chapter and revision free as it lands.

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