The Agent Era

Module 1: Understanding AI Agents

Picture this: chatbot vs agent

A chatbot answers once. An agent keeps going until the goal is done.

Chatbot

Youone question
→
LLMone reply
→
Stopno tools

Agent

Youa goal
→
Planmulti-step
→
Toolssearch / APIs
→
Goal metthen stop

This course’s practice starts with one LLM call (chatbot-style). Later modules add tools, memory, then Flask.

What is an AI Agent?

Definition

An AI Agent is an autonomous system that:

Observes its environment and processes information
Thinks about what actions to take
Plans multi-step solutions to problems
Acts by executing tools or generating responses
Learns from outcomes and improves

Where Do Agents Fit in the AI Ecosystem?

Capability AI ML LLM Agent
Learns from data Partial Yes Yes Yes
Understands language No No Yes Yes
Uses external tools No No No Yes
Makes autonomous decisions Partial Partial No Yes
Multi-step reasoning No No Partial Yes
Persistent memory No No No Yes

Real-World Agent Applications

🛫

Flight Booking Agent

Books flights by searching multiple airlines, comparing prices, and completing purchases autonomously.

Can search APIs
Can make decisions
Remembers preferences
🔬

Research Agent

Searches the web, reads papers, summarizes findings, and generates reports without human intervention.

Searches documents
Synthesizes information
Creates summaries
💼

Business Automation

Processes invoices, schedules meetings, sends emails, and manages workflows automatically.

Executes tasks
Integrates tools
Works 24/7
🎓

Study Assistant

Answers questions, searches notes, explains concepts, and adapts to student learning style.

Personalizes learning
Uses memory
Provides guidance
🏥

Medical Advisor

Reviews patient history, suggests treatments, schedules appointments, and monitors health metrics.

Analyzes data
Makes recommendations
Follows up
🤖

Customer Support

Handles tickets, connects users with specialists, learns from interactions, resolves issues.

Learns patterns
Escalates smartly
Improves over time

Agent vs Chatbot: What's the Difference?

🤖 AI Agent

Observes environment & context
Plans multi-step solutions
Uses multiple tools autonomously
Makes independent decisions
Learns & adapts over time
Works towards goals
Maintains persistent memory

💬 Chatbot

Waits for user input
Responds to single queries
Limited tool integration
User makes decisions
Fixed patterns (no learning)
Answers questions
Conversation-only memory

Before you click Practice — Module 1 notebook

The lab is three cells: install → key + helper → one ChatGroq call. You are proving you can talk to an LLM through LangChain. That is the brain of an agent — not yet tools, memory, or a loop.

Install langgraph + groq→Paste API key→ChatGroq.invoke one sentence

In Kodin: finish this page → Practice → run cells top to bottom. Stay in the app; paste the Groq key in the notebook prompt.

Practice task 1

Install packages into this notebook’s Python

Run the first code cell. It uses sys.executable -m pip so packages go into Kodin’s Jupyter kernel, not a random Windows pip.

# Install into THIS notebook kernel (not Windows pip).
import sys
import subprocess

print("Installing into:", sys.executable)
subprocess.check_call([
    sys.executable, "-m", "pip", "install", "-qU",
    "langgraph", "langchain-groq", "langchain-core",
])
print("Done. Run the next cells.")

Expected: Prints the kernel path, then “Done.”

Why this cell: A plain !pip install on Windows often installs into a different Python, then the next cell fails with ModuleNotFoundError: langgraph. If import still fails: Kernel → Restart Kernel, then Run All.
Practice task 2

Set the Groq key and the helper that reads GPT-OSS replies

Paste your Groq API key when the cell asks. The model is always openai/gpt-oss-20b. groq_text() turns whatever the model returns into a printable string.

import os
MODEL = "openai/gpt-oss-20b"

def groq_text(msg) -> str:
    """GPT-OSS may return content as a string or a list of parts."""
    c = getattr(msg, "content", msg)
    if isinstance(c, list):
        parts = []
        for p in c:
            if isinstance(p, str):
                parts.append(p)
            elif isinstance(p, dict):
                parts.append(str(p.get("text") or p.get("content") or ""))
        c = "\n".join(x for x in parts if x)
    if not c:
        extra = getattr(msg, "additional_kwargs", {}) or {}
        c = extra.get("reasoning_content") or extra.get("reasoning") or ""
    return str(c or "").strip()

if not os.getenv("GROQ_API_KEY"):
    os.environ["GROQ_API_KEY"] = input("Enter GROQ_API_KEY: ").strip()
if not os.getenv("GROQ_API_KEY"):
    raise SystemExit("Set GROQ_API_KEY before running the next cells.")
print("API key ready. Model:", MODEL)

Expected: “API key ready. Model: openai/gpt-oss-20b”

Why this cell: GPT-OSS 20B does not always put a plain string in message.content. It may send a list of parts, or put thinking in reasoning_content. Printing the raw object looks messy; this helper is what later cells use.
Practice task 3

First LLM call with ChatGroq

This is a chatbot-style call: one prompt in, one answer out. There is no tool, no memory, no loop. Compare that with the Agent vs Chatbot section above.

from langchain_groq import ChatGroq

llm = ChatGroq(model=MODEL, temperature=0)
response = llm.invoke("Explain what an AI Agent is in exactly one sentence.")
print(groq_text(response) or response)

Expected: One sentence defining an AI agent, printed in the notebook.

Why this cell: ChatGroq is the LangChain wrapper around Groq. model=MODEL uses GPT-OSS 20B. temperature=0 keeps the answer steady for class demos. invoke is a single shot — the model cannot search or remember the next cell unless you send history yourself.

Checklist in the notebook: packages installed, key set, invoke ran with no error. Then you are ready for Module 2, where the same LLM is asked to think in ReAct format.