Overview

1 The rise of AI agents

LLM chat apps are evolving from reactive Q&A into systems that can plan and take action on our behalf. This chapter introduces AI agents as software that perceives context, decides, and acts to achieve goals with LLMs as their reasoning engine. It distinguishes agentic behavior—autonomy and persistence across multiple steps—from tool-using assistants that require per-step approval, and frames the core agentic loop of sense, plan, act, and learn. The emphasis is practical: build agents that can turn objectives into results while applying the right guardrails and human oversight when stakes rise.

Action depends on tools. Agents are configured with tool descriptions, invoke them like functions, chain outputs between calls, and treat errors as normal control flow with retries, fallbacks, and approvals instead of crashes. A key accelerator is the Model Context Protocol (MCP), an open, JSON‑RPC–based standard that shifts integrations from bespoke, per-agent wrappers to reusable external servers. MCP lets agents consistently discover and call capabilities across languages and providers, improves reliability and extensibility, and provides clearer security boundaries, reducing fragmented tool plumbing and inconsistent responses.

Capability is organized into five interacting layers: Persona (role, constraints, and style), Actions & Tools, Reasoning & Planning (from model-native thinking to structured strategies for long-horizon or high-risk work), Knowledge & Memory (context-aware retrieval and persistence via RAG), and Evaluation & Feedback (critics, guardrails, and human-in-the-loop checks). To surpass single-agent limits, the chapter motivates multi-agent systems for specialization, parallelism, and context management, outlining assembly-line agent flows, hub‑and‑spoke orchestrations, and collaborative teams, each with cost, latency, and control tradeoffs. The roadmap builds from these layers and patterns toward realistic, production-adjacent agentic systems.

Common patterns for directly communicating with an LLM or an LLM with tools. If you’ve used earlier versions of ChatGPT, you experienced direct interaction with the LLM. No proxy agent or other assistant interjected on your behalf. Today, ChatGPT itself has plenty of tools it uses to help respond from web search, coding and so on, making the current version function like an assistant.
Top: an assistant performs a single or multiple tasks on behalf of a user, where each task requires approval by the user. Bottom: An agent may use multiple tools autonomously without human approval to complete a goal,
The four-step process agents use to complete goals: –Sense (receive input – goal or feedback) -> Plan (define the task list that completes the goal) -> Act (execute tool defined by task) -> Learn (observe the output of the task and determine if goal is complete or process needs to continue) ->
For an agent to use a tool, that tool must first be registered with the agent in the form of a JSON description/definition.l Once the tool is registered, the agent uses that tool in a process not unlike calling a function in Python.
An agent connects to an MCP server to discover the tools it hosts and the description of how to use each tool. When an MCP server is registered with an agent it internally calls list_tools to find all the tools the server supports and their descriptions. Then, like typical tool use internally, it can determine the best way to use those tools based on the respective tool description.
the five functional layers of agents – Persona, Actions & Tools, Reasoning & Planning, Knowledge & Memory, and Evaluation & Feedback
The Persona layer of an agent is the core layer, consisting of the system instructions that define the role of the agent, and how it should complete goals and tasks. It may include how to reason/plan and access knowledge and memory
The role of Actions & Tools within the agent, and how tools can also help power the other agent layers. Tools are a core extension of agents but are also fundamental to the functions used in the upper agent layers
The Reasoning & Planning of agents and how agentic thinking may be augmented. Reasoning may come from many forms, from the underlying model powering the agent, to prompt engineering and even through the use of tools
The Knowledge & Memory layer and how it interacts with and uses the same common forms of storage across both types. Agent knowledge represents information the LLM was not initially trained with but is later augmented. Likewise, memories represent past experiences and interactions of the user, agent or even other systems.
The Evaluation & Feedback layer and the mechanisms used to provide them. From tools which may help evaluate tool use, knowledge retrieval (grounding) and provide feedback, to other agents and workflows that provide similar functionality
The agent flow pattern of assembly with multiple agents. The flow starts with a planning agent that breaks down the goal into a high-level plan that it then passed to the research agent, which may execute the research tasks on the plan and after completing will pass to the content agent, which is responsible for completing the later tasks of the plan, such as writing a paper based on the research
The agent orchestration pattern, often referred to as hub-and-spoke. In this pattern, a central agent asks as the hub or orchestrator to delegate tasks to each of work agents. Worker agents complete their respective tasks and return them to the hub, which determines when the goal is complete and outputs the results.
A team of collaborative agents. The agent collaboration pattern allows agents to interact as peers to allow back and forth communication from one agent to another. In some cases, a manager agent may work as a user proxy and help keep collaborating agents on track

Summary

  • An AI agent has agency, the ability to make decisions, undertake tasks, and act autonomously on behalf of someone or something, powered by large language models connected to tools, memory, and planning capabilities.
  • An agents agency provides them the ability to process with an autonomous loop called Sense-Plan-Act-Learn process.
  • Assistants use tools to perform single tasks with user approval, while agents have the agency to reason, plan, and execute multiple tasks independently to achieve higher-level goals.
  • The four patterns we see LLMs being used in include: direct user interaction with LLMs, assistant proxy (reformulating requests), assistant (tool use with approval), and autonomous agent (independent planning and execution).
  • Agents receive goals, load instructions, reason out plans, identify required tools, execute steps in sequence, and return results, all while making autonomous decisions.
  • Agents use actions, tool functions (extensions that wrap API calls, databases, and external resources) to act beyond their code base and interact with external systems.
  • Model Context Protocol (MCP), developed by Anthropic in November 2024, serves as the "USB-C for LLMs," providing a standardized protocol that allows agents to connect to MCP servers, discover available tools, and use them seamlessly without custom integration code.
  • MCP addresses inconsistent tool access, unreliable data responses, fragmented integrations, code extensibility limitations, implementation complexity, and provides easy-to-build standardized servers.
  • AI Agent development can be expressed in terms of five functional layers: Persona, Tools & Actions, Reasoning & Planning, Knowledge & Memory, and Evaluation & Feedback.
  • The Persona layer represents the core role/personality and instructions an agent will use to undertake goal and task completion.
  • The Tools & Actions layer provides the agent with the functionality to interact and manipulate the external world.
  • The Reasoning & Planning layer enhances an agent's ability to reason and plan through complex goals that may require trial-and-error iteration.
  • The Knowledge & Feedback layer represents external sources of information that can augment the agent’s context with external knowledge or relate past experiences (memories) of previous interactions.
  • The Evaluation & Feedback layer represent external agent mechanisms that can assist in improved response accuracy, encourage goal/task learning and increased confidence in overall agent output.
  • Multi-agent systems include patterns such as Agent-flow assembly lines (sequential specialized workers), agent orchestration hub-and-spoke (central coordinator with specialized workers), and agent collaboration teams (agents communicating and working together with defined roles).
  • The Agent-Flow pattern (sequential assembly line) is the most straightforward multi-agent implementation where specialized agents work sequentially like an assembly line, ideal for well-defined multi-step tasks with designated roles.
  • The Agent Orchestration pattern is a hub-and-spoke model where a primary agent plans and coordinates with specialized worker agents, transforming single-agent tool use into multi-agent delegation.
  • The Agent Collaboration pattern represents agents in a team-based approach. Agents communicate with each other, provide feedback and criticism, and can solve complex problems through collective intelligence, though with higher computational costs and latency.
  • AI agents represent a fundamental shift from traditional programming to natural language-based interfaces, enabling complex workflow automation from prompt engineering to production-ready agent architecture.

FAQ

What is an AI agent and how is it different from a generative assistant?An AI agent is software that perceives its environment, decides what to do, and acts to achieve a goal—often over multiple steps. A generative assistant typically responds to a single prompt and stops. Assistants may use tools but usually require user approval per step. Agents operate against a user-approved goal, plan and execute multi-step work autonomously, and gate high‑stakes actions (like purchases or emails) behind explicit approval.
What does “agentic” mean in this context?Agentic describes systems that exhibit agency—the ability to perceive, decide, and act with some autonomy in pursuit of a goal. The book uses a practical engineering definition: if a system senses context, plans, acts with tools, and iterates toward a goal, it’s agentic, regardless of philosophical debates about intention.
What are the four LLM interaction patterns covered and how do they differ?The chapter outlines a spectrum of autonomy and approval: - Direct LLM chat: no tools; text in, text out. - Tool-augmented LLM: a single tool call triggered implicitly per prompt. - Assistant: per-task approval; user confirms each action. - Agent: goal-level approval; the agent plans and executes steps, with gated approvals for high-stakes actions. Use cases range from simple Q&A (direct chat) to multi-step research and automation (agents).
What is the Sense–Plan–Act–Learn loop?It’s the internal cycle agents use to complete goals: - Sense: receive a goal or feedback and gather context. - Plan: reason about the steps and choose tools. - Act: execute tool calls (often chaining outputs to inputs). - Learn: evaluate results, update memory, and decide whether to continue or finish. This adapts classic patterns like OODA and BDI to LLM-powered agents.
How do agents use tools, and how should failures be handled?Agents use registered tool functions (described in JSON-like schemas) that wrap APIs, databases, apps, or services. Production agents treat failures as normal control flow: surface errors to the model, decide to retry or fall back, ask the user when needed, and cap retries to prevent loops. Tool management, schema evolution, and error handling distinguish demos from production systems.
What is the Model Context Protocol (MCP) and why does it matter?MCP is an open standard (based on JSON-RPC 2.0) that lets agents discover and call tools hosted on external servers. It shifts integrations from bespoke, per-agent wrappers to reusable servers: agents connect, call list_tools to discover capabilities, and invoke tools consistently. Benefits include consistent tool access across models, standardized responses, language-agnostic extensibility, easier implementation via SDKs, and clearer security surfaces (authZ/authN, sandboxing, least privilege, and human-in-the-loop for risky actions).
What are the five functional layers of an agent?The chapter organizes agent capability into: - Persona: the agent’s role, style, constraints, and instructions. - Actions & Tools: the capabilities to affect the world or retrieve context. - Reasoning & Planning: how the agent thinks and sequences steps. - Knowledge & Memory: external knowledge and interaction-derived memory. - Evaluation & Feedback: critics, guardrails, and quality checks. These layers interact continuously rather than executing in a strict order.
When is model-native reasoning enough, and when should I add structured reasoning?Model-native reasoning suffices for short-horizon, low-risk tasks with few tools, especially on strong frontier models. Add structured reasoning (e.g., ReAct, plan-and-execute, reflection, Tree of Thought) when tasks are long-horizon, tool choices are many, errors are costly or irreversible, you need auditable traces, or you use smaller/older models. Always layer structure for safety‑critical or regulated tasks.
How do knowledge and memory differ, and why is the context window important?Knowledge is external, relatively static reference material (docs, code, schemas). Memory is dynamic, interaction-driven state (conversation history, user preferences, past decisions). Agents typically maintain short-term conversational memory in-context and long-term memory retrieved selectively. The model’s context window constrains how much can be attended to at once, so retrieval-augmented generation (RAG), summarization, ranking, and chunking are critical to keep context relevant and efficient.
What multi-agent patterns are introduced and when should I use each?Three patterns: - Agent-flow (assembly line): chained specialists pass work downstream; simple and controllable for well-defined pipelines. - Orchestration (hub-and-spoke): a central agent plans and delegates to worker agents; good for handling multiple goals through a single entry point. - Collaboration (teams): peer agents communicate and critique; powerful for complex, open-ended tasks but can be chatty and costly. Coordination styles include shared threads, blackboards, or simple chaining. Choose the cheapest pattern that meets requirements, considering latency, token cost, and complexity.

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
  • AI Agents in Action, Second Edition 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
  • AI Agents in Action, Second Edition ebook for free