What is an Agent?

 

Imagine Alfred is an Agent

Imagine Alfred receives a command, such as: “Alfred, I would like a coffee please.”

Because Alfred understands natural language, he quickly grasps our request.

Before fulfilling the order, Alfred engages in reasoning and planning, figuring out the steps and tools he needs to:

  1. Go to the kitchen
  2. Use the coffee machine
  3. Brew the coffee
  4. Bring the coffee back

Once he has a plan, he must act. To execute his plan, he can use tools from the list of tools he knows about.

In this case, to make a coffee, he uses a coffee machine. He activates the coffee machine to brew the coffee.

And this is what an Agent is: an AI model capable of reasoning, planning, and interacting with its environment.

We call it Agent because it has agency, aka it has the ability to interact with the environment.

An Agent is a system that leverages an AI model to interact with its environment in order to achieve a user-defined objective. It combines reasoning, planning, and the execution of actions (often via external tools) to fulfill tasks.

 

Think of the Agent as having two main parts:

  1. The Brain (AI Model)

This is where all the thinking happens. The AI model handles reasoning and planning. It decides which Actions to take based on the situation.

  1. The Body (Capabilities and Tools)

This part represents everything the Agent is equipped to do.

The scope of possible actions depends on what the agent has been equipped with. For example, because humans lack wings, they can’t perform the “fly” Action, but they can execute Actions like “walk”, “run” ,“jump”, “grab”, and so on.

How does an AI take action on its environment?

LLMs are amazing models, but they can only generate text.

However, if you ask a well-known chat application like HuggingChat or ChatGPT to generate an image, they can! How is that possible?

The answer is that the developers of HuggingChat, ChatGPT and similar apps implemented additional functionality (called Tools), that the LLM can use to create images.

Can you generate an image of broccoli-shaped chair!

What type of tasks can an Agent do?

An Agent can perform any task we implement via Tools to complete Actions.

For example, if I write an Agent to act as my personal assistant (like Siri) on my computer, and I ask it to “send an email to my Manager asking to delay today’s meeting”, I can give it some code to send emails. This will be a new Tool the Agent can use whenever it needs to send an email.

def send_message_to(recipient, message):
“””Useful to send an e-mail message to a recipient”””

The LLM, as we’ll see, will generate code to run the tool when it needs to, and thus fulfill the desired task.

send_message_to(“Manager”, “Can we postpone today’s meeting?”)

The design of the Tools is very important and has a great impact on the quality of your Agent. Some tasks will require very specific Tools to be crafted, while others may be solved with general purpose tools like “web_search”.

 

AI Non-Playable Character in a video game
AI agents powered by LLMs can make Non-Playable Characters (NPCs) more dynamic and unpredictable.

Instead of following rigid behavior trees, they can respond contextually, adapt to player interactions, and generate more nuanced dialogue. This flexibility helps create more lifelike, engaging characters that evolve alongside the player’s actions.

 

To summarize, an Agent is a system that uses an AI Model (typically an LLM) as its core reasoning engine, to:

  • Understand natural language: Interpret and respond to human instructions in a meaningful way.

  • Reason and plan: Analyze information, make decisions, and devise strategies to solve problems.

  • Interact with its environment: Gather information, take actions, and observe the results of those actions.