You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
AI agents represent a paradigm shift from simple chatbots to autonomous systems that can perceive their environment, reason about what to do, take actions using tools, and iterate until a task is complete.
The Agent Loop:
===============
+-------------+
| Observe |
| Environment |
+------+------+
|
v
+-------------+
+---->| Reason |
| | & Plan |
| +------+------+
| |
| v
| +-------------+
| | Act |
| | (Use Tools) |
| +------+------+
| |
| v
| +-------------+
| | Evaluate |------ Goal met? ---> DONE
| | Result |
| +------+------+
| |
| No |
+------------+
(iterate)
Key insight: An agent takes multiple steps autonomously rather than generating a single response.
| Tool Category | Examples | What It Enables |
|---|---|---|
| Code execution | Python interpreter, shell | Run calculations, process data |
| File operations | Read, write, edit files | Manage documents and code |
| Web browsing | Search, web scraping | Access current information |
| API calls | REST APIs, databases | Interact with services |
| Communication | Email, Slack | Collaborate with humans |
User: "What's the weather in London right now?"
LLM outputs: {
"tool": "get_weather",
"arguments": {"location": "London, UK", "units": "metric"}
}
System executes: get_weather("London, UK", "metric")
Returns: {"temp": 12, "condition": "cloudy", "humidity": 78}
LLM: "It is currently 12 degrees C and cloudy in London, with
78% humidity."
The model does not execute functions directly — it outputs structured requests, and application code handles execution. This keeps the system secure and controllable.
Multi-Step Agent Example:
Goal: "Analyse Q3 sales data and create a summary report"
Step 1: [Think] Find the Q3 sales data file
Step 2: [Act] Search for files matching "Q3*sales*"
Step 3: [Think] Found "Q3_sales_2025.csv" -- read it
Step 4: [Act] Read the CSV file
Step 5: [Think] Analyse trends, top products, anomalies
Step 6: [Act] Run Python code for statistics
Step 7: [Think] Create visualisations
Step 8: [Act] Generate charts with matplotlib
Step 9: [Think] Compile into a report
Step 10: [Act] Write the report to a file
Step 11: [Done] Report created
ReAct (Reasoning + Acting) interleaves thinking and acting:
Thought: I need the population of Tokyo.
Action: web_search("population of Tokyo 2025")
Observation: Approximately 13.96 million (city) or 37.4 million (metro).
Thought: The user probably wants the metro figure.
Answer: Tokyo has about 14 million in the city proper and
37.4 million in the Greater Tokyo Area.
One LLM handles all reasoning and tool use. Simple but limited for complex tasks.
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.