AI Agents,
Engineered

How to design, build, evaluate, and operate AI agents whose work you can check.

A vendor-neutral guide for software engineers. No machine-learning background required.

500 pages · 133 diagrams · 27 chapters · PDF, EPUB, Kindle, paperback

Cover of AI Agents, Engineered: three overlapping rings in ochre, teal, and charcoal on cream paper.

“I didn’t see every step. How much of this can I trust?”

You hand a language model a task that would take a person half an hour. Instead of an answer, you watch it work: it searches, reads, tries something, hits an error, corrects itself, and comes back finished. The first feeling is delight. The second arrives a beat later and lasts longer.

This book is about that second feeling. I wrote it for engineers who are comfortable with software but not necessarily with machine learning, and who want to get past both the hype and the dread to the engineering underneath.

Its argument fits in one sentence: an agent is only as trustworthy as the signal you can use to verify it.

—Enrique

The idea under every chapter

Every agent is the same loop.

Look, think, act, see what happened, go again. The engineering is in what you let through.

  1. ObserveChapters 3, 7Read the state of the task: what was asked, what has been done, what came back.
  2. ReasonChapters 2, 4A model picks the next step. It sounds equally sure when it is wrong; its tone is not evidence.
  3. ActChapters 5, 17A tool touches the world: a file, a query, a payment. What it can reach is a design decision.
  4. ResultChapters 3, 18The outcome lands back in the context, and the loop runs again—or stops.
  5. VerifyChapters 12, 16Grant autonomy only as far as a signal you can check: a passing test, a valid schema, a source you can open, a person who signs.

Seven parts, in the order you’ll need them.

From what an agent is, to building one, to keeping it honest in production. Part I is free to read here.

  1. Part I: Foundations

    Free to read
    Chatbot, workflow, and agent differ in one thing only: who decides the next step.
    Figure 1.2
  2. Part II: Building Agents

    In the full book
    • 3 The Agent Loop
    • 4 Planning, Reasoning, and Self-Correction
    • 5 Tools and the Action Space
    • 6 Skills, Protocols, and Interoperability
    One pass through the loop has four beats circling a growing history.
    Figure 3.2
  3. Part III: Context Engineering

    In the full book
    • 7 Managing the Context Window
    • 8 Retrieval and Knowledge
    • 9 Memory: Working State Across Long Runs
    The anatomy of an assembled context.
    Figure 7.1
  4. Part IV: Patterns and Choices

    In the full book
    • 10 Workflows and Composition Patterns
    • 11 Multi-Agent Systems
    • 12 Oversight and Autonomy
    • 13 Writing the Outer Loop
    • 14 Choosing Your Approach: When Not to Build an Agent
    The autonomy dial.
    Figure 12.4
  5. Part V: Making Agents Reliable

    In the full book
    • 15 Observability and Debugging
    • 16 Evaluating Agents
    • 17 Security, Safety, and Guardrails
    • 18 Reliability, State, and the Harness
    The lethal trifecta.
    Figure 17.2
  6. Part VI: Shipping and Operating

    In the full book
    • 19 Cost, Latency, and Performance
    • 20 Deploying and Scaling
    Prompt caching.
    Figure 19.3
  7. Part VII: Applications and the Road Ahead

    In the full book
    • 21 Coding Agents
    • 22 The Coding Workflow in Practice
    • 23 Research and Business Agents
    • 24 Agent UX and Human Trust
    • 25 Transversal Recipes: Big Patterns That Cut Across Industries
    • 26 Agents as Classifiers and Scorers
    • 27 The Frontier and How to Keep Learning
    The coding-agent loop.
    Figure 21.2

Plus A Minimal Agent, Annotated · Glossary · Annotated Further Reading and Source Map.

133 diagrams, one visual language.

Every idea gets a picture you can reason with. Select one to see it full size.

Start reading

Chapter 1. What Is an Agent?

The preface and Part I are free on this site, with the book’s diagrams, notes, and search.

Continue reading Chapter 1

This chapter keeps a promise made in the preface: before anything gets built, we pin down what an agent is. The need is practical, and immediate. Vendors label scripted bots “agents”; researchers reserve the word for systems that run unattended for hours; and somewhere in between, you have to make actual decisions with actual budgets. If the term stays fuzzy, you will reach for an autonomous agent where a three-step pipeline would have been cheaper and easier to debug, or you will hand-wire a rigid pipeline for a problem whose steps you genuinely cannot predict. The chapter does three things. It states the agent idea itself, explains why it became practical when it did—deliberately without dates—and lays out the compass the book will steer by. It then draws the working distinction among chatbots, workflows, and agents that every later chapter leans on. And it closes with the question too few people ask out loud: whether you need an agent at all.

Pick your format.

Same book everywhere. Buying on Leanpub gets you every future revision free.

PDF + EPUB

On Leanpub

$24.99 or more

  • DRM-free files for any reader
  • Every future update, free
  • Pay what you like above the minimum
Buy on Leanpub

Kindle

On Amazon

$12.99

  • Reflowable, on every Kindle device and app
  • Linked notes and all 133 diagrams
  • No DRM

In Amazon’s review now. The listing goes live within days.

Paperback

On Amazon

$39.99

  • 6 × 9 in, 499 pages
  • Printed on demand, shipped by Amazon
  • ISBN 979-8-17888-133-0

In Amazon’s review now. The listing goes live within days.

About the author

Enrique Gutiérrez

Enrique Gutiérrez is a professor of Computer Science at the Universidad Politécnica de Madrid and a research affiliate at MIT. He works on natural language processing, algorithm design, and AI agents—in particular, on turning language models into instruments whose outputs can be checked rather than merely trusted.

  • TeachesComputer science, Universidad Politécnica de Madrid
  • ResearchResearch affiliate, MIT
  • Works onNatural language processing, algorithm design, AI agents

Questions

Who is this book for?

Engineers who build software and are starting to build with agents, or deciding whether to. No machine-learning background is required: every term is defined where it first appears.

Is it tied to a framework or vendor?

No. It teaches the patterns underneath the tools—the loop, the tool contract, the context budget, the evaluation harness—and names products only as labeled examples.

Will it go out of date?

It is written to last: no claim depends on which model is best this quarter or what a token costs today. Leanpub buyers get every revision free.

What can I read for free?

The preface and Part I, right here, plus the glossary of 87 terms.

Which format should I buy?

Leanpub if you want PDF and EPUB with free updates, Kindle if you read on Kindle, and the paperback if you want it on your desk.