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 smart model that knows how to pick and use the right digital tools to get a job done.
The Agent's Toolkit
๐ป System Diagnostic: Agent Thinking...
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." It's like we get to see the AI's internal monologue!
SYSTEM LOG: Agent Thinking...
[USER_QUERY]: "How much does a pizza cost in New York and what's the weather?"
[THOUGHT]: This is a multi-step problem. I can't answer both at once.
[PLAN]: First, find the price of pizza. Second, find the weather. Third, combine the answers.
[ACTION]: Use `web_search` tool with query "average pizza price NYC".
[TOOL_RESULT]: "$25"
[THOUGHT]: Okay, I have the price. Now for the weather.
[ACTION]: Use `weather_api` tool with location "New York, NY".
[TOOL_RESULT]: "75ยฐF and Sunny"
[FINAL_RESPONSE]: A pizza in New York costs about $25, and the weather is currently 75ยฐF and sunny! ๐โ๏ธ
Which Tool Should I Use?
Your mission is to help Agent Sparky decide which tool to use for each job. Drag and drop (or just think about) the right tool for each question!
- To answer 'What is 523 times 78?', Sparky should use the... [Calculator Tool]
- To answer 'What's the weather like tomorrow in London?', Sparky should use the... [Web Search Tool]
- To answer 'What appointments do I have on Friday?', Sparky should use the... [Calendar Tool]
Design a Tool Schema
Agents need strict instructions on how to use their tools. This is done with a special format called JSON. Your job is to map out a "Pizza Ordering" tool for an agent by finishing the code below.
๐ป Sandbox: Build a Tool
โญ Pro-Tip: From Sandbox to Real World
The JSON you're writing is a simple version of a "function definition" that real developers use to build AI agents. They use powerful toolkits like LangChain and AutoGen to connect AI models to hundreds of different tools, from sending emails to controlling video games!
Architect an Agent
Your turn to be the architect! In a text editor or on paper, design a JSON schema for a `travel_planner` agent. It needs TWO tools: one called `get_flight_price` (which needs a `destination` parameter) and another called `book_hotel` (which needs a `city` and `nights` parameter). How would you structure this so the agent knows what tools it has available?
An AI agent is only as safe as the tools you give it. Never give an agent a tool that can access your personal files, passwords, or camera without your direct permission. A good agent asks before it acts on something important!
๐ Learn More
- Deep Dive into LangChain Tools - See the official documentation real developers use.
- Simple AI Agent on Replit - See a real, working code example you can run and remix!
๐จโ๐ฉโ๐ง 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.
Family Challenge: Brainstorm a silly "agent" to help with a household chore, like a 'Sock Matching Agent.' What tools would it need? (e.g., a `camera_tool` to see the socks, a `robot_arm_tool` to pick them up). This is a fun way to explore logic together!