Tool Use & Function Calling
Function calling means the model writes a structured JSON request instead of prose — "call get_order_status with order_id ORD-123" — and YOUR code validates it, runs it as the user, and feeds the result back. The model only proposes; the runtime executes. This topic covers the contract, the reliability levers, and the security boundary.
01.The Problem: A Genius With No Hands
You wire an LLM into your shop's support chat. A customer asks:
"Did my order ORD-123 ship yet?"
Your model has three options, and all three are bad:
- Guess from memory. It was never trained on your order table — and even a fine-tuned model's knowledge is frozen at training time (topic 161). Wrong status = angry customer.
- Refuse. Correct but useless.
- Actually check the database. …but a raw LLM completes text. It has no hands. It cannot open a connection, click a button, or POST to an API. There is no "check" for it to do.
So the question becomes
If the model can only ever produce text, how can that text become a safe, real action?
The answer is function calling (introduced by OpenAI in June 2023, Anthropic tool use in 2024, standardized across the industry by 2025): the model's text output becomes a machine-readable request, and your program turns it into an action.
The Function-Calling Loop
The Function-Calling Loop
The model never executes anything — it emits structured intent; your runtime validates, authorizes, executes, and feeds results back.
Unlock Topic #168: Tool Use & Function Calling
You are viewing a preview. The full in-depth technical walkthrough, worked derivations, and code notebooks for this concept, along with self-assessment quizzes, are available with Pro or Lifetime Access.
Failure modes, high-throughput bottlenecks, and real FAANG implementation decisions.
Interactive system topology diagrams, live parameter simulators, and downloadable SVG charts.
Staff-level multiple-choice quiz questions with instant feedback and answer explanations.
Firebase Google authentication automatically syncs your completed topics and quiz scores.
How clear and actionable was this distributed systems breakdown?