Lesson 4 / 12 · 9 min
From chatbot to agent: the reasoning-action loop
What turns a chatbot into an agent: tools, a loop, and the ability to take actions and observe results.
A chatbot reads a message and writes a reply. An agent can also act: it can call a tool, read the result, and decide what to do next, looping until the task is done. That loop is the whole difference, and it is simpler than it sounds.
The ReAct loop
The common pattern is called ReAct, short for Reason and Act. At each step the model produces a thought (its reasoning), then either an action (call a tool with some input) or a final answer. If it took an action, the system runs the tool and feeds the result back as an observation. The model reasons again with that new information. Repeat until it answers.
User: Is the large nitrile glove still in stock, and what is the price?
Thought: I need current stock and price. I should use the catalog tool.
Action: lookup_product({ "name": "nitrile glove", "size": "L" })
Observation: { "sku": "GLV-NTR-L", "stock": 240, "price_idr": 85000 }
Thought: In stock with a price. I can answer now.
Answer: Yes, the large nitrile gloves are in stock (240 units) at
Rp 85.000 per box. Would you like to order?Tools are the agent's hands
On its own the model can only produce text. Tools are functions you expose to it: look up a product, check a calendar, create a CRM lead, send a WhatsApp message. The model never runs code itself, it requests a tool call, your system executes it, and returns the result. This is what lets an agent touch the real world while you keep full control over what it is allowed to do.
Planning and stopping
For multi-step tasks the model can plan: break the goal into steps, do them in order, and adapt if a step fails. Two practical guardrails matter here. Give it a step limit so a confused agent cannot loop forever, and a clear definition of done so it knows when to stop and answer rather than over-working a simple request.
Notice that nothing here requires a fancy framework. An agent is a loop around an LLM that can call tools, with limits. Understanding it at this level is what lets you reason about why one misbehaves and how to fix it.
What you take away
- An agent = an LLM in a loop that can call tools and observe results
- ReAct: thought, then an action or a final answer, with observations fed back
- Tools are functions you expose; the model requests, your system executes
- Always cap the steps and define when the task is done
Curated sources
Hand-picked references for going deeper, reviewed by our team.