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!)
๐ค 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?
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! โก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."
๐ค 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: 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!
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!
- Open Google's Teachable Machine in a new tab.
- Choose "Image Project" and then "Standard image model".
- For "Class 1", rename it to "Thumbs Up". Use your webcam to take at least 20 pictures of yourself giving a thumbs up. ๐
- For "Class 2", rename it to "Hand Raised". Take 20+ pictures with your hand raised, like you have a question. โ
- Click the "Train Model" button. It might take a minute, but you're training a real AI!
- 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!
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.
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.
๐ Learn More
- Deep Dive into LangChain Tools - See the official documentation real developers use. This is the "instruction manual" for building powerful agents. Bookmark it.
- Simple AI Agent on Replit - See a real, working code example you can run and remix! Your Mission: Fork this Replit project and try to implement the `get_rental_car` tool you designed in the Master Builder challenge. Can you make it work? This is how you go from a TomorrowHub lesson to a real portfolio project.
- Free APIs for Your First Agent - An AI Agent is only as good as its tools. APIs are how agents connect to real-world data (like weather, movies, or even Pokรฉmon stats!). With a parent's help, find a fun, free API here and challenge yourself to write a Replit agent that can use it.
๐จโ๐ฉโ๐ง 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.