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...

LLM features, long-running agents and the MCP tools they call: three practical books on building AI that survives production, with tested Go code for every pattern.
Bought separately
$63.00
$45.00
About the Bundle
Three books for backend engineers who have been asked to put AI into real products, and keep it running.
Each book treats AI as what it is in production: a dependency that is slow, costs money, sometimes goes down and is sometimes wrong. Each one applies engineering you already know (timeouts, idempotency, state machines, rate limits, audit) to it. Each comes with an open-source Go companion repository where every snippet in the book is tested in CI.
Read them in any order. Each book stands alone, and together they cover the whole path: one model call, a long-running agent, and the tools it touches.
What you get: 39 chapters, PDF and EPUB, with an Interview Corner, a production checklist and a TL;DR in every chapter, plus free updates. The bundle costs less than buying the three books separately.
All incidents are composites. Drafted with AI assistance; reviewed, tested and edited by the author.
About the Books
Your agent runs at 3 a.m. with nobody watching. Build it like it knows.
The demo was flawless. Then the agent ran overnight. It looped for six hours on a listing it could never fix. A pod restart made it refund the same order twice. An approval request scrolled out of a chat channel, and the run waited all weekend. Text hidden in a seller's listing told it to send order data somewhere it shouldn't.
None of these are model problems. They are distributed-systems problems with a model in the loop, and backend engineers already know how to solve most of them.
Agents Never Sleep treats an agent as what it is in production: a long-running state machine whose next step is chosen by a model, calling real tools, touching real money and data. Then it applies proven engineering from payment systems and workflow engines to that loop.
What you'll be able to do
Code you can run today
Every Go snippet in the book comes from the open-source companion repository, github.com/AlwyAbdullah/agents-never-sleep. It has 17 packages, uses only the standard library, and every package is tested in CI. One command, go run ./cmd/night-shift, runs three production stories offline, with no API key.
In that demo a stuck agent is stopped after 4 steps. A kill switch pauses refunds for one tenant. In a refund run, one worker dies mid-run and another resumes from the journal without repeating the approval or the refund.
Read the code for free. Buy the book for the why: the failure stories, the trade-offs, and when each pattern is overkill.
What's inside
Who it's for
Backend engineers and tech leads who build, run or review AI agents, and engineers preparing for "design an agent platform" interviews. If you've built services, queues and state machines, you're ready. No ML background is needed.
Not for you if you want ML theory, prompt collections, or a step-by-step guide to one agent framework.
Part of a series: Models Make Things Up (single LLM features) and The Tool Layer (MCP servers and agent tools). Each book stands alone.
Facts that can change were checked in November 2026. All incidents are composites. Drafted with AI assistance; reviewed, tested and edited by the author.Table of contents
Every agent is a new client. Build the server side like it.
You published a tool. Now strangers' agents call it thousands of times, with arguments chosen by a model that read your description once and believed every word. One loops all night. One sends the same refund twice. One arrives with a token that was never meant for you. And one read a product listing that told it to do something else.
An MCP server is a public API whose caller is creative, retries a lot, and acts on text it found somewhere. Most MCP material stops at "here is how to register a tool". The Tool Layer starts where real users, real tenants and real money begin.
What you'll be able to do
Code you can run today
Every Go snippet in the book comes from the open-source companion repository, github.com/AlwyAbdullah/the-tool-layer: a small MCP server (revision 2026-07-28, Streamable HTTP), standard library only, with every package tested in CI. Start it with go run ./cmd/kiosk-mcp, then run go run ./cmd/kiosk-client in a second terminal. No API key is needed.
The client walks through the failure cases against the real server: no token, a cross-tenant lookup, an invalid enum, the same refund sent twice, a 429 with Retry-After, and finally "nothing left to refund".
Read the code for free. Buy the book for the why: the incidents behind each check, the trade-offs, and when a check is overkill.
What's inside
Who it's for
Backend engineers building MCP servers or exposing their product to agents, tech leads and security reviewers deciding what agents may touch, and engineers preparing for "design a tool platform for agents" interviews.
Not for you if you want an agent-framework tutorial, prompt tricks, or a complete MCP reference.
Part of a series: Agents Never Sleep (running agents in production) and Models Make Things Up (single LLM features). Each book stands alone.
Facts that can change were checked in November 2026. All incidents are composites. Drafted with AI assistance; reviewed, tested and edited by the author.Table of contents
Your LLM demo worked. Then production happened: a provider outage turned into a minute-long spinner, the model invented a refund policy, a retry loop quadrupled the bill, and a user talked the assistant into a discount code.
Models Make Things Up is for backend engineers who have been asked to "add AI" to a real product. It treats the language model as what it is in production: a slow, billed, sometimes-down, occasionally wrong dependency, and shows the engineering that makes features built on it reliable.
What you will learn
What is inside: 14 chapters, 5 appendices (glossary, production-readiness checklist, LLM API error taxonomy, eval set template, sources), 9 diagrams, and an Interview Corner, Production checklist and TL;DR in every chapter. Every Go snippet comes from a companion repository (standard library only, every package tested). PDF (146 pages) and EPUB.
No model rankings, no hype. Provider-agnostic engineering that stays useful when models change.
Who it is for: backend engineers and tech leads building or reviewing LLM features, and engineers preparing for "design a system with an LLM" interviews.
Who it is not for: people looking for ML theory, fine-tuning, or a prompt-tricks collection.
Facts that can change were checked October 2026. All incidents are composites.Code you can run today
Every Go snippet in the book comes from the open-source companion repository, github.com/AlwyAbdullah/models-make-things-up: 20 packages covering all 14 chapters, standard library only, every package tested in CI. go run ./cmd/kiko runs the whole book in one request flow, offline and with no API key: a provider outage answered by the fallback chain, a cached repeat, a refund that runs once, and a prompt-injection attempt whose made-up discount code is blocked before it reaches the customer.
Read the code for free. Buy the book for the why: the incidents behind each pattern, the trade-offs, and when a pattern is overkill.
Table of contents
Part of a series: Agents Never Sleep (running agents in production) and The Tool Layer (MCP servers and agent tools). Each book stands alone.
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
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
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
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.