<b>Flowise offers two extremely powerful</b> <b>solutions for building</b> <b>complex agent workflows. </b> <b>Multi-agents and sequential agents. </b> <b>Deciding which solution to go</b> <b>with can be rather confusing.
</b> <b>So in this video we'll compare these two</b> <b>different features by</b> <b>creating the same project in both. </b> <b>Let's start by having a look at the</b> <b>multi-agent example. </b> <b>Here we have this supervisor node which</b> <b>is responsible for delegating the tasks</b> <b>between the different worker nodes.
</b> <b>For example the software developer node</b> <b>and a code reviewer. </b> <b>And if we compare this to</b> <b>the sequential agent example,</b> <b>you will notice that this</b> <b>flow looks way more complex,</b> <b>but this also gives us way more control</b> <b>over the behavior of our application. </b> <b>First let's have a look at creating a</b> <b>multi-agent team using multi-agent.
</b> <b>First I'm going to save my chat flow and</b> <b>let's call it multi-agent</b> <b>software development team. </b> <b>Let's save this and for this example I</b> <b>simply want a team with two workers. </b> <b>A software developer and a code reviewer.
</b> <b>With multi-agents this is super simple. </b> <b>Let's go to add nodes and under</b> <b>multi-agents let's start</b> <b>by adding a supervisor node</b> <b>and let's also assign</b> <b>an LLM to the supervisor. </b> <b>So for this I'll use</b> <b>the chat openai node.
</b> <b>So for the chat openai node</b> <b>I'll select my credentials,</b> <b>I'll select the model name as GPT40 and</b> <b>let's set a temperature of 0. 4. </b> <b>And lastly let's connect our chat openai</b> <b>node to the supervisor node.
</b> <b>Great! The supervisor is responsible for</b> <b>delegating the task between</b> <b>the different worker nodes. </b> <b>If we open up the additional parameters</b> <b>we can see that the system prompt was</b> <b>pre-populated for us</b> <b>and in this prompt we can see that the</b> <b>team members is actually a variable</b> <b>which is dynamically populated for us.
</b> <b>And in this prompt the supervisor is</b> <b>instructed to decide on which team member</b> <b>needs to be called next</b> <b>or to respond with the word finish to</b> <b>terminate the execution. </b> <b>We don't have to change anything here. </b> <b>Let's simply save this prompt, let's</b> <b>close this popup and</b> <b>let's assign our workers.
</b> <b>Let's go to add nodes and under</b> <b>multi-agents let's add two worker nodes. </b> <b>So I'll simply copy this node and let's</b> <b>assign the name and worker prompts. </b> <b>For the first worker let's</b> <b>call it software developer.
</b> <b>And for the worker prompt let's enter</b> <b>something like you are</b> <b>a software developer. </b> <b>Build an app based on</b> <b>the user's requirements. </b> <b>Use technologies like</b> <b>React, JavaScript and Talwin CSS.
</b> <b>Pass the code to the</b> <b>code reviewer once done. </b> <b>You can complete your task once the code</b> <b>reviewer provides a suitable response. </b> <b>Great, let's have a</b> <b>look at our second worker.
</b> <b>For the worker name let's</b> <b>call this code reviewer. </b> <b>And for the worker prompt let's enter</b> <b>your job is to perform a code review. </b> <b>Check that the code is well written,</b> <b>performant and</b> <b>contains suitable comments.
</b> <b>Always pass your feedback</b> <b>back to the software developer. </b> <b>Let's save this and let's also attach our</b> <b>workers to the supervisor node like so. </b> <b>When using multi-agents to create AI</b> <b>teams this is</b> <b>actually all you have to do.
</b> <b>Let's save this flow and let's test it. </b> <b>Let's ask you to build an app for us like</b> <b>build a to-do list app. </b> <b>The execution is complete and let's have</b> <b>a look at what we got back.
</b> <b>First we can see that the supervisor</b> <b>correctly determined</b> <b>that the next step should</b> <b>be the software developer. </b> <b>So the software developer was executed</b> <b>and produced all of this code. </b> <b>This was then passed</b> <b>back to the supervisor</b> <b>who then determined that the code</b> <b>reviewer should be called next.
</b> <b>And the code reviewer therefore returned</b> <b>these refinements to the solution. </b> <b>This feedback was then passed</b> <b>back to the software developer</b> <b>and the software developer and the code</b> <b>reviewer went back and forth a few times</b> <b>and then finally</b> <b>returned this final feedback. </b> <b>Great, this was very easy to set up</b> <b>and we can easily add more workers to</b> <b>this project without</b> <b>having to change anything else.
</b> <b>One limitation with this though is that</b> <b>we have very little</b> <b>control over our application</b> <b>and we are relying on the supervisor to</b> <b>make the right decisions for us. </b> <b>The best we can do is try and adjust the</b> <b>supervisor system prompt</b> <b>or the worker prompts effective behavior</b> <b>of this application. </b> <b>Now in order to understand</b> <b>how sequential agents work</b> <b>we will try to replicate this application</b> <b>using only the nodes</b> <b>available to the sequential agents.
</b> <b>Let's create a new flow and let's call</b> <b>this sequential agent software team. </b> <b>Let's save this and let's start by adding</b> <b>a node to the canvas</b> <b>and instead of going to multi-agents we</b> <b>will now scroll down</b> <b>to sequential agents. </b> <b>Sequential agents need a starting node</b> <b>and this represents</b> <b>the start of our project.
</b> <b>Let's also attach a chat model so under</b> <b>add nodes and on the chat models</b> <b>I'm going to add the chat</b> <b>openai node to the canvas. </b> <b>I'll select my credentials, let's select</b> <b>the model name as GPT40</b> <b>and let's set the</b> <b>temperature to something like 0. 2</b> <b>as we do want our models to follow our</b> <b>prompt instructions.
</b> <b>Let's attach our model</b> <b>to the starting node. </b> <b>We don't actually need agent memory for</b> <b>this example but we do need state. </b> <b>So let's go to add nodes</b> <b>and under sequential agents</b> <b>let's add the state node and let's attach</b> <b>our state node to our starting node.
</b> <b>Great! We will have a look at why we need</b> <b>the state node in a second</b> <b>but let's first</b> <b>continue with our application. </b> <b>Once the application starts we want a</b> <b>supervisor node to be executed.
</b> <b>The supervisor will be responsible for</b> <b>determining which node</b> <b>should be called next. </b> <b>So let's go to add nodes</b> <b>and with the sequential agents</b> <b>we need to think which node</b> <b>we will use for our supervisor. </b> <b>We can either set an</b> <b>agent node or an allyl m node.
</b> <b>For the supervisor I will</b> <b>be using the allyl m node</b> <b>and this won't make sense in a second. </b> <b>Let's connect the starting node to the</b> <b>allyl m node and let's</b> <b>call this supervisor. </b> <b>The supervisors function is simply to</b> <b>determine which node to call next</b> <b>and to set a variable in state.
</b> <b>So the allyl m node would be perfect for</b> <b>that as the allyl m nodes</b> <b>allow us to extract information from the</b> <b>output and then update a state variable. </b> <b>So let's set up the supervisor node. </b> <b>Within additional parameters let's start</b> <b>by setting a system prompt.
</b> <b>Let's enter you are a supervisor tasked</b> <b>with managing a conversation</b> <b>between the following workers. </b> <b>With a multi-agent node the list of</b> <b>workers was simply a variable</b> <b>which was dynamically populated for you. </b> <b>But with the sequential agents we</b> <b>actually have to list</b> <b>the names of the agents</b> <b>or workers within this flow.
</b> <b>This provide further instructions like</b> <b>given the following user's request</b> <b>respond with a worker to act next. </b> <b>Each worker will perform a task and</b> <b>respond with their results and status. </b> <b>When finished respond with finish.
</b> <b>Select strategically to minimize the</b> <b>number of steps taken. </b> <b>Let's save the system prompt and let's</b> <b>also add a human prompt. </b> <b>The human prompt is a special kind of</b> <b>prompt which will be appended at the end</b> <b>of the list of messages.
</b> <b>Let's enter something like given the</b> <b>conversation above who should</b> <b>act next or should be finished. </b> <b>Select one of software</b> <b>developer or code reviewer. </b> <b>So at the start of our application the</b> <b>system prompt will be added</b> <b>at the very top of our prompt.
</b> <b>Then each of our workers will run and</b> <b>append their messages to</b> <b>the conversation history. </b> <b>Then this human prompt will be added at</b> <b>the very end of the conversation</b> <b>and then instruct this model to figure</b> <b>out which node to call next. </b> <b>I hope that makes sense.
</b> <b>Now the result of executing this node</b> <b>will be either software developer,</b> <b>code reviewer or the word finish. </b> <b>So we just want to extract that single</b> <b>word and we can do that</b> <b>using the JSON structured output. </b> <b>Let's click on add item and let's extract</b> <b>a value called next.
</b> <b>Next we'll have a type of enum which is</b> <b>simply a list of possible values. </b> <b>These possible values</b> <b>will be software developer,</b> <b>code reviewer, so I'll simply paste these</b> <b>into this field, comma, finish. </b> <b>So looking at the values we've got</b> <b>software developer,</b> <b>comma, code reviewer, finish.
</b> <b>And for the description I'll</b> <b>enter the role to act next. </b> <b>That's it. </b> <b>So the end result of this node will</b> <b>simply be either software developer,</b> <b>code reviewer or the word finish.
</b> <b>In fact let's go ahead and test out this</b> <b>node by itself by adding</b> <b>an end node to this project</b> <b>and let's attach the LLM to the end node. </b> <b>Great. </b> <b>Let's save this flow and</b> <b>in the chat let's enter,</b> <b>build a to-do list app and the result</b> <b>from executing this</b> <b>will be a JSON structure</b> <b>with a property called next and a value</b> <b>of software developer.
</b> <b>Now we need to figure out how we can use</b> <b>the results from the LLM node,</b> <b>so this value over here to conditionally</b> <b>calling the correct agent. </b> <b>So let's close the chat, let's delete</b> <b>this end node and</b> <b>let's add a condition node. </b> <b>So on the sequential agents</b> <b>let's add this condition node</b> <b>and let's attach the LLM</b> <b>node to our condition node.
</b> <b>Let's call our condition node, determine</b> <b>next node and within the conditions,</b> <b>let's add two conditions. </b> <b>So for the variable we could try and use</b> <b>the output from the previous node,</b> <b>so the LLM node, but a better</b> <b>implementation is to use state. </b> <b>So what we could do is take</b> <b>the output from this LLM node</b> <b>and install it in state and these state</b> <b>values will be available to all the</b> <b>agents within this flow.
</b> <b>So within state let's click on additional</b> <b>parameters and let's</b> <b>create a new property</b> <b>which I'll call next. </b> <b>For the operation let's select replace</b> <b>and initially this value will be blank. </b> <b>Let's go to update state, let's click on</b> <b>add item and when we</b> <b>double click on the key value,</b> <b>we can see the property that we just</b> <b>created in the state called next</b> <b>and for the value we can now assign the</b> <b>value which we created</b> <b>in the structured output</b> <b>which we called next as well.
</b> <b>So for the value let's click on flow dot</b> <b>output dot and let's call this next. </b> <b>This flow dot output is actually</b> <b>referring to the output</b> <b>of this node, the LLM node,</b> <b>and in this output we have</b> <b>this property called next. </b> <b>So we're simply assigning the value of</b> <b>next to the state value of next.
</b> <b>Great, so back in our condition for the</b> <b>variable we can now select that next</b> <b>property within state</b> <b>and now we can say that if state is equal</b> <b>to a value of software developer,</b> <b>then we want to trigger the</b> <b>output of software developer. </b> <b>Then let's create another condition also</b> <b>on the next value in state</b> <b>and if this is equal to code reviewer,</b> <b>then we want to trigger</b> <b>the output of code reviewer. </b> <b>Let's save this and you will now notice</b> <b>that on the condition node</b> <b>we now have different outputs</b> <b>for code reviewer, software</b> <b>developer, and an end state.
</b> <b>This end state will be triggered when the</b> <b>LLM node returns a value of finish</b> <b>or anything that's not code</b> <b>reviewer or software developer. </b> <b>Let's start by adding our two workers</b> <b>under add nodes under sequential agents. </b> <b>Let's add the agent node.
</b> <b>I'm actually going to duplicate this node</b> <b>and let's start with</b> <b>our software developer. </b> <b>For the agent name let's set software</b> <b>developer and for the system prompt,</b> <b>let's enter something like</b> <b>you are a software developer. </b> <b>Build an app based on</b> <b>the user's requirements.
</b> <b>Use technologies like react, javascript,</b> <b>development, and node</b> <b>for creating the app. </b> <b>Always pass the code</b> <b>to the code reviewer. </b> <b>The process may be completed once the</b> <b>code reviewer provides a suitable review.
</b> <b>Then let's have a look</b> <b>at our second worker. </b> <b>Let's give it a name of code reviewer and</b> <b>for the system prompt let's enter</b> <b>your job is to review code</b> <b>from the software developer. </b> <b>Ensure that good coding practices were</b> <b>followed and that the</b> <b>code is well commented.
</b> <b>Pass your feedback back to the software</b> <b>developer once done. </b> <b>Now let's attach our code reviewer from</b> <b>the conditions output</b> <b>to our code review agent. </b> <b>Let's do the same for the software</b> <b>developer and let's</b> <b>also add an end state.
</b> <b>So let's go to add nodes. </b> <b>Let's grab our end node and let's attach</b> <b>this end output from the condition</b> <b>and let's attach it to our end node. </b> <b>Great.
</b> <b>We will improve this end</b> <b>state in a few minutes,</b> <b>but let's first focus on getting these</b> <b>two worker nodes working. </b> <b>So the first time we run this</b> <b>application, the next state</b> <b>will be blank and the supervisor</b> <b>node will try to determine</b> <b>which agent to call next. </b> <b>Initially that's most likely going to be</b> <b>the software developer.
</b> <b>Therefore the condition node will call</b> <b>this software developer</b> <b>node who will produce some</b> <b>sort of output. </b> <b>Now each of these agent nodes</b> <b>need some sort of end state. </b> <b>So after this node is executed, what is</b> <b>it supposed to do next?
</b> <b>This can either be an end node or a loop. </b> <b>And for this example, we do want a loop. </b> <b>So under sequential</b> <b>agents, let's add a loop.
</b> <b>Let's attach the agent to the loop node</b> <b>and we want to loop</b> <b>back to the supervisor. </b> <b>So I'll actually copy the name of the</b> <b>supervisor and paste it into the loop. </b> <b>Let's do the same thing</b> <b>for the code reviewer agent.
</b> <b>Like so. </b> <b>This simply means that after the software</b> <b>developer has executed,</b> <b>it will append its output to the message</b> <b>list and then loop back to the supervisor</b> <b>node over here. </b> <b>The supervisor will now attempt to figure</b> <b>out which node to call next.
</b> <b>And that will most</b> <b>likely be the code reviewer. </b> <b>So the condition node will then trigger</b> <b>the code reviewer who</b> <b>will then review the output</b> <b>of the software developer</b> <b>and provide some feedback. </b> <b>The code reviewer will then loop back to</b> <b>the supervisor, etc.
</b> <b>At some point, the software developer is</b> <b>actually going to</b> <b>respond to the supervisor</b> <b>saying that the process can be completed,</b> <b>at which point this</b> <b>end state over here will</b> <b>be triggered. </b> <b>But of course, we don't want to just</b> <b>terminate this</b> <b>process without any output. </b> <b>So let's add one more node to summarize</b> <b>all the previous</b> <b>messages and provide something</b> <b>for our end user.
</b> <b>Let's go to add nodes</b> <b>under sequential agents. </b> <b>Let's add an LLM node. </b> <b>Then let's connect this end</b> <b>condition to the LLM node.
</b> <b>And let's attach our LLM node</b> <b>to this end state over here. </b> <b>Let's give this LLM node a name, which is</b> <b>summary and under conditional parameters. </b> <b>And let's add a human prompt like given</b> <b>the above conversations,</b> <b>reasonings and instructions,</b> <b>generate a final summarized answer.
</b> <b>And remember, the reason we're using a</b> <b>human prompt is because</b> <b>the human prompt will be</b> <b>appended at the bottom</b> <b>of our messages list. </b> <b>So therefore, this model will have a view</b> <b>of all the previous</b> <b>outputs from these different</b> <b>nodes. </b> <b>So it will be able to summarize those</b> <b>conversations for us.
</b> <b>That's all we have to do in this node. </b> <b>And I think that's all we have to do for</b> <b>this project, actually. </b> <b>Let's save this flow</b> <b>and let's test it out.
</b> <b>So in the chat, let's</b> <b>enter, build a to-do list app. </b> <b>Our supervisor is running. </b> <b>And we can see that the next property in</b> <b>state was set to software developer.
</b> <b>The software developer was then executed</b> <b>and they produced some code for us. </b> <b>This then looped back to the supervisor,</b> <b>who now determined that</b> <b>the next node to be called</b> <b>should be the code reviewer. </b> <b>And therefore, the code reviewer was</b> <b>correctly called, which then provided</b> <b>some feedback as well.
</b> <b>And this time, the software developer was</b> <b>called to make those revisions. </b> <b>After some back and forth between the</b> <b>agents, our supervisor</b> <b>finally set the state to finish. </b> <b>And therefore, our summary node was</b> <b>called, which then provided the final</b> <b>output of this chain.
</b> <b>I hope this video helped you to better</b> <b>understand the inner</b> <b>workings of sequential agents. </b> <b>If you would like to learn more about</b> <b>using sequential agents,</b> <b>then definitely check out</b> <b>this crash course over here.