- Preface
- How to use this book
-
Chapter 0. Foundations
- 0.1 Setting up
- 0.2 Chat models and messages
- 0.3 Asking for help: the idea
- 0.4 Example: looking up an order
- 0.5 Middleware
- 0.6 The stand-in model
- 0.7 Common pitfalls
- 0.8 Summary
-
Chapter 1. What the harness adds
- 1.1 One tool, two builders
- 1.2 The harness and the deep agent
- 1.3 Built-in tools
- 1.4 The system prompt
- 1.5 A real run
- 1.6 Common pitfalls
- 1.7 Summary
-
Chapter 2. Files as working memory
- 2.1 Files during a run
- 2.2 Agent state
- 2.3 The backend
- 2.4 A real run
- 2.5 Common pitfalls
- 2.6 Summary
-
Chapter 3. Planning with a to-do list
- 3.1 Adding the to-do list
- 3.2 The to-do list in the agent state
- 3.3 Planning: a real run
- 3.4 When a plan does not help
- 3.5 Common pitfalls
- 3.6 Summary
-
Chapter 4. Handing work to a subagent
- 4.1 Counting tokens
- 4.2 The context window
- 4.3 Handing a job to a subagent
- 4.4 Context isolation: a real run
- 4.5 Common pitfalls
- 4.6 Summary
-
Chapter 5. Your own subagents
- 5.1 A subagent of your own
- 5.2 Several tool calls in one reply
- 5.3 A real run: two jobs, two subagents
- 5.4 Common pitfalls
- 5.5 Summary
-
Chapter 6. Conversations that continue
- 6.1 A second invoke that remembers
- 6.2 What the checkpointer saves
- 6.3 A real run
- 6.4 Common pitfalls
- 6.5 Summary
-
Chapter 7. Asking before acting
- 7.1 A run that stops before a tool
- 7.2 Continuing the run
- 7.3 Approve, edit or reject
- 7.4 A real run
- 7.5 Common pitfalls
- 7.6 Summary
-
Chapter 8. Permission rules
- 8.1 A rule that refuses
- 8.2 Patterns and order
- 8.3 Holding a path for a person
- 8.4 What rules do not cover
- 8.5 A real run
- 8.6 Common pitfalls
- 8.7 Summary
-
Chapter 9. Where files really live (advanced)
- 9.1 Files on your disk
- 9.2 A store shared by threads
- 9.3 Routing by path
- 9.4 Four backends side by side
- 9.5 A real run
- 9.6 Common pitfalls
- 9.7 Summary
-
Chapter 10. Remembering across conversations (advanced)
- 10.1 A file in every system message
- 10.2 Memory that outlasts a thread
- 10.3 A real run
- 10.4 Common pitfalls
- 10.5 Summary
-
Chapter 11. Skills (advanced)
- 11.1 A skill on file
- 11.2 What the model gets first
- 11.3 A real run
- 11.4 Skill, tool, system prompt, memory file
- 11.5 Common pitfalls
- 11.6 Summary
-
Chapter 12. Keeping the context small (advanced)
- 12.1 Moving a large result into a file
- 12.2 Summarizing older messages
- 12.3 How summarization decides and cuts
- 12.4 A real run
- 12.5 Common pitfalls
- 12.6 Summary
-
Chapter 13. Project: a research assistant
- 13.1 The plan of the assistant
- 13.2 Step 1: the sources, kept read-only
- 13.3 Step 2: two researchers at once
- 13.4 Step 3: a plan, and a report that waits
- 13.5 The whole assistant: a real run
- 13.6 Sources on disk (advanced)
- 13.7 Remembering the reader's preferences (advanced)
- 13.8 A skill for the report format (advanced)
- 13.9 Long sources (advanced)
- 13.10 Common pitfalls
- 13.11 Summary
- Answers to the self-checks
- Glossary
Deep Agents, Step by Step
14 chapters, 362 pages, every output from a real recorded run, with runnable example code for every listing. Start free with chapters 0 to 2.
Minimum price
$14.99
$19.99
You pay
Author earns
About
About the Book
Learn to build agents that plan their work, keep notes in files, hand jobs to helpers, and stop to ask you before they act, using LangChain's open-source deepagents library.
This book starts from zero. If you know Python but have never used an LLM framework, chapter 0 teaches the basics every later chapter needs: chat models, messages, tools, the agent loop and middleware. Each new idea then comes the same way: a plain-language picture, the smallest example that runs, a figure, and only then the formal definition.
What's inside- 14 chapters, 362 pages, in one PDF
- Every printed output comes from a real recorded run, not from memory
- Runnable example code for every listing; most examples run offline from the recordings, so you can follow along without paying for model calls
- Self-check questions in every chapter, with answers at the back; exercises in every chapter, with full solutions in the example code
- A final project: a small research assistant that plans, sends two researchers in parallel, and waits for your approval before it writes its report
- Foundations
- What the harness adds
- Files as working memory
- Planning with a to-do list
- Handing work to a subagent
- Your own subagents
- Conversations that continue
- Asking before acting
- Permission rules
- Where files really live (advanced)
- Remembering across conversations (advanced)
- Skills (advanced)
- Keeping the context small (advanced)
- Project: a research assistant
The book shows the model's mistakes as they happened in the recordings. In the final project the model miscounts late tickets, and a weak review step lets the error through; the chapter traces the error to its source and shows how to check better. Chapter 8 shows a real gap in path-based permission rules (file names that start with a dot) and how to work around it.
Who it's for- Python developers new to LLM frameworks: start at chapter 0 and follow the beginner route (chapters 0 to 8, then the project)
- Developers who have used LangChain or another agent framework: skim chapter 0, then see exactly what create_deep_agent adds and why
Not covered: training or fine-tuning models, running code or shell commands from an agent, deployment, or a full reference of every option. The official documentation is the place for those.
Versions: written and verified in November 2026 against deepagents 0.7.39, langchain 1.5.0 and langgraph 1.2.22, Python 3.11. Recordings use DeepSeek's deepseek-flash model. Running every example and exercise solution once cost about US$0.20.
Format: PDF, 7.5 × 9.25 in. Vector figures. English.
Categories
Feedback
Author
About the Author
Eric W is an independent AI consultant who helps teams build agents that work outside the demo: agents that plan, keep state, hand work to helpers and stop for human approval.
Before going independent, he spent six years in fintech, and earlier worked at IBM, HP and Cisco. That background shapes how he writes: every output in his books comes from a real recorded run, every example ships as runnable code, and the mistakes the model made stay in the book along with how to catch them.
He also builds his own products, including 1000usdinchina.com, a China travel budget planner with an AI trip-planning option.
Example code for his books: https://github.com/airplanecraft/books-deepagents
Contents
Table of Contents
Get the free Community Edition
You can get the free Community Edition in PDF or EPUB just by sharing your name and email address with the author.
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.