Typorithm · medium

Tool / Function Calling

tool-usellmtoolsfunction-callingschema
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn Tool / Function Calling

0%

Tools & Agents

You describe tools with a name, description, and JSON input_schema. When useful, the model emits a tool_use block with arguments; your code runs the real function and returns a tool_result, then the model continues toward an answer.

A tool is just a description: a name, a plain-English description of what it does, and a JSON input_schema for its arguments. You send this list with the request so the model knows what it can call.

When the model decides a tool would help, it does not run anything itself — it emits a tool_use block naming the tool and supplying arguments that match your input_schema.

Your code executes the real function (call an API, query a database), then sends the output back as a tool_result. The model reads that result and continues toward its final answer.

01

A tool = name + description + input_schema.

02

The model emits tool_use; your code runs it.

03

You return a tool_result so the model can continue.

const tools = [{
  name: "get_weather",
  description: "Get weather for a city",
  input_schema: { type: "object", properties: { city: { type: "string" } } },
}];
// model returns tool_use; you run it and return tool_result

Read the implementation

Connect each part of the code to the concept before you type.

1. Tool name

name is the identifier the model emits when it decides to call this tool.

name: "get_weather",

2. Tool description

description tells the model what the tool does and when to reach for it — write it for the model.

description: "Get weather for a city",

3. Input schema

input_schema is JSON Schema describing the arguments the model must supply.

input_schema: { type: "object", properties: { city: { type: "string" } } },

4. A parameter

Each property names one argument and its type, so the model fills it in correctly.

city: { type: "string" }

5. The round trip

The model emits a tool_use block; your code runs the real function and returns a tool_result.

// model returns tool_use; you run it and return tool_result

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

Tool / Function Calling: Lesson & Practice · Typorithm | ApplyDjinn