Introduction to Agentic AI1 of 18 steps (6%)

What Is an AI Agent

Understanding Agents

An AI agent is a program that uses a large language model (LLM) to make decisions and take actions. It observes the world, thinks about what to do, and acts. Then it observes the result and repeats.

This is different from a simple LLM chat. A chat answers your question once. An agent keeps going until it solves your problem.

The Agent Loop

Every agent follows the same basic pattern:

  1. Observe: The agent sees the current situation (the user's question, previous results, available tools).
  2. Reason: The LLM thinks about what to do next.
  3. Act: The agent calls a tool or returns an answer.
  4. Repeat: Go back to step 1 with the new information.

Example: Research Agent

You ask the agent: "What are the latest trends in renewable energy?"

Step 1: Observe. The agent sees your question and knows it has web search and fetch tools.

Step 2: Reason. The LLM thinks: "I need to search for recent renewable energy information."

Step 3: Act. The agent calls web_search("renewable energy trends 2026").

Step 1 again: Observe. The agent gets a list of search results.

Step 2: Reason. The LLM thinks: "I found some results. Let me read the top article."

Step 3: Act. The agent calls fetch_webpage("https://...").

Step 1 again: Observe. The agent has the full article text.

Step 2: Reason. The LLM thinks: "I have enough information. Let me summarize."

Step 3: Act. The agent returns a summary to you.

How Agents Are Different From Chains

Chain: You write code that says: First, search. Then fetch. Then summarize. The order is fixed. The code decides what happens next.

Agent: The LLM decides what happens next. It can search multiple times if needed. It can skip steps if they are not needed. It adapts to what it finds.

Why Use an Agent

Agents are useful when:

  • The task has multiple steps but you don't know the exact order ahead of time.
  • The LLM needs to decide which tool to use based on the situation.
  • The task is open-ended and might go in different directions.

Examples:

  • Research assistant: Search, read, summarize based on what you find.
  • Customer support: Look up order info, check inventory, decide if you can help or route to human.
  • Data analysis: Load data, run calculations, visualize results based on what the data shows.

The Trade-off

Agents are flexible but expensive. Each reasoning step (each "decide what to do") costs money and time. Each tool call also costs money.

A simple chain might search once, fetch once, summarize once. An agent might search three times, fetch five pages, summarize multiple times. It depends on what the agent decides is needed.

Key Concepts

Tools: Functions the agent can call. Search, fetch, calculate, send email, etc.

Tool descriptions: Text that tells the LLM when to use each tool. These are critical. A bad description means the agent picks the wrong tool.

Context: All the information the agent has seen so far. The more steps the agent takes, the more context it needs to remember.

Token limit: LLMs have a maximum amount of information they can process at once. Long agents can hit this limit.

Next Steps

Now that you understand what an agent is, the next question is: when should you actually use one? Let's explore that.

Discussion

  • Loading…

← Back to Academy