PATCHBOOK SERIES
Patchbook: Agents are just loops
Short, simple chapters that serve as a conceptual upgrade for software engineers.
The first book in this series, Patchbook: LLMs are just APIs, established the mental models: the model is a stateless engine, the host controls everything, and an agent is just a loop.
This book is about that loop. A chatbot is a loop paced by a human. A retrieval pipeline is a loop that consults your data. An autonomous agent is a loop that no longer waits for the human at all. Each chapter adds one more capability to the same loop (managed history, attachments, retrieval, structured output, and tools) until the loop can run on its own.
In development. Chapters will appear below as they are written.
- Chapter 0: What you will learnA list of things this book can teach you.
- Chapter 1: Building a Chatbot, Part 1The message array, chat history as a data structure, a simple chatbot, and streaming responses.
- Chapter 2: Building a Chatbot, Part 2Attachments as content blocks in the message array: files, documents, and images.
- Chapter 3: Building a Chatbot, Part 3Managing chat history: append, trim, summarize, and persist.
- Chapter 4: RAGRetrieval Augmented Generation: giving your LLM access to your data with keyword search and re-ranking.
- Chapter 5: Structured DataHow to get reliable structured output from LLMs.
- Chapter 6: Tool CallingHow LLMs can invoke external tools and functions.
- Chapter 7: Gotchas, Part 1Pitfalls in multi-turn systems: stochastic drift, prompt injection, and context window overflow.
- Chapter 8: Building Your Own AgentHow to combine the patterns into a complete LLM agent.
- Chapter 9: Gotchas, Part 2Pitfalls specific to autonomous agents: context poisoning, runaway loops, and tool misuse.