AI Agents Academy

Build your first agent, add memory, tools and planning to it, then run a team of agents and try the MCP protocol in a visual simulator that works without any API.

60hands-on lessons

Module 1 · Lesson 2 · 13 min read

Language model, chatbot and agent

LLM vs Chatbot vs Agent

Introduction

A large language model, a chatbot and an agent are three related but fundamentally different concepts. In this lesson we compare them in terms of inputs, memory, tools and who decides the next step, and we see the difference in practice in a short Python program.

Learning objectives

  • Explain what a large language model can and cannot do on its own
  • Distinguish between the chatbot flow and the agent loop flow
  • Explain why tools reduce hallucination without eliminating it
  • Identify the engineering safeguards needed when moving from a chatbot to an agent

Three concepts that are often confused

Many beginners confuse three different things: the large language model, the chatbot and the agent. Understanding the difference determines how you design your system, what you test, and which risks you must account for.

Language model (LLM)Text ← textChatbotLLM + dialogue historyAI agentLLM + goal + tools + memory + loopAnswers onceRemembers the dialoguePlans and decidesCalls toolsRepeats until done
A language model generates text, a chatbot adds dialogue memory, and an agent adds a goal, tools, an execution loop and decisions.

The large language model (LLM)

A large language model (LLM) is a huge mathematical function: it takes text (split into units called tokens) and predicts the next tokens. The model itself has no memory between one call and the next, cannot browse the internet or run a program, and does not know what happened after its training data cutoff. All it sees is the text sent to it in this call.

The chatbot

A chatbot is an application that wraps the model in a dialogue interface. It keeps the message history and sends it with every new message, so it seems to "remember" the conversation. Its flow is simple: a message from the user, then a reply from the model, then waiting for the next message. The user leads the dialogue and decides the next step.

The agent

An agent adds three essential things: a goal it pursues over several steps, tools with which it can affect the world or fetch information, and a loop in which the model itself decides the next step until it finishes. In an agent, the model drives a number of steps between the user's message and the final reply.

A structured comparison

AspectLanguage modelChatbotAgent
InputA single textA message with the dialogue historyA goal with context
MemoryNoneThe current conversation historyShort- and long-term, depending on the design
ToolsNoneUsually none or limitedA core part of the design
Who decides the next stepThe callerThe userThe model inside the loop
Calls per requestOneUsually oneSeveral calls

A practical example: one question, three ways

Suppose a student asks: "What is my average grade in last semester's courses?"

  • The model alone does not have the student's grades, so it either apologizes or, more dangerously, invents a convincing-looking number. This phenomenon is called hallucination.
  • The chatbot will ask the student to type their grades, then compute the average inside the text, and it may get the arithmetic wrong because language models are not precise calculators.
  • The agent decides to call a db_search tool to fetch the grades from the university system (after checking permission), then a calculator tool to compute the average precisely, then writes the answer, naming the courses it counted.

The following code simulates the difference between the two flows without a real model. The fake_llm function is purely rule-based, for illustration.

python
GRADES = {"stu-17": [88, 92, 75, 81]}   # a tiny database

def calculator(values):
    return round(sum(values) / len(values), 2)

def db_search(student_id):
    return GRADES.get(student_id, [])

def fake_llm(history):
    # Simulates the model's decision: what do I do now?
    last = history[-1]
    if last["role"] == "user":
        return {"tool": "db_search", "args": {"student_id": "stu-17"}}
    if last["role"] == "tool" and last["name"] == "db_search":
        return {"tool": "calculator", "args": {"values": last["content"]}}
    return {"final": f"Your average grade is {last['content']}"}

def chatbot(message):
    return "Please type your grades so I can compute the average."   # one reply, then wait

def agent(message, max_steps=5):
    history = [{"role": "user", "content": message}]
    tools = {"db_search": db_search, "calculator": calculator}
    for _ in range(max_steps):
        decision = fake_llm(history)
        if "final" in decision:
            return decision["final"]
        result = tools[decision["tool"]](**decision["args"])
        history.append({"role": "tool", "name": decision["tool"], "content": result})
    return "Stopped: exceeded the maximum number of steps"

print(chatbot("What is my average grade?"))
print(agent("What is my average grade?"))

What does this mean for the developer?

Moving from a chatbot to an agent is not just an upgrade but a change in the nature of responsibility. An agent carries out actions that can have real effects: sending an email, editing a record, booking an appointment. So you need:

  • A clear definition of the allowed tools and the permissions of each tool.
  • A maximum number of steps to prevent infinite loops, as with max_steps above.
  • Logging every step (tracing) so you know why the agent made a particular decision.
  • Human approval points before sensitive actions.

Summary

A language model is a function that predicts the next text and has no memory or tools of its own. A chatbot adds a dialogue interface and a message history, but the user still drives every step. An agent adds a goal, tools and a loop in which the model itself decides the next step across several calls. This extra capability brings engineering responsibilities: tool permissions, step limits, tracing and human approval.

Terms

TermEnglishDefinition
Large language modelLarge Language Model (LLM)A model that predicts the next tokens in a text based on what came before
TokenTokenA small unit of text processed by the model, which may be a word or part of one
ChatbotChatbotA conversational application that sends the message history to the model and shows its reply
HallucinationHallucinationThe model producing false information in a confident tone
Function callingFunction CallingA mechanism by which the model requests a tool to be run with specific arguments
TracingTracingRecording the agent's steps and decisions for later review

Review questions

  1. Why does a chatbot seem to remember even though the model itself has no memory?
  2. In the grade average example, why is it better to use a calculator tool instead of letting the model compute?
  3. What four safeguards does a developer need when moving to an agent, and why?
  4. Who decides the next step in a chatbot and in an agent?

References