The Rise of AI Agents
local graph
Chapter 2 — The Rise of AI Agents
Section titled “Chapter 2 — The Rise of AI Agents”This chapter will explore the evolution of AI agents, tracing their roots from early robotic process automation (RPA) systems to the sophisticated multi-agent architectures of today. We will define what an AI agent truly is, break down its essential components, and examine the different types of AI agents that are shaping industries across the globe.
In this chapter, we are going to cover the following topics:
- Evolution of agents from RPA to AI agents
- Definition of an AI agent
- Different types of AI agents
- Components of an AI agent
By the end of this chapter, you will have a clear understanding of the evolution of AI agents, their key components, and how they are transforming industries.
Technical requirements
Section titled “Technical requirements”You can access the complete code for this chapter in the book’s accompanying GitHub repository at https://github.com/PacktPublishing/AI-Agents-in-Practice.
Evolution of agents from RPA to AI agents
Section titled “Evolution of agents from RPA to AI agents”The journey from traditional rule-based automation to sophisticated AI-driven agents has been marked by significant technological advancements. Initially, automation was limited to rigid, predefined workflows, but with the rise of machine learning, reinforcement learning, and large language models (LLMs), AI agents have evolved to become more autonomous, intelligent, and capable of complex decision-making. Let’s have a look at the different flavors agents have had in recent decades.
- Robotic process automation (RPA): This represents the earliest phase of automation, focused on rule-based systems designed to execute predefined tasks. These systems followed strict logical flows, executing actions based on explicit conditions and structured inputs. While effective for repetitive processes, RPA lacked flexibility, adaptation, and the ability to process unstructured data. Take, for example, a rule-based chatbot that follows a strict decision tree without learning from interactions; however, it cannot handle dynamic environments or unexpected inputs.
- Traditional ML/RL-based agents: As artificial intelligence progressed, traditional machine learning (ML) and reinforcement learning (RL) agents began to emerge. These agents could learn from data, make decisions based on probabilistic models, and optimize their actions through trial and error. Let’s double-click on both of them:
- Rule-based agents: These transitioned from static rule sets to machine-learning-based models that could classify and predict outcomes based on training data.
Take, for example, an early customer support chatbot that followed a strict decision tree to respond to user queries, routing them with a mechanism of named entity recognition.

- Rule-based agents: These transitioned from static rule sets to machine-learning-based models that could classify and predict outcomes based on training data.
Take, for example, an early customer support chatbot that followed a strict decision tree to respond to user queries, routing them with a mechanism of named entity recognition.
Definition
Named entity recognition (NER) is a natural language processing (NLP) task that identifies and classifies key information, such as names of people, organizations, locations, dates, and other predefined entities, in a given text.
- Reinforcement learning (RL) agents: These learned by interacting with environments, optimizing actions for long-term rewards. RL agents were widely applied in gaming, robotics, and complex problem-solving domains.
For example, DeepMind’s AlphaGo learned to play the board game Go by simulating millions of games and optimizing strategies through trial and error.
However, these early agents had a major shortcoming: limited generalization. Take AlphaGo, for instance—while it mastered the game of Go through millions of simulated matches, its intelligence was narrow and domain-specific. AlphaGo couldn’t apply its knowledge to other board games like chess or navigate unrelated tasks such as customer service or scheduling. This kind of AI could excel in a tightly scoped environment but failed to adapt when the rules, context, or input patterns shifted.
This lack of flexibility revealed a broader challenge in AI: the need for agents that can reason across domains, understand ambiguous instructions, and adapt in real time to dynamic environments.
That’s where LLM-based agents come into play.
- LLM-based agents: With the advent of LLMs, AI agents became more capable of reasoning, planning, and interacting dynamically. Generative AI enabled these agents to not only respond to queries but also synthesize information, automate workflows, and integrate with various external systems – as we will see in detail throughout this chapter.
At a high level, the power of LLM-based agents is that they can leverage models like GPT-4o not only to understand context and retrieve relevant information but also to orchestrate a set of components that enable the agent to interact with the surrounding environment. This is the “extra layer of intelligence” that differentiates modern AI agents from both previous RPA systems and LLMs themselves.
In addition to that, the moment we leverage large multi-modal models, AI agents can incorporate different modalities, such as text, speech, vision, and structured data, to interact in more human-like ways.
For example, you can think about an LLM-based agent as a retail assistant that can process spoken questions, analyze product images, and query inventory databases in real time.
- Multi-agent systems and self-replicating agents: A major breakthrough in AI agent evolution has been the introduction of multi-agent systems, where multiple AI agents collaborate to solve complex tasks. These systems allow for task delegation, specialization, and parallel execution, leading to greater efficiency and autonomy. Take, for example, a multi-agent research system where one agent retrieves papers, another summarizes them, and a third generates actionable insights for a team.
In addition to that, we could also provide those agents with “self-replication” capabilities, meaning that they can generate additional agents to handle subtasks, effectively scaling themselves to meet demand. Take, for example, an AI project manager that spawns specialized sub-agents to handle design, coding, and testing in a software development workflow.
- AGI agents–the next frontier: The ultimate goal of AI evolution is the development of Artificial General Intelligence (AGI) agents—systems that can perform any intellectual task a human can. AGI agents would integrate reasoning, planning, memory, and self-improvement to function autonomously across a wide range of applications.
At the time of writing this book, this is something which still has to be fully qualified as common understanding, yet it is an exciting time to witness the always evolving boundaries of AI agents.
Throughout this book, we will mainly focus on single, LLM-based agents, touching on the multi-agentic framework in Chapter 7. Let’s start with a definition of what an AI agent is.
Components of an AI agent
Section titled “Components of an AI agent”An AI agent is a software-based entity capable of perceiving its environment, reasoning about its goals, making decisions, and executing actions—often autonomously—through interaction with external systems. Unlike traditional automation, which follows pre-programmed rules, AI agents can dynamically adapt based on context, leverage external tools, and incorporate memory to improve decision-making over time.
At a technical level, an AI agent consists of several core components:
- LLM: The reasoning engine of the agent, providing natural language understanding, response generation, and task planning. LLMs like GPT-4, Claude, and Gemini enable agents to process user inputs, generate responses, and even engage in multi-step reasoning.
- System message: Think about the system message as the “mission” of the agent, as it provides underlying instructions that shape the agent’s behavior. In addition to the main goal, system messages define tone, role, and constraints (e.g., “You are a customer support assistant; respond concisely and empathetically”).
- Memory: Enables an agent to retain context over time, improving continuity and personalization. At a high level, memory can be differentiated into short-term (session-based) and long-term (databases storing past interactions). However, there are many nuances of agentic memories, including short-term, episodic, and procedural, that we are going to explore in Chapter 4.
- Tools: Extend an agent’s capabilities beyond the LLM. Agents interact with external tools such as APIs, databases, search engines, and automation scripts to fetch real-time data, perform calculations, or trigger external processes.
- Knowledge base: Stores structured and unstructured domain knowledge that the agent can reference. This includes retrieval-augmented generation (RAG) systems, proprietary company data, or specialized knowledge repositories for enhanced decision-making.

Figure 2.1: Main components of an AI agent
Figure 2.1: Main components of an AI agent
On top of that, we also have an orchestration layer, meant to govern the flow of tasks within the agent, ensuring coordination between components.
Note
AI agents might or might not have a user interface. On one side, agents can be user-facing conversational applications that react based on a user’s input (for example, a customer service AI agent addressing a user’s query about a specific product). On the other side, they could also act “behind the scenes” in automation workflows; if this is the case, they might not need a UI at all, as they are triggered by events (for example, an AI agent that provides resolution to issues everytime a ticket is raised in the system of record).
Let’s consider the following example. Imagine an academic institution developing an AI agent designed to help high-school students grasp complex STEM topics. By leveraging large language models, memory, and orchestration, this agent provides personalized tutoring, references authoritative sources, and adapts to each student’s learning needs.

Figure 2.2: Example of an AI tutor assistant
Figure 2.2: Example of an AI tutor assistant
Let’s zoom in on each component:
- LLM: This acts as the core reasoning engine, the “brain” of the agent, providing explanations, solving problems, and answering student questions in a conversational manner – all thanks to the additional information provided by the agent’s components.
Note
It’s important to remember that LLMs are typically trained on public or generic datasets. This means they often lack a deep contextual understanding of specific industries, proprietary data, or organizational processes unless explicitly grounded in such information. That’s why providing an external knowledge base relevant to the specific use case can equip agents with domain-specific knowledge, improving accuracy, trustworthiness, and usefulness in real-world scenarios.
- System message:This defines the agent’s personality, ensuring it remains aligned with its educational purpose (after all, we don’t want an AI tutor that will do students’ homework on their behalf, but rather an assistant that can support them in the learning process, strengthening their weaknesses and focusing on specific learning areas).
- Orchestration:This ensures smooth interaction between the UI, LLM, and various components. It routes requests intelligently, deciding when to fetch external data, refer to stored student performance history, or generate content directly from the LLM.
- Memory:This tracks students’ chat sessions to keep the conversation relevant (short-term). Plus, it stores previous students’ interactions to have relevant knowledge about their academic profile. This knowledge allows the agent to use strengths and weaknesses data to reinforce challenging topics and optimize lesson plans.
- Knowledge: Relevant knowledge that the agent will need to retrieve to answer specific questions is stored. It is particularly useful if we need to ground the model on a specific set of documents (for example, a school’s manuals).
- Tools and API integrations:This is the place where we provide our agent with tools to perform actions. An example might be students’ and school calendars. This will allow the agent to book a lesson on a student’s behalf, according to availability and compatibility with the academic curriculum.
- UI (student interface): This provides an interactive chat-based learning experience, integrating text, diagrams, and step-by-step problem-solving.
Here’s how it works in practice:
- A student asks a complex physics question about Newtonian mechanics.
- The LLM processes the query, using prior interactions and contextual memory.
- The orchestrator determines whether the answer requires reference material, past student performance data, or external web searches.
- If necessary, the agent retrieves relevant information from the school’s reference manuals.
- The LLM tailors the explanation to the student’s level, reinforcing areas where they’ve struggled in past exams.
- The student receives an interactive response, complete with step-by-step explanations, visual aids, and practice questions.
- Eventually, the agent offers the student the option of booking some extra lessons on the topic in available slots, according to its calendar.
- If the student accepts, the agent will book lessons on their behalf.
Now, the question is: how can the agent know when to invoke specific knowledge or a specific tool?
What makes this mechanism so powerful is the language model’s ability to understand natural language. Every time a tool or component—like a “book meeting” action—is initialized, it’s not just defined by its underlying logic (such as the API call and POST request to add an event to a calendar). It’s also accompanied by a natural language description. This description explains, in plain terms, what the tool does and what kind of output it returns. The LLM reads this description and uses it to decide when and how to invoke the tool during a task. In essence, the model isn’t just executing code—it’s reasoning through the available actions based on their human-readable descriptions.

Figure 2.3: Example of how to describe an agent’s components in natural language
Figure 2.3: Example of how to describe an agent’s components in natural language
Now, the moment the user asks the agent something, the agent – powered by the brain of the LLM – will go and read through all its components’ descriptions and understand which one to invoke to solve the user’s query.
As we will see, there are different strategies we can define for the agent to invoke the proper tool. For example, we might want to have a tool always invoked as the first one, and then let the agent decide whether it needs to invoke other tools or not. One strategy to address this prescriptive order is to simply write it in the system message. For example:
You are a helpful AI assistant. You have access to the following tools:
- Tool A
- Tool B
When you receive the user’s query, always invoke Tool A. If you cannot accomplish the task with Tool A, then invoke Tool B. Make sure NOT to invoke Tool B before trying Tool A.
These strategies are defined at the orchestrator level, as we will see in Chapter 3.
Different types of AI agents
Section titled “Different types of AI agents”AI agents come in varying levels of complexity and capability, ranging from simple retrieval-based agents to fully autonomous systems. Understanding these different types helps organizations and developers select the right kind of AI agent for specific use cases. In this section, we are going to cluster AI agents into three primary types: retrieval agents, task agents, and autonomous agents.
Retrieval agents
Section titled “Retrieval agents”In Chapter 1, we introduced the concept of RAG as a technique in GenAI applications where an LLM retrieves relevant documents or snippets from a knowledge base (properly embedded and stored in a VectorDB) before generating responses.
Retrieval AI agents build upon the foundations of RAG but incorporate advanced agentic behaviors, making them more autonomous and adaptive. In fact, we are adding to a standard RAG pipeline an additional layer of intelligence and planning that allows the agent to “strategize” on how to retrieve the most relevant pieces of information.
Note
Retrieval AI agents are often referred to as agentic RAG. With this approach, knowledge sources are treated as “tools,” meaning that they will come with a description in natural language so that the agent can decide which source to invoke depending on the user’s query. Once the source is invoked, the retrieval mechanism follows the same pattern as traditional RAG, yet we will have this additional layer of intelligence that can decide whether it is enough to answer or not, and if necessary, invoke further sources.
Let’s consider the following example. Let’s say we want to build an AI assistant for a doctor to quickly retrieve information about treatments. Given the doctor asks: “What are the latest treatments for Type 2 diabetes?”, let’s see how the two approaches compare:
- Traditional RAG approach:
- The RAG system retrieves the top three relevant articles from the database.
- The model extracts relevant text from those articles and generates a response summarizing key treatments.
- If the retrieved documents do not fully answer the doctor’s question; the model cannot refine the search unless the doctor manually submits a new query.

- The RAG system retrieves the top three relevant articles from the database.
Figure 2.4: Traditional RAG pipeline
Figure 2.4: Traditional RAG pipeline
- Retrieval AI agent approach
- The agent retrieves an initial set of documents and analyzes them.
- It detects that some retrieved studies are outdated, so it refines its search criteria and retrieves more recent publications.
- It recognizes a gap in information regarding a specific drug and fetches a dedicated study on that drug.
- Finally, it synthesizes all retrieved sources into a comprehensive answer, ensuring relevance and completeness.

- The agent retrieves an initial set of documents and analyzes them.
Figure 2.5: Agentic RAG pipeline
Figure 2.5: Agentic RAG pipeline
In conclusion, agentic RAG can lead to several improvements over traditional RAG:
- Multi-step and recursive retrieval: Instead of a single-pass retrieval, AI agents iteratively refine their search, breaking down complex queries into multiple steps.
- Contextual awareness: They maintain a memory of previous interactions, allowing them to ask clarifying questions or adjust retrieval strategies dynamically.
- Tool-driven query execution: Retrieval AI agents can interact with APIs, databases, or vector search engines, making them capable of fetching real-time and structured data.
- Adaptive knowledge augmentation: Unlike static retrieval in RAG, AI agents can enrich responses by fetching information from different sources and synthesizing them contextually.
- Autonomous decision-making: These agents can determine when to retrieve more information, which sources to query, and how to refine their results for optimal relevance.
Retrieval agents are the simplest form of AI agents, yet the extra layer of intelligence is already demonstrating great improvements for the overall user experience. However, the real power of an AI agent comes to life when they can combine retrieval skills with actionable tasks.
Task agents
Section titled “Task agents”Task agents go beyond information retrieval by performing specific actions. These agents are designed to automate workflows and replace repetitive tasks for users. Unlike retrieval agents, they execute predefined actions in response to user commands or external triggers.
Note
When talking about AI agents, you will often hear the terms tasks, tools, skills, plugins, functions, and actions as interchangeable ways to refer to the agent’s capabilities of “doing things.” You will also see that different AI orchestrators come with different terminology. Let’s try to get some clarity:
Tasks define what needs to be accomplished and can range from simple actions, like sending an email, to complex processes involving multiple actions.
Tools provide external means to perform tasks, like a data visualization tool to create charts or a language translation service to interpret text in different languages.
Plugins extend functionality through integration with other platforms, and they typically come with a set of operations or functions that can be executed against that platform (list rows, append new record…).
Functions outline internal methods of operation – for example, a get_weather function, properly defined, will be able to return the current weather in a given location.
Skills represent the agent’s learned proficiencies and are typically defined in a declarative way (natural language). You can think about skills as “mini-prompts” that are invoked only in cases where that specific skill is needed.
Actions are the concrete steps or operations that an AI agent takes in response to a given situation or input. They are the real-time manifestations of an agent’s functions and skills, leading to observable outcomes.
Let’s consider once again an example in the healthcare domain, this time from the perspective of the general practitioner’s office receptionist, John.
John manages a high volume of appointment requests. Patients book visits through various channels: phone calls, emails, and an online booking system. Managing last-minute cancellations and rescheduling requests is time-consuming and often leads to gaps in the schedule.
A typical process in John’s day might look like the following:
- John receives an email from Patient X to book an appointment and shares some preferences in terms of date and time
- John checks the availability of the specialist practitioner required and tries to match the earliest slot possible with Patient X’s preferences
- John doesn’t find any match, hence goes back to Patient X to find alternatives
- Finally, John and Patient X agree on a slot and the appointment is scheduled
If you think about the above steps, they are nothing but tasks that John is meant to perform to achieve the goal – scheduling the appointment in an optimized slot for both the practitioner and the patient.
Whenever we want to map and enhance a business process with an AI agent – more specifically, a task agent – a good practice is that of transposing the human tasks into agentic tasks. Let’s see, for example, how a task agent can assist John:

Figure 2.6: How a task is performed by a task agent
Figure 2.6: How a task is performed by a task agent
- The AI agent automatically scans the email received from Patient X. It extracts key details like the Patient’s name and contact details, preferred date and time, and the specialist practitioner required.
- The AI agent checks the availability, invoking the plugin (the tool we equip our agent with) to the clinic’s scheduling system. It matches Patient X’s preferences with the earliest available slots for the specialist practitioner. If there’s a match, it proceeds to step 5.
- The AI agent finds no match. Since no match is found, the AI agent generates a list of the next best available slots based on the specialist’s schedule. It also drafts a response email to Patient X, leveraging a writing skill, with suggested alternatives, but John reviews and approves it before sending.
- Patient X responds with a new preference and either:
- Accepts one of them (proceed to step 5) 2. Requests new options, then the AI agent repeats step 3.
- Once John and Patient X agree on a slot, the AI agent automatically schedules the appointment in the system, leveraging the same plugin as above. Plus, it sends a confirmation email to Patient X with the details, leveraging an email plugin. Finally, it updates the specialist’s calendar and notifies them of the booking.

Figure 2.7: Example of the anatomy of the AI agent for the practitioner’s office
Figure 2.7: Example of the anatomy of the AI agent for the practitioner’s office
As you can see, the AI agent acts as John’s assistant, handling repetitive scheduling tasks while he focuses on in-person patient interactions.
Autonomous agents
Section titled “Autonomous agents”Autonomous agents represent the most advanced category of AI agents. Unlike retrieval and task agents, which operate within predefined boundaries, autonomous agents strategically orchestrate multiple tasks and retrieval processes, making real-time decisions to optimize workflows. These agents exhibit a high degree of independence, adaptability, and contextual awareness, allowing them to perform complex operations with minimal human intervention.
The key distinction of autonomous agents lies in their ability to:
- Combine retrieval and action: They can both find information (like a retrieval agent) and act on it (like a task agent).
- Plan and self-adjust: They dynamically adapt based on new information or changing constraints.
- Perform multi-step workflows: They break down complex tasks into subtasks, execute them iteratively, and adjust based on results. Let’s continue with John’s clinic example. As the clinic gets busier, managing appointments, cancellations, and reschedules becomes overwhelming. A task agent helped streamline individual actions, but now an autonomous agent takes over the end-to-end scheduling process with minimal supervision. Here is how it works, step by step:
- Intake and prioritization: The agent monitors all channels (email, portal, phone transcripts), extracts patient preferences, urgency, and specialist needs, and ranks requests based on priority. For example, a canceled appointment opens a slot, and the agent immediately matches it to Patient X, who’s been waiting for a similar time. 2. Planning and optimization: It reviews the full daily schedule, identifies conflicts or idle gaps, and builds an optimized plan—shuffling low-priority visits to make room for urgent ones. 3. Execution with feedback: The agent messages patients with options, updates calendars, books appointments, and sends confirmations—all automatically. If preferences change, it loops back, refining its actions. 4. Real-time adaptation: A doctor calls in sick. The agent halts new bookings, reschedules affected patients, and notifies staff—handling all steps autonomously unless human input is needed. 5. Continuous learning: At day’s end, it analyzes outcomes, updates patient preferences, and adjusts future prioritization logic.
The autonomous agent can plan, retrieve, decide, act, adapt, and learn—all without relying on predefined workflows. John now focuses on edge cases, while the agent intelligently handles the rest.
Autonomous agents represent the next step in AI-driven process automation. By merging retrieval AI capabilities (context awareness, real-time query refinement) with task execution skills (appointment scheduling, automated notifications), autonomous agents can fundamentally reshape business processes and daily operations.
Note
Even if autonomous agents resonate very well with the concept of business process automation, keep in mind that they can also represent a new enhancement for customer experience. For example, in the above scenario, rather than calling or sending an email, Patient X could leverage a conversational UI that the AI agent provides (this could be via the clinic website or WhatsApp channel). By doing so, Patient X will experience a new and smoother way of interacting with the clinic, while the AI agent is capturing the intent, asking more questions if further information is needed, and orchestrating the backend to execute its tasks.
There are different degrees of autonomy we can provide our agents with, and the decision is based upon the business scenario as well as the level of confidence we have in the accuracy of the solution.
Summary
Section titled “Summary”AI agents have progressed from basic automation tools to sophisticated autonomous systems, transforming business operations and professional workflows. This chapter explored the three primary types: retrieval agents, which enhance knowledge access through Agentic RAG; task agents, which automate specific actions like scheduling and email management; and autonomous agents, which combine retrieval and execution with strategic decision-making to optimize complex workflows. Deploying the right type of AI agent for each use case is key to achieving impactful automation and enhancing users’ experience.
Starting from the next chapter, we are going to dive deeper into each component of an AI agent, starting with the AI orchestration.