Build a DEEP Research Agent That Doesn't Suck (Flowise AI Tutorial) β
FlowiseAI v3 TutorialFreshπ
2025-07-09
Build Process β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BUILD CHATBOT WORKFLOW β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β PLANNING β
β ββββββββ β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Define βββββΊβ Choose βββββΊβ Setup β β
β β Scope β β Stack β β Project β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β β
β βΌ β
β DEVELOPMENT β
β βββββββββββ β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Build βββββΊβ Add AI βββββΊβ Test & β β
β β Features β β Logic β β Debug β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β β
β βΌ β
β DEPLOYMENT β
β ββββββββββ β
β βββββββββββββββ βββββββββββββββ β
β β Deploy βββββΊβ Chatbot β βββ LIVE! β
β β to Cloud β β Running β β
β βββββββββββββββ βββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββKey Components β
- Project architecture
- Core features implementation
- Best practices
Transcript β
[00:00] In this video, I'll show you how to build a deep research agent flow that doesn't suck. A while back, a team member asked me to help research a potential partnership with another company. So, we had to look into things like the company's background and the background of its directors. So, I thought deep research agents would be the perfect candidate for this. So, we tried using research models like Perplexity Sonar model, but we found it actually elucinated a lot of the information. In fact, he started doing research on people who were never associated with that company. So, I
[00:32] found this article from Anthropic where they detail how they built their multi- aent research system. So, this goes into a lot of theory around research and how people approach research as well. So when you're given a complex topic to research, you might come up with an initial plan, perform some research, and then based on your initial findings, you might have to refine your plan to do additional research. So what you'll end up with is some orchestrator agent that will come up with an initial plan and
[01:02] then spawn off sub agents and each sub agent has a very specific task that it needs to execute. All of the findings from the sub aents will be fed back into this orchestration agent and it will then decide if additional research is required and in spawn of additional sub agents or finally produce a final report and in flow-wise it looks something like this. So we'll have this planner agent which is effectively that orchestrator who will then spawn off sub agents and
[01:35] this can be any number of sub aents by the way and then the responses from the sub aents will be collected by this writer agent and we will then decide if more sub aents are required and if so we'll hand back over to the planner agent who will figure out the next steps or finally we'll see that final report along with the citations. This is an extremely powerful flow for doing deep research. And this iteration node in Flowwise is incredibly powerful. So let's dive in. Let's start by creating a
[02:06] new agent flow. And I'm going to name this deep research tutorial. And now we can get started. The first thing I want to do is open up the start node and change it from chat input to form input. And let's give it a name like research. And for the description, we can enter anything we want like a research agent that takes in a query and returns a detailed report. Then for the form inputs, let's add a new input of type string. And for the label, we'll call it
[02:37] query. And for the variable name, I'll just call it query as well. We'll use this variable name to refer to this value in our flow. Then I'm also going to add two variables to our flow state. So let's add the first one which we'll call sub aents. This will contain the list of our sub agents. Let's add another variable and this one we'll call findings and this is where the research from our sub aents will be stored. Then let's close this. And if we save our flow and open the chat, we now get this
[03:09] form instead of a chat interface. So what we want to do now is add an LLM that will look at the user's query and then determine what sort of research needs to be done and then create the sub agents. So let's go to add nodes. Let's add the llm node and let's connect these two nodes and let's double click on llm node. I'm going to rename this to planner. And for the model, I'll simply use chat open AAI and I'll select my credentials. And for the model, I'll go
[03:41] with GPD 4.1 mini. Then let's also add a system message. So under messages, let's select the role as system. And then for the prompt, we can enter something like this. Feel free to pause the video if you want to see this full prompt. But I'll also link to this entire flow in the description of this video and you can download it for free. But this is simply telling the LLM to look at the user's query and to come up with a research strategy. We're then telling it to create a list of sub agents with specific tasks. And then I'm just
[04:12] telling it what the current date and time is. Let's save this. Then let's add another message. Let's select user as the role. And now we'll simply tell it what the query was. So we'll enter query. And to refer to that variable, we can enter double curly braces. And then from the form input, let's select query. We'll leave memory enabled. And before we do anything else, let's actually test this workflow. So I'm going to save it. Then let's enter a query like the differences between open AI meta and
[04:46] anthropic in how they approach training models and their target markets. Let's send this and now we're getting a response back and all right let's have a look at this. So here we can see things like the reasoning and the research plan that this LLM came up with. It's also suggesting the sub agents that we'll need. So, sub agent one will perform research on OpenAI's approach to training models. Research two will look at Meta's approach to training models and agent 3 will research anthropics
[05:17] approach to training models and agent four will have a look at researching OpenAI's target markets. The same with agent five and agent six will look at anthropics markets. Cool. This looks good to me. But now, how do we actually use it in this application? Does LLM simply return text to us? But what we really want is a list of agents with their tasks. So what we'll do is open this planner node and then scrolling to the bottom, we can go to this JSON structured output section and let's add a JSON structured output and let's give
[05:50] it a name like sub agents. Then for the type we'll select a JSON array. Now this will allow us to add a JSON schema to define exactly what this output should look like. So you can simply ask JPT to help you with the structure, but I'll simply paste in this one. So we've got an object with a property called task. Then task is an object itself with two properties. The type, which is string, and a description, which will tell the
[06:21] NLM how to populate this field. So then let's also give a description for our sub agents, which could be a list of sub aents to perform research tasks. Then finally we also want to update our state variable. So at the bottom let's click on update state and under keys let's select sub agents and for the value we'll simply add the output of this node. All right. So let's have a look at the difference. I'm going to clear the chat. Let's send that exact same query again. And now we get this object
[06:54] starting with curly braces. And this square bracket means this is an array or list of values. And now we can see a few different subtasks. We've got one here to research open AI. Then we've got another one here for meta etc. So now that we have this list of sub aents, we need some way to iterate through each of these and then gather their results. So that takes me to a new node in agent flows called iteration. So I'm going to add it next to our planner agent and I'm
[07:25] going to connect the planner agent to this iteration node. Before we continue with this flow, let me explain how the iteration node works. So, I'm temporarily just going to create a new flow. I'm just going to call this iterations demo. And let's add the iterations node and hook it up to the start node. If we double click on the iterations node, we can see it expects an array of values. Now, an array or list starts and ends with these square brackets. And within
[07:58] these brackets, we can add a list of values separated by commas like 1 2 3 4 5 as an example. And what this node will do is look at this array and then run through each of these values one by one. So what we can do is add an LLM node and drop it into this iterations node. And now this LLM node will run as many times as there are entries in this array. And each of those iterations will give you access to the current value that it's
[08:28] looping over. So the first time this runs, the value of one will be passed to the LLM and then the LLM can do whatever it wants and produce some result. Then the LLM will be called again with the value of two and etc. So let me show you how that works. Let's say we've got this LLM. I'll just assign a model to it quick like GPT 4.1 mini. And then let's add a system prompt. And let's say respond with. And now I'm going to grab the current value of the iteration. And
[09:01] then let's say and nothing else. Okay. So let's save this flow and let's run this. So in the chat I can enter whatever I want. It really doesn't matter. And if we have a look at this process flow, we can see that the iteration note was called. And then we can see this llm was called five times. If we have a look at the output from the llm, we can see the first one responded with one. And if we look at the second one, it responded with two. And we'll
[09:31] expect the rest of these to respond with the current value of their iteration. Now, realistically, as with our sub aent solution, this array of values would be something way more complex like objects. An object is represented with starting and closing curly braces. I'm just going to expand this to make it a bit more readable. But these objects can contain different properties as well. For instance, a name property with a value of Alice and an age property with a
[10:04] value of 30. We can have multiple of these objects in our list by separating them with commas. So we could have a list of names and ages like this. So this means if we save this, I'm actually going to adjust the system prompt of our LLM to say something like from the context extract the name and age then respond with hello name and I see you are age years old and then we're passing in the current structure of this iteration. Let's save this. Then in the
[10:36] chat let's say hey and if we now look at the process flow let's look at llm1. We can see in the system prompt that we received that structure for the first iteration and of course our output says hello Alice I see you are 30 years old. We'll see the same thing for the second iteration as well. And finally if you wanted to see what the iteration node produces it's simply this. If we expand this we can see that the output is actually a consolidated view of all of the responses of the LLM node. So if we
[11:08] actually wanted to see some output, what we could have done is add something like a direct reply. So let's just attach this. And then for the direct reply node, we can just grab the output of this iterations node. So if we had to run this again, let's just clear this. Let's run it again. And now we can see the output from the iterations node in the chat window. Cool. So that was a crash course on iterations. So let's have a look at how we can use this iterations node in our deep research
[11:39] flow. If we have a look at what the planner node returned, it returned an object with a property called sub agents. Sub aents is an array of values starting and ending with a curly braces. And then in this array we get this object with a property called task. This is similar to how we had those objects with a name and age properties. This time we just have one called task. So all we have to do is pass this array to our iterations node and it will be able
[12:11] to loop through each of those sub agents. Let's double click on the iterations node and for the input array what we can do is grab the output from our planner node. So since we're storing the list of sub aents in global state, all we have to do is scroll down, go to flow state and then grab the sub aents. So as a reminder, we set the sub aents in the planner node by going down to the bottom and in update state, we're
[12:41] setting sub aents over here. So now that our iterations node has a view of all of these sub aents, it will loop through each of those sub aents one by one. So to trigger the actual sub aents, let's go to add nodes. Let's add the agent node. And I'm going to rename the agent to sub agent. And of course for the model I'm going to select chat openai and GPT 4.1 mini. Right now for the system prompt. So I'm
[13:12] going to add this prompt. And again you can find this prompt in the description of the video along with the entire workflow for free. But in short what this is saying is you're a sub agent assigned with a specific task by a research coordinator. And then it's just saying that your job is to complete a task using the available tools. And we will assign a web search tool, a web scraper, and access to archive. And then it's just saying that you have to write a detailed report and include things like citations. All right, let's save this. Let's start adding our tools. The
[13:45] first thing I want to add to this agent is access to archive which contains research papers. Let's add another tool. And this will give our agent access to web search. So let's add Tavly API. And then let's select our credentials. And if you don't yet have credentials, all you have to do go to tavly.com and all you have to do is sign up for an account and you get a lot of free credits with this. So it won't cost you anything. And from the dashboard you simply copy the API key and then in flowwise simply
[14:17] click on create new credential and then add your API key in this field. Now I've already done that so I'm not going to do it again. And now that we're able to effectively perform a Google search, we can add the web scraper tool, which will allow the agent to scrape the content of the pages from these results. All right, let's scroll down. I'm going to keep memory enabled. And then for the input message, I'm going to tell this agent what its research task is. So what we can do is say research task.
[14:50] And this is equal to the current iteration that we're on. And this iteration object will contain the task that it needs to execute. And let's test it. So I'm going to save the flow. And in the chat, let's start a new chat. Let's add our prompt again. Let's send this. All right. So now the execution completed. Let's have a look at the process flow. We can see that three sub aents were called. And if we have a look at the output from these sub agents, we can see that Tavly API was called. And
[15:21] we can see this research task was indeed passed in. And this agent was responsible for researching open AI and their approach to training AI models along with the target market. And we can see this agent called the TAVY tool quite a few times. And finally, it produced this final output along with its citations. And if we have a look at agent two, this agent decided to call Tavly API along with the web scraper tool. And its task was to research meta's approach to training models. And
[15:52] of course if you scroll down we can see all of its findings along with its citations. And finally this agent decided to go to archive which is interesting and tavly API and it was responsible for researching anthropic. And of course finally we get our output along with the citations. As we saw earlier this iterations node will give us a complete view of all of the responses generated from the sub nodes. So effectively it will give us all of
[16:22] the output from all of these sub agents which is huge. So what we can do is add another LLM. So let's add the LLM node. We'll connect the iterations node to this LLM. And this guy is responsible for looking at all the output from the sub agents based on all of those findings. I'm just going to call this one writer. And then for the model, let's add chat open AAI and let's select GPT 4.1 mini. For the messages, let's
[16:54] add our system message. And for the content, let's add this system prompt. Again, you can download all of this in the description of this video. We're simply telling the LLM to take these raw research findings and then write out a clear, structured, and long form markdown report from it. We're telling this writer to start with a compelling title and a 200 to 300word abstract then followed by basically all of those insights and findings from the sub agents. But what we'll also do is take
[17:26] the output from this writer LLM and then add it to this finding state variable. So if we click on the start node, we added this findings variable to state which is currently empty. So what we can do is in the writer node let's scroll all the way down let's go to update flow state then under key let's select findings and for the value we'll use the output from this writer node what I'm also going to do by the way is I'm going to disable memory because at this point
[17:58] the conversation history is going to be massive it contains everything from our initial query to the planning agents output along with all of the sub agents findings as well. And the context length is going to be insane and we don't want to process all of that. All the writer node really needs is that consolidated view from the iterations node. So underneath the system message, let's click on add message. Let's add a user message. And then for its content, we
[18:28] can add the research topic which is the query from our form. We'll also pass in the existing findings which is initial at first and we'll pass in the new findings which is the output from the iteration node. The reason we're adding existing findings is that after this step we're going to add a condition node that will check if this report actually addresses the user's query. And if not we might have to go back to the planner agent to continue with our
[18:59] investigation. So when we get back to this view, we want to pull all the findings that we have so far and then look at the new findings and then formulate a new report. All right, let's save this and let's close this and let's test it so far. So let's open our chat. I'm going to clear the chat and let's send our query. Let's submit this. All right, so we're getting the response back along with a lot of citations as well, which is cool. And if we expand
[19:30] this, we can have a look at this report. And this is actually phenomenal. So we get that abstract back and we get our introduction. The training methodologies for OpenAI, meta, anthropic, the target markets are pulling through as well along with this beautiful table and all of these citations. So this is already looking incredible. But we can make this even better. So what we'll do next is add a condition node to check if that report actually addresses the query from
[20:01] the user and if not go back to the planning agent to continue doing research. So let's do this. Let's go to add nodes and let's add the condition agent node. Then let's connect the writer to this condition agent node. And let's rename this guy to more sub agents. And for the model, I'll select Chad OpenAI again. And I'll select my credentials. And for the model, we'll go with GPT4.1 Mini. And for the
[20:32] instructions, we'll keep it simple. We'll just say given a research topic, previous sub aents and their findings, determine if more sub aents are needed, or if the findings are sufficient for the research topic. And for the input, what we'll add instead is the form topic, the list of sub agents, as well as our current findings. Cool. Let's save this. And now we can define different scenarios. And the agent will try to match this input to one of these
[21:03] scenarios. For the first scenario, let's just say more sub aents are needed. And for the second scenario, findings are sufficient. All right, beautiful. So now this condition node gives us two outputs. This first output relates to this very first scenario which says more sub aents are needed and then the second output will link to the second scenario that says the findings are sufficient. So if we need more sub aents we can simply loop back to our planning agent.
[21:35] So we can loop by going to nodes. Let's add the loop node and connect this path to the loop node. And let's rename this guy to back to planner. And then under loop back to let's select the planner node. And let's leave the max loop count on five. So if we feel that we don't need any more agents, then we can simply write the report back to the user. So let's select direct reply. Let's connect these two paths. And I'm going to rename
[22:06] this note to generate report. And of course, all we have to show the user is from our state variables, we want to grab the findings variable. This contains the last report that was generated by the writer node. And that should be it. Let's run this flow end to end this time. At this time, we should get an accurate and detailed report. Let's run this. And that's it. So we get our abstract, an introduction, the training methodologies, the target
[22:37] markets, this beautiful table and a lot of different content along with all the citations as well. And in this instance, the agent decided that no more sub agents were required, so it generated the report. This is awesome. If you enjoyed this video, then please hit the like button and subscribe to my channel for more Flowwise content. Let me know down in the comments what other use cases I should cover. YouTube thinks you'll enjoy this next video, so click on the card on the screen. I'll see you in the next one. Bye-bye.