The year of agents: A new book shares the principles of how to build them

By Janus Boye

Sam Bhagwat is the author of multiple books and also a co-founder at Gatsby. Now he is building mastra, the typescript framework for building ai agents

In January, Sam Altman, the CEO of OpenAI, famously told us that 2025 would be the “year of agents.”

In late February, Sam Bhagwat published the first version of his book Principles of Building AI Agents to help educate developers. Sam, is a veteran of web development and long time part of our community,

The book has become the go-to guide for engineers building with AI — and their product managers and CEOs. One founder from the famous Y Combinator startup incubator even called it "the most popular book in San Francisco".

Now it is out in the 2nd edition with new sections on MCP, image generation, voice, Agent 2 Agent, and much more. As Sam notes in the foreword, two months is a very short time to write an updated edition of any book, but AI is masterful at time dilation.

In a recent members’ call, Sam joined us a we held an informal book launch for the community. Let’s start by diving into what’s actually in this much hyped and very timely book.

A practical guide to building agents that cuts through the hype

Principles of Building AI Agents came out in the 2nd edition in May

Principles of Building AI Agents focuses on the substance without hype or buzzwords. The 2nd edition is a light read at 133 pages and comes with code examples and diagrams.

As someone who's been at the frontier of software for a long time (first with Gatsby, now with Mastra), Sam wanted to create something practical that cuts through the hype around AI. Given the right tools and knowledge, anyone can and should be able to build a simple agent in just 5 minutes. That’s why this book is intentionally short: it’s meant to get you building in as quickly as possible.

In our call, Sam explained that the book stemmed from numerous whiteboarding sessions with people building agents, identifying a need to share accumulated knowledge. You'll find that Sam has broken everything down into digestible pieces – from choosing the right LLM to structuring workflows and implementing RAG. The code examples are meant to be something you can actually use to get a simple, complete project working in just a day or two.

The book is structured around seven chapters:

  • Prompting a Large Language Model (LLM)

  • Building an agent

  • Graph-based workflows

  • Retrieval-Augmented Generation (RAG)

  • Multi-agent systems

  • Testing with Evals

  • Local dev and serverless deployment

Before going much further, it’s probably time to answer the question: What is an agent?

What is an agent really?

Rapid advances in large language models (LLMs) have made new kinds of AI applications, known as agents, possible. In the book, Sam writes:

“Think of agents as AI employees rather than contractors: they maintain context, have specific roles, and can use tools to accomplish tasks.”

He also offers another way to think about agents with agency as a spectrum:

  • At a low level, agents make binary choices in a decision tree

  • At a medium level, agents have memory, call tools, and retry failed tasks

  • At a high level, agents do planning, divide tasks into subtasks, and manage their task queue.

In the call, Sam mentioned that agents are in particular gaining traction in customer support.

Note also that in mid-July, OpenAI introduced ChatGPT agent to bridge research and action.

What’s next when it comes to agents?

We're all figuring this out together since the field is moving so quickly and clearly there is a big need for education in this hyped space.

Matt Garrepy from CMS Critic got his hands on the book and shared a short review with this quote:

"We are engineers. And engineers can over-engineer things. With RAG, you should fight the tendency."

Start simple, check quality and then get complex is some solid advice from the book.

In the call, Joyce Peralta from McGill in Montréal, also asked about the need for governance. According to Sam, the topic of governance will be the big one for 2026. The book also comes with a few more predictions for the future, including these:

  • Reasoning models will continue to get better.

  • We’ll make progress on agent learning.

  • Security will become more important.

And to close with the final wise words from the book:

“In a field where the ground shift constantly, we're all perpetual beginners. To build something enduring, you have to stay humble.”

Thanks, Sam, for sharing your experience and helping educate the marketplace!

Learn more about building AI agents and get your own copy of the book

You can get a digital copy of the book for free and with limited availability, you can also get a printed copy for free.

The conversation naturally continues in our peer groups at conferences in Europe and North America. Why not join us and be a part of it?

There were no slides in the call, but you can lean back and enjoy the recording below.