Function calling for phone agents: how tools work

Intermediate⏱ 14 min📝 Quiz
Understand how an LLM decides to call a tool, how to define tools clearly, and how to keep calls fast and safe.

Outcome of this lesson

You can define a tool the model will call at the right moment with the right arguments.

How tool calling works

  1. You describe each tool: a name, a description and a schema of parameters.
  2. During the call the LLM decides whether a tool is needed and returns a structured request, e.g. check_availability(date="2027-02-14", service="cleaning").
  3. The platform sends that request to your webhook (your server).
  4. Your server runs the logic (calendar, CRM, database) and returns a result as JSON.
  5. The LLM reads the result and speaks the answer naturally.

A well-defined tool

{
  "name": "check_availability",
  "description": "Find open appointment slots. Use BEFORE offering any time to the caller. Returns up to 3 slots.",
  "parameters": {
    "type": "object",
    "properties": {
      "date": {"type": "string", "description": "Preferred date, YYYY-MM-DD"},
      "service": {"type": "string", "enum": ["cleaning", "filling", "crown", "emergency"]}
    },
    "required": ["date", "service"]
  }
}

Tool design rules

  • Small and specific. One job per tool. “check_availability” and “book_appointment”, not “do_everything”.
  • Descriptions are instructions. State when to use the tool and when not to.
  • Use enums for fixed choices to avoid made-up values.
  • Return clean, short JSON. The model reads it on the live call; huge payloads slow everything.
  • Return useful errors. {"ok": false, "reason": "slot_taken", "alternatives": [...]} lets the agent recover gracefully.
  • Be idempotent. If a booking call is retried, it must not create two appointments.
  • Least privilege. The tool can book; it cannot delete customers or issue refunds unless that is explicitly required and gated.

Narrate the wait

Tools add delay. Tell the agent in the prompt to say a short bridge line (“Let me check Thursday for you”) and to keep it honest — never to claim something is done before the tool confirms.

Do this now

Write schemas for two tools your agent needs. For each, write one sentence for “use when…” and one for “do not use when…”.

💡 Real-world example

Illustrative scenario. An agent told callers “You’re booked!” before the booking tool had returned. When the slot turned out to be taken, the caller was confused and annoyed. Fix: the prompt now says “Only say a booking is confirmed after book_appointment returns ok:true.”

✅ Checklist

🛠 Your assignment

Pick one risky action (refund, cancel, share data). Decide what extra check or human approval it needs.

📝 Check your understanding

Answer 2 of 3 correctly to complete this lesson.

1. What does the LLM return when it wants to use a tool?
2. Why use enums in a tool schema?
3. When may the agent say a booking is confirmed?
Free lesson — create a free account to save progress, take the final exam and get your certificate. Next lesson →
💬 Questions about this lesson?
Ask the community — practitioners and the BFOUNT team answer.
Ask a question
Was this lesson helpful?