liveBook · Manning

Chapter 1: What is an AI agent?

What you will learn in chapter 1 of Build an AI Agent (From Scratch)

The introduction explains why the book builds agents from scratch rather than relying on frameworks from the outset.

After this chapter you will be able to

Section by section

Introduction

The introduction explains why the book builds agents from scratch rather than relying on frameworks from the outset.

Key terms: agent-building frameworks, build agents from scratch, mental model, debugging failures

1.1 The age of AI agents

Surveys three kinds of modern AI agents and identifies LLMs as their common foundation.

Key terms: personal AI agents, customer-facing agents, specialized agents, AI agent, LLM agent, LLMs

1.2 Understanding LLM agents

This section identifies LLMs as the decision-making core of the agents discussed and introduces questions the following sections will address.

Key terms: LLMs, decision-making core

1.2.1 What is an LLM?

This section defines how the book uses “LLM,” explains next-token prediction and generalization, and introduces reasoning models.

Key terms: LLM, multimodal models, foundational architecture, tokens, next token, generalization, reasoning models, thinking tokens, <think>

1.2.2 What is an LLM agent?

Defines an LLM agent through a research example and explains how LLM-directed decisions, tools, and an iterative loop let it complete tasks whose steps are not known in advance.

Key terms: LLM agent, autonomous control flow, control flow, current context, goals, LLM, tools, loop, action space, agent loop

1.3 Workflow vs. agent

The section frames LLM application design as a choice about control of execution flow, distinguishing developer-defined workflows from LLM-directed agents.

Key terms: workflows, agents, execution flow, levels of agency, current step, next step, available steps

1.3.1 Workflow: Developer-defined flow

This section defines developer-controlled workflows and explains three patterns: a single LLM call, a chain, and a router.

Key terms: workflow, predictability, single LLM call, prompt, response, chain, predefined sequence, focused, well-defined tasks, router, predefined path

1.3.2 Agent: LLM-directed flow

This section explains how an agent lets an LLM direct tool use and repeat actions until a task is complete, with tool creation as a higher level of autonomy.

Key terms: agent, LLM, current context, external tools, callable functions, parameters, multistep loop, current state, action, result

1.3.3 Combining workflows and agents in practice

This section explains how to embed agents within structured workflows and why that hybrid design can be useful.

Key terms: workflow, agent, agents as nodes in a workflow, quality review, hybrid approach, complexity, agent loops, graceful degradation

1.4 Tasks that require agents

This section introduces a two-stage decision for choosing whether a task needs an agent rather than a simpler approach.

Key terms: LLM, agent, workflow

1.4.1 Tasks that require an LLM

This section explains how to decide whether a task needs an LLM before considering an LLM agent, using data structure and input diversity as the main criteria.

Key terms: LLM agent, computational cost, deterministic approaches, unstructured data, structured data, clear schemas, Input diversity, rule-based system, hardcode the logic

1.4.2 Conditions for using agents

Explains when an agent is worth using instead of a single LLM call, weighing task complexity and value against cost, latency, and error risk.

Key terms: multistep research task, agents, costs, latency, errors propagate, task complexity, task value, error cost and detectability

1.4.3 GAIA: An agent gym

Introduces GAIA as a benchmark of agent-suited tasks and explains why its clear answers and accessible problems make it useful for practicing agent development.

Key terms: GAIA, question-and-answer pairs, multistep reasoning, agentic approach, clear answers, fast feedback, agent development cycle, observe-analyze-improve cycle, web search, information synthesis

1.5 Context engineering

This section distinguishes prompts from context and explains why an agent needs the right information in the LLM’s context window.

Key terms: prompt, system prompts, user prompts, context, context window, context engineering, next token

1.5.1 Why agents fail

This section distinguishes failures caused by limited model intelligence from failures caused by missing information, and explains why the information in an agent’s context matters to its performance.

Key terms: insufficient model intelligence, lack of necessary information, context, information deficiency, agent performance

1.5.2 From prompt engineering to context engineering

This section explains why tool-using agents need context engineering in addition to prompt engineering.

Key terms: prompt engineering, system prompts, context, context engineering, tool-execution results, conversation history, external knowledge

1.5.3 Bigger context isn’t always better

This section explains why large context windows do not make it useful to give an LLM all available information.

Key terms: context window, context rot, lost in the middle, highly relevant information

1.5.4 Five context-engineering strategies

The section distinguishes five ways to shape an agent’s context and shows how three of them work together in memory systems.

Key terms: Generate, Retrieve, context, Write, Reduce, context window, context rot, Isolate, sandbox environments, separate agents

1.5.5 From context engineering to harness engineering

The section defines the harness as everything outside the model that supports an agent and explains why real-world agent use has brought harness engineering into focus.

Key terms: harness, harness engineering, context engineering, Agent = Model + Harness, memory and skills, code execution, multi-agent

1.5.6 The journey of this book

This section maps the book’s progression from a basic agent loop through added capabilities to evaluation.

1.6 Prerequisites for reading this book

This section identifies the Python skills, local setup, service access, and likely costs needed to follow the book’s hands-on exercises.

Key terms: plain Python, data structures, control flow, functions, classes, local Python development environment, code editor or IDE, pip, uv, OpenAI API key

1.7 Summary

Summarizes what LLM agents are, how their control differs from workflows, when they are useful, and why context engineering matters.

Where this is used later

Concepts explained in this chapter

Chapter 2: The brain of AI agents: LLMs →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.