- Chapter 1: Understanding What an Agent Is
- Chapter 2: Building the Agent Loop
- Chapter 3: Designing Tools for Agents
- Chapter 4: Engineering Context
- Chapter 5: Adding Memory
- Chapter 6: Planning and Reasoning
- Chapter 7: Applying Workflow Patterns
- Chapter 8: Building Multi-Agent Systems
- Chapter 9: Connecting Agents to the World
- Chapter 10: Keeping Humans in the Loop
- Chapter 11: Evaluating Agents
- Chapter 12: Securing Agents
- Chapter 13: Operating Agents in Production
- Chapter 14: Learning from Case Studies and Looking Ahead
- Appendix A: Setting Up the Environment
- Appendix B: Pattern Cheat Sheet and Decision Tree
- Appendix C: Evaluation Templates and Checklists
Designing AI Agents
Build reliable, production-grade agents with tools, memory, planning, and evaluation
AI agents are easy to demo and hard to ship. This hands-on TypeScript guide starts with a 120-line agent loop and grows it into a system you can test, secure, and run in production.
Minimum price
$9.00
$10.00
You pay
Author earns
Buying multiple copies for your team? See below for a discount!
About
About the Book
AI agents are easy to demo and hard to ship. A model that calls a few tools in a loop can look impressive in an afternoon. Making that system reliable, affordable, safe, and maintainable is an engineering job, and this book is about that job.
You'll start by writing an agent loop of about 120 lines of TypeScript, with no framework, so you know exactly what every later piece does. Then you'll grow it, chapter by chapter, into a system you could run in production.
What you'll learn
- When to build an agent, and when a fixed workflow is the better choice
- How to design tools, schemas, and error messages a model can use well
- How to manage context, compaction, prompt caching, and long-term memory
- Planning with ReAct, plan-and-execute, reflection, and extended thinking
- Workflow patterns: chaining, routing, parallel calls, orchestrator-workers, and evaluator-optimizer
- Subagents, handoffs, MCP tools, and a sandbox for running code
- Approval gates, interruptions, and escalation to a human
- Evals with code graders, trajectory checks, and LLM judges
- Defending against prompt injection with permissions and blast-radius limits
- Tracing, cost accounting, retries, and versioning in production
Who this book is for
Software engineers, backend and full-stack developers, and technical leads who are comfortable with TypeScript or JavaScript and want to build agents that do real work. No machine learning background is needed.
Team Discounts
Team Discounts
Get a team discount on this book!
Up to 3 members
- Minimum price
- $22.00
- Suggested price
- $25.00
Up to 5 members
- Minimum price
- $36.00
- Suggested price
- $40.00
Up to 10 members
- Minimum price
- $63.00
- Suggested price
- $70.00
Up to 15 members
- Minimum price
- $90.00
- Suggested price
- $100
Up to 25 members
- Minimum price
- $135
- Suggested price
- $150
Author
About the Author
Sandeep Kumar Patel is a senior web developer with more than 17 years of experience building web applications in object-oriented JavaScript and JSON. In 2012 he founded tutorialsavvy, a programming blog that developers have been reading ever since.
He is GATE-2005 Information Technology (IT) qualified and holds a Master's degree from VIT University, Vellore.
Contents
Table of Contents
Get the free sample chapters
Click the buttons to get the free sample in PDF or EPUB, or read the sample online here
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.