Vollständiges Transkript anzeigen (4.164 Wörter)
Hey what’s up Sean. So today let’s talk about Loop versus Graph Engineering. Two biggest buzzwords in AI agent space recently. I am probably exactly like most of you guys, which is I don’t know how to keep up with all these new concepts, but I still find it very interesting because whenever a new concept becomes viral, usually I’m curious about what triggered it. What I find out is that this guy called Peter Steinberger, who’s also the author of This Little Lobster, which is OpenClaw, said that are we still talking about loops or did we shift to graphs yet? And he post this on July 18th 2026, which is about 13 days ago and he got 3 million views. And look at this first comment, it said bro stop I’m on vacation. So sometimes you know these important people in the space who mention a keyword, and then everybody’s going to start talking about it. I remember exactly something like that in Context Engineering and for today this video we are going to demystify all of these core AI agent concepts and especially on loop and the graph. We’re going to jump in a little bit on the system design real quick and at the same time we’re also going to walk you through a real coding example called Waku-Agent which is under my GitHub, ShenSeanChen and we published this about 2 or 3 weeks ago and we got more than 700 stars. If you think this video is helpful for you, please give us a star, give us a like and that would be very helpful for us. With Waku-Agent you can launch a dashboard like this and you can just ask something like what’s up on my Google Calendar on Thursday. Right? And then it’s going to check what kind of graph it’s going to use, decides if it needs to retrieve some memories and then eventually decide you know what kind of tools it should be using, right? Right here, it’s listing the events from my Google Calendar, and eventually send you the reply. And it did a bit of a testing in the valve system and then you know, it spit out the gave me the final answer for the results. I’m going to talk a bit more details into this. But without further ado, let’s get started on the system design. First thing first, I want to talk about the AI agent engineering ladder that we have come across over the past 3 years because I think that helps us to kind of understand where we came from and where we’re going. The first one is obviously Prompt Engineering, and to me Prompt Engineering was the very first or early version of how people start to get used to how to use an LLM. I feel the most accurate word to describe this was role playing because at the very beginning we didn’t know how to use LLMs, we had Chat GPT 3.5, and we tell it, hey you are the best poet like your Shakespeare or Li Bai, right, write me a poem about the scenery I’m looking at right now in Switzerland. Then it’s going to pretend that it’s one of those poets you just mentioned and then talk to you back, right? That was Prompt Engineering. You basically draft the prompt so that you control the LLM to talk to you in a certain way you want. And then we quickly evolved into what we call Context Engineering, and that is because when people move from just playing with LLM as a consumer product to actual workflows, you realize that you not only need prompt, but also you need to feed in data, for example if you build a customer service chatbot or if you build a sales agent like Automanus.io which is my company, you need to really think about how do you construct the context for the agent so that the agent will be able to talk to the clients on behalf of the businesses, right? So you not only will say hey you are the best salesperson in the world, you will talk in certain ways, do not say certain things, you also need to feed in data, such as what are some of the customer relationship data people already have on their Excel sheets, Google Sheets, CRM system, all these kind of things and you need to really put them together and make sure that the agent can accurately be fed with the right information. So we moved from prompt to context very quickly to fix that problem. And then we moved on to skills, which I think is sort of teaching the AI what kind of procedure it should follow, right? It’s a procedure following process in AI agent harness, this is called procedural memory. It’s a memory that you tell, say you tell a kid, hey when you walk home, walk on the right hand side if you are in the US or in China, right, walk on the left hand side if you’re in the UK or Japan, that is a procedural memory that you want a person, or you want an LLM, to remember and there’s no you know extra data, it’s just fact that it should be doing when a certain situation happens, okay? So why do we need skills? It’s because that if you just, if you, if you provide a lot of context to the AI, sometimes it can be a little repetitive. You don’t want to always provide you know the same order to AI again and again and again. So having a skill to determine a workflow becomes really, really handy. Just like for example, if you’re coding on CLAUDE CODE, you don’t want to explain to Claude that do not use emoji, do not use emoji, do not use emoji or I prefer to use emoji, use these emojis, don’t use the brain emoji, I hate that, right? These kind of things you have to repeatedly tell the context, then it’s becoming less convenient, so you can build up skill to make sure the LLM is following that procedure. Then comes with loop. What does loop do? A loop is basically saying, hey, maybe sometimes you have a goal and you want to finish that goal but we don’t know the exact skills you should have to finish that goal. We might tell you, hey there are a bunch of tools you can use, right, that’s why Anthropic came with MCPs, you can call your Google Calendar, you can call your Gmail’s APIs, you can call your GitHub APIs, these tools become handy and then you’re telling the LLM, be like okay run a loop, know your goal which is maybe help me fix this bug that the customer come up with. Run this loop and here are a bunch of tools, here’s a web search tool, here’s a bunch of API calls, here’s a bunch of MCPs, use them. Loop it until at some point you finish the goal and that’s the end of the iteration. And then the question comes, why do we need graph? What is graph do? Because graph technically is a procedure that is predetermined. Many people are criticizing graph engineering is not new because maybe in 2023 I remember people already using AirFlow, people using step functions, people are talking about how do we make sure that a deterministic workflow can be set up properly so that we don’t just tell LLM to make all the decisions because sometimes we know exactly how a certain task needs to be done, there’s a step there, there’s an SOP there. So to me it kind of feels like, okay we moved from skills, which is strict procedure following, to loops which is, hey agents, go figure it out yourself, to eventually we realize that, hey, we need a mixture of both, that in my opinion is graph, okay? Technically, sometimes you should write the skill first, okay? How do you cross the road, on what side do you walk in the pavement depending on which country you’re in, and how do you respond to your client, how do you respond to me when I’m coding with an coding agent, right? And then you should turn that into a graph. If you see that there’s a lot of repetition in the workflows, especially if you’re building a workflow for corporate, if you’re working in e-commerce, maybe you see exactly how your customer service should be answering questions related to logistics, to refund, to check in samples, you realize that you can really consolidate this into a graph when the workflow stops changing. Perhaps there’s still part of the workflow that you need to use a loop, where the loop is basically doing this exploratory work out there, right? It’s probably doing, you know, a bunch of research for you and I think Deep Research is one of the early examples of a loop engineering workflow here, where you just say, hey go crazy, just go search the internet and I want a report. These kind of work are, you know, less standardized or it doesn’t have an SOP in it. It’s just about, I want more information or I have a certain goal, use the tools available to you to figure it out for me. It’s quite different from graph, because sometimes we know exactly what tools they should be using to finalize a task for me. Okay guys, that was a conceptual walkthrough of this AI agent engineering ladder. Now let’s take a look at what a loop and a graph look like. What a loop does is that it discovers what to do next. So maybe this is you and you ask a question to an LLM and the LLM is basically saying, hey do I need to use any tools, if yes choose a tool, run it and check if it finished the task, come back to the LLM and then loop it again and again and again. Until at some point LLM is like, hey we don’t need a tool anymore, let’s reply to the user. Examples here could be like you are trying to fix a bug on a pull request on GitHub. You basically ask CLAUDECODE or CODEX and be like fix this bug, tell me when it’s fixed. And this is going to go ahead and then use a bunch of tools like web search, GitHub CLI, checking your Supabase, checking your AWS, checking your Google Cloud, all these kind of stuff and at the end saying, okay we’re done. Okay and the bug is fixed because of ABCD. That is a loop. A graph on the other hand is somewhat similar, but it’s not exactly the same. So you might have a standardized process every day and be like, oh I want to understand how many people submitted pull requests overnight and who are these guys who submitted some tasks, can we take a look at them and tell me if things are fixed or not and maybe at the same time, I want to understand you know what are some of the latest news out there on AI agents, and maybe we wanna do some web search as well, maybe we wanna run some, you know, get commands at the same time, we know exactly how it works, okay. And then you probably want this to be done in parallel. So you ask a question and then it’s going to check out the GitHub to check out the pull request, it’s going to search the website for you to do some exploratory analysis, and it’s probably also going to check your calendar plus the memories stored locally or on the cloud and then it’s going to synthesize these information and tell us, hey is there anything else to do? If not end this and reply. If yes please explain what kind of things do you still need to do, okay. You see the difference here, so sometimes you can have some loops here, okay, maybe having an agent loop to search the web or have an agent loop to fix the bugs on GitHub is part of this graph, okay. So you can see graph is basically saying, okay, I know exactly what you should be checking, maybe they’re in parallel, maybe they are happening in sequences, do it the way I want and once you finish synthesize it and tell me the answer. Are you guys still with me? Let’s check a real example first. Come back here, let’s come to Waku Agent Dashboard, the way you set it up by the way is come to this website github.com/ShenSeanChen/waku-agent, you can either click on code and copy this and then type in to your terminal and say get clone and paste that in and hit enter, which is this way, and then you can just copy this and paste in your terminal, or recently we released a new package in Python called waku-agent, all you need to do is copy this, pip install the waku agent into your terminal, set up your environment call keys and then you can launch a dashboard. Copy this, paste this in. Because I’m already using port 7777, so let’s use 7778, as an example, paste that in. You can see this is it, okay, since I already set it up, I’ll come back to this local host 7777, and so what you’re seeing right here is an entire AI agent harness, starting from the gateway which can be the chat of here, or you can use some other channels such as Discord, Telegram, WhatsApp, stuff like that. And then it’s going to check out a retrieval gate to see if we need any procedural memory, which is skills as we mentioned, or semantic memory or episodic memory which are durable facts or the dated events that happened in your local memories, okay. And then it’s going to run through an agent loop using LLM agents and calling the tools and eventually give you the reply during which the LLM Ops is gonna trace the data, test it and then release it the new version of the prompt and feedback to the harness, but this is the entire harness, okay, and loop engineering is happening here in this little loop. A graph workflow is basically after this gateway, you can predefine some of the process in between here, so we have a new tab called graph, we currently have two graphs here, one is called triage, another one is called gather. For triage graph what it does is that it’s saying okay start point and then it’s gonna classify, if it requires some agent calls and then at the same time it might just check out my calendar and see what’s going on, okay, and I can just be like what’s up today. Alright, you can see the trigger this triage first, right, it checked the Google calendar for me and also at the same time was checking you know if we need to have some need to do some serious agent calls here, and it eventually decided that okay it’s gonna use some tools, so they use the list events, read the apple calendar for me, you just saw a very simple graph kind of call already, okay, so what it did was that it checked as I mentioned, if it needs some serious agent calls, and in parallel at the same time, was already checking my calendar because I was asking what’s up today, and then after that I use this loop to run to call the tools like list events, read apple calendar and all these kind of stuff and then give me the reply, okay. But what if I need to test something else, so here in this local agent harness, what I recently updated is that you can very clearly mention the workflow you built in the graph, we have gather, so you can clearly say slash gather and then say tell me what’s up with Waku-Agent and any new PRs, any competitive projects, let’s see what happens. You see that it triggered this graph instead, okay, let’s come back to the overview, it’s showing me that it was triggering this graph and it used these tools simultaneously, and then it’s synthesizing the answers for me, okay. So, so what it did was that it gave me a morning brief on what kind of PRs are out there and we have released a new package, which you can check in this GitHub, if you scroll down a little bit, we have released a new package for agent graphs recently and also there are some PRs to be reviewed, okay, let’s come here, so if you click into pull request you can see there are some PRs here for me to be reviewed. And for the web search you can see that it researched about Harrison Chase, publish your harness, your memory, and your own videos in Harness, Evolve our ranking, okay, it was doing the command research for me as well. Alright, so you might be wondering how did this work? If we come back to the tab for graph, you can see that we clearly defined two different use cases of graph, one is triage, another one is gather, and they have very specific ways of running the agents and they both use loops because when it does the web search, you need to search for the information and come back to me, right? When it does the check calendar it’s gonna check the calendar until it find out what’s going on in my calendar and then come back to me, okay. These things are all kind of intertwined in this agent harness system. So if we come back to the system design, there’s something interesting I wanted to show you which is how exactly did the workflow finish from the beginning to the end from a time usage and parallel processing perspective. For the loop, an agent loop, for example web search, it’s gonna decide what it’s gonna do first, right, it’s gonna check out my GitHub calling tools one by one, right, maybe after the first call the agent decided okay we need to do one more call and then it called it again and then it checked the calendar and then it synthesized information for me. But in the graph example which is this, which is this workflow for gather information, it used multiple tools in parallel because we already told it you need these four tools, right, maybe each one of them spend different amount of time and then it did the GitHub first and the web search did the most amount of time, calendar check and memory retrieval did the least amount of time because it’s an instant or maybe because you did not need any memory retrieval at all and then it’s going to synthesize the information because it’s got a lot of context at the same time. So you cannot say so you cannot say graph engineering is replacing loop engineering because they are co existing. And you cannot say loop engineering or graph engineering is better than the other one because we need them in different use cases. A loop is something you need when the model decides what to call one step at a time, a graph is something like when you know the shape and you just want them to move together, okay, it really depends on the situations you’re building for. In your local files we have a Waku folder and then we have a graph folder and within the graph folder we have to find the graph engines which is literally a graph and you’re gonna add nodes which in our case could be web search tools, could be agent calls, could be MCPs, anything, right, and then you’re also defining edges which is, okay do where do we go after using one tool right, after the web search do we go synthesizing or do we go somewhere else right, the graph we also defined nodes which is basically saying what kind of things can be a node, right, tool calls, LLM calls, agent calls, router, these kind of things and then under this graph folder we also have another folder called workflows, you can see we have triage here right, remember triage was the chart we showed you which is it’s gonna classify if it needs to use some complex models to do agent calls or is it doing some calendar checking at the same time, these two things are happening in parallel at the same time and the code is actually very simple, you define these functionalities to make sure that the triage graph is working properly with this predefined workflows, right, you add node when you need to add more tools, you add edges by defining the initial prompt from start can go to either classify or check calendar at the same time. If we check out the gather tool as well, remember it’s the similar thing as our previous chart, you can scan the GitHub, website, check calendar, memory, okay, GitHub, website, calendar, memory, these are all the nodes and after that you synthesize it and then you decide if we should return the answer, obviously we’re doing the same thing, we’re building the graph here, right, we’re adding these nodes and we are adding those edges too. I hope this is easy to understand and you can feel free to add more dot py files here to make this graph workflows even larger, and in that case I would love to work with you and then you can feel free to contribute to this repo and be one of our contributors and submit your own workflows, because once you submit your own workflows and it’s approved it will be available here, if I type in slash graphs it’s gonna tell me that it has gather, it has triage and triage is the router, it’s basically gonna read the local files of these workflows from graphs and people can use it, this will be very cool and it will probably become a community if you guys are interested and feel free to be our contributors and also if you’re interested in talking more in depth of these concepts with us, if you feel you want to discuss with me about your workflows and any questions you have about system design about these agent harness all these kind of stuff, you can feel free to come to my personal website, seanchen.io and then click on join over here to join our community, I’m just getting started to do this because I don’t have enough time to answer all of your questions, I feel like the most efficient way is that I can host some live sessions with you twice a month so that I’ll be able to answer most of your questions and we can prepare some, you know, build sessions real time showing you my real setup and all these kind of stuff, if you join this community you will be assigned to a private discord and I will share more details there, including the original files of all of these design charts that I built in the past in real code, so that you can sort of open it in your own excalidraw website to learn about it. So last but not least, I think this is an important question we should ask ourselves which is, isn’t this just deterministic workflow from 2023? What is new now is that some of the nodes that we’re using right now are non deterministic, could be a LLM call and at the same time sometimes the model can pick the edge, alright, the routing is the way that you know you’re letting the LLM as a judge, do I pick a simple model to answer the questions or do I use a more complex model to answer this question and also you need some guards which a previous directional graph scheduler never did. These are buzzwords as I mentioned but buzzwords are viral for a reason, sometimes because of famous people, sometimes because it’s actually useful, so I hope this kind of videos is helpful for you and again if you have any questions feel free to ask me and I would love to answer your questions live in our community, just come to my personal website, seanchen.io and then there are a bunch of sources here looking forward to and if you love this project please give us a star on GitHub repo and I would love to work with you. Thank you so much for your attention, appreciate it.