📋 Table of Contents
1️⃣ Fundamentals
What is Function Calling?
Function calling (also called "tool use") is the ability to invoke external tools or APIs to perform actions beyond generating text. Instead of just answering with words, an AI can call functions with specific parameters.
Why Function Calling Matters
- Accuracy: Executes exact operations rather than describing them
- Integration: Connects AI with real systems
- Dynamic Responses: Adapts behavior based on tool results
- Reliability: Reduces hallucination by delegating to trusted tools
User: "What's the weather in Paris?"
Without function calling: "It's probably nice in spring..."
With function calling: Calls weather_tool → Returns "Current: 18°C, Sunny"
2️⃣ Core Concepts
A. Tool Definition
Every tool has three essential components:
Tool Name: weather_fetch
Purpose: Get current weather for a location
Parameters: latitude, longitude, location_name
B. Function Call Structure
A complete function call includes:
| Component | Purpose | Example |
|---|---|---|
| Tool Name | Identifies which tool to use | weather_fetch |
| Parameters | Input data the tool needs | latitude: 48.8566, longitude: 2.3522 |
| Values | Actual data for parameters | location_name: "Paris, France" |
C. Parameter Types
Required Parameters (must always include):
- Authentication details
- Core identifiers
- Primary search terms
Optional Parameters (include when needed):
- Filters
- Format preferences
- Advanced options
Example:
Tool: places_search
Required: query (what to search for)
Optional: max_results (how many to return)
location_bias_lat, location_bias_lng (where to search)
🎯 3️⃣ Tool Selection Strategy
Step 1: Understand the User's Need
Ask yourself: What action does the user want?
| User Request | Action Type | Category |
|---|---|---|
| "Find restaurants in Tokyo" | Search for locations | Places/Search |
| "What's the weather?" | Get current data | Weather/Data |
| "Call my assistant" | Send message | Communication |
| "Show me on a map" | Display locations visually | Visualization |
Step 2: Match to Available Tools
Create a mental checklist:
❓ Does this need real-time data? → Use fetch/search tools
❓ Does this need to show locations? → Use map tools
❓ Does this need to send information? → Use communication tools
❓ Does this need to display something? → Use visualization tools
Step 3: Verify Tool Capability
NOT appropriate to use a tool for:
- Questions answerable from general knowledge
- Tasks the tool wasn't designed for
- Requests requiring authentication you don't have
Q: "What is photosynthesis?"
Tool: Call biology_database tool
A: Answer directly from knowledge
Q: "What's the current Bitcoin price?"
Tool: Use your training data ("Bitcoin was...")
A: Call crypto_price tool (has real-time data)
🔧 4️⃣ Payload Construction
A. Payload Anatomy
A payload is the data you send to a tool:
{
"tool_name": "weather_fetch",
"parameters": {
"latitude": 48.8566,
"longitude": 2.3522,
"location_name": "Paris, France"
}
}
B. Parameter Rules
Rule 1: Type Matching
Parameter expects: Number
Your value: "48.8566" (string)
Parameter expects: Number
Your value: 48.8566 (number)
Rule 2: Required vs Optional
weather_fetch(location_name: "Paris")
weather_fetch(location_name: "Paris", latitude: 48.8566, longitude: 2.3522)
Rule 3: Enum Values
Some parameters only accept specific values:
travel_mode: "car"
travel_mode: "driving"
Accepted: "driving", "walking", "transit", "bicycling"
C. Payload Construction Examples
User: "Find coffee shops in Bangkok"
Tool: places_search
{
"queries": [
{
"query": "coffee shops Bangkok",
"max_results": 5
}
]
}
User: "Show me luxury hotels in Bali with 3-star rating within 10km"
Tool: places_search
{
"queries": [
{
"query": "luxury hotels Bali 3-star",
"max_results": 8
}
],
"location_bias_lat": -8.6500,
"location_bias_lng": 115.2167,
"location_bias_radius": 10000
}
⚠️ 5️⃣ Common Mistakes to Avoid
Mistake 1: Wrong Tool for the Job
❌ User: "How many people live in Tokyo?"
Tool Used: places_search
Issue: Finds locations, not population data
✓ Correct: Use web_search or general knowledge
Mistake 2: Missing Required Parameters
❌ Tool: fetch_sports_data
Payload: { data_type: "scores" }
Issue: Missing "league" parameter
✓ Correct Payload:
{
"data_type": "scores",
"league": "nba"
}
Mistake 3: Wrong Data Type
❌ web_search(query: 12345)
Issue: query expects string, not number
✓ web_search(query: "12345")
Mistake 4: Invalid Enum Value
❌ places_map(travel_mode: "car")
Issue: "car" not in accepted values
✓ places_map(travel_mode: "driving")
Mistake 5: Over-engineering Simple Questions
❌ User: "What's 2+2?"
Action: Call calculator_tool
Issue: Basic math, answer directly
✓ Correct: Answer "4" directly
💡 6️⃣ Practice Examples
Example 1: Weather Query
Question: "Is it raining in Singapore right now?"
Understand Need:
- Need current weather data
- Real-time information required
Select Tool:
→ weather_fetch (designed for current weather)
Construct Payload:
{
"tool": "weather_fetch",
"parameters": {
"location_name": "Singapore",
"latitude": 1.3521,
"longitude": 103.8198
}
}
Interpret Result:
- If result includes "rain": "Yes, it's raining"
- If no rain: "No rain currently, it's clear/cloudy"
Example 2: Location Search & Display
Question: "Show me the top 3 coffee shops near my hotel in Kyoto on a map"
Note: This requires TWO tools: places_search + places_map_display_v0
First Call - Search Payload:
{
"queries": [
{
"query": "coffee shops Kyoto",
"max_results": 3
}
],
"location_bias_lat": 35.0116,
"location_bias_lng": 135.7681
}
Second Call - Map Payload:
{
"locations": [
{
"name": "Coffee Shop A",
"latitude": 35.0150,
"longitude": 135.7700,
"place_id": "ChIJ...",
"notes": "Cozy atmosphere, free WiFi"
},
{
"name": "Coffee Shop B",
"latitude": 35.0120,
"longitude": 135.7680,
"place_id": "ChIJ...",
"notes": "Traditional Japanese cafe"
},
{
"name": "Coffee Shop C",
"latitude": 35.0100,
"longitude": 135.7650,
"place_id": "ChIJ...",
"notes": "Modern roastery"
}
]
}
Example 3: Sports Data
Question: "What was the final score of yesterday's NBA game between Lakers and Celtics?"
Understand Need:
- Recent sports data
- Specific game score
Select Tool:
→ fetch_sports_data
Construct Payload:
{
"data_type": "scores",
"league": "nba",
"team": "Lakers"
}
🎓 7️⃣ Assessment Strategy
Before Attempting a Question
Use this checklist:
- Read the question completely
- Identify what the user actually wants (not what they said)
- List all available tools in your mind
- Eliminate tools that don't fit
- Verify required parameters
- Check parameter data types
- Confirm enum values (if applicable)
- Review your payload once more
During Question Solving
Analyze the Request
Question: "Show me a map of tourist attractions in Barcelona"
- User wants: Visual map display
- Of what: Tourist attractions
- Where: Barcelona
- Action: Show/display
Identify the Core Need
- Core Need: Display locations on a map
- Potential Tools: places_search, places_map_display_v0
- First step: Search for attractions (places_search)
- Second step: Display on map (places_map_display_v0)
Double-Check
- ✓ Are all required parameters included?
- ✓ Are data types correct?
- ✓ Are enum values valid?
- ✓ Does this actually solve the user's problem?
Common Assessment Traps
Trap 1: Red Herring Information
Question: "I'm in New York and want to find restaurants that serve sushi and cost less than $20. I have a gluten allergy. Show them on a map."
Red Herring: "I have a gluten allergy"
- Places search tool can't filter by allergies
- Include in conversation context, not in tool payload
Real Requirements:
- query: "sushi restaurants under $20 New York"
- location: New York
- action: Display on map
Trap 2: Overthinking
Question: "What's 2+2?"
Overthinking: "Should I call a calculation tool?"
✓ Correct: Answer directly - no tool needed
Trap 3: Wrong Tool Assumption
Question: "Create a presentation about climate change"
Assumption: "I need a pptx tool"
✓ Correct: Create_file with HTML or markdown, OR use visualization tools (depends on what's available)
Final Assessment Tips
Tip 1: Read Once, Understand Twice
- First read: Get the gist
- Second read: Catch specific requirements
Tip 2: Map to One Tool = Simplicity
- If multiple tools needed, sequence them
- Each tool has one clear job
- Chain results from one to the next
Tip 3: Validate Against Requirements
- ✓ Does the tool exist? (Name it)
- ✓ Can the tool do this? (Describe capability)
- ✓ Are parameters provided/inferable? (List them)
- ✓ Are parameter values correct type? (Verify)
- ✓ Is result meaningful to the user? (Final check)
Tip 4: One Attempt = One Chance
- Use the checklist before submitting
- No second attempt possible
- Precision over speed
📖 Quick Reference: Common Tool Categories
Data Retrieval Tools
web_search
General web information
fetch_sports_data
Sports scores, standings
weather_fetch
Current weather
places_search
Locations, restaurants, attractions
Visualization Tools
places_map_display_v0
Show locations on map
visualize:show_widget
Display charts, diagrams
recipe_display_v0
Interactive recipes
Communication Tools
message_compose_v1
Draft emails, messages
recommend_claude_apps
Suggest tools
File & Content Tools
create_file
Generate new files
str_replace
Edit existing files
present_files
Share files with user
🎯 Key Takeaway Formula
TOOL SELECTION = Match user need to tool capability
PAYLOAD CONSTRUCTION = Provide required parameters with correct types
SUCCESS = User gets exactly what they asked for
Remember: Precision > Creativity. Correctness > Cleverness.
🚀 Ready for Your Assessment?
You have all the tools you need. Trust your checklist. Go ace it! 💪