Home โ€บ The AI Gets Hands (Agents & Tools)
๐Ÿง  Module 04 ยท Intermediate

The AI Gets Hands (Agents & Tools)

โœจ PAN'S RULE: If it's not chaotic, it's not magic! โœจ

An AI that can only talk is like a brain in a jar โ€” super smart, but pretty boring. Let's give that brain some hands, feet, and a jetpack so it can actually DO things in the world! ๐Ÿš€

๐Ÿฆพ

What is an AI Agent?

Imagine a brilliant robot chef ๐Ÿค–. It knows every recipe in the world (that's its AI brain), but it can't cook without its tools!

๐Ÿด๐Ÿฅ„๐Ÿฅฃ

Giving an AI "tools" is like handing our robot chef a spatula, a whisk, or an oven. When you ask it for a pancake, the AI thinks, "Aha! To make a pancake, I need the `whisk` tool and the `frying_pan` tool." Then, it uses them to actually make you a pancake! An AI Agent is a super-smart AI that doesn't just talkโ€”it can pick the right digital tool to actually get a job done!

Pan's Tech Deep-Dive: What's an API?

How does a weather tool *actually* work? It uses something called an API (Application Programming Interface). Think of it like this: an AI Agent is at a restaurant (the internet). The API is the menu. The agent can't go into the kitchen and make the food itself, but it can read the menu and tell the waiter (the API) exactly what it wants: "I'll have the weather for New York City, please!" The API then brings back the perfect data. APIs are the secret sauce that lets different programs talk to each other! This is the magic that powers AI Agent tools. When an agent uses its `web_search` or `weather` tool, it's actually making an API call behind the scenes to get that live data.

The Agent's Toolkit (Try Clicking 'em!)

๐Ÿง  AI MODEL
โ†’
๐Ÿค– Sparky here! I use this trusty tool for math problems like 2+2! What's 100 * 5?
๐Ÿค– Hey, Sparky again! This is my portal to the internet. I use it to look up live information, like 'What's the weather today?'
๐Ÿค– It's Sparky! I use this tool to check schedules and appointments. Perfect for asking 'Do I have soccer practice on Tuesday?'
๐Ÿค– Sparky here! This is my creative tool. With it, I could do something silly like take the Mona Lisa and add a cat wearing sunglasses. That's called image-to-image prompting!
๐Ÿ“บ This video uses awesome animation to show how an AI agent thinks. Watch for the part where it decides which "tool" to use to answer a question!
๐Ÿค” Click here for Pan's Debrief!

Did you see it? 1. The agent first breaks down the big request ("plan my trip") into smaller questions. 2. Then, it chooses the right tool for each question (like a flight search tool). 3. Finally, it puts all the answers together to give one helpful response! That's the core magic of an AI agent.

๐Ÿ’ป Agent Sparky's Brainwaves ๐Ÿ’ป

When you give an agent a complicated question, it doesn't just guess. It makes a plan, step-by-step. This is called "Chain of Thought." Instead of a boring text log, let's see how Sparky thinks!

โ“

"How much is a pizza in NYC and what's the weather?"

โžก๏ธ
๐Ÿค”

"Whoa, that's two questions. I need a plan!"

โžก๏ธ
๐Ÿ—บ๏ธ

Plan:
1. Find pizza price.
2. Find weather.
3. Report back!

โžก๏ธ
๐ŸŒ

Using my `web_search` tool for the pizza price...

โžก๏ธ
โœ…

"Done! A pizza is $25 and it's 75ยฐF and sunny! ๐Ÿ•โ˜€๏ธ"

Based on Sparky's thinking, what's the most important skill an agent needs to solve this problem?

Guessing the answer really fast.
Breaking a big problem into small steps.
Using only one tool for everything.
Pan's Pro-Tip: Agent Architectures

Sparky uses a "Chain of Thought" to make a plan and then follow it. But some advanced agents use a "ReAct" (Reason + Act) loop. They think of one step, take an action, observe the result, and then think of the next step. It's like checking the map after every single turn on a road trip instead of just at the beginning!

๐Ÿค– A Real Robot's Brain!

So how does a developer actually make Sparky think? They write code! That whole amazing "Chain of Thought" you just saw can be started with just a few lines of code, like this example in Python.

from some_agent_library import agent
                
question = "How much is a pizza in NYC and what's the weather?"
response = agent.run(question)
print(response)

See? You give the agent the question, and the code library handles all the thinking, planning, and tool-using behind the scenes. You just get the final answer!

โšก Remix this code LIVE! โšก
๐Ÿ›ก๏ธ AGENT INVESTIGATION: FACT OR FICTION?

AI's Can Be Confidently Wrong!

Sometimes, an AI will "hallucinate" โ€” it makes something up but says it with total confidence. Your job as an agent builder is to be a detective! For the statement below, use a safe search engine like Kiggle to see if the AI is telling the truth.

An AI tells you: "Polar bears are native to Antarctica and are often seen hunting penguins."

โœ… Fact
โŒ Fiction

๐Ÿค– Pan's Note: Get ready! We're about to teach our Pizza-Bot a new trick by writing it a special instruction list. It's easier than it looks!

๐Ÿค– Speaking the Agent's Language

Before you upgrade the Pizza-Bot, you need to know a secret language: JSON (JavaScript Object Notation). It looks a little weird, but it's just a super simple way for programmers to list instructions for a computer. It uses key-value pairs, like a label and what it means.

{"name": "Sparky", "skill": "planning"}

Here, "name" is the key, and "Sparky" is the value. That's it! When you edit the code below, you're using JSON to give the AI agent a perfect set of instructions for its new tool.

๐Ÿ•
โšก HACKER CHALLENGE

๐Ÿ’ป Hacker Challenge: Upgrade the Pizza-Bot!

Your mission is to upgrade the Pizza-Bot's brain! This block of code is called a 'schema.' Think of it as the instruction manual for a tool. By adding a new parameter, you're teaching the agent that the pizza tool has a new feature it can use. In the sandbox below, add a new parameter for the pizza's crust and set its value to stuffed. Then hit Run!

Waiting for execution...
BUILD-ALONG PROJECT

Train a Custom Vision Tool!

Let's go beyond pre-made tools. We're going to build a brand new tool for our agent: a vision tool that can tell if you need help with your homework! We'll use a real-world tool called Teachable Machine to do it. No code needed!

Watch this guide to see how Teachable Machine works!

  1. Open Google's Teachable Machine in a new tab.
  2. Choose "Image Project" and then "Standard image model".
  3. For "Class 1", rename it to "Thumbs Up". Use your webcam to take at least 20 pictures of yourself giving a thumbs up. ๐Ÿ‘
  4. For "Class 2", rename it to "Hand Raised". Take 20+ pictures with your hand raised, like you have a question. โœ‹
  5. Click the "Train Model" button. It might take a minute, but you're training a real AI!
  6. Once it's trained, test it out in the "Preview" window. Does it recognize your thumbs up and raised hand? You just built a custom vision tool!

You didn't just play with an AI โ€” you built a brand new tool for an AI Agent! The model you trained is a custom `vision` tool. An AI Agent could now use it. Imagine you tell your homework bot: "If you see me raise my hand, find a video explaining photosynthesis." The Agent would use YOUR `hand_raised_detector` tool to see your signal, then activate its `web_search` tool to find the video. You just built one of the five senses for an AI!

๐Ÿ›ก๏ธ Safety Check: AI's Aren't Your BFFs

When you use tools like chatbots or a webcam, you're creating data. That's powerful! Remember Pan's rules: 1) Always get a parent's permission before using your camera. 2) Chatbots are tools, not friends. They don't have feelings and can't keep secrets. 3) Never share personal info (your full name, school, address, or secrets) with a public AI. Think of it like a postcard โ€” anyone might read it, so don't write anything you wouldn't want the world to see!

The Uh-Oh Protocol: If an AI ever feels strange or uncomfortable: 1. STOP ๐Ÿ›‘ 2. TELL a Parent or Guardian ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘ง 3. CLOSE the Window โŒ. Itโ€™s not about being scared; it's about being in control.

๐Ÿ† MASTER BUILDER CHALLENGE

Architect a Travel Agent's NEW Tool

Time to be the lead architect! The `TravelBot 3000` already has tools for flights and hotels. Your mission is to design a new tool for its brain.

Part 1: The Blueprint. Design your `get_rental_car` tool in the sandbox below.
Part 2: The Build. Head to the Replit linked in the "Learn More" section and try to implement the tool you just designed. This is how you build a real portfolio project.

Waiting for execution...

๐Ÿ“š Learn More

๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘ง Parent Corner

An "AI Agent" is like a chatbot that can take action. Instead of just answering questions, it can use "tools" to browse the web, do math, or even order a pizza for you! This lesson is a great introduction to the logic of programming and problem-solving.

Conversation Starter: This lesson introduces a crucial safety topic: chatbots are tools, not friends. Ask your child, "Why is it a bad idea to tell a secret to a chatbot?" Discuss that these systems don't have feelings and that real people can sometimes review the conversations.

Family Challenge: Try the "Train a Custom Vision Tool" activity together using Teachable Machine. Brainstorm other fun things to teach the AI to recognize: different types of toys, happy vs. sad faces, or even different family members! It's a fantastic, hands-on way to understand how machine learning works without writing any code.