Leanpub Header

Skip to main content

AI agents for developers

Tool calling, MCP, planning, memory, multi-agent systems, safety, evaluation and cost, with Python examples and TypeScript notes

AI agents for developers
This book is 100% completeLast updated on 2026-11-22

You have shipped a feature that calls a model once. Now someone wants one that keeps going on its own: looks things up, decides what to check next, and does something about it. That is an agent, and most of the work is not in the model.

Minimum price

$12.99

$19.99

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
About

About

About the Book

You have shipped a feature that calls a model once. Now someone wants one that keeps going on its own: looks things up, decides what to check next, and does something about it. That is an agent, and most of the work is not in the model.

This book follows one agent from a first draft to something you could leave running. It is an on-call assistant: an alert fires, and it reads deploys, logs and metrics, finds the likely cause, and proposes a fix that a person approves. You'll start by building the plain workflow and seeing where it breaks, then write the tool-calling loop yourself against a model running on your own machine. You'll design tools a model uses well, move them into an MCP server, bound the loop with budgets, and compare ways to plan. Then the hard parts: what the model sees at each step when the context fills up, what it should remember between incidents, which actions need a human, and how instructions hidden in a log line can steer what the agent does. You'll split it into several agents and see what that costs, test it over repeated runs, price an incident, and decide whether a framework earns its place.

Each chapter ends with a decision about the agent. The final chapter takes the agent questions AI engineering interviewers ask and answers them from the trade-off.

Examples are in Python and run as part of the book's build, with notes where TypeScript does the job differently. Claims about papers, benchmarks and libraries are checked against the primary source. You need to be able to program. You don't need a machine learning background.

Author

About the Author

30labs

30labs publishes practical guides for developers who build with AI: coding agents, model APIs, tool servers and the languages around them. Every code example in a 30labs book is run before publication, and the output printed under it is what the program produced. Books in English and Brazilian Portuguese.

Contents

Table of Contents

  • 1. What an agent is, and when a workflow wins
  • 2. Tool calling from the wire up
  • 3. Designing tools an agent can use
  • 4. The Model Context Protocol in practice
  • 5. The loop: control, budgets and stopping
  • 6. Planning: act as you go, plan first, or plan in parallel
  • 7. Self-correction and verification
  • 8. Context engineering: what the model sees at each step
  • 9. Memory across runs
  • 10. Humans in the loop: permissions, approval and autonomy
  • 11. Securing an agent that reads untrusted text
  • 12. Many agents: when to split, and how they fail
  • 13. Evaluating and debugging an agent
  • 14. Cost and latency of an agent run
  • 15. Frameworks, or your own loop
  • 16. The interview

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