Principles
of Building
AI Agents
Principles of Building AI Agents is the world's leading guide to getting started with AI agents. Written by Sam Bhagwat, CEO of Mastra, it covers the core concepts, tools and patterns developers need to build agents that reason, use tools, manage memory and orchestrate workflows in production.
- Agents
- Memory
- Workflows
- RAG
- Tools
- Traces
The Complete Handbook for Building Production AI Agents

189,500 Books Printed
Principles of Building AI Agents has been distributed to people across the globe.

Patterns
Explore the second book in agentic series that builds on Principles

Sam Bhagwat
Sam Bhagwat is the CEO of Mastra and the author of Principles of Building AI Agents. Watch him go over a few chapters of his book.
Read and shared worldwide.
What's inside?
Principles of Building AI Agents gives you a clear overview of how modern AI agents work and the core concepts, tools and patterns you will use to build real agentic systems. The book opens with LLM fundamentals and prompt engineering before moving into agents, tool calling, memory, workflows and RAG. Later chapters cover multi-agent systems, observability and evals, deployment, coding agents and multimodal capabilities. Each chapter includes code examples and real-world patterns.