Build Your Own AI Agents

Lesson 3 of 7

Giving Agents Tools

Tools turn talk into action. Learn how an agent chooses a tool, fills in its inputs and uses the result.

🟡 Intermediate 65 XP

Learn it

A tool is a function with a name, a description and inputs — like getWeather(city).

The model reads the descriptions and decides which tool fits the task.

Your code actually runs the tool and hands the result back to the model.

Key terms

Tool schema
The name, description and parameter types describing a tool.
Tool call
The model's request to run a tool with specific arguments.
Least privilege
Give an agent only the access it truly needs.
Human-in-the-loop
A person approves risky actions before they happen.

Trace a tool call

  1. 1User: 'Will I need an umbrella in Prague tomorrow?'
  2. 2Model picks: getWeather(city='Prague', day='tomorrow')
  3. 3App runs: Returns {rain_chance: 80%}
  4. 4Model answers: 'Yes — 80% chance of rain. Take an umbrella!'

Defining a tool (JavaScript)

javascriptconst tools = {
  getWeather: {
    description: "Get tomorrow's weather for a city",
    parameters: { city: "string" },
    run: async ({ city }) => {
      return { city, rainChance: 0.8 }; // pretend API
    },
  },
};

The description is what the model reads. The run function is what your app executes.

Try it

Match each task to the best tool

'What's 17% of 240?'
'Remind me Friday'
'Latest news on Mars rovers'
'What did I save about Rome?'

Challenge

Design 3 tools for your agent. For each: name, one-sentence description, parameters, and whether it needs human approval. Explain why.

Pick whichever way suits you — every mode earns the same bonus XP.

Write at least 40 more characters to submit.

Mark your own work

Guided walkthrough — 0/2 clues revealed

  1. Clue 1 locked — reveal it only if you get stuck.
  2. Clue 2 locked — reveal it only if you get stuck.

Each clue costs 4 XP (never below 17 XP). You'd earn 33 XP right now.

Quiz time

Question 1 of 2Score 0

Who actually runs the tool code?