ToolExecutor should probably use an array of StructuredTool instances rather than Tool instances #7

Closed
opened 2026-02-15 17:05:12 -05:00 by yindo · 0 comments
Owner

Originally created by @zeropaper on GitHub (Feb 1, 2024).

While trying to use a DynamicStructuredTool instance with a ToolExecutor, I noticed that TS was yelling at me.

const tools = [
  new DynamicStructuredTool({
    name: "search",
    description: "Search the web",
    schema: z.object({
      input: z.string(),
    }),
    callbacks: [toolRunCollector],
    async func({ input }, runManager) {
      console.log("searching for", input);
      return Promise.resolve("whatever");
    },
  }),
];

const toolExecutor = new ToolExecutor({
  tools // TypeScript is yelling at me here
});

I suspect that the ToolExecutorArgs interface should be:

https://github.com/langchain-ai/langgraphjs/blob/8ee245f992443c8d7efc0b505451a6cd5cc75504/langgraph/src/prebuilt/tool_executor.ts#L10-L16

import { StructuredTool } from "@langchain/core/tools";
// ...
export interface ToolExecutorArgs {
    tools: Array<StructuredTool>;
    /**
     * @default {INVALID_TOOL_MSG_TEMPLATE}
     */
    invalidToolMsgTemplate?: string;
}

As Tool extends StructuredTool (which is quite weird in my book).

Originally created by @zeropaper on GitHub (Feb 1, 2024). While trying to use a `DynamicStructuredTool` instance with a `ToolExecutor`, I noticed that TS was yelling at me. ```ts const tools = [ new DynamicStructuredTool({ name: "search", description: "Search the web", schema: z.object({ input: z.string(), }), callbacks: [toolRunCollector], async func({ input }, runManager) { console.log("searching for", input); return Promise.resolve("whatever"); }, }), ]; const toolExecutor = new ToolExecutor({ tools // TypeScript is yelling at me here }); ``` I suspect that the `ToolExecutorArgs` interface should be: https://github.com/langchain-ai/langgraphjs/blob/8ee245f992443c8d7efc0b505451a6cd5cc75504/langgraph/src/prebuilt/tool_executor.ts#L10-L16 ```ts import { StructuredTool } from "@langchain/core/tools"; // ... export interface ToolExecutorArgs { tools: Array<StructuredTool>; /** * @default {INVALID_TOOL_MSG_TEMPLATE} */ invalidToolMsgTemplate?: string; } ``` As [`Tool` extends `StructuredTool`](https://api.js.langchain.com/classes/langchain_core_tools.StructuredTool.html) (which is quite weird in my book).
yindo closed this issue 2026-02-15 17:05:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#7