LangGraph.js API Reference
    Preparing search index...

    Type Alias ToolCallFromTool<T>

    ToolCallFromTool: T extends { name: infer N }
        ? InferToolInput<T> extends infer Args
            ? Args extends never
                ? never
                : Args extends Record<string, any>
                    ? { args: Args; id?: string; name: N; type?: "tool_call" }
                    : never
            : never
        : never

    Infer a tool call type from a single tool. Works with tools created via tool() from @langchain/core/tools.

    For DynamicStructuredTool, this extracts the input type from the _call method, which is the most reliable source as it's the pre-computed input type.

    Type Parameters

    • T

      The tool type (e.g., DynamicStructuredTool)

    import { tool } from "@langchain/core/tools";
    import { z } from "zod";

    const getWeather = tool(
    async ({ location }) => `Weather in ${location}`,
    { name: "get_weather", schema: z.object({ location: z.string() }) }
    );

    // Infer: { name: "get_weather"; args: { location: string }; id?: string; type?: "tool_call" }
    type WeatherToolCall = ToolCallFromTool<typeof getWeather>;