Optimizing workflows of agents in scenarios in an optimized workflow graph
Provided are a computer implemented method, system and computer program product for optimizing workflows of agents in scenarios in an optimized workflow graph. Documents are processed to determine scenarios in which the agents are deployed, tools invoked by the agents, and workflows of the agents and the tools in the scenarios. A workflow graph is generated having nodes representing the agents invoked in the scenarios and the tools invoked by the agents. The workflow graph includes paths between the agents in the scenarios indicating an order in which the agents are invoked in the scenarios and the tools invoked by the agents in the scenarios. A determination is made of workloads at the nodes in the workflow graph. A node in the workflow graph is identified having a workload exceeding a threshold. The identified node is modified in a modified graph to reduce the workload at the identified node.
1 . A computer implemented method for managing agents in a computing environment, comprising:
processing documents to determine scenarios in which the agents are deployed, tools invoked by the agents to perform processes defined for the agents in the documents, and workflows of the agents and the tools in the scenarios;
generating a workflow graph having nodes representing the agents invoked in the scenarios and the tools invoked by the agents, wherein the workflow graph includes paths between the agents in the scenarios indicating an order in which the agents are invoked in the scenarios and the tools invoked by the agents in the scenarios;
determining workloads at the nodes in the workflow graph;
identifying, by an agent reorganizer, executing in the computing environment, a node comprising an agent executing in the computing environment, represented in the workflow graph and having a workload in the computing environment exceeding a threshold;
modifying the identified node in a modified workflow graph to reduce the workload at the identified node in the computing environment to redistribute the workload of the identified node across other nodes executing in the computing environment; and
providing the modified workflow graph to execute the agents and the tools according to the modified workflow graph defined at the nodes of the modified workflow graph.
2 . The computer implemented method of claim 1 , wherein the identifying the node comprises determining a target node having connecting paths from source nodes calling the target node in different scenarios.
3 . The computer implemented method of claim 2 , wherein the target node comprises a first target node, wherein the source nodes comprise a first source node connecting to the first target node via a first path in a first scenario and a second source node connecting to the first target node via a second path in a second scenario, wherein modifying the identified node comprises:
adding a second target node representing an additional instance of an agent or tool represented by the first target node; and
modifying the first path from the first target node to disconnect from the first target node and connect to the second target node in the first scenario to indicate the first source node calls the agent or the tool represented by the second target node, wherein the second path remains connected to the first target node in the second scenario to indicate the second source node calls the agent or the tool represented by the first target node.
4 . The computer implemented method of claim 3 , wherein a third path connects the first target node in the first scenario to a third target node and wherein a fourth path connects the first target node in the second scenario to a fourth target node, wherein the modifying the identified node further comprises:
modifying the fourth path to connect the second target node to the fourth target node.
5 . The computer implemented method of claim 1 , wherein the identifying the node comprises determining a target node that has a workload exceeding a threshold and connected to by source nodes in different scenarios, further comprising:
dividing the source nodes into n sets, wherein the source nodes in each of the n sets contribute to the workload of the target node that combined are less than the threshold;
creating n−1 target nodes representing an agent or tool represented by the target node; and
for each set of n−1 sets, modifying the paths of the source nodes in the set to disconnect from the target node and connect to the n−1 target nodes.
6 . The computer implemented method of claim 1 , wherein the identifying the node comprises determining a source node and target node in the workflow graph, such that the source node is invoked from the nodes in multiple scenarios and there are multiple paths between the source node and the target node in the workflow graph representing the source node invoking the target node in the multiple scenarios over the multiple paths.
7 . The computer implemented method of claim 6 , wherein the modifying the identified node comprises:
generating a new node in the modified workflow graph representing functionality of the agents or the tools represented by the source node and the target node.
8 . The computer implemented method of claim 7 , further comprising:
removing the source node from the modified workflow graph; and
modifying the paths from the nodes connecting to the source node to connect to the new node in the modified workflow graph.
9 . The computer implemented method of claim 8 , further comprising:
determining whether there are other nodes other than the source node connected to the target node; and
removing the target node from the modified workflow graph in response to determining that only the source node is connected to the target node.
10 . The computer implemented method of claim 1 , wherein the processing the documents comprises extracting the processes, actions, and the workflows for the scenarios, further comprising:
inputting the extracted processes, actions and workflows for the scenarios into a large language model to generate agent architectures for the scenarios representing agents invoked in the workflows; and
processing the agent architectures to generate workflow graphs for the scenarios defining how the agents, the tools, and commands are invoked in the workflows, wherein the workflow graph is generated by combining the workflow graphs for the scenarios into a single workflow graph representing the nodes that are invoked from multiple scenarios.
11 . A computer system for managing agents in a computing environment, comprising:
a processor set;
one or more computer-readable storage media; and
program instructions stored on the one or more computer-readable storage media to cause the processor set to perform operations comprising:
processing documents to determine scenarios in which the agents are deployed, tools invoked by the agents to perform processes defined for the agents in the documents, and workflows of the agents and the tools in the scenarios;
generating a workflow graph having nodes representing the agents invoked in the scenarios and the tools invoked by the agents, wherein the workflow graph includes paths between the agents in the scenarios indicating an order in which the agents are invoked in the scenarios and the tools invoked by the agents in the scenarios;
determining workloads at the nodes in the workflow graph;
identifying, by an agent reorganizer, executing in the computing environment, a node comprising an agent executing in the computing environment, represented in the workflow graph and having a workload in the computing environment exceeding a threshold;
modifying the identified node in a modified workflow graph to reduce the workload at the identified node in the computing environment to redistribute the workload of the identified node across other nodes executing in the computing environment; and
providing the modified workflow graph to execute the agents and the tools according to the modified workflow graph defined at the nodes of the modified workflow graph.
12 . The computer system of claim 11 , wherein the identified node comprises a first target node, wherein a first source node connects to the first target node via a first path in a first scenario and a second source node connects to the first target node via a second path in a second scenario, wherein modifying the identified node comprises:
adding a second target node representing an additional instance of an agent or tool represented by the first target node; and
modifying the first path from the first target node to disconnect from the first target node and connect to the second target node in the first scenario to indicate the first source node calls the agent or the tool represented by the second target node, wherein the second path remains connected to the first target node in the second scenario to indicate the second source node calls the agent or the tool represented by the first target node.
13 . The computer system of claim 11 , wherein the identifying the node comprises determining a target node that has a workload exceeding a threshold and connected to by source nodes in different scenarios, further comprising:
dividing the source nodes into n sets, wherein the source nodes in each of the n sets contribute to the workload of the target node that combined are less than the threshold;
creating n−1 target nodes representing an agent or tool represented by the target node; and
for each set of n−1 sets, modifying the paths of the source nodes in the set to disconnect from the target node and connect to the n−1 target nodes.
14 . The computer system of claim 11 , wherein the identifying the node comprises determining a source node and target node in the workflow graph, such that the source node is invoked from the nodes in multiple scenarios and there are multiple paths between the source node and the target node in the workflow graph representing the source node invoking the target node in the multiple scenarios over the multiple paths.
15 . The computer system of claim 14 , wherein the modifying the identified node comprises:
generating a new node in the modified workflow graph representing functionality of the agents or the tools represented by the source node and the target node.
16 . A computer program product comprising:
one or more computer-readable storage media; and
program instructions stored on the one or more computer-readable storage media to perform operations comprising:
processing documents to determine scenarios in which agents are deployed, tools invoked by the agents to perform processes defined for the agents in the documents, and workflows of the agents and the tools in the scenarios;
generating a workflow graph having nodes representing the agents invoked in the scenarios and the tools invoked by the agents, wherein the workflow graph includes paths between the agents in the scenarios indicating an order in which the agents are invoked in the scenarios and the tools invoked by the agents in the scenarios;
determining workloads at the nodes in the workflow graph;
identifying, by an agent reorganizer, executing in a computing environment, a node comprising an agent executing in the computing environment, represented in the workflow graph and having a workload in the computing environment exceeding a threshold;
modifying the identified node in a modified workflow graph to reduce the workload at the identified node in the computing environment to redistribute the workload of the identified node across other nodes executing in the computing environment; and
providing the modified workflow graph to execute the agents and the tools according to the workflows defined at the nodes of the modified workflow graph.
17 . The computer program product of claim 16 , wherein the identified node comprises a first target node, wherein a first source node connects to the first target node via a first path in a first scenario and a second source node connects to the first target node via a second path in a second scenario, wherein modifying the identified node comprises:
adding a second target node representing an additional instance of an agent or tool represented by the first target node; and
modifying the first path from the first target node to disconnect from the first target node and connect to the second target node in the first scenario to indicate the first source node calls the agent or the tool represented by the second target node, wherein the second path remains connected to the first target node in the second scenario to indicate the second source node calls the agent or the tool represented by the first target node.
18 . The computer program product of claim 16 , wherein the identifying the node comprises determining a target node that has the workload exceeding the threshold and connected to by source nodes in different scenarios, further comprising:
dividing the source nodes into n sets, wherein the source nodes in each of the n sets contribute to the workload of the target node that combined are less than the threshold;
creating n−1 target nodes representing an agent or tool represented by the target node; and
for each set of n−1 sets, modifying the paths of the source nodes in the set to disconnect from the target node and connect to the n−1 target nodes.
19 . The computer program product of claim 16 , wherein the identifying the node comprises determining a source node and target node in the workflow graph, such that the source node is invoked from the nodes in multiple scenarios and there are multiple paths between the source node and the target node in the workflow graph representing the source node invoking the target node in the multiple scenarios over the multiple paths.
20 . The computer program product of claim 19 , wherein the modifying the identified node comprises:
generating a new node in the modified workflow graph representing functionality of the agents or the tools represented by the source node and the target node.