Questions
3 of 24
1What is a Tool in LangChain and how does it differ from a plain function or API call?
2What is the difference between the tool() helper, DynamicTool, and StructuredTool class?
3How does an LLM decide which tool to call — what role does the tool description play?
4What is the role of Zod schema in tool definitions and how does it map to OpenAI's function calling spec?
5What is a ToolNode in LangGraph and how does it differ from calling a tool manually inside a graph node?
6How do you wrap a REST API call with auth headers inside a Tool in TypeScript?
7How do you handle async errors and retries inside a Tool without crashing the agent loop?
8How do you pass runtime context (userId, authToken, DB connection) into a Tool using RunnableConfig?
9How do you build a Toolkit (grouped set of related tools) using BaseToolkit?
10How do you validate and sanitize tool output before it is passed back to the LLM?
11How do you stream tool call results back to the client in real time?
12How do you implement tool-level authorization — allowing certain tools only for certain users?
13How do you build stateful tools that read/write to a database across multiple agent turns?
14How do you prevent tool abuse or infinite loops where an agent keeps calling the same tool repeatedly?
15How do you implement parallel tool calling — when the LLM decides to call multiple tools simultaneously?
16How do you create a human-in-the-loop tool that pauses the agent and waits for user approval before executing?
17How do you unit test and mock tools in isolation without invoking the LLM?
18How do you implement tool call caching to avoid redundant API calls for identical inputs?
19How do you design a multi-agent system where one agent's tool is actually another agent (agent-as-tool pattern)?
20How does LangGraph's ToolNode handle tool call errors and surface them back into the message state?
21What is the difference between tool_choice: "auto", "required", and "none" when binding tools to an LLM?
22How do you implement dynamic tool loading — where the set of available tools changes based on user role or session state?
23How do you trace and observe tool call latency in production using LangSmith?
24What are the token cost implications of registering too many tools and how do you mitigate it?
03 / 24

How does an LLM decide which tool to call — what role does the tool description play?

An LLM decides which tool to call based on the tool's name and description, which guide the model's reasoning about when and how to use each tool; the description is the most critical factor for effective tool use.

An LLM does not have the ability to execute tools or code on its own. Instead, when you provide it with a set of tool definitions (name, description, and input schema), the model processes these as part of its context. When given a user request, the LLM analyzes the request and the available tool definitions, then decides whether it needs to use a tool to fulfill the request. If it decides a tool is needed, it outputs a structured response containing the name of the tool to call and the arguments to pass to it — but it does not execute the tool itself[citation:8]. The application code is then responsible for actually invoking the tool function and returning the result back to the LLM for the final answer[citation:10].

The tool description is arguably the single most important element in the tool definition for guiding LLM behavior[citation:1][citation:4]. Since the LLM has no innate understanding of what a tool does, it relies entirely on the name and description you provide to understand the tool's purpose and decide when it's appropriate to use it. A clear, detailed description helps the model correctly select the right tool for the right task. Conversely, a vague or missing description can lead to the model either ignoring the tool entirely or using it incorrectly[citation:10].

Example: Tool Definition with Detailed Description

LangChain's official documentation and community best practices emphasize several guidelines for writing effective tool descriptions.

  1. 1

    Be Clear and Descriptive: Explain exactly what the tool does, when to use it, and what the expected outputs are. This is the most important factor for effective tool use[citation:4].

  2. 2

    Use Descriptive Tool Names: Choose names that clearly indicate functionality, such as search_weather instead of get_data[citation:4].

  3. 3

    Include Examples: Where possible, include examples of proper tool usage in the description to clarify expected input formats[citation:4].

  4. 4

    Describe Parameters: Provide detailed descriptions for each parameter, explaining the expected format, constraints, and examples[citation:4].

  5. 5

    Use JSON Schema: Specify proper data types and constraints using JSON Schema to guide the LLM's argument generation[citation:8].

  6. 6

    Balance Detail with Token Usage: Descriptions become part of the prompt tokens and contribute to the overall cost, so be thorough but not overly verbose[citation:4].

Even with perfect descriptions, tool-calling accuracy varies significantly across different LLMs. In a Docker benchmark evaluating 21 models across 3,570 test cases, OpenAI's GPT-4 achieved a near-perfect tool selection F1 score of 0.974. Among open-source models, Qwen 3 (14B) performed exceptionally well with an F1 score of 0.971, while Qwen 3 (8B) achieved 0.933 with significantly lower latency[citation:7]. Quantized versions of models showed no significant difference in tool-calling accuracy compared to their non-quantized counterparts, suggesting quantization can reduce resource usage without negatively impacting performance[citation:7].

When tool calling fails, the issues typically fall into several categories, based on Docker's testing of local models. Some models exhibit eager invocation, calling tools even for simple greeting messages like "Hi there!" Others show wrong tool selection, choosing an incorrect tool for the task, such as using a search tool when they should use an add-to-cart tool. Invalid arguments are another common failure, where parameters are missing or malformed. Finally, some models display ignored responses, failing to incorporate tool outputs into their final answer, leading to awkward or incomplete conversations[citation:7]. These issues highlight why evaluating model tool-calling capabilities is essential for production applications.

In LangChain, tools are passed to agents, and the LLM decides when and how to invoke them based on the prompt and goal[citation:1]. The agent follows the ReAct (Reasoning + Acting) pattern, alternating between reasoning steps and tool calls, feeding observations back into the loop until it can deliver a final answer[citation:10]. This iterative process continues until the model either emits a final output without tool calls or reaches an iteration limit[citation:10].

Difficulty: 5/10
Topics: tool selection, prompt engineering, LLM agents

Scenario Questions

0-2 years experience
  1. 1

    You need to add a simple search tool to a LangChain agent. How would you write the tool description so the LLM knows when to call it?

  2. 2

    If the LLM keeps calling the wrong tool for a user query, what’s the first thing you would check in the tool description?

2-5 years experience
  1. 1

    During a sprint you notice the agent is calling a weather API for queries that are actually about stock prices. Walk me through how you would debug the tool selection logic.

  2. 2

    You have three data‑retrieval tools with overlapping capabilities. How would you design their descriptions to minimize ambiguous calls, and what trade‑offs might you consider?

5-8 years experience
  1. 1

    At scale, the agent’s token budget is tight and tool descriptions are large. How would you redesign the description format or selection mechanism to keep latency low while preserving accurate tool calls?

  2. 2

    Explain how you would implement a custom ranking function that weighs tool description relevance against LLM confidence, and what edge cases you’d guard against.

8+ years experience
  1. 1

    Your organization is migrating from a proprietary LLM to an open‑source model. What architectural changes would you make to ensure tool selection continues to work reliably across the new model’s different prompting behavior?

  2. 2

    How would you set up a cross‑team governance process for writing and versioning tool descriptions to avoid drift and maintain consistency in large, multi‑service deployments?

Follow-up Questions

  • How would you handle a situation where two tools have very similar descriptions?
  • What impact does the length of the description have on token usage and model performance?
  • Can you describe a fallback strategy if the LLM fails to pick any tool?