The Core Idea: An AI agent is a system where a language model decides what to do next, uses tools to act in the world, looks at the results, and repeats until a goal is reached. A chatbot answers once. An agent works on a task.
- Beginner: What Are AI Agents?
An AI agent is a program that pursues a goal on its own. A language model acts as its brain: it reads the situation, chooses an action (such as calling a tool), sees what happened, and chooses the next action. This repeating cycle continues until the task is finished or a limit is reached.
Think of a human assistant. You say book me the cheapest flight to Delhi next Friday, and they search, compare, pick, and book. You did not tell them each click. An agent is the software version of that assistant.
One-line definition: Agent = LLM + tools + a loop + a goal.
- Beginner: LLM vs Chatbot vs Agent
These three words are often mixed up. They are layers, each adding something to the one before it:
| Plain LLM | Chatbot | AI Agent | |
|---|---|---|---|
| What it is | A model that predicts the next token | An app around an LLM with a chat window and memory of the conversation | An LLM that plans and acts in a loop |
| Takes actions in the world? | No, it only produces text | Usually no, it replies with text | Yes, through tools |
| Handles multi-step tasks? | Only inside one answer | One question and answer at a time | Yes, it keeps going until the goal is met |
| Uses live data? | No, only what it was trained on | Sometimes | Yes, it fetches what it needs |
| Who decides the next step? | The person, every time | The person, every time | The model, within limits you set |
| Example | A raw model API call | A customer FAQ bot | A coding agent that edits files and runs tests |
Important: The line is not sharp. Many products sit between a chatbot and an agent. The useful question is: does the model choose actions and loop on the results? If yes, it is acting as an agent.
- Medium: Why Agents Are Useful
Agents are useful when a task cannot be solved in one reply because the answer depends on steps, fresh data or actions:
| Need | How an agent helps | Example |
|---|---|---|
| Many steps | Breaks work into steps and carries them out | Research a topic, then write a report |
| Fresh or private data | Calls tools to fetch it | Check an order status in a database |
| Real actions | Sends emails, edits files, books, pays (with permission) | Create a calendar event |
| Handling surprises | Reads results and adapts | Retry with another search when the first fails |
| Saving human time | Does repetitive digital work | Sort and answer routine support tickets |
Rule of thumb: If you can write the exact steps in advance, a normal workflow or script is cheaper and more reliable. Use an agent when the steps depend on what is found along the way.
- Medium: Real-World Agent Examples
| Area | What the agent does | Typical tools |
|---|---|---|
| Coding assistants | Read a codebase, edit files, run tests, fix errors | File system, terminal, test runner |
| Customer support | Understand a request, look up the order, answer or hand over to a human | Order database, help-center search, ticket system |
| Research assistants | Search sources, read pages, compare and summarize with citations | Web search, document reader |
| Data analysis | Write queries, run them, build charts, explain results | SQL, Python, plotting |
| Personal assistants | Manage email, calendar and reminders | Email, calendar, notes |
| IT operations | Watch alerts, diagnose a fault, apply a safe fix | Monitoring, logs, runbooks |
- Advanced: Levels of Autonomy and When Not to Use an Agent
Agents are not all-or-nothing. It helps to think in levels, from least to most independent:
| Level | Who decides | Example |
|---|---|---|
| 0 · Plain LLM | Person, every step | Ask a question, get text |
| 1 · Workflow with LLM steps | Your code decides the order | Summarize, then classify, then store |
| 2 · Agent with tools | The model picks tools inside limits | Support agent with a lookup tool |
| 3 · Agent with approval | The model proposes, a human approves risky actions | Refund agent that asks before paying |
| 4 · Autonomous agent | The model plans over many steps alone | Long-running research or coding agent |
Costs of agents: More latency (many model calls), more cost (tokens add up), and less predictability (the path can differ every run). Start at the lowest level that solves the problem, and move up only when needed.
- Visual Explanation: Chatbot vs. Agent and the Four Ingredients
The figure compares a chatbot with an agent on the same question, then lists the four ingredients that make something an agent.
Click to see when NOT to use an agentCompare ▼
Part 1 shows that the agent reaches the answer by looping through tools. Part 2 lists the four ingredients. Open the bar to see when a simple workflow is the better choice.
- Python Implementation: A Chatbot and a Tiny Agent Side by Side
This script runs the same question through a chatbot (one call) and a tiny agent (a loop with two tools). A simple rule-based function plays the role of the language model so you can see every step without an API key.
# Chatbot vs agent: the agent loops (decide -> use a tool -> look at the result -> repeat)PRICES = {"laptop": 900, "phone": 600, "tablet": 450} def tool_cheapest(): name = min(PRICES, key=PRICES.get) return name, PRICES[name] def tool_percent(value, pct): return round(value * pct / 100, 2) TOOLS = {"cheapest": tool_cheapest, "percent": tool_percent} def chatbot(question): # One call, no tools, no loop: it can only answer from what it already knows return "I cannot see the live price list, so I can only guess." def fake_llm(goal, history): # Stands in for a real model: reads what happened so far and picks the next step used = [h["action"] for h in history] if "cheapest" not in used: return {"action": "cheapest", "args": {}} if "percent" not in used: price = history[-1]["result"][1] return {"action": "percent", "args": {"value": price, "pct": 17}} return {"action": "finish", "answer": "17% of the cheapest item costs " + str(history[-1]["result"])} goal = "What is 17% of the price of the cheapest item?"print("Chatbot:", chatbot(goal)) history = []for step in range(1, 6): decision = fake_llm(goal, history) if decision["action"] == "finish": print("Agent final answer:", decision["answer"]) break result = TOOLS[decision["action"]](**decision["args"]) history.append({"action": decision["action"], "result": result}) print("Step", step, "| action:", decision["action"], "| result:", result)The chatbot can only guess, while the agent calls the first tool, reads its result, uses that result to call the second tool, and then answers. The loop of decide, act, observe is the whole idea of an agent. Later lessons replace the rule-based function with a real model.
Knowledge Check
Key Points
The Big Picture
Goal → model decides → tool acts → result observed → repeat until done
Everything in this series is about making that loop smarter, safer, more reliable and cheaper.
Up Next: You now know what an agent is. In How AI Agents Work you will open the box and study the architecture, the observe, reason, act loop and the agent lifecycle.