Module 01 · Lesson 1.2
Chatbots vs. LLM Workflows vs. Tool-Using Agents
On this page
Teams often argue about whether a system is "really" an agent. The argument is worth having, because the answer changes how you test the system, what can go wrong and who is accountable when it does. The useful question is not how clever the model is. It is: who decides what happens next?
In this lesson you will separate three designs that all use a language model: a chatbot, an LLM workflow and a tool-using agent. You will run one customer request through all three in a single Python file, compare the answers, and learn the trade-offs that should drive your choice.
What you will learn
- Classify a system as a chatbot, an LLM workflow or a tool-using agent by locating its control flow.
- Describe three common LLM workflow shapes: chain, router and fan-out.
- Compare the designs on predictability, cost, latency, testing effort and risk.
- Explain why an agent's decisions must be measured by evaluation rather than read from code.
- Recognise hybrid designs that place a bounded agent step inside a fixed workflow.
Before you start
- What Is an AI Agent? from this module, or a working understanding of the agent loop.
- Python 3.10 or later.
The question that separates them
All three designs send text to a language model and get text back. The difference is where the control flow lives: the logic that decides which step runs next.
- Chatbot
- A conversational interface in which the model replies to each message. It may keep the conversation history, but it has no tools, so it cannot look anything up or change anything. Every answer comes from its training and the conversation itself.
- LLM workflow
- A program in which your code fixes the sequence of steps, and one or more steps call a model for something language-shaped: extracting fields, classifying, summarising or drafting. The model fills gaps inside a path you wrote.
- Tool-using agent
- A program in which the model chooses the next action from a set of tools, observes the result and chooses again, until it answers or a limit stops it. The path is decided at run time, by the model, inside limits your code enforces.
- Message
- Model replies
From training and conversation only
- Reply
- Request
- Extract order ID
Model step
- Look up order
Code step
- Branch on status
Code step
- Draft reply
Model or template step
Your code owns the sequence; the model fills two narrow gaps.
- Request
- Model chooses
Which tool, or answer now
- Runtime checks and runs
Allowlist, validation, limits
- Observation
Back to the model; repeat
- Answer or stop
The model owns the sequence; your runtime owns the limits.
Common LLM workflow shapes
LLM workflows are not a lesser category. Many systems that get called agents would be better built as workflows. Three shapes cover a great deal of practical work:
- Chain: steps run in a fixed order, each using the previous output. Extract the order ID, look the order up, draft the reply.
- Router: a model classifies the input once, and code sends it down one of several fixed paths. A billing question goes to the billing path and a delivery question to the delivery path.
- Fan-out: independent model calls run in parallel on parts of the input, and code combines the results. Summarise each of five supplier documents, then merge the summaries.
In each shape the model makes a bounded decision, such as a label or a draft, and your code decides what that decision leads to. That boundary is what makes workflows straightforward to test: you can test each step on its own and list every path.
Step by step: one request, three designs
Step 1: Read the scenario
A customer of Quillfeather Cycles, the fictional shop from the previous lesson, writes: "Where is my order QF-1042? It was due yesterday." The order is delayed, and the carrier has posted a notice explaining why. A genuinely helpful answer mentions that notice.
Step 2: Save and run the file
Save the code below as
three_shapes.pyand runpython three_shapes.py. Every model function is a rule-based fake, so the output is identical on every run.What you should see: Three labelled answers, with two lines of agent tool use printed just before the agent's answer.
Step 3: Read the chatbot's answer
It is fluent and plausible, and it is not based on anything. With no tools and no data, a chatbot can only give a generic reply or, worse, a confident guess.
Step 4: Read the workflow's answer
It is correct and grounded, but incomplete. The workflow never checks carrier notices, because nobody wrote that step.
Step 5: Read the agent's answer
It found the notice because the fake model chose a second tool after seeing the status
delayed. The number of steps depended on what the first step found.
"""One customer request handled three ways: chatbot, workflow and agent.
The "model" functions are rule-based fakes so the file runs offline.
Watch who decides the next step: nobody (chatbot), your code (workflow)
or the model (agent).
"""
import json
import re
# Fictional data for Quillfeather Cycles.
ORDERS = {
"QF-1042": {"status": "delayed", "carrier_ref": "CR-77"},
"QF-1043": {"status": "dispatched", "carrier_ref": "CR-78"},
}
CARRIER_NOTICES = {"CR-77": "Regional depot closed; parcels held for up to 48 hours."}
def lookup_order(order_id: str) -> dict:
return ORDERS.get(order_id, {"error": f"unknown order {order_id}"})
def carrier_notice(carrier_ref: str) -> dict:
return {"notice": CARRIER_NOTICES.get(carrier_ref, "no notices")}
def fake_extract_order_id(text: str) -> str | None:
"""Stands in for a model call that extracts a single field."""
match = re.search(r"QF-\d{4}", text)
return match.group() if match else None
# 1. Chatbot: one model call, no tools, no access to your data.
def chatbot(request: str) -> str:
return "Orders usually arrive within a few days. Can I help with anything else?"
# 2. Workflow: your code fixes the steps; the model fills a narrow gap.
def workflow(request: str) -> str:
order_id = fake_extract_order_id(request) # model step
if order_id is None:
return "Please include your order ID, for example QF-1234."
order = lookup_order(order_id) # code step
if "error" in order:
return f"I could not find order {order_id}."
return f"Order {order_id} is {order['status']}." # template step
# 3. Agent: the model chooses each next action from what it has seen.
TOOLS = {"lookup_order": lookup_order, "carrier_notice": carrier_notice}
def fake_agent_model(request: str, seen: list[dict]) -> dict:
if not seen:
order_id = fake_extract_order_id(request)
if order_id is None:
return {"answer": "Please include your order ID, for example QF-1234."}
return {"tool": "lookup_order", "args": {"order_id": order_id}}
last = seen[-1]
if last.get("status") == "delayed":
return {"tool": "carrier_notice", "args": {"carrier_ref": last["carrier_ref"]}}
if "notice" in last:
return {"answer": f"Your order is delayed. Carrier update: {last['notice']}"}
if "error" in last:
return {"answer": "I could not find that order."}
return {"answer": f"Your order is {last['status']}."}
def agent(request: str, max_steps: int = 5) -> str:
seen: list[dict] = []
for _ in range(max_steps):
decision = fake_agent_model(request, seen)
if "answer" in decision:
return decision["answer"]
tool = TOOLS.get(decision["tool"])
result = tool(**decision["args"]) if tool else {"error": "unknown tool"}
print(f" agent used {decision['tool']}: {json.dumps(result)}")
seen.append(result)
return "Stopped: step limit reached."
if __name__ == "__main__":
request = "Where is my order QF-1042? It was due yesterday."
print("chatbot :", chatbot(request))
print("workflow:", workflow(request))
print("agent :", agent(request))All three designs in one file. Every model function is a fake, so it runs offline.
chatbot : Orders usually arrive within a few days. Can I help with anything else?
workflow: Order QF-1042 is delayed.
agent used lookup_order: {"status": "delayed", "carrier_ref": "CR-77"}
agent used carrier_notice: {"notice": "Regional depot closed; parcels held for up to 48 hours."}
agent : Your order is delayed. Carrier update: Regional depot closed; parcels held for up to 48 hours.What the comparison really shows
It is tempting to conclude that the agent won. Look again. One extra condition in workflow() (when the status is delayed, call carrier_notice()) would make the workflow just as helpful, and it would stay cheaper, faster and fully predictable. An agent earns its place only when the branches cannot reasonably be written down in advance: when there are many possible next steps and the right one depends on what has been found.
There is a second lesson in the file. The agent's "model" here is also a set of rules, so you can read exactly why it chose carrier_notice. With a real model those rules do not exist anywhere in your code. The choice comes from the instructions, the tool descriptions and the observations, and it can change when any of them changes, or when the provider updates the model. That is the real cost of an agent: decisions move out of code you can read and into behaviour you have to measure.
| Question | Chatbot | LLM workflow | Tool-using agent |
|---|---|---|---|
| Who decides the next step? | Nobody: one reply per message | Your code | The model, within limits your code enforces |
| Access to live data | None | Through fixed code steps | Through tools the model chooses |
| Predictability | Wording varies; no actions | High: every path can be listed | Lower: paths vary with input, instructions and model version |
| Cost and latency | One model call | A known number of calls | Variable; depends on the number of steps |
| How you test it | Review sample replies | Unit-test each step and each path | Evaluate behaviour across many scenarios, repeatedly |
| Typical failure | Confident answers with no basis | Cases nobody anticipated | Wrong or excessive actions, loops, injected instructions |
Hybrid designs are normal
Real systems mix the designs. A support platform might route each message with a workflow, answer common questions with a single grounded model call, and hand only open-ended investigations to a bounded agent with read-only tools. The agent becomes one step in a workflow, with a budget, a timeout and a fixed place to put its result.
Hybrids let you spend unpredictability only where it buys something. They also give you a natural fallback: when the agent step fails or runs out of budget, the surrounding workflow can hand the case to a person.
Security and reliability considerations
- Risk grows with the model's control. A chatbot can mislead; a workflow can mishandle the cases you anticipated; an agent can take actions you did not anticipate. The OWASP entry on excessive agency (opens in a new tab) describes how too much functionality, permission or autonomy turns a model error into real damage.
- Every design needs grounding. If an answer depends on facts, they must come from a tool or a retrieved source, and the answer should say so. The chatbot in the example shows what happens otherwise.
- Agents need limits that workflows get for free. A workflow has a fixed number of steps. An agent needs explicit step, time and cost limits, enforced in the runtime.
- Tool results are untrusted input. Carrier notices, emails and web pages are written by other people. An agent that reads them can be steered by instructions hidden inside them, a risk Module 7 covers in depth.
Common errors and how to fix them
A simple, fixed process was built as an agent, and it is slow, costly and occasionally takes odd routes.
Why it happens: The team reached for an agent before writing the steps down.
Fix: Write the process as a numbered list. If the order of steps rarely changes, rebuild it as a workflow and keep the model for the language-shaped steps only.
The workflow keeps missing cases that customers raise.
Why it happens: The real process has more branches than the code anticipated.
Fix: Log unhandled cases, add branches for the frequent ones, and consider a bounded agent step only for the long tail that cannot be listed.
The agent's behaviour changed although nobody changed the code.
Why it happens: Its decisions live in the model, so a model update, an instruction edit or a new tool description changed them.
Fix: Pin model versions where the provider allows it, version your instructions and tool descriptions, and run an evaluation suite before any change. Module 8 covers this.
A chatbot gives confident answers about orders it cannot see.
Why it happens: It has no tools or data, so it fills the gap with plausible text.
Fix: Either connect it to data through a workflow or tools, or instruct it to say that it cannot check orders and point the customer to a channel that can.
Validation checklist
Tick each item once you have confirmed it.
Hands-on exercise
Classify and redesign
Classify four fictional systems as a chatbot, an LLM workflow or a tool-using agent. Then change the workflow in three_shapes.py so it gives the same answer as the agent without becoming an agent.
You will need
- System A: a website widget where customers ask questions and a model replies from its training. It has no tools.
- System B: every night, a script sends each new product review to a model, which labels it positive, neutral or negative; code then files the label in a spreadsheet.
- System C: an assistant that, given a failed payment ID, decides whether to read the payment log, the customer's account or the payment provider's status page, and keeps investigating until it can explain the failure.
- System D: a model classifies each inbound email as billing, delivery or technical, and code sends it to a matching fixed handler.
three_shapes.pyfrom this lesson.
Acceptance criteria
Your work is done when every one of these is true.
Hints (2)
- For each system, ask: if the model were removed, would the sequence of steps still exist in code?
- Your workflow change needs one condition and one extra function call.
Show a model answer
System A is a chatbot: there are no tools and nothing happens beyond the reply. System B is an LLM workflow with a single model step; code decides everything that happens to the label. System C is a tool-using agent, because the model chooses which source to read next based on what it has found, and the number of steps is not fixed. System D is a workflow with a router: the model makes one classification and code owns every path after it. The tempting mistake is to call D an agent because the model's output changes what happens next, but the model chooses once, among paths you wrote, rather than choosing actions in a loop. For the code, a strong answer adds a condition after the lookup (if the status is delayed), calls carrier_notice(order["carrier_ref"]) and includes the notice in the reply. The comparison should note that the workflow needed one more condition and one more test, and in return stays predictable, cheaper per request and easy to reason about. The agent would only be preferable if delays had many different causes, each needing a different investigation.
Knowledge check
Choose an answer, then check it. Nothing is recorded — this is for you.
Show the answer and explanation
Answer: C. The model makes one bounded decision and code owns every path that follows, which makes it a routing workflow. The second option is tempting because the label does change the outcome, but the model chooses among paths you wrote, once; it does not choose actions in a loop.
Show the answer and explanation
Answer: B. In a workflow you can list and test each path. In an agent the path is chosen by the model and can change with the input, the instructions or the model version, so you measure behaviour across scenarios. The last option is tempting but wrong: an agent's tools, validators and runtime limits can and should be unit-tested; it is the model's choices that need evaluation.
Show the answer and explanation
Answer: D. The missing behaviour is a single predictable branch, so adding it keeps the workflow cheap, fast and testable. Replacing the workflow with the agent also works, which makes it tempting, but it buys flexibility the task does not need and adds variable cost and evaluation effort.
- Written by
- PromptFable Editorial
- Last updated 13 Nov 2026
- Review
- Reviewed by Waseem Nadir, Technical Reviewer
- Last reviewed 27 Nov 2026
References
Primary sources for the technical details in this lesson. Vendor platforms change — check the official page if anything here looks different from what you see.
- How tool use works(opens in a new tab)
Anthropic · Official documentation · Vendor documentation describing the client-side tool loop and when tools are not the right fit.
- Function calling with the Gemini API(opens in a new tab)
Google · Official documentation
- LLM06:2025 Excessive Agency(opens in a new tab)
OWASP Gen AI Security Project · Official documentation
PromptFable is independent and is not affiliated with, endorsed by or sponsored by Anthropic, Google, OpenAI or any other vendor. Claude, Gemini, Google AI Studio and other product names are trademarks of their respective owners.