Module 2 • Beginner

How AI Agents Work

Understand the Sense → Think → Act loop. Learn how agents plan, use tools, and achieve goals autonomously.

📊 Module Progress

Complete objectives and quizzes to unlock your badge!
0/9 Tasks Completed

🎯 Learning Objectives

Understand the Sense → Think → Act loop — The core cycle that powers all AI agent behavior.
Know the key components — Prompt, context window, tools, memory, and evaluation.
See how agents break down tasks — From complex goals to executable steps.
Understand evaluation & iteration — How agents know when to stop or retry.

📖 Theory: The Agentic Loop

🤖 What Powers AI Agents? The Sense→Think→Act→Evaluate Loop

Every AI agent follows a continuous cycle: Sense → Think → Act → Evaluate. This repeats until the goal is achieved.

1. SENSE — Receive Input

The agent receives information from its environment. This could be a user prompt, a notification, a scheduled event, or a system trigger.

Example: User says "Research top 3 AI tools for students."

2. THINK — Plan & Reason

The agent analyzes the goal, breaks it into steps, checks available tools, and creates a plan of action.

Agent thinks: "I need to search web → compare features → summarize → present results"

Tools available: web_search, web_fetch, summarize

3. ACT — Execute the Plan

The agent uses its available tools to carry out each step in the plan. This is where the work happens.

Agent executes: Calls web_search("best AI tools for students 2026") → Fetches each result → Compiles findings into a list.

4. EVALUATE — Check if Goal is Met

After executing, the agent assesses whether the original goal has been achieved. If yes → return result. If no → adjust plan and repeat from SENSE.

Agent decides: "Did I provide 3 AI tools with links? Yes → Done. No → Re-plan."

🔍 SENSE

Receive input

🧠 THINK

Plan & reason

ACT

Use tools

EVALUATE

Goal achieved?

repeat if needed

🔧 Key Components of an AI Agent

  • Prompt/Input: The user's request or trigger event that starts the agent.
  • Context Window: The agent's "working memory" — recent messages and tool results that it can reference.
  • Tools: External capabilities the agent can use (web_search, write_file, APIs, etc.).
  • Memory: Long-term storage across sessions — learned facts, preferences, history.

💡 Real-World Examples: The Loop in Action

🌤️

Example 1: Weather Check

User: "What's the weather in Ipoh?"

Agent (SENSE): Receives user message → recognizes need for current weather data.

Agent (THINK): "I need to use a weather tool or web search. Location: Ipoh."

Agent (ACT): Calls web_search("weather Ipoh now") → gets results → extracts temperature and forecast.

Agent (EVALUATE): "Did I provide current weather for Ipoh? Yes → return answer."

Result: "Currently 32°C in Ipoh, partly cloudy with 70% humidity."
📁

Example 2: File Organization

User: "Organize my Downloads folder — move all PDFs to a 'PDFs' folder."

Agent (SENSE): Receives request → identifies file operation task.

Agent (THINK): "Steps: 1) List files in Downloads 2) Filter for .pdf extension 3) Create PDFs folder if missing 4) Move files 5) Report summary."

Agent (ACT): Uses file tools → lists Downloads → finds 15 PDFs → creates folder → moves all → counts moved items.

Agent (EVALUATE): "All PDFs moved? Yes (15/15) → Done!"

Result: "Done! Moved 15 PDF files to Downloads/PDFs/"
🔬

Example 3: Research Task

User: "Find the top 5 Python courses for beginners and list their prices."

Agent (SENSE): Gets request → identifies it as research task requiring real-time info.

Agent (THINK): "Break down: Search for Python courses → Find top 5 → Extract prices → Format as list. Tools needed: web_search ×5, maybe web_fetch for details."

Agent (ACT): Runs web searches, visits course pages, extracts pricing data.

Agent (EVALUATE): "Did I return 5 courses with prices? Yes → complete. Missing price for one? → Search again for that course."

Result: Presents structured list: 1) Coursera — $49/month, 2) edX — Free audit, 3) ...

🧪 Hands-On Exercise

Try the Agentic Loop Yourself (10 minutes)

Step 1 — Choose a task that requires tool use
Good examples: "Search for latest news about AI", "Summarize this article: [URL]", "Calculate compound interest on $1000 at 5% for 10 years."

Step 2 — Give the task to an AI agent
Use OpenClaw, Claude with tools, or ChatGPT Advanced Data Analysis. Type your prompt clearly.

Step 3 — Observe the loop in action
Watch for: 1) Does the agent acknowledge it needs to use tools? 2) Does it break the task into steps? 3) Does it call tools sequentially? 4) Does it evaluate the result before responding?

Step 4 — Reflect
Did you see the complete Sense→Think→Act→Evaluate cycle? Which step was most obvious? What would happen if the agent failed at evaluation?

💡 Pro Tip: Prompt Engineering for Better Loops

To make the agent's loop more effective, structure your prompts to encourage planning:

Bad: "Find me AI tools."
Better: "Search for the top 5 AI tools for students, compare their features, and present a table with tool name, key feature, and pricing."

The better prompt helps the agent create a clearer plan → better execution → better results.

📝 Quiz: How AI Agents Work (5 Questions)

Test your understanding of the agentic loop and its components.

Q1: What is the FIRST step in the agentic loop?

A
Think
B
Sense (receive input)
C
Act
D
Evaluate

Q2: What does the "Context Window" refer to?

A
The agent's working memory (recent messages + tool results)
B
The browser window size
C
Number of tools available
D
The number of tokens used

Q3: If the agent doesn't achieve the goal, what happens in the loop?

A
It gives up and stops.
B
It adjusts the plan and repeats from SENSE
C
It asks the user to restart it.

Q4: Which tool would an agent use to search the internet?

A
web_search
B
write_file
C
delete_all
D
play_music

Q5: What is the purpose of "Memory" in AI agents?

A
To remember across sessions
B
To store the agent's code
C
To make the agent faster
D
To display images
🧠
Agentic Thinker
You've completed all objectives and quizzes!