Chatbot vs agent β one shot vs loop
A chatbot takes your question and gives one answer. That's it. A customer asks "What's the refund policy?" and ChatGPT replies with canned text from its training data.
An agent does something different. It looks at your question and decides: "I need to run a query, check the result, maybe call another tool, and loop until I have the real answer." It's the difference between a parrot (ChatGPT) and a detective (agent).
User: "What's Apple's stock price?"
ChatGPT: "Apple's stock price as of my last training (April 2023) was around $170."
Reality: Wrong. Training data is stale.
User: "What's Apple's stock price?"
Agent: "I need to fetch this. Calling yfinance."
Result: Real price. Real data. Updated now.
The agent is only smarter because it has two superpowers: tools (functions it can call) and a loop (repeat until done). Without those, it's just a chatbot.
The agent loop: think β act β observe β repeat
Every agent runs the same basic loop. It's simple but powerful.
Real example from Jumia Kenya support:
Customer: "I want a refund for order #4521."
Aisha (the agent) thinks: "I need to look up this order in the system."
She acts: Calls lookup_order(4521)
She observes: Order found. Status: delivered. Amount: KSh 4,500.
She thinks again: "Refund is valid. I should process it."
She acts: Calls process_refund(4521, 4500)
She observes: Refund successful. Status: pending_bank_transfer.
She thinks: "Done. I can reply now."
She returns: "Refund approved. You'll see KSh 4,500 in your account in 2β5 business days."
That's the agent loop in real life. One question. Multiple steps. Multiple tools. One final answer.
The three ingredients: LLM + tools + loop
An agent is made of exactly three pieces. Remove any one, and it stops being an agent.
Why plain LLMs aren't agents (and what they can't do)
A plain LLM can only predict text. It has no access to tools, no memory of past actions, and no loop. Let's see what happens when you ask it a question it can't answer from training data.
Example: Stock price lookup
Same question, two different systems. Watch what happens.
The difference: ChatGPT guesses. The agent knows. That's because the agent has a tool and a loop.
Pseudocode of the minimal agent loop
Here's what happens under the hood. This is pseudocodeβwe haven't implemented the tools yet. That's Lesson 07. But this is the skeleton every agent follows.
That's it. The agent is just a while-loop that keeps asking "What should I do next?" until the LLM says DONE.
The observation-step tension: how the agent knows to stop
The trickiest part of the loop is: when does the agent stop? It can't loop forever. Three strategies exist.
The challenge is observation tension: the LLM needs information from past tool calls to decide what to do next, but if it loops forever trying to "understand" each result, the agent never completes. Good agent design balances exploring and deciding.
Real-world analogy: Aisha at Jumia Kenya support revisited
Let's map the agent loop onto a real human job. Aisha works at Jumia Kenya customer support. She handles refund requests.
Her question (goal): "Customer wants a refund for order #7834."
Her tools (available actions):
lookup_order(order_id)β check order statuscheck_policy(order_age, category)β is refund allowed?process_refund(order_id, amount)β issue the moneysend_email(customer, message)β reply to customer
Her loop (think-act-observe):
1. Think: "I need to check if this order is eligible for refund."
2. Act: Call lookup_order(7834)
3. Observe: Order found, 15 days old, electronics category
4. Think: "Jumia's policy: electronics can be refunded within 30 days. This qualifies."
5. Act: Call process_refund(7834, KSh 12,500)
6. Observe: Refund approved and queued
7. Think: "Done. I should confirm with the customer."
8. Act: Call send_email(customer@example.com, "Your refund of KSh 12,500 is on the way.")
9. Done. Close the ticket.
Aisha is an agent because she has three things:
- Intelligence (LLM role): She can read the request and decide what to do.
- Tools: She has access to the order system, refund system, and email.
- A loop: She loops through multiple actions (lookup β check β process β notify) until the problem is solved.
Without tools, she can't access data. Without a loop, she can't do multi-step work. The agent is the same idea, but for software.
What you'll build in Lessons 07β10
Now that you understand the three ingredients, here's your roadmap:
By Lesson 10, you'll have built four complete agents from scratch, each tougher than the last.
How AI teams use this concept
Every time a large LLM chatbot like Claude or GPT-4 handles a complex question, it's using an internal agent-like loop. The model reads the query, decides if it needs to "call" knowledge (retrieve context from its memory), thinks about the answer, and loops through reasoning steps. The agent loop is how modern AI systems go beyond single-pass prediction to multi-step reasoning and tool use.
Try it yourself
Mini Challenge
Pick a customer support task (refund request, password reset, order tracking). Write down:
- The question the agent receives
- 3β5 tools it would need
- The steps in the loop (think-act-observe-repeat)
Example: A password reset agent gets the question "I forgot my password." Tools: `validate_email()`, `send_reset_link()`, `confirm_reset_status()`. Loop: validate β send β confirm β done.
Test your knowledge
You understand the loop.
Now go build with it.
Join the Best AI Program: The AI-Era Agentic Engineer β 5 months, fully online, with placement assistance. Week 1 is free.
Explore The AI-Era Agentic Engineer β