What Is an AI Agent

Updated · 5 min read
mediumPython 3.13aiagentstool-usellmautomation

An AI agent is a system that uses a model, a set of tools and a control loop to work toward a goal, deciding its own next step each time. A chatbot answers one message; a workflow follows steps a person designed; an agent plans, acts, looks at the result and decides what to do next, until the goal is reached or it stops.

A Travel-Planning Agent

Navika, in Dallas, asks an agent: "Plan a two-day trip to San Francisco to visit my sisters next month, under $600." A capable agent might work like this:

Plan, act, observe, repeat, and ask before acting
  1. Understand the goal: dates, budget, who she's visiting.
  2. Search flights with a flight tool, then compare prices and times.
  3. Search hotels near her sisters.
  4. Prepare an itinerary that fits the budget.
  5. Ask before booking: "Book this flight and hotel for $540?"

The model chose those steps itself, in that order, based on what each tool returned. That is what makes it an agent.

Chatbot vs Workflow vs Agent

ChatbotWorkflowAgent
Who decides the stepsNo steps: one reply per messageA person, in advanceThe model, as it goes
Uses toolsUsually notYes, in a fixed orderYes, chosen at each step
PredictabilityHighHighLower
Best forQuestions and draftsRepeated, well-understood tasksOpen-ended tasks with unknown steps

You met workflows in "Workflows vs Agents". Prefer a workflow whenever you can write the steps down; use an agent only when you can't.

Parts of an Agent

PartDescription
ModelIt is used to decide the next step and write the final answer
ToolsIt is used to search, look up, calculate or act, such as booking or sending
LoopIt is used to repeat: call the model, run the tool it asks for, return the result
Short-term memoryThe conversation so far, including every tool result, sent with each call
Long-term memoryNotes saved between sessions, such as preferences, stored by your code
GuardrailsStep limits, approvals, permissions and logs that keep the agent safe

Common Mistakes

Building an agent for a fixed process. A workflow is cheaper, faster and easier to test.

Giving an agent every tool at once. More tools mean more ways to go wrong; add only what the task needs.

No limit on steps. A confused agent can loop, spending time and money.

Interview Corner

What makes a system an AI agent?

A model that decides its own next steps, tools it can call, and a loop that feeds tool results back until the goal is met or a limit is reached.

When should you use a workflow instead of an agent?

Whenever the steps are known in advance. Workflows are more predictable, cheaper and easier to test; agents suit open-ended tasks where the steps depend on what is found.

Practice

Exercise: agent or workflow? For each task, decide and explain: sending a monthly fee reminder email; researching three after-school programs and comparing them; resetting a forgotten password. Which one, if any, really needs an agent?

Check your understanding:

  1. What three parts make an agent?
  2. Who decides the steps in a workflow, and in an agent?
  3. Why did the travel agent ask before booking?

Quick check: AI agents

4 questions
1What is an AI agent?
2Who decides the steps in a workflow?
3When should you prefer a workflow?
4Why must an agent ask before booking?

Key Takeaways

Quick reference

NeedChoose
One answerChatbot
Known stepsWorkflow
Unknown stepsAgent, with guardrails

Was this tutorial helpful?

Lesson 102 of 186