
Principles of Building AI Agents

Suggested reading: “o1 isn’t a chat model” by Ben Hylak
Sam Bhagwat • Principles of Building AI Agents
The key to effective tool use is clear communication with the model about what each tool does and when to use it.
Sam Bhagwat • Principles of Building AI Agents
in Mastra we define the conditional path execution on the child step rather than the parent step. In this example, a processData step is executing, conditional on the fetchData step succeeding.
Sam Bhagwat • Principles of Building AI Agents
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.
Sam Bhagwat • Principles of Building AI Agents
Think of agents as AI employees rather than contractors: they maintain context, have specific roles, and can use tools to accomplish tasks.
Sam Bhagwat • Principles of Building AI Agents
You should describe both what it does and when to call it.
Sam Bhagwat • Principles of Building AI Agents
Best practices: Provide detailed descriptions in the tool definition and system prompt Use specific input/output schemas Use semantic naming that matches the tool's function (eg multiplyNumbers instead of doStuff)