Overview

1 What is an AI agent?

The chapter introduces AI agents as systems built around large language models that can decide what to do next, use tools, and repeat that process until a goal is reached. It begins by showing the broad landscape of agents today, including personal assistants, customer-facing support systems, and specialized tools for coding or research. Although these systems look different on the surface, they all depend on LLMs as the core decision-maker, which is why the book treats AI agents and LLM agents as essentially the same idea.

At the heart of an agent is autonomous control flow: instead of following a fixed sequence written entirely by a developer, the model helps determine the next action based on context and progress. The chapter explains that this autonomy comes from combining three parts: an LLM, tools that connect it to the outside world, and a loop that lets it act, observe results, and continue or stop. It also draws a clear distinction between workflows and agents, showing that workflows are developer-defined and predictable, while agents are LLM-directed and flexible. In practice, the two are often mixed, with workflows providing structure and agents handling the parts of a task that require adaptation.

The chapter then focuses on when agents are worth using and how to measure them. It argues that LLMs should only be introduced when tasks involve unstructured data or diverse inputs, and that agents are best reserved for problems that are complex, valuable enough to justify higher cost and latency, and tolerant of occasional errors. To support development, the book uses GAIA as a benchmark for agentic tasks that require research, synthesis, and multi-step reasoning. Finally, it introduces context engineering as the key discipline for making agents work well: instead of just writing prompts, developers must carefully manage what information enters, leaves, and stays in the model’s context, since the quality of that context often determines whether the agent succeeds or fails.

Example of a language model’s generalization capability.
User requests flow through the research agent, which branches into multiple searches and synthesis.
The LLM Agent's decision loop is an iterative process of LLM decision-making and tool use.
Progression of agency levels in LLM applications.
LLMs can only produce accurate, high-quality responses when sufficient information is provided in the context.
Even with large context windows, longer inputs can degrade model performance(Source: https://research.trychroma.com/context-rot).
An overview of the journey through the book.

Summary

  • AI agents span a wide spectrum, from personal assistants like ChatGPT and Claude to customer-facing agents and specialized tools like Claude Code and Cursor. All share a common foundation: LLMs as their decision-making core.
  • An LLM agent consists of three elements: the LLM (brain), tools (means of interacting with the external world), and a loop (iterative process until goal completion). The LLM decides which tool to use and when to stop.
  • Workflows are developer-defined execution flows where LLMs perform specific steps. Agents are LLM-directed flows where the model dynamically determines its own process. Production systems often combine both approaches.
  • Use agents when tasks require multiple unpredictable steps, provide sufficient value to justify costs, and allow for error detection. The GAIA benchmark provides ideal practice problems for agent development.
  • Context engineering is the discipline of providing the right information at the right time. Five strategies (Generation, Retrieval, Write, Reduce, Isolate) form the framework for building effective agents throughout this book.

FAQ

What is an AI agent in this chapter’s definition?An AI agent is a program that uses an LLM as its decision-making core to autonomously decide what actions to take and when to stop, based on its current context and goal.
How is an AI agent different from a simple workflow?A workflow follows a developer-defined sequence of steps, while an agent lets the LLM dynamically decide what to do next and when to stop.
What three elements make autonomous agent behavior possible?The three core elements are an LLM, tools, and a loop. The LLM makes decisions, tools let it act on the external world, and the loop repeats reasoning and action until the task is complete.
Why do agents need a loop?Agents need a loop because they usually cannot know in advance which tools they will need or how many steps a task will take. The loop lets them keep reasoning, acting, and observing until the goal is achieved.
What is the difference between a workflow and an agent in practice?Workflows are predictable and developer-controlled, making them useful for fixed processes. Agents are more flexible and useful when the path to the answer is uncertain, requires tool use, or needs iterative reasoning.
When should I use an LLM at all?Use an LLM when the task involves unstructured data like text, images, or audio, or when user input is diverse and hard to handle with rules alone. If the task is simple, structured, and predictable, traditional programming may be better.
When is an agent the right choice instead of a single LLM call?An agent is a good choice when the task is complex, multi-step, hard to predict in advance, or requires external tools and repeated decision-making. If one LLM call can solve it, a workflow is usually simpler and cheaper.
What is GAIA and why is it used in this book?GAIA is a benchmark of question-answer tasks that require multi-step reasoning, web searches, calculations, and synthesis. This book uses it because it provides clear answers, helps measure agent improvements, and does not require specialized domain knowledge.
What is context engineering?Context engineering is the practice of providing an LLM with the right information, in the right form, at the right time. It includes deciding what to retrieve, what to keep, what to summarize, and how to manage tool outputs and memory.
Why is bigger context not always better?Bigger context can hurt performance because models may become less accurate as the context grows, a problem sometimes called context rot. The book emphasizes providing only the most relevant information rather than filling the context window with everything available.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Build an AI Agent (From Scratch) ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Build an AI Agent (From Scratch) ebook for free