Tool Use & Function Calling Explained
From the course AI Agents & Automation: Build Intelligent Workflows
Tool use (also called function calling) is the mechanism that turns a language model into an agent. It lets the AI call external APIs, query databases, and interact with the real world.
How Function Calling Works
- You define a set of "tools" — functions the AI can call, with descriptions and parameter schemas
- The AI receives a user request and your tool definitions
- The AI decides whether to call a tool and with what arguments
- Your code executes the tool and returns the result to the AI
- The AI uses the result to formulate its response
Example: Weather Tool
You define:
- Tool name:
get_weather - Description: "Get current weather for a city"
- Parameters:
{ city: string, units: "celsius" | "fahrenheit" }
User asks: "What's the weather like in Tokyo?"
AI decides to call: get_weather({ city: "Tokyo", units: "celsius" })
Your code calls a weather API and returns: { temp: 22, condition: "partly cloudy" }
AI responds: "It's 22°C and partly cloudy in Tokyo right now."
Common Tool Types
- Search tools — Web search, database queries, document retrieval
- Action tools — Send emails, create calendar events, update CRM records
- Computation tools — Run calculations, execute code, process data
- Integration tools — Connect to Slack, GitHub, Jira, Stripe, etc.
Multi-Tool Orchestration
Powerful agents use multiple tools in sequence:
User: "Find our top 3 customers by revenue this quarter and draft a thank-you email to each"
Agent thinks: I need to query the database, then compose emails
- Calls
query_databasefor top customers- Calls
get_customer_detailsfor each customer- Calls
draft_emailthree times with personalized content- Presents drafts for human approval
Parallel Tool Calls
Modern APIs support parallel tool calling — the AI can request multiple tool executions simultaneously:
- "What's the weather in Tokyo, London, and New York?" → 3 parallel
get_weathercalls - This reduces latency significantly for multi-step tasks
Security Considerations
- Principle of least privilege — Only give agents access to tools they need
- Input validation — Always validate tool parameters before executing
- Rate limiting — Prevent agents from making excessive API calls
- Confirmation gates — Require human approval for destructive actions (delete, send, purchase)
- Audit logging — Record every tool call for accountability
Key Takeaways
- •Function calling lets AI models invoke external APIs and tools
- •You define tools with names, descriptions, and parameter schemas
- •Agents can chain multiple tools together to complete complex tasks
- •Parallel tool calling reduces latency for multi-step operations
- •Always implement security: validation, rate limits, confirmation gates, and audit logs
Progress is kept in this browser only.