Module 5 · AI that takes action: agents · Lesson 23 of 32
Agents: think, act, check, repeat
12 minFree GenAI course · BeginnerLesson 5.2By Saket Bhatnagar
Researched and drafted with AI, reviewed and edited by Saket Bhatnagar.
In short
- An AI agent is a language model in a loop: think about the next step, use a tool, look at the result, repeat.
- It keeps going until the goal is done, it hits a limit, or it needs you to decide something.
- Agents are powerful but slower, costlier and riskier than one answer, so they need step limits and human approval.
Video lesson · coming soon
What are AI agents? Explained in 3 minutes
Lala, your AI mentor, will walk you through this lesson in a short animated video. Until then, everything is here to read and try.
- 01 Dinner for six, no stairs, ₹800 each
- 02 Think, act, observe, repeat
- 03 A captain, ball by ball
- 04 Watch the agent book a table
- 05 Not everything needs an agent
- 06 Limits and a human yes
- 07 Try it, then meet MCP
Meera wants dinner for six on Saturday in Indiranagar, Bengaluru. Two friends are vegetarian, the budget is about ₹800 each, and her dad cannot climb stairs. She hands the job to her cousin Arjun. Arjun does not solve it in one go.
He searches, calls a place, hears “8 pm is full”, tries another, checks for a lift, and then messages Meera: “8:45 at a place with a ramp, okay?” Search, try, look, adjust, ask. An AI agent works exactly like Arjun.
From one answer to a loop
In the last lesson, the model asked for one tool and used the result in one answer. That covers “will it rain tomorrow?”. But booking Meera’s dinner needs many tool calls, and each one depends on what the last one found.
Nobody can write the full plan in advance, because nobody knows which restaurant will be full. So instead of one tool call, we let the model run in a loop and choose the next step each time.
The agent loop
Drag to exploreThe model thinks, acts through a tool, and observes the result, then thinks again. It leaves the loop when the goal is done, or pauses to ask a person when a choice is theirs to make.
Diagram connections:
- Your goal to Think (starts)
- Think to Act (use a tool) (picks a tool)
- Act (use a tool) to Observe (result)
- Observe to Think (repeat)
- Think to Ask a person (needs a yes)
- Think to Done (goal met)
- Your goal: Dinner for six, Saturday, veg options, step-free, about ₹80…
- Think: The model plans the single next step from everything it has…
- Act (use a tool): The app runs the tool the model asked for, like a restauran…
- Observe: The tool result is added to the context for the next think…
- Ask a person: Pause for a choice or an approval before anything risky.
- Done: The goal is met, or a step limit stopped the loop.
Watch an agent book a dinner table
Let’s give Meera’s job to an agent with three tools: a restaurant search, a booking tool and a way to message Meera. Notice how the plan changes when something goes wrong, and where the agent stops to ask.
Every “think” step is a fresh model call. The model sees the goal plus every tool result so far, all inside its context window. That is how it “remembers” that Rooftop Grill had stairs.
// Optional: the agent loop, in pseudo-code
let steps = 0;
while (steps < 15) { // a hard step limit
const reply = await model(goal, history, tools); // think
if (reply.done) break; // goal met
if (needsApproval(reply.toolCall)) await askHuman(reply.toolCall);
const result = await runTool(reply.toolCall); // act
history.push(result); // observe
steps++;
}Chatbot, workflow or agent?
Not every AI feature should be an agent. A useful test: who decides the next step? In a workflow, a person wrote the steps in advance. In an agent, the model chooses them as it goes.
| Approach | Who picks the next step | Good for | Watch out for |
|---|---|---|---|
| Chatbot (one answer) | Nobody: there is one step | Explaining, drafting, quick questions | No fresh data or actions without tools |
| Workflow | The developer, in advance | Repeatable jobs: summarise every new support ticket | Breaks when something unexpected happens |
| Agent | The model, after each result | Messy, open-ended jobs: research, fixing code, bookings | Cost, speed, loops and wrong actions |
In 2026 you meet agents in coding assistants that read a codebase, edit files and run tests. Research assistants read dozens of web pages before writing a report. Other assistants can click around a website for you. All of them run this same loop.
Where agents go wrong, and how to keep them safe
Small mistakes add up over many steps. Say each step is right 95 times out of 100. Over ten steps, the whole run is right only about 60 times out of 100. Long tasks need checks along the way, not only at the end.
- Going in circles: the agent searches the same thing again and again. A step limit and a budget stop the meter running forever.
- Cost and waiting: ten think steps means ten model calls, each reading a growing history. An agent task can cost many times more than one answer.
- Forgetting: very long runs overflow the context window, and early facts fall out. Good agents keep short notes of what matters.
- Being tricked: a web page the agent reads might hide instructions. Tool results are data, never orders.
- Wrong actions: a mis-booked table is annoying; a wrong payment is serious. Anything costly or hard to undo needs a human yes.
Check yourself
Check yourself
What makes something an agent rather than a single tool call?
Pick an answer to see why it is right or wrong.
Check yourself
Every night, your app must summarise each new support ticket and email the summary to the team. What should you build?
Pick an answer to see why it is right or wrong.
Check yourself
Your dinner-booking agent finds the only free slot is an hour later than asked. What should it do?
Pick an answer to see why it is right or wrong.
Remember these three
- An agent is a model in a loop: think, act with a tool, observe the result, and repeat until done.
- Use a workflow when you know the steps; use an agent when the path depends on what each step finds.
- Keep agents safe with few clear tools, step and cost limits, logs, and a human yes before risky actions.
Questions people ask
- What is an AI agent in simple words?
- An AI agent is a language model that works towards a goal over many steps. It plans a step, uses a tool, looks at the result and decides the next step, until the job is done or it needs your input.
- What is agentic AI?
- Agentic AI is the general idea of AI systems that act with some independence: planning, using tools and adjusting over several steps. Most agentic systems are built from the same think, act, observe loop with limits and human checks.
- What is the difference between an AI agent and a chatbot?
- A chatbot gives one reply to each message. An agent may make many model calls and tool calls behind the scenes for one request, choosing each step itself, before it reports back.
- Are AI agents reliable enough to use?
- For well-scoped jobs with good tools, often yes, and they are widely used for coding and research. Errors still add up over long tasks, so keep step limits, logs and human approval for anything important.