Questions
24 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?
24 / 24

What are the token cost implications of registering too many tools and how do you mitigate it?

Registering many tools significantly increases token consumption and degrades tool selection accuracy; mitigation strategies include tool filtering middleware, dynamic loading, and cost-aware model cascading.

Each tool added to an agent increases the prompt size because all tool schemas (names, descriptions, parameter schemas) are sent to the LLM on every call. With 20+ tools, token waste becomes significant, tool selection accuracy degrades as the model struggles to choose from too many options, and latency increases [citation:5]. To mitigate this, use a LLMToolSelectorMiddleware that pre-filters tools before each model call, invoking a cheap model (like Haiku) to select only the top-k relevant tools based on the user's query [citation:5]. For production optimization, the CascadeFlow library implements intelligent routing where simple queries are handled by cheap models (gpt-5-mini) and only complex queries escalate to expensive models (claude-opus-4-6), achieving 40-60% cost savings [citation:10].

Tool Pre-selection Middleware (Cost Mitigation)
Mitigation Strategies Summary
  1. 1

    Tool pre-selection middleware: Use cheap LLM to filter tools before each call [citation:5]

  2. 2

    Always-include list: Critical tools bypass pre-filtering [citation:5]

  3. 3

    Tool count caps: Limit selected tools (e.g., top 10) [citation:5]

  4. 4

    CascadeFlow routing: Simple queries handled by cheap models; complex queries escalate [citation:10]

  5. 5

    Dynamic loading: Only load tools needed for current user context [citation:3]