From aa0984e8024f396e49e2f19ae29bb017b6cef337 Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Wed, 4 Jun 2025 13:44:09 +0100 Subject: [PATCH] Bugfix/Tool node selected tool (#4578) fix tool node selected tool --- packages/components/nodes/agentflow/Tool/Tool.ts | 5 ++++- packages/components/src/agentflowv2Generator.ts | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/components/nodes/agentflow/Tool/Tool.ts b/packages/components/nodes/agentflow/Tool/Tool.ts index f2ab96e7..c37b1e01 100644 --- a/packages/components/nodes/agentflow/Tool/Tool.ts +++ b/packages/components/nodes/agentflow/Tool/Tool.ts @@ -125,7 +125,10 @@ class Tool_Agentflow implements INode { async listToolInputArgs(nodeData: INodeData, options: ICommonObject): Promise { const currentNode = options.currentNode as ICommonObject const selectedTool = (currentNode?.inputs?.selectedTool as string) || (currentNode?.inputs?.toolAgentflowSelectedTool as string) - const selectedToolConfig = currentNode?.inputs?.selectedToolConfig as ICommonObject + const selectedToolConfig = + (currentNode?.inputs?.selectedToolConfig as ICommonObject) || + (currentNode?.inputs?.toolAgentflowSelectedToolConfig as ICommonObject) || + {} const nodeInstanceFilePath = options.componentNodes[selectedTool].filePath as string diff --git a/packages/components/src/agentflowv2Generator.ts b/packages/components/src/agentflowv2Generator.ts index c5765f52..a8033278 100644 --- a/packages/components/src/agentflowv2Generator.ts +++ b/packages/components/src/agentflowv2Generator.ts @@ -76,10 +76,10 @@ interface AgentToolConfig { interface NodeInputs { agentTools?: AgentToolConfig[] - selectedTool?: string + toolAgentflowSelectedTool?: string toolInputArgs?: Record[] - selectedToolConfig?: { - selectedTool: string + toolAgentflowSelectedToolConfig?: { + toolAgentflowSelectedTool: string } [key: string]: any } @@ -284,10 +284,10 @@ Now, select the ONLY tool that is needed to achieve the given task. You must onl if (Array.isArray(tools) && tools.length > 0) { selectedTools.push(...tools) - node.data.inputs.selectedTool = tools[0] + node.data.inputs.toolAgentflowSelectedTool = tools[0] node.data.inputs.toolInputArgs = [] - node.data.inputs.selectedToolConfig = { - selectedTool: tools[0] + node.data.inputs.toolAgentflowSelectedToolConfig = { + toolAgentflowSelectedTool: tools[0] } } }