Hello guys, welcome back. In this video, let's go through agnos workflows. In the last video, I explained about this eggno teams.
And in this video, let's go through agno workflow. I have updated the code here in the agno workflows in the GitHub. Please find the code which I will be presenting in this video.
So, you can go along with me in this video. And also, I have this code already being cloned in my local computer. As you can see here, if I just do ls li agno workflows already [snorts] and I can go inside ao workflows and then this is already open in my VS code.
I will be showing you from the VS code how the video will proceed is first let's understand the theory behind it. Again as always I will provide the timestamp in the video. Feel free to jump between different sections in the video because the video may be a little bit longer than usual.
First, let's go through this documentation and see what workflow is actually about. Then I will show you these three different files. First we'll create a simple workflow and second one I will show you the branching concept in workflow and same as last video we'll run that in the agent OS and after that it will be just having the traces also being showing there you can already get help from the last video but I will also show you how you can also get the traces in the ANOS itself so you don't need to hook any other tracing providers into the workflow that you will be working.
Let's get started. If you go to this egnoorkflow. py, I have this documentation on the top link which will open us to the documentation of the workflow.
First, let's understand the few paragraphs here and understand what workflow is all about. Right? Just to give you a little bit back memory about the teams also.
When we went through the teams, there was a leader and there is a agent or sub agent uh inside that orchestrator or the team agent and there can be a team of agents also as a member being assigned. There will be different ways how you can create the teams and in this team section you can just go there and read the documentations. I provided you the brief idea of what teams is all about and create agents using it to solve your use cases.
But I showed you simple example here also. My job is to show you how things work. I think you can take this further.
Read the documentations. And one thing you need to be noticing here is the documentation keeps on changing any framework these days. Please refer to the latest documentations because you might be watching the video maybe 6 months from now when I create this video.
The documentation might not be updated. always take help from my videos but refer to this latest documentations right because these things must be mentioned because in my earlier videos I see the comments that okay this is all outdated and so on but that's the way because I cannot go and update each and every videos that I create because things are changing quite fast in the AI world right now let's go to the workflow right here it says build deterministic workflows by orchestrating the agents, teams and functions in steps for reliable multi- aent system. Meaning that in sometimes you might need one agent doing some task and the output of that agent needs to go to the next one and then next one and so on.
Right? In these cases, you cannot use this multi- aent orchestrator where the team leader assigns the task to different agents because they're simultaneous work. You can do a sync and at the same time two different agents can work together and pass the result to the team leader and team leader will provide you the answer.
Similar to how we work normally, there's a team leader. We can have the task and then the team leader can assign the task, get the output and then provide the final response. Right?
In the normal working life, we have the workflow, right? Step one needs to be completed. This is the same concept also here in the agent to make it more deterministic.
Egno workflows enable you to build deterministic controlled agentic flows by orchestrating agents, teams, functions. You can say you can have different ways through a series of defined steps. Unlike the free form agent interactions, workflows provide structured automation with predictable execution patterns.
Step Y needs to be done after step X for example, right? Making them ideal for production systems that require reliable repeat table processes. Clear?
Each step in the workflow workflow handles a specific part of the larger task with output automatically flowing from one step to the next creating a smooth pipeline from start to finish. Think of it like an assembly line. Each step specializes in one thing and together they accomplish the complex task that would be harder for a single agent or a team to handle.
I think it's clear plain English that you can understand compared to the teams and the workflow. Here is the diagram. This is the workflow input.
It can be string, pyic, dictionary, list, whatever. There is the workflow. There is step one team.
Step two team. Step three team. Step one will do some task provide the output to step two a step two gives to step three and then there is this final output but in this concept also it will not be always this case that's the reason I'm not going to go depth in this video but let me know in the comment section if you want me to go more depth I will create the videos but it will take some time because I need to allocate some time to study myself and the create the videos here the work overview view there is building the workflows.
From here you can see different blocks. Each of these you can just go here and read. And here there is this running workflows also right because although there is one step, second step, third step you can see there is also this parallel concepts that allows you to execute one or more steps in parallel.
That is also possible depending upon the use case. Right? If you want to go here and read in depth, there are many things that can be done with the workflows because there is sequential workflow, fully Python workflow, stepbased workflow, there is custom functions, conditional workflow and there is also the diagram here for you to get understanding.
Here you start there is a condition to check uh steps skip past previous step next and the end example good diagram here there is parallel workflow. You can see there is the start parallel execution happening step 1 a 1 b 1 c remember there is 1 a 1 b 1 c right and then all of the output is being passed to step two it is a deterministic workflow but in some cases you can run things parallel in certain steps that's the reason it's saying step one a b c not going to two right because first it needs to complete a b c and the output of that will be mored and passed to step two and then to the final step. These are the different scenarios depending upon your use case.
For example, here you can see the example use case is shown multissource research, parallel analysis, concurrent data processing something like this, right? Because let's take example of concurrent data processing. You might be doing some let's say table from different tables.
you are aggregating something or you are doing some sort of data prep-processing. Let's say that you want to do step A, B, C in different tables, you want to have all the results of that into one table and then pass that to the next workflow step. In these cases, you can still do the parallel execution.
You don't need to wait until A is finished because A and B are isolated but in the same step. I hope it is clear. And there is this iterative workflow also here you can see start loop starts step in loop there is this condition if it is yes it goes to the step after the loop if not it revolves in the loop it's simple Python steps right if this do this and there is this branching workflow also con I will show you example this also in this in this video there is the router and there is thing route one route two route three there is step A B C We have all the answer as a final step and then we end it.
For example, here export routing, content type detection, multi-path processing and there is grouped steps, workflow, advanced workflow patterns and so on. There are different things as you can see here. There is orderly stopping but this is outside the thing.
If I go to workflow patterns, it's outside this but still inside the workflow. You can see different things can be inside the workflow. Go through this documentation.
Use the one that is necessary for your use cases. I hope now you get the concept of workflow. Now let's go into the code.
I will go into the code here in VS code. As always simple importing things. If you are following my tutorial in agno similar things from agno agent import agent from agno teams we imported teams.
Now we import workflow quite uh easy to follow pattern here there is tools doc go or tavi as it is for doggo you you don't need to have the account or tab you need to go to this tab website create account you will be provided 1,00 credits of monthly plan I'm just using this free one and it will also show you how much you have used that is API key just take the API key and then pass it in this env V here. By the way, I will remove this once the video is published, but you get the point. Pass the environment variables here.
And with the environment variable there, we are loading this from here. Import OS. We are loading this.
And now we don't even need this grog because I'm using this llama cpp. But before going into llama cpp, I need to run the llama cpp locally, right? I will just go here and run the llama cpp.
And by the way, if you are new to llama, you can use lama and all sorts of things, but I prefer llama cpp. There is a video that I have already created. If you are new, you can watch that.
But I'm running this locally. One drawback of this is that you need to have have good hardware to run this. You can see everything is going all sorts slots are idle now.
Good. It's running. We have these agents simple agents I have been explaining many times define the agents with specific roles right and now here is find relevant informations about the topic this is the researcher right and I'm passing this grog but I'm not using grog I'm using llama cpp the second one let me use this and then there is this writer this is the researcher there is the writer and we have the writer agent write a clear engaging article based on the research.
Now you get the idea, right? This is a workflow. So first it needs to do some research and write it, isn't it?
That means there is a pattern here, right? What is happening here? It says llama CPP.
Okay, here the bracket is missing. I will do comma here. It should be working.
And now same case here bracket missing. But yes, it should be fine. And now we have the workflow again.
Here we are chaining them together into the workflow. Right? Here is the workflow.
Give the name. And here we have this DB. I'm providing this SQL database locally.
And it will be created here inside this folder. And then the steps. First go to the researcher and then writer.
And now I'm saying here write an article about climate change solutions. Whatever you want to do. I will save this one.
I will go to the terminal right here. I have my llama CPP running. I will just go to another tab here.
I'm inside agno teams. But I need to go back to the eggno workflows folder. Right?
And then I can run uvron python 3 agno workflow. py. If I run enter, let's see what happens here.
You can see workflow information. Workflow content creation. There is two steps.
Write an article about climate change not solutions. Step one is being uh triggered meaning the researcher is doing the task for us. Once that is done you can see climate change this this once that is passed we will see it's a good in the UI also.
By the way just showing these different steps. Once that is done it will pass to the next step. We'll be seeing here in the UI also.
I will show you in the UI but I mean in the terminal here you can see this is three dots showing here meaning something is happening under the hood and it's saying starting the step one once that is completed we will be seeing step two and then finally we will have the answer this is the drawback also from the terminal of course it's good in the terminal but you can see sometimes the rendering effects here I will show you in the next one how to run this in the agent OS but let's wait until this is completed because it will take some time to do the research. One thing when this is running is also good idea here is if you are using the paid version of this LLMs be aware because once you have this researcher it goes and resource things it can consume lots of tokens better if you are trying try with the open source for example I'm using llama server it doesn't cost me anything right it's up to you and now you can see this icon is gone step one is completed maybe it went to step two let's see here swing is still down now you can see the step two writer is kicking in writer climate change solutions in 2025 a road map of this and now it is doing all sorts of things it is still streaming but you get the point first step is done it goes to the next step and when the next step is done then it will provide us the answer this is the clear pattern of the workflow and now you can see it is doing quite a lot of research. It is doing research providing all the informations what it is, why it matters, key progress and so on.
Right? Let's see if it's completed. It's still running.
It started step two writer. And yeah, I cannot scroll now because it's running under the hood. Once this is completed, this revolving sign with the green dots will be gone.
Okay, that is done. Now you can see here the sources are also being provided from where it is taken and so on. It is writing us the uh things based on the task that is being provided.
It took 170 seconds around 3 minutes to complete this task. Right? That is the workflow.
Now let me go to this branching workflow. This is little bit longer. Let's go through it.
There is the documentation link is there. Here I'm just importing all sorts of things. Here we have this router and here is the hacker news.
Here I'm using hacker news. You can use multiple tools and I'm using llama cpp. We have the hacker news agent one agent.
There is this web agent which does the comprehensive web research. And now I have this content agent. Then what I'm doing here is create the resource steps because this is the workflow.
You need to provide the steps. Right? First we have three agents.
Now I'm creating the research steps. First research hacker news. I'm saying the step passing the name.
This is the hacker news agent. I'm passing the hacker news agent as your agent and that is the first one that I created. The code is simple.
The main thing is you need to first create the agent and then once you create the agent pass the step into it. I have three steps. Research hacker news research wave publish the content three agents.
Here I create a function. Now in the function I have this research router. We need to know which agent to trigger.
Uh I'm taking the example from this documentation. Use the original workflow message. If this is the fy step this is the normal things mentioned here and now I'm saying the keyword here.
If you have these keywords use the hacker news. If the topic is tech or startup related use this one. This is handy in the enterprise concept also because if you have a database and you know the keywords you can see okay if this keyword is present go to this agent and do the stuffs and then we go to the next one this way it's deterministic you know what is doing which agent is doing what that is one part the normal python things here if keyword if any keyword in topic go with the tech keywords and this research hacker news go to research web.
If that is not present, you get the idea. If there is tech related keywords, go to hacker news. If you don't find any tech related keywords, then do another agent research wave.
And now we are creating the workflow. You have the workflow name, description. And here is a simple example.
In your use cases, if it's complex, try to provide as clear instruction as possible. And now here is the steps and this is the router we are providing. There is this name you can give the name selector research router and here you can see choices is between the research and the research wave and research hacker news and we are providing the description.
Once that is done and we have this step as publish content based on the keyword either go with the research hacker news or go with the research wave. After that you need to do the publish content. It's simple.
Right now I'm saying create a folder tmp and a branching workflow so that we can view that into the agent OS UI. Same thing kicks in here. I have the agent OS providing the workflow in the teams.
We provided the team and here we provide the workflow. Then we just uh run this app. Let me copy this command.
Now I will just control C. I am saving this again. If I change something here, I will go to the terminal.
I will just go here inside the folder. Ctrl V and I will run this one. Now it will run in the local host.
We'll connect this to the agent OS. You can see here this is this. If you want to see the documentation, just click the link.
But now we want to connect this to the agent. Right? For agent OS, you need to go to agent OS.
to get the link. There are many ways to go to the link but I have here in the agent OS I can just go here first right and then from there I can click this try agent OS and I will be here how to connect there is this add agent OS in my earlier video I just already connected before but in this let's still uh add agent OS but you can watch my agent OS video also how to do these things but I will go here and say add in here there is two things local live server we want to do from the local right and what is the endpoint endpoint is local host 8,000 you can give any name here I can just give let's say workflow something like this you don't need to provide the tax but if you wish you can just say workflow something just connect now you can see this turns green meaning that our locally running workflow is now connected to this agno provided UI. You can see that it already detects a workflow called intelligent research workflow.
And you can just click this chart here or you can go to this chat icon. Remember it seems empty and you might be thinking where is my workflow? But you need to go into this here.
If you hover here these three things appear in the drop-down go to the workflow. Now you can see there is intelligent research workflow and you can go here and see the configs two steps there is this DB ID also descriptions written here sessions you can see the steps also being shown here automatically either you go from the resource hacker news or research web and then into the publish content I really like how INO team has built this easy to use UI for us it's free until now maybe in the future Also there will be some kind of free tire if there is subscription but also I find this really helpful. Now you can go here and ask the question.
So maybe you can write what is machine learning simple example. Let's see what happen when I run this machine learning it knows that it is tech related in the steps it says research hacker news. The router knows the first step we have the keywords.
It knows this is related to hacker news. I need to go there and do some research. Now it goes there and do some research.
You can even click this one and see what is happening here. There is workflow started, router started, resource hacker news right here, run started, hacker news, resource run completed and hacker news, router completed because router started, router completed and then it goes to the publish content. It needs to write the content and now it is saying here okay publisher content content completed and now we have this answer absolutely happy to dive deeper and it provides us the answer you get the point with the UI is quite easier this is great and now you can see all the steps also being shown this helps you okay what is happening under the hood instead of in the terminal it's better you can just go here drill things you can see the metrics also how many tokens are being used these are the tokens used you can go to the session sons and here in the teams in the workflow this is what is machine learning this is the metrics there is metrics there is details all sorts of things if you want to have some evaluations memory knowledge it will be shown there if you want to see the traces you know the steps taken from the UI from the chat already but if you want to see the traces now it is not shown here in the traces because we haven't enabled the traces now the third one will Let's enable the traces and ask the same question and see how it uh works under the hood into the traces.
You see which step is taking how much time and how many tokens. Right? I can leave this running and I will first go to the terminal.
I will cancel this because sometimes if I don't cancel this running one, it will not show in the UI. Just cancel this because we are going to run the new file anyway. The next file is this one agno branching workflow same one adding traces on top of it.
For that we need to import this set of traces setup tracing and I'm saying here the DB for the tracing right and then what I do here is same nothing is changed there is these three things all the things are here same but only one thing that needs to be changed after importing you need to be saying tracing equals true that's it with that what happens is you are enabling the tracing everything is store locally you are just rendering in the UI right I will just save this one I will go to the terminal and from here let me go back to the file just to copy this is not agent osent OS tracing I will update this in the GitHub also for you so that you can just copy and run it ctrl C I will go to the terminal inside the eggno workflows folder I will do ctrl + v Enter. Okay, it says that what happened here? Path does not exist.
If I do ls, there is the file uvron fast api divo branching workflow. The file name is traces not tracing traces py. Before I run, I will go to the file and run traces.
So I don't forget it so that you also don't get the same mistake. Enter. Now you can see it is running locally.
Now what I can do is just go to the UI. It will be already connected because it's already being opening here. It's already connected.
Meaning there is this green icon here. I can go to the chat again. I can go to this workflows.
And now I can go here and ask the question same as before. Let's say hi. Simple example.
Hi. It will say hi. Right?
It it's also good to see when I asked hi. What happens? So you can see so it it just went hi.
This is the thing also that sometimes depending upon your prompt what you provided. If you don't provide if there is simple hi hello don't go to the step just answer me. If you provide that in the agent workflow description, it will just say hi, hello, thank you, goodbye, greetings.
But now you can see it just went through this step. Hello, how can I help you? This is the research wave.
And this is web researcher. You can see hello. Hello.
And now there is hello. Meaning that we don't need to go through that path. But this can be prevented by updating the system.
But we don't need to go into that now. But just to give you the information. But now here I can just say what is ML it should know I'm talking about machine learning it should go to the hacker news well now what happens here you can see I'm using this tavi that's interesting here here if I go to the code where is the code here I'm using here hacker news and the tavi right but here you can see it thinks that I'm talking about what is ML and here it does not find machine learning it went to this resource instead of hacker news now you can see I'm saying what is ML and then here you can see it went through the resource strategy router and what is ML behind the scenes workflow started router resource wave it does the tably source completed and then resource router this this this this And here is what I found or help you with how ML solves real world problems.
Finance, finance, you get the thing. How you ask also depends where it wants to route. Be clear when you provide the constraints and when you provide the answer.
Just to show you again I will show you here what is machine learning. If you just say what is ML, the agent does not know what is ML. ML is machine learning.
But we haven't provided that information. Agent is LLM under the hood. If we don't provide any context right it does not know it's machine learning it can be anything although it went inside this and said okay ML solves world problems but I'm saying here what is ML it should give me the machine learning things like what is machine learning I just want to have the definition of machine learning right now let's see what happens I could also have provided more instructions and now you can see it's already going to the hacker news researcher because there we have the old machine learning this also gives you The idea that what you ask or what your end users will be asking is highly dependent on how you are creating the workflow.
This is the same situation that we also face at the workplace because you are creating the agent thinking your own way but the users think differently. You think that users will ask things with clear instructions but with the help of this chat GPT or all the things where you can ask random questions. In the enterprise also the habit is to ask the question randomly and it finds difficult for the agent uh to grab the information from the data source it provided.
But here you can see all the steps are gone. Now it will provide us the answer. Maybe it will go and we have said that if it's machine learning go and find the articles it will still uh provide something related to things from hacker news.
Let's see what happens if I say machine learning it's almost completed but the main idea here was to show you the traces. I will show the traces but here you can see here is what I found. Machine learning is the engine that turns raw data this so you get the idea.
And now it says supervise, unsupervised, semi-supervvised, reinforcement, self-ser supervise, key techniques and all sorts of things is being provided depends upon what you ask and how you create the workflow and the agents behind it. Now if I go to traces now you can [snorts] see there is a traces in the traces you can see all the steps that is being you can just go inside it and see what is happening under the hood and you will get the answer. the traces enabled.
I'm taking some time to explain you so that you get the understanding also how things work and and so on. You can imply these things into your [snorts] day-to-day work or your pet projects. That's all for this video.
I will be creating another video related to guard rails.