Course file
week13_agents_intro/README.md
Welcome to Module 2. You've built neural nets, trained GPT, called APIs, and built a RAG system. Now you're going to build something that actually does things on its own: an AI agent.
An AI agent is just three things in a loop:
That's it. The LLM thinks, picks a tool, gets the result, thinks again, picks another tool (or answers). This loop is what makes it an "agent" instead of a one-shot chatbot.
The most common agent pattern is called ReAct (Reasoning + Acting). It works like this:
Read this blog post from Anthropic — it's the best explanation of agent patterns out there:
Building Effective Agents — Read at least the first half. You'll come back to it later.
You need the Anthropic Python SDK. If you don't have it yet:
pip install anthropic
Create a .env file in this folder with your API key:
cp .env.example .env
Then open .env and paste your key:
ANTHROPIC_API_KEY=sk-ant-your-key-here
Don't have an API key? Go to console.anthropic.com, sign in (your parent set this up), go to API Keys, and create one. Keep it secret — never commit it to git.
python react_loop.py
This runs a minimal ReAct agent with 3 simple tools. Watch what happens:
Try these questions:
get_random_number, reverse_string, or count_words. Follow the pattern of the existing tools.react_loop.py with at least one new tool you addedreflection.md filled inCopy your error message and paste it into Claude or ChatGPT:
"I'm building a ReAct agent with the Anthropic Python SDK. I got this error: [paste error]. Here's my code: [paste code]. How do I fix it?"
This is the same pattern from Module 1 — use AI to debug AI.