A tool is a small helper that does one job really well (like a calculator or weather app). Your AI (the “brain”) can ask a tool to do that job and then use the result to answer you.
One‑liner: A tool is a helper your AI can use to get something done.
Tool calling is when the AI decides to use a tool during a conversation.
Flow:
- User asks: “What’s the weather in Karachi?”
- AI thinks: “I need real weather data.”
- AI calls tool:
get_weather(city="Karachi") - Tool returns:
{"temp": 33, "condition": "Cloudy"} - AI answers: “It’s 33°C and cloudy in Karachi.”
Think of it like a student using a calculator during an exam: the student decides when to use it, pushes the buttons (inputs), gets the number (output), and writes the final answer in their own words.
- LLMs don’t have live data. Tools fetch today’s facts (weather, news, prices).
- LLMs can’t act by themselves. Tools do things (send email, book a slot, run code).
- Accuracy & safety. Tools can validate math, check a database, or enforce rules.
| Tool | What it helps with |
|---|---|
| Search | Look up facts on the web |
| Calculator | Do exact math |
| Weather | Get live weather |
| Email/SMS | Send a message |
| Code Runner | Execute code safely |
| Database | Read/write app data |
- Smartphone & apps: Your phone (AI) decides when to open Maps (tool) to navigate.
- Kitchen: The chef (AI) uses a blender (tool) only when a recipe needs it.
- Office: The manager (AI) asks the finance system (tool) for an invoice total.
- Intent detection: “This needs outside help.”
- Pick a tool: Choose the right helper.
- Fill inputs: Provide clean, specific arguments (e.g.,
city="Karachi"). - Run tool: Call the function/API.
- Use result: Explain it in normal language to the user.
- (Optional) Act again: If needed, chain another tool (e.g., then send an email).
-
Make three cards (tools): Calculator, Weather, Dictionary.
-
Assign one student as AI, three students as tools, and one as User.
-
User asks: “What’s 19×23 and is it hotter than 30°C in Karachi?”
-
“AI” decides:
- Calls Calculator → gets
437. - Calls Weather → gets
33°C.
- Calls Calculator → gets
-
“AI” responds: “19×23 = 437. Yes, it’s hotter than 30°C (33°C).” This makes tool calling visible and fun.
You define a name, inputs, and what it returns (output). For example:
Tool name: get_weather
Inputs: city (text)
Returns: { temp: number, condition: text }
The AI picks this tool when it sees a weather question and fills in city from the user’s message.
- Use tools for live info, precise math, database reads/writes, sending messages, or doing real actions.
- Don’t use tools when a normal explanation, story, or concept answer is enough.
- One job per tool (single responsibility).
- Clear names & inputs (e.g.,
send_email(to, subject, body)). - Predictable outputs (simple JSON).
- Handle errors (what if the city isn’t found?).
- Stay safe (never expose secrets; validate inputs).
Let guess which tool you’d use for different tasks:
- “Translate this sentence.”
- “Find cheapest flight.”
- “Save my progress.”
Answers:
- Translation tool
- Search + Price tool
- Database tool
