Agents & Tools · 10 min read · Intermediate
Function & Tool Calling Loops
Let LLMs invoke real backend tools (search, SQL lookups, calculators) safely via typed tool declarations.
What you'll learn
- Declare tool names, descriptions, and JSON parameter schemas
- Execute requested tools on your server and return structured tool results
- Cap maximum tool-call iterations to prevent infinite loops
Overview
Let LLMs invoke real backend tools (search, SQL lookups, calculators) safely via typed tool declarations.
Code Example
const tools = [{
name: "get_order_status",
description: "Look up an order status by orderId",
parameters: { type: "object", properties: { orderId: { type: "string" } }, required: ["orderId"] }
}];
Key Takeaways
- Declare tool names, descriptions, and JSON parameter schemas
- Execute requested tools on your server and return structured tool results
- Cap maximum tool-call iterations to prevent infinite loops
Quick Check
Check Your Understanding
Score: 0 / 1
1. Who actually executes a function/tool when an LLM returns a tool call?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.