
AI Agents from Scratch
Tool Calling, Loops, and Failure Recovery — Before You Reach for a Framework
Understand the core mechanics of an AI agent before adopting a framework. Explore tool calling, execution loops, and failure recovery to see how agents work and where they can go wrong.
View on Amazon ↗Opens Amazon in a new tab. Check the listing for formats and availability.
About this book.
Job ads everywhere ask for "experience building AI agents." Most developers who have called an LLM API a hundred times still cannot say what separates an agent from a chatbot wrapper — and often, neither can the people writing the ad.
AI Agents from Scratch fixes that by building one. In sixteen short, hands-on chapters, you write a real, working, multi-tool agent in plain Python and the Anthropic Claude API — no framework, nothing hidden — so every piece of "the loop" is code you wrote and can explain.
Inside, you will
- Build a full perceive-decide-act-observe loop by hand
- Route between tools and manage context across steps
- Recover from failure with stopping conditions and retries
- Test an agent whose output changes every run
- Measure what a run costs, instead of guessing
- Learn when a framework like LangGraph is worth it
Every chapter ends with a practice task and a deliberate "break it on purpose" challenge. If you can write Python and want to explain exactly how an agent works in your next interview, start here — before you install anything.
Reader resources.
Includes a README with setup notes and a chapter-by-chapter file index.
Official documentation and guides for topics covered in this book.
← Back to the books