Overview

Tool use enables language models to interact with external systems by generating structured function calls that are executed by the host application. Rather than relying solely on the model’s training data, tool use extends capabilities to real-time data retrieval, computation, file manipulation, API calls, and code execution. The model receives tool definitions (name, description, parameters), decides when a tool is needed, generates the call with appropriate arguments, and incorporates the result into its response. This pattern transforms LLMs from text generators into general-purpose reasoning engines that can take real-world actions.

Key Concepts

  • Function calling — The model outputs a structured tool invocation (function name + JSON arguments) instead of free text. The application executes the function and returns results.
  • Tool definitions — JSON Schema descriptions of available tools, including parameter types, descriptions, and constraints. Better descriptions improve tool selection accuracy.
  • MCP (Model Context Protocol) — An open standard for connecting AI models to external tools and data sources through a unified interface.
  • Parallel tool calls — Some models can invoke multiple independent tools simultaneously, reducing latency for multi-step tasks.
  • Tool confirmation — Safety pattern where the application asks the user to confirm before executing high-risk tool calls (file deletion, payment, etc.).
  • Retrieval tools — Tools that search databases, documents, or APIs to inject relevant information into the context window.

Trade-offs

  • Tool definitions consume context window tokens
  • Model may hallucinate tool calls with invalid parameters
  • Each tool call adds latency from external system round-trips
  • Security requires careful scoping of tool permissions and input validation
  • Too many tools can confuse tool selection; too few limits capability
  • Agent Patterns orchestrate multiple tool calls in reasoning loops
  • Prompt Engineering includes writing effective tool descriptions
  • RAG is often implemented as a retrieval tool