Build an AI agent from first principles: the model-tools-loop core, designing tools with schemas, the tool-use protocol of the Claude API, managing context, guardrails and human approval, evaluating agents, and the frontend that makes an agent trustworthy to use.
An agent is a language model running in a loop, choosing tools to call until it reaches a goal. Take away the buzzwords and that's the whole idea:
1while not done:
2 model looks at the conversation so far
3 model either answers, or asks to call a tool with some input
4 your code runs the tool and adds the result to the conversationWhat makes it an agent is that the model decides the next step. Compare that with a workflow, where your code decides the steps and calls the model at fixed points ("summarize this, then translate it, then format it"). Anthropic's engineering post Building effective agents (December 2024) draws exactly this line, and makes a point worth repeating: start with the simplest thing that works. Many products need a single well-crafted model call, or a workflow, not an agent.
Agents fit when
Workflows or single calls fit when
Coding assistants that edit files and run tests, research assistants that search and read, and support bots that look up orders and issue refunds within limits are all agents built from the same few parts. This tutorial builds those parts.