diff --git a/web/app/components/workflow/nodes/tool/node.tsx b/web/app/components/workflow/nodes/tool/node.tsx index 55f75afdfb..6a7c51b74a 100644 --- a/web/app/components/workflow/nodes/tool/node.tsx +++ b/web/app/components/workflow/nodes/tool/node.tsx @@ -64,7 +64,8 @@ const Node: FC> = ({ }, [nodes]) const mentionEntries = useMemo(() => { - const entries: Array<{ agentNodeId: string, extractorNodeId?: string }> = [] + const entries: Array<{ agentNodeId: string, extractorNodeId?: string, paramKey: string }> = [] + const seen = new Set() const toolParams = data.tool_parameters || {} Object.entries(toolParams).forEach(([paramKey, param]) => { const value = param?.value @@ -75,8 +76,13 @@ const Node: FC> = ({ const agentNodeId = match[1] if (!agentNodeId) continue + const entryKey = `${paramKey}:${agentNodeId}` + if (seen.has(entryKey)) + continue + seen.add(entryKey) entries.push({ agentNodeId, + paramKey, extractorNodeId: param?.mention_config?.extractor_node_id || (param?.type === VarType.mention ? `${id}_ext_${paramKey}` : undefined), }) @@ -112,9 +118,7 @@ const Node: FC> = ({ return Boolean(errorMessage) } - const itemsMap = new Map() - - mentionEntries.forEach(({ agentNodeId, extractorNodeId }) => { + return mentionEntries.map(({ agentNodeId, extractorNodeId, paramKey }) => { const agentNode = nodesById[agentNodeId] const agentLabel = `@${agentNode?.data.title || agentNodeId}` const agentWarning = getNodeWarning(agentNode) @@ -122,20 +126,14 @@ const Node: FC> = ({ const extractorWarning = extractorNodeId ? getNodeWarning(nodesById[extractorNodeId]) : false - - const key = `agent-${agentNodeId}` - const existing = itemsMap.get(key) - const hasWarning = (existing?.hasWarning || false) || agentWarning || extractorWarning - - itemsMap.set(key, { - key, + const hasWarning = agentWarning || extractorWarning + return { + key: `${paramKey}-${agentNodeId}-${extractorNodeId || 'no-extractor'}`, label: agentLabel, type: BlockEnum.Agent, hasWarning, - }) + } }) - - return Array.from(itemsMap.values()) }, [mentionEntries, nodesById, nodesMetaDataMap, strategyProviders, language, t]) const hasConfigs = toolConfigs.length > 0