langchain.js
    Preparing search index...

    Interface ToolCallRequest<TState, TContext>

    Represents a tool call request for the wrapToolCall hook. Contains the tool call information along with the agent's current state and runtime.

    interface ToolCallRequest<
        TState extends Record<string, unknown> = Record<string, unknown>,
        TContext = unknown,
    > {
        runtime: Runtime<TContext>;
        state: TState & AgentBuiltInState;
        tool: any;
        toolCall: ToolCall;
    }

    Type Parameters

    • TState extends Record<string, unknown> = Record<string, unknown>
    • TContext = unknown
    Index

    Properties

    runtime: Runtime<TContext>

    The runtime context containing metadata, signal, writer, interrupt, etc.

    state: TState & AgentBuiltInState

    The current agent state (includes both middleware state and built-in state).

    tool: any

    The BaseTool instance being invoked. Provides access to tool metadata like name, description, schema, etc.

    This will be undefined for dynamically registered tools that aren't declared upfront when creating the agent. In such cases, middleware should provide the tool implementation by spreading the request with the tool property.

    wrapToolCall: async (request, handler) => {
    if (request.toolCall.name === "dynamic_tool" && !request.tool) {
    // Provide the tool implementation for dynamically registered tools
    return handler({ ...request, tool: myDynamicTool });
    }
    return handler(request);
    }
    toolCall: ToolCall

    The tool call to be executed