CHAPTER 01 · Anatomy of an AI Agent · 2 / 5
The six parts
A production agent has six conceptual parts. Hold all six in your head and most design questions become "which part does this belong to?"
1. The model
The LLM itself, the reasoning engine. You usually don't build this; you call it via a provider API. Key properties you'll design around: its context window (how much it can read at once), whether it supports tool/function calling, whether it can stream, and whether it exposes a reasoning/thinking mode. Treat the model as a powerful but stateless, occasionally-unreliable component you orchestrate, not as the system itself.
2. The loop (orchestrator)
The control structure that drives the model: call the model, see if it asked for tools, run them, feed results back, repeat until it produces a final answer. This is the agent's "main function." It owns iteration limits, streaming, and the bridge between the model's requests and your code's actions. (Chapter 2.)
3. The tools
The actions the agent can take, each described to the model by a schema (name, description, parameters). A tool might read a document, search a database, send an email, or generate a file. Tools are how the agent affects the world and gathers information beyond its training. The set of tools defines the agent's capabilities. (Chapter 3.)
4. The context
Everything assembled and sent to the model on a given call: the system prompt, the conversation history, the available tools, and any injected information (available documents, retrieved snippets, prior-turn summaries). Context is constructed fresh for each call. This is the most underappreciated part and the one that most determines quality. (Chapter 5.)
5. The memory / state
What persists across calls and across sessions: conversation history, generated artifacts, the status of long-running work, user preferences. The model is stateless between API calls; memory is how continuity is created. It usually lives in a database and is selectively loaded into context. (Chapters 5, 9.)
6. The surrounding system
Everything that makes the agent a real product rather than a demo: authentication and authorization, storage, streaming transport, secrets management, rate limiting, observability, error handling, and the data model. This is the bulk of the engineering, and it's where agents succeed or fail in production. (Chapters 8–18.)