AI EngineeringInterview preparation
Foundation·Concept·2 min read

Function calling and tool calling

Practice this question

Overview

  • Function calling lets a model propose a named function and structured arguments.
  • Tool calling is the broader pattern that includes functions and capabilities such as search or code execution.
  • A proposed tool call is an untrusted request that your application chooses whether and how to execute.

Why this matters

Models need current facts and access to approved actions outside their learned knowledge.

An everyday example

A support employee asks the claims team for status rather than making it up.

A technical example

Model proposes getClaimStatus({claimId: "C42"}); application validates arguments, authorizes C42, and returns a minimal result.

How it works

  1. Register tool schemas
  2. Receive call
  3. Check tool allowlist
  4. Parse arguments
  5. Authorize
  6. Execute with deadline
  7. Return result with matching call ID
  8. Ask model for the answer.

Architecture and flow

User → model → proposed tool → validation/authorization → service → observation → model → answer.

The insurance assistant example

A claim-status tool exposes read-only status. Creating a claim is a separate tool with approval and idempotency protections.

When to use it

For fresh account data, search, or explicit business actions.

When to avoid it

Do not expose raw SQL execution, arbitrary HTTP destinations, or unrestricted shell commands to a customer-facing agent.

Interview answer

“The model selects a tool and arguments; my backend validates and authorizes the call, executes business logic, and returns a result for the model to explain.”

Benefits, trade-offs, and production considerations

  • Handle multiple calls, malformed arguments, timeouts, duplicates, and unknown tools.
  • Tool-result text is also untrusted.
  • Built-in provider tools and application functions can have different execution responsibilities.
  • Official OpenAI function calling guide.
Adapted from 13_AI.MD · “Function calling and tool calling”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.