Agents & Tool Use / Tool Integration

Tool Use

Beginner [2/5]
Function calling Tool calling External functions

Definition

Tool use (also called function calling) is the ability of an LLM to recognize when it needs external capabilities and generate structured requests to invoke specific tools. Instead of just generating text, the model can call calculators, search engines, APIs, or any function you define.

This transforms LLMs from pure text generators into systems that can take real actions in the world.

Key Concepts

  • Tool definitions: Schema describing available tools and parameters
  • Tool selection: Model decides which tool to use
  • Parameter extraction: Model extracts values from conversation
  • Result handling: Tool output is fed back to the model

Examples

Tool Definition
How to Define Tools
{ "name": "get_weather", "description": "Get current weather for a location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "City and state, e.g. 'Boston, MA'" }, "unit": { "type": "string", "enum": ["celsius", "fahrenheit"], "description": "Temperature unit" } }, "required": ["location"] } }
Tools are defined with a name, description, and parameter schema.
Tool Use Flow
How Tool Calling Works
1. USER MESSAGE "What's the weather in Tokyo?" 2. MODEL RECOGNIZES NEED FOR TOOL → Generates tool call: { "tool": "get_weather", "arguments": {"location": "Tokyo, Japan"} } 3. YOUR APPLICATION EXECUTES TOOL → Calls weather API → Returns: {"temp": 22, "condition": "sunny"} 4. MODEL RECEIVES RESULT → Generates final response: "It's currently 22°C and sunny in Tokyo!"
The model generates structured requests; your code executes them.
Common Tools
Tool Categories
RETRIEVAL TOOLS • search_documents(query) • get_webpage(url) • query_database(sql) COMPUTATION TOOLS • calculate(expression) • run_python(code) • analyze_data(data) COMMUNICATION TOOLS • send_email(to, subject, body) • post_to_slack(channel, message) • create_calendar_event(...) ACTION TOOLS • create_file(name, content) • update_record(id, fields) • make_purchase(item, amount)
Tools extend LLM capabilities to interact with the real world.

Interactive Exercise

🔧
Design a Tool

Design a tool definition for a "send_reminder" function that:

  • Takes a message and time
  • Optionally takes a recipient email
  • Returns success/failure status

Write the tool definition in JSON format.

Pro Tips
  • Write clear descriptions—the model uses them to decide when to call tools
  • Keep parameter names intuitive
  • Always validate tool inputs before execution
  • Return structured data the model can easily interpret

Related Terms