Artificial Intelligence (AI) · Advanced level

Advanced level · Module 2: AI Agents and Tool Use · Lesson 1 of 4

Tool and Function Calling

Let a model request calls to functions you define, and execute them safely.

In this lesson you will

  • Define tools with clear schemas
  • Execute tool calls and return results to the model

Key concepts

tool schemafunction callingargument validationtool results

The lesson

With tool calling, you describe functions — name, purpose and parameters — and the model can ask to call them, such as search_policies(query) or get_office_hours(location). Your code runs the function and returns the result to the model.

The model only requests; your code decides. Validate arguments before executing, as you would any user input.

Clear tool descriptions and small, focused tools make correct use more likely.

Step by step

  1. Define a read-only search tool with a schema.
  2. Let the model call it for a question.
  3. Validate the arguments and run it.
  4. Return the result and get the final answer.

Practice activity

Add the policy search tool to the capstone assistant.

Expected result: An assistant that calls the search tool correctly and answers from its results.

Check your understanding

  1. Who actually executes a tool call?

    Show answer

    Your code, after validating the request.

  2. Why keep tools small and focused?

    Show answer

    Clear, simple tools are used correctly more often.

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.