Skip to content
tezvyn:
Menu

Tool Use: Giving LLMs Access to External Systems

Source: platform.claude.comMediumHow cards are made

Tool use lets an LLM call external functions, like a brain accessing a calculator or the internet. This is the core mechanism behind AI agents that can search the web, run code, or query a database to answer questions. The biggest footgun is assuming the model will always generate a valid function call; without enforcing a strict schema to match your function's expected input, your agent can fail unpredictably.

The mental model

Think of tool use (or function calling) as giving an LLM a set of APIs it can call. By itself, an LLM is a powerful text-prediction engine, but it's disconnected from real-time data and external systems. Tools are the bridge that allows the model to go beyond its training data to fetch live information, interact with private databases, or execute code.

How it works

The process is an agentic loop between you and the model: 1. You define a set of available tools, including their names, descriptions, and input schemas, and pass them to the model in your API request. 2. The user provides a prompt, like "What's the latest on the Mars rover?" 3. The model analyzes the prompt and its available tools. It decides that the web_search tool is needed. 4. Instead of generating text, the model's response stops with a tool_use reason, containing a structured object like {"name": "web_search", "input": {"query": "latest Mars rover news"}}. 5. Your application (a client tool) or Anthropic's backend (a server tool) executes this function. 6. You send the function's output (e.g., a list of search results) back to the model in a subsequent turn. 7. The model uses this new context to synthesize a final, informed answer for the user.

When to use it

• Accessing real-time data: For tasks involving current events, stock prices, weather, or any information not in the model's training data. • Interacting with private systems: To query internal company databases, customer relationship management (CRM) software, or personal files. • Executing code: To perform calculations, run data analysis scripts, or interact with system shells.

When not to use it

• For simple tasks: If a task can be accomplished with good prompting alone, using a tool adds unnecessary latency and cost from the extra API round-trip. • Without schema validation: The most critical footgun is trusting the model to always generate a perfectly formed tool call. This leads to brittle agents that break on malformed inputs. Always use features like Claude's strict: true to force the model's output to conform exactly to your defined tool schema.

One canonical example

A user asks: "What's the weather in Paris?"

1. Tool Definition: You've provided a tool named get_weather that accepts a location string. 2. Model Response: The model returns a tool_use block: {"name": "get_weather", "input": {"location": "Paris"}}. 3. Execution: Your code executes this function, which calls a weather API and gets back {"temperature": "15°C", "condition": "Cloudy"}. 4. Final Answer: You send this result back to the model, which then generates the user-facing response: "The current weather in Paris is 15°C and cloudy."

Interview question

What is the primary risk, or "critical footgun," when integrating external tools with an LLM?

  • a.A) The LLM generating a tool call that does not conform to the defined input schema.Correct
  • b.B) The LLM selecting an inappropriate tool for the user's request, leading to irrelevant actions.
  • c.C) The external system failing to execute the tool call or returning an error.
  • d.D) The LLM providing outdated information from its training data instead of using a tool.
Why?

The card explicitly states, "The most critical footgun is trusting the model to always generate a perfectly formed tool call. This leads to brittle agents that break on malformed inputs." This highlights the importance of schema validation. While an LLM might select an inappropriate tool (B), the card emphasizes the structural integrity of the tool call itself as the primary vulnerability for agent stability and unpredictable failures.

Just read this? Test yourself on what you have been reading.

Read the original → docs.anthropic.com

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on llms — each one lists the topics its interview covers.

See open roles