Here at Mastra, the open source Typescript framework forbuilding AI agents, we’ve had a front-row seat to how peopleare building agents.Back in February 2025 (practically ancient times, in AIworld), we published the popular guide Principles of BuildingAI Agents.In May, we updated the guide to include MCP, agenticRAG, and a few other emerging principles.But our work was far from finished.2025 is the year of agents and, over the summer, we began tosee a set of stories and guides emerging from prominent AIcompanies, model labs, and early-stage AI startups.The people pushing agents into production werepublicly describing their successes (and failures).Principles was textbook-style knowledge. This wasmessier and rough, expressed in ah-ha! moments, lessonslearned, and retrospectives — knowledge that sprawledvi Introductionacross social media posts, Substacks, eng blogs, and Gitrepos.Collecting and wrangling these lessons for our userseventually led to this book: Patterns for Building AI Agents —now Volume 2 of an eventual trilogy. Principles are conceptual, patterns are pragmatic.While Principles of Building AI Agents covered what to build,Patterns covers how to build.Principles will get you through the first few weeks ofbuilding, but Patterns should be on your desk until itscontents are imprinted in your mind.We start off by sharing patterns for agent design andarchitecture, then dive into the art and science of contextengineering. Next, we dig into the discipline of evals, thestandard way for iterating on and refining agent quality.Finally, we talk about agent security, a field evolving inresponse to novel attack patterns. Agents are in the hands ofearly adopters — and attackers are enthusiastic earlyadopters!Thanks for coming along as we all learn together. Thisbook is a work in progress and a living document.Perhaps as you build, you’ll discover a new pattern thatmakes it into our next edition!
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tags
Text Preview (First 20 pages)
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Generating text preview…
Loading comments...
Reply to Comment
Edit Comment