DevInterviewMasterStart free →
Agentic AI PatternsFree to read

What is an AI Agent? (Explained Simply)

Let's start from absolute zero

Imagine you ask a friend: "Book me the cheapest flight to Delhi next Friday." A normal chatbot would just talk about flights. An AI agent would actually go check prices, compare them, and book one for you. That ability to take actions to reach a goal , not just chat, is what makes something an "agent".

Key points

The one-line definition

An AI Agent is a program that uses an LLM (like Claude or GPT) as its "brain" to decide what to do, then uses tools to actually do it, repeating until a goal is achieved.

Note: Brain (LLM) + Hands (tools) + a Loop = Agent.

Chatbot vs Agent (the key difference)

CHATBOT (just talks) AGENT (talks AND acts) ──────────────────── ──────────────────────

You: book a flight You: book a flight │ │ ▼ ▼ ┌─────────┐ ┌─────────┐ │ LLM │ │ LLM │ ◄────┐ └─────────┘ └────┬────┘ │ │ │ │ loop ▼ ▼ │ "Sure! Here is how ┌─────────────┐ │ you can book a │ USE A TOOL │──┘ flight..." (just │ search/book │ words, no action) └─────────────┘ │ ▼ ✅ Flight booked!

Every agent has 3 parts

The basic agent loop (memorise this picture)

┌──────────────────────────────────────────┐ │ │ ▼ │ ┌──────────┐ ┌──────────┐ ┌────────────┐ │ │ THINK │──► │ ACT │──► │ OBSERVE │──┘ │ (decide) │ │ (use a │ │ (read the │ │ │ │ tool) │ │ result) │ └──────────┘ └──────────┘ └────────────┘ ▲ │ │ goal not done yet? │ └────────────────────────────────┘ │ goal done ▼ ✅ FINISH

A tiny code example (don't worry, read it like English)

Here is the simplest possible agent loop. Notice it is literally just a while loop around "ask the LLM what to do next".

goal = "Find today's weather in Mumbai"
history = []

while True:
    decision = llm(goal, history)        # 1. THINK
    if decision.is_final_answer:
        print(decision.answer)            # done!
        break
    result = run_tool(decision.tool,      # 2. ACT
                      decision.args)
    history.append(result)                # 3. OBSERVE

▶ Try it: a tiny agent (no real LLM, runs in your browser)

Edit the goal string and press Run. Real Python runs right here in your browser.

# This is a fake agent so you can FEEL the Think -> Act -> Observe loop.
# Change the goal below and hit Run!

tools = {
    "weather": lambda city: f"{city}: 31C, sunny",
    "shout":   lambda text: text.upper(),
}

def fake_brain(goal):           # pretend the LLM decided this
    if "weather" in goal:
        return ("weather", "Mumbai")
    return ("shout", goal)

goal = "what is the weather in Mumbai?"
tool, arg = fake_brain(goal)    # 1. THINK
result = tools[tool](arg)       # 2. ACT
print("Tool chosen :", tool)
print("Observation :", result) # 3. OBSERVE

▶ Free playground: write any Python you like

This is a real Python interpreter (Pyodide). Experiment freely!

# Your sandbox. Type anything and Run.
print("Hello from real Python in your browser!")
print("2 to the power 10 =", 2 ** 10)
for i in range(1, 4):
    print("counting", i)

When do you actually need an agent?

ScenarioRecommendationWhy
Just answering a question from text you give it❌ No agent neededA plain LLM call is cheaper and faster.
The task needs live data (search, database, API)✅ Use an agentIt can fetch real info instead of guessing.
The task has many steps that depend on each other✅ Use an agentThe loop lets it adapt as it learns more.
You need a one-off, predictable transformation❌ Use a simple scriptAgents add cost and unpredictability.

Beginner misunderstandings

MistakeConsequenceFix
"An agent is a smarter chatbot."You miss the whole point and over-use chatbots for action tasks.Remember: the difference is ACTION (tools), not intelligence.
"The LLM runs the tools itself."Confusion about how it works and where bugs come from.The LLM only REQUESTS a tool. YOUR code runs it and feeds the result back.
Using an agent for everything.Slow, expensive, and harder to debug.Use the simplest thing that works. Agents are for genuinely multi-step, dynamic tasks.

Remember these 3 lines

Key takeaways

Frequently Asked Questions

What is What is an AI Agent?

Imagine you ask a friend: "Book me the cheapest flight to Delhi next Friday." A normal chatbot would just talk about flights. An AI agent would actually go check prices, compare them, and book one for you.

How does What is an AI Agent work?

An AI Agent is a program that uses an LLM (like Claude or GPT) as its "brain" to decide what to do , then uses tools to actually do it , repeating until a goal is achieved.

What are the key takeaways about What is an AI Agent?

An AI agent uses an LLM as a brain to decide actions and tools to perform them. It runs a Think → Act → Observe loop until the goal is reached. Use agents only when the task is multi-step and needs live actions/data. The LLM never runs tools itself — it requests them and your code executes.

Browse all Agentic AI Patterns topics →

Practice this on DevInterviewMaster

Read the full What is an AI Agent? (Explained Simply) breakdown with interactive demos, quizzes, and Hinglish notes.

Open the interactive topic →

800+ system-design, LLD, coding, and design-pattern topics. Unlock everything with Pro (₹499, one-time) or Ultimate (₹999, one-time) — lifetime access, no subscription.