Claude Certified Architect - Foundations – Prepare for and pass the exam!

#Claude Architect Foundations #AI Certification #Agentic Workflows #Prompt Engineering #Tool Use #Context Management #LLMs #AI Tools
💬 Chat with this Video
Ask anything about this video…
Hey, this is Andrew bringing you another tech certification course and this time it's the Claude Architect Foundations Certification. Uh, and so I think I might be only one of the only providers that actually has this course out and on top of that I've put in the work and done a lot of hands-on uh, labs in this course. So you will not only just learn the concepts, you'll be able to apply them uh, very effectively. And I think you're going to be really happy uh with the content because even if you are not utilizing claude and you're using some kind of other agent or AI vertical the knowledge here is extremely transferable uh extremely deep and extremely valuable. Uh so I hope you are excited to jump into this course as much as I had making it and I will see you soon. Cha chia. [music] Hey, this is Andrew Brown and we're at the start of your journey asking the most important question for us which is what is the Claude Architect Foundations course. So this is a uh certification from Anthropic and it will help you teach you the broad underlying concepts of building agents expose you to clouds models coding tools and SDKs. It's focused on the adoption of workloads for orgs or if you really need to understand MCP. Anthropic created the idea of MCP so they really want you to know it in this course. not that hard to learn. The exam code for this is CCA-f. There technically is no official exam code, but this is what everybody is going with. Uh consider this certification if you want to know how to effectively build aic workflows. You're planning to adopt claude as your primary AI driver within your org or you are part of the cloud the claude um partner network because it might be a requirement for you to advance within their network. Um but we'll continue on here. You can see the road map is really really expanding. Um, and so I just want to give you some uh tips here. So if you're going to take the Claude AR certified architect looking for my pen. Where's my pen? There it is. If you're take if you're thinking about taking this, take the Claude code essentials. There's a 30% overlap between them, but this one will get your feet wet and so you're not overwhelmed when you jump into this course. This is not an easy course despite them saying that it is. You need to have developer experience and I will help you through it. I'm a developer of 20 years. So you are in very very good hands. If cloud code essentials is too much then you should be starting with the genai essentials. And if you really are struggling here then you should be looking out for my cloud code from zero which is expensive but it's really designed to use the super plain language and to break things down one to one so that you can be successful. Um, in terms of the ecosystem, I've thrown in my Nvidia one in here because I believe that understanding how um these LLMs work uh like what takes it to deliver them at scale is very very important in data centers and that will help you understand if you ever want to bring your own model or just understand the costs uh involved. But you can see there's a lot going on there and uh you do not need to take the claude certified architect to do my uh claude code boot camp when that comes out. Um but you know it doesn't hurt, right? Let's talk about how long it will take to pass. Well, I would say if you're a beginner, it's going to take 30 hours and it might even take you longer because the concepts here are so new, even for me, that it was taking me time to basically understand them. And so for experienced people, if my course is 12 hours, even if you two times it, you're going to be taking 12 hours to do it. Um, so just consider that. So maybe average time 12 hours 50% lecture labs 50% practice exams and you know study once one hour a day should be a good pace for you. Don't do this in a single day you'll burn out and you won't keep the information but do not take too long as it will leave your mind. Okay. Um so what does it take to pass exam? do the the video lectures, but the main thing is do the hands-on labs. And it's hard because I cannot give you one-on-one instruction or one uh onetoone instruction because LMS are chaotic. They like to do things differently, but you should watch my videos and then try to figure it out yourselves. What I'm providing you is my developer knowledge, my developer troubleshooting, and my judgment in terms of what looks good and what doesn't. And so you're watching them as a reference to figure out how to apply them and if you're getting the code that you want. Uh the other thing that I would just say is that um I do have the code bases so you like it's all the code is there for you. So if you just want to run them and just inspect my code or even try to prompt it to make it better go ahead and do that but just understand I cannot give one to one instructions unless I spend a lot of time engineering this stuff and then we're losing all the learning value. Okay we got paid practice exams on the platform. We usually give you one for free. It's over there on exampro.co at uhcca-f. Where do you take this exam? Well, Anthropic is using SkillJar to um serve it. They technically have their own course, but I'm going to tell you it's not enough. It simply is not enough. Um and it's very much research based where I am giving you hands-on so you can actually apply the knowledge. Um, and so I it's a good pairing like if you want to just round out and have a second source, but uh you're going to struggle if you just use them as your primary source. And and I need to point out that um this certification right now at the time of this video is only available to claude partner network. So everyone just saw the name Claude certified architect and said I want to go get it. But you might not be able to get it because if your company doesn't qualify for this and they have crazy requirements to get in, not crazy, but you have to have at least 10 people in a certain size of company, whatever, whatever, and you have to be aligned. Um, uh, you might not be able to get this. And if you can't, Exampro has got you covered. Just take ours and generate it out. Um, pass it on our platform, our version of it. And until you can get it, then you can, you know, uh, come back to here if this ever becomes GA. and they might make this generally available to everybody not just in the partner network. So what is the content outline? Well, there are five domains. So we have agentic architecture and orchestration, tool design and MCP integration, cloud code configuration and workflows, prompt engineering, structured output, context management and reliability. Uh notice here we see claude code. This is not a cloud code course, but the middle section here has a lot of cloud code in it. So 30% of this content comes from my cloud code essentials. So if you've already taken that course, you are doing really well. So I think it's like basically half of domain 2 and all of domain 3 is coming from my cloud code essentials. But the new content here in domain one, especially domain five, are extremely valuable, but they're completely new concepts for most people. And so uh the only way I can make this content is I had to do it. In fact, I found that often the docs were wrong, the exam guide was wrong, the AI was wrong. And so only by doing it by going through the process did we find out the real truth of these tool tools. Um and so that will probably improve with time but you know having the real truth is you doing it for real. Okay. And so that's why we have so many labs. Um but yeah the domains are all weighted differently as per usual. The passing grade is 720. So it's much higher. The other ones usually there's 70%. This one's 72%. Um there are 60 questions and you have 17 questions you can get wrong. a huge pool of questions uh and lots of opportunity to get things wrong. It's just multiple choice. But despite being multiple choice, the questions are very verbose. Um it's like they're writing solution architect professional questions. I don't know why they did that because it just makes it really hard. Not in the sense that the question they're asking is hard, but the ability to parse it. And to me, that's a mistake, but that's the choice they made. Um the duration is two hours. You have a lot of time, two minutes per question. So take your time reading the questions and absorbing what they're trying to say. Your exam time is 120 minutes. Your seat time is 150 minutes. Technically, there's probably no seat time because they're using Skill Jar. Um as the as the delivery for their certification. Uh but you should still plan to review instructions. If there is an online proctor, there probably isn't. Uh and read and accept the NDAs or complete the exam and provide feedback. Okay. We don't know how long this course is valid for unless it becomes generally available to everybody, not just people in the Claude uh partner network. We're just not going to know. Um but anyway, hopefully that gives you a clear idea and I will see you soon. Cha chia. Hey folks, it's Andrew and I just want to give you considerations about this course. So in terms of requirements, we are not covering the setup of agent SDK or cloud code. I have that in uh another course which is my cloud code essentials course. The reason I didn't include it in here is um I just don't want this course to get be bloated and have repetitive content and so I'm trying to uh reduce the amount of share and so I felt that I have a very good robust uh setup in another course and also if setup does change I'll update in that course and this will keep this course uh fresh because I don't want people to feel that this course is out of date because the setup may have changed and so that's been separated out for a reason but it's still available to you for free and paid. Um, so just go look for that. The approach we're taking for this is we're going to walk the exam guide. I found that by just going through and trying to do everything they say in the order that they say it is effective learning um for this certification because of what they're trying to show you. And I would say that it's very important that we take an implementation focused approach. I know people are using the anthropic content which is very conceptual based and there's people failing because it doesn't stick unless you do it. So for me um I'm going to take an implementation approach because I think that will be the best result for you. Um and so the idea here is we will look at a code example and we will go implement it. Okay. And I did mention that anthropic does have free courses. They are very conceptbased. So they have really nice diagrams, but they're really not showing you uh implementation um or not enough implementation specifically for this um certification. That might change later on. Um but you know, I want to cover the gaps that are not being covered here. And uh you know, implementation I think is going to be what is going to be best for you, best for everybody. Uh and so that's what I'm going to do. Okay. Chowo chia. All right. So in this um follow along we're going to look at uh learning how stop reason works and we're basically learning also how to implement tool use. All right. And so what I'm going to do is make a new folder here. Um and I'm going to call this one actually before I do that just because I need to be diligent about this. I'm say get init add get add all get commit m uh init hello world because I just want to get us set up here. Okay. So, um I'm going to push this repo later. I'll probably make a video prior to this to show you where it is. So, you already know where this is, but at this point in time, I don't actually have it pushed to get. But anyway, we want a new folder here. And the new folder is going to be stop reason. Okay. And I want to describe what it is that I want to accomplish in here. So, um I'm going to make a plan here. I just like to call them plans. And I'm just kind of writing up ahead. And we're going to ask Claude to help us out because Claude knows a good enough about agent SDK. It's not always the best at it, but generally it knows what's going on here. So what is our what is our goal? Uh we want to show the user how stop reason works. So um by showing so we want to show the user how sub works within the claw agent SDK. Okay. So we need to see stop reason for uh tool use. We need to see stop reason for uh end result. We need to see how it's chained uh appended. How the results is appended. I want to use a weather uh tool use example. Uh we are implementing in Python. Um we want to use the uh lib SDK parser SDK parser to format logging information. Okay, so I'm going to go ahead and do that. And by the way, you know, if you get something different, this repo's up there. You can always copy my code and then try to run the same thing if you're not getting the exact same results, okay? because you're just not going to be able to do it unless we go the old school way and I write this by hand. And I can write the code by hand, but I'm assuming folks out there, you want to leverage Claude as much as you can and we will do that. Okay. But I totally am comfortable doing it the old school way. So I'm going to go here and say um please execute the plan for uh plan MD um and generate the code into the stop reason folder. Okay, I probably should have told it like the purpose of this is to show an example, right? And so we're talking about stop reason, but we're going to also learn about tool use here while this is going. Um, and so I'm going to pause here and then we will see what we come back with. If there's anything I need to accept, I will accept it back in just a moment. Okay, I'm just watching this thing go. And right off the bat, it's like it created a requirements txt with anthropic. I'm like, wait, that's not right. So, uh, I think we're going to have to help it out here. So, tab to amend. I'm going to hit tab to amend and say, uh, look, I shouldn't you be using using the for here claude agent SDK. This is what I'm confused about. And we'll double check this here because, you know, they're always changing stuff on us and we want to keep nice up to date here as possible. So I will just double check here as we can't just fully trust I guess we already have the tabs open here. We can't fully trust this stuff but it says claude agent SDK. So that must be what it is. The claw the claude code SDK was renamed cloud agent SDK. So that is prop the proper name and so it's confused on its implementation. I'll go back over to here. I said the claude agent SDK and so it's the first thing we see here. So, I'm just going to edit this requirements while this is going because we'll probably keep using this document. So, uh yeah, that's fine. We'll come you we'll come back to that in a moment. We'll just say yes for the session so it can work and so we'll be un under uninterrupted. And I'm going to go ahead and do this here. Yeah, you can use Python. Sure. And what I want to do here is just help out with the requirements. So the first thing is use must use the agent cloud uh cloud agent SDK. Okay. Must Python 3. Uh I mean that's pretty obvious. Python 3 uh must implement must use lib uh format messaging here. We'll go ahead and do that. And this might help a little bit. We are creating a code example to learn about stop reason scope. We are learning about agent claude agent STK and claude uh agent. Yeah, we'll just say that that's fine. Okay, we don't need that. And so now we've kind of adjusted that. Here's trying to run it in an environment. I don't know why it's doing that. Just use the local Python environment. No, I don't need to do it that way. Okay, that's silly. Um, and the reason I say that is just because we could create isol environments, but like we're just installing that one thing, and I don't want to be doing that all day every day. I'm already on WSL 2. I don't need any more isolation here. So, um, let's go take a look at what it's produced and see if this is even readable here. Okay, so we're going to go all the way to the top here. And right away, I don't like this because it's giving us um fixed weather data. So, I guess I should have been more particular and saying like, hey, go use an API endpoint for that, which is fine. But anyway, so here we have Claudian uh options and the the client. That's fine. We have a tool use block and a tool result block. Okay. And they have simulated weather results. We are defining a tool. Get weather get current weather for a city. And I mean this looks like a decorator. So a decorator in Python uh helps enrich functions. So this has to be tightly coupled to this. I'm not an expert in Python, but I know decorators when I see one. And so this is adding additional data that it needs to know about this function here. And so the function takes in args and then we're going to parse the args. Right? So here we're taking a city and it's going to look based on the weather data if it matches and then it's going to return that information. So we have type text um text result. Okay. Then we'll go down below here. And so we have logger helpers. Um I again I want to keep everything within my logging tool. So I'm not sure why we have that. We have stop reason annotation. So, I think what's going to help is looking at the main loop here. So, we have create SDK MCP server. Why do we need an MCP? Well, I guess we could do it that way. And so, I'm going to go over to here. All right. I guess that's how it wants to do it. That's fine. So, we have weather tools. And so, we add a tool and then we have MPC servers weather server options. So, you know, my thought as a as a programmer, as a developer, is like, why is it putting it into an MCP? I probably wouldn't want to do that right off the bat. So, there's that. Here's explaining the stuff. I don't need it to explain it. Okay, so here's the problem with this this program. Okay, first thing is like I'm going to go say stop reason here. Stop reason. Um the problem with this program is I don't want the program to actually explain how it works. All we are doing is outputting key uh outputs to observe. Okay, that's step one. Number one, uh the other thing is you implemented an MCP server. Do we really need that? to show tool use. I mean, isn't there isn't there something simpler? Something simpler. And then the other thing is like can't you use add API endpoint public to get weather data? So, we'll go off and we'll do that. While it's doing that, let's go look it up ourselves, okay? because there's nothing stopping us from reading the code. But I wanted to show you like because I keep telling people they're like, "Yeah, you know, Claude can do whatever." I'm like, "Yeah, but it doesn't know itself." And you still have to go look things up. So, what we'll do here is we'll take a look and we'll go to the API reference. That might be a good starting point. This usually what I do for projects is I go there, say, "Yes, I really need to make a ding or something so I can hear it as it's doing that." We'll go over to here and I'm going to see does it have any information here that might help us. No, not really. That's not going to be useful. We'll go back to the developer guide. Um, usually I just go straight to API reference and usually that has all the information I need. But this does not look good. So, we'll go back a second here. Uhhuh. Go back a second here. I remember seeing a lot of stuff here before. Where is it? I guess we'll just scroll on down till we find it here. So, what I'm looking for is that tool use implementation. I remember having like a bunch of boxes and saying like, hey, if you need to do this, you need to do that. Give me a moment to go find that. Okay. All right. So, one thing that's confusing like here I'm under tools. We're seeing anthropic, but there's also the agent SDK. So, which is it? Right? And so, that's something we're going to have to figure out in right now. So, just give me a moment to figure out why there's a discrepancy there. Hey, this is Andrew and in this video we're going to take a look at setup for both um agent SDK and Claude Code. Technically, I have them already both installed and so the process might look a little bit different. If you need it completely from scratch and seeing that process, you can absolutely do that by looking at my Claude Code essentials course uh which shows multiple installations on multiple machines. And if for whatever reason this is out of date, go to that other course because it will have the most upto-date way of doing that. So we'll go ahead and say cloud code install. It's going to be dependent on what kind of system you're on. So I'm on WSL 2. And so that's going to be with Linux. And so what I'm looking for here is the installation instructions. Um and so here they are. And so we have these modes. So we have native install, homebrew, and windget. And they recommend it. In general, people almost always recommend the in uh the native installs because they're going to install directly from the source or they're going to compile and be the latest up to date. If you take these other ones, uh the releases might be old and so you might run into an issue where you're having weird API issues because they're old and um uh yeah, I would just say go with the native install. So, I'm on WSL, so I'm going to go ahead and grab this installer here. I have a new folder I've made for for this course and we'll go ahead and install it. Again, it's already installed, but we will run in here so you have an idea of that installation process. So, it's just taking a moment there. See, it already says that it's installed and we have version 2.1. To launch up Claude, we're going to type in Claude. Okay. And it thinks I'm already logged in. So, I'm just going to log out here for a second. Log out. I might not actually be logged in. I actually didn't check. But uh what I'm constantly doing to see is I'll type in uh claude o status and that will tell you whether you're logged in or not. Um again in my cloud code essentials we have a lot of stuff that covers authentication and all these uh little things. So if you really want to know all of it you can go ahead and do that over there. But we'll launch cloud. I'm going to go ahead. It wants dark mode. Sometimes it'll ask me on setup. If it doesn't do this uh all these steps and you just type for/lo but anyway I'm going to go here to my subscription. probably one of the best ways that you can use claw because it's the most cost- effective way right now for learning. And so here it has opened up a new window in a Chrome browser. It has a weird looking Chrome here. Um, and so I'm going to ignore this one because it's weird. I'm going to go ahead and copy that. Make a new link. Paste it in here. It seemed like that was like an isolate Chrome browser running. I'm going to hit authorize. We'll go back over to here. Copy the code. We will paste it in. Hit enter. Okay, now we are successfully logged in. Enter. Enter. If you didn't see that uh that whole setup, you just type in login. It will do the same thing. Okay, so that's part one of getting uh Claude there. I just want to make sure that it is actually working. And so I'm just going to say uh I'll just talk to Claude here. Can you create me a readme.md file um that is completely empty in this folder. Okay. And so I'm going to go ask it to do that. Just making sure that it works. And we'll say yes, we can do that. We're using the set model down below here. We can change our models if we go here and type in like haiku and things like that. Um, again, as we work through implementations, I will change things and just follow along as we go here. And I'll go over to here. And so, we should have a folder or file. Um, I'm not seeing it. So, I'm just going to do code period. Sometimes that helps it open up into context. And so, here it is. Okay. So, that works. That's great. We'll go back over to here. And so, step one is done. We have Claude installed. It's working. Uh the second part is the agent SDK. So let's go ahead and take a look at that. So um we'll go over to Claude uh agent SDK. Here it is over here. And uh yeah, it's been renamed. Yeah, that doesn't matter here. And so we're just looking for the install. Here it is. Okay. So we have pip install agent SDK. Okay. I'm going to go ahead and hit enter uh here. Yes. Okay. And I don't think you can use the SDK. I was thinking about like can you use subscription? I don't know. I will always use it with the key as I was just thinking about that because um well normally you'd be using this in a production environment. So it would never be tied to a subscription, but I just want to check if we can use it in development uh with subscription in just a moment. All right. So the suggestion is is that we can actually use your subscription. I don't know if it's true, but we'll have to validate it. Uh but the idea is that if we are logged in with the claude uh CLI, so if we go back over to here, we'll have to test this in a moment. I mean, we are testing it right now, I should say. And so we'll do this. And so it says that I'm logged in, right? And so the idea is that if I was to uh use any kind of code here, it should be picked up. So I'm going to go ahead here. We'll make a new folder and we'll just say hello world. It'll be our first hello world of using the agent SDK. I'm probably going to try to use the agent SDK more than um cloud code. I guess we'll find out when we go through this uh course. But just because I we can use cloud code to help us write code for agent SDK, but um I think that this course especially this first section is really about implementation for um companies and things like that. So I think we'll benefit better driving it that way. But anyway, so um here we have an example code. I'm going to go ahead and copy this here and we will take a look at what we're looking at. Well, first of all, I got to make sure I have a file. So, we'll go here and this will be hello.py or just main.py, I suppose. Main.py. And we'll go ahead and paste this. Okay, I'm just going to zoom out here for a second. And so, we have uh the agent SDK. Okay, here we have a message fix uh find and fix the bug in the off.py. So, I'm going to change this to like hello world.rb. And I'm going to I'm going to make a mistake. puts puts hello world. Okay. And so I have a few mistakes here, right? So what are the mistakes? Uh it's should be puts, not puts. Uh it should have two um double quotations or singles and then it shouldn't have a parentheses or it should. Right? So we'll go over to here and say find and fix the bug in the hello world.b. Okay. And so we are giving it the option to read, edit, and use bash in order to accomplish its tasks. And then it will print out uh the results down below here. I'm just going to fix indentation. I like two spaces, not four spaces, which is what the creator Python wanted you to use, but was never enforced that way. And so this should do something if it works. So I'm going to go ahead and run it. Uh if you don't know how to run it, you could just ask cloud to do it. I one thing I would like is the requirements.txt. So, I'm going to go over to here and just say, um, hey Claude, we don't say hey Claude, but uh, in my hello world, uh, I want to add a requirements.txt that my main.py will need. Can you figure out what I need? Okay. And I mean, we already know what it is. It's right over here. Um, it's this. And so probably would just be that in an empty file, but I figured, you know, let's try to just get a little bit warmed up here uh for cloud API. Sure. Okay. And we'll give it a second here to get that implemented. Again, just if you're really really rusty with this stuff, we're just trying to get going here. That looks good to me. We'll say yes. That's all I was expecting. And so there it is. And so I'm going to go ahead here and we're just going to make a readme. And this one's going to be um you know cd hello world. You write your own uh documentation. I sure do if that's what you're thinking. Python hello uh hello or just main.py. So I have main.py. Okay. So what I'm going to do here is just quit out of here. No reason to waste credits for such such a simple action. and we will cd into our hello world folder. I'm gonna try to keep these um lowercase underscore. Just gonna go ahead and fix that there. There we go. Uh it won't let me do it. Well, that one's just going to be like that. I'll try to not do that in the future, folks. Um but we'll go ahead and we'll just type in python main.py. And it's saying there's no file there. Uh I think there is. Oh, it did change. It did change. It's not in my UI. Let's go ahead and give this a refresh. It was weird. like we don't we can't change it. And guess what? It did change it. That's fine. I I want that. Okay. So, we'll say uh Python main.py. There we go. And I don't see any output. So, we'll go back over to here. We'll just print some stuff. So, let's just say print uh running uh fix agent. And we'll go ahead and try that again. We're getting no output. Oh, interesting. Um, that's kind of strange for such a simple app. And I'm just going to say here, running main.py does not print to uh terminal. What's wrong? And I'll go in the front here, just type in debug. Debug is just a um I guess it's a skill that specializes in debugging, but this should work. I'm not sure why it's not uh picking it up. It's kind of embarrassing that this basic script is not working right off the bat. Like this print should be working. Absolutely. Um, my primary language is Ruby, so sometimes I have a lack of confidence in Python, but uh, we'll give it a second and it'll tell us what the problem is. Okay. And Oh, right. Yes, yes, yes, yes. Well, did you even have that over there? Oh, I missed it. Okay. And that makes sense with async.io. I actually have a coding course I never publish where I cover async.io. So basically um if you have asynchronous stuff you have to then run it within the um uh the as async tool is how it works. So that's good that it caught that. We'll go ahead and say yes. I don't need it to run it but it might try to run it for us. Great. And so I'm just going to stop this here. We'll type in clear and we'll go back and hit up. And it now executes um which is fine. So, here we have a bunch of stuff, but it's kind of hard to read. So, I'm going to go and take this here, and I'm going to feed it back. Oops. Feed it back here. We're going to get set up here. So, I'm going to go ahead and just say, um, back to Claude. I'll go back a level. This is where we really should be. Every time you trigger Claude, it creates a project in your home directory. So, I wanted to try to stick in the same place. So I could go ahead and just say um so I got back uh data for my um hello world. Hello world main pi but it's not human readable. I'm going to change this to plan. I hit shift shift tab. So now and hit it again. So I'm on plan mode. uh uh can you tell me how we can make the uh this output useful to a human and can we create our own uh Python uh library for parsing it? Okay. And so I've given it the format and I mean it might come up with something really simple like uh pretty print where it will just print the structure. But what I'm hoping is that maybe we'll have this little file and then we can uh use it in other places, right? So, I know it seems like we're getting a little bit already advanced, but that's just how we roll here. Let's go ahead and hit yes. I just wanted to have full access there. Notice why I said yes always. If I go over to here, it added this. It says always let cloud API to do stuff, which I don't remember getting cloud API before. I just remember it working. So, I'm not sure why it needs to do that now, but uh that's fine. And so it's off to the races. Uh trying to execute here, which is fine. I don't want that. Microsoft Foundry is always popping up on me. They're like, "Hey, do you want to use Microsoft Foundry?" No, I'm using Claude right now. Go away. Uh what is it? Uh what's the insult on Microsoft these days? Mic Microsop Microsop. [laughter] And so, um what we're looking for here, it's really taking a long time here. It's not that complicated what I'm asking for it to do. I'll pause here and we'll see what it comes back with its plan. Okay. All right. And so I think we got a plan back. Let's take a look at the plan. And we have the hello world main pie script uses the claude agent SDK and calls the print on each yielded by query. This produces raw Python object repo strings. Um the user wants human readable terminal output a reusable Python library. That's true. And so here it's saying SDK uh init.py um formatter main.py. PI and then we have SDK parser format. So here it's suggesting the format. So each handles these parts. It puts the parser there. Export a single format message. And by the way, you know, if you're like, I don't have the exact same code as you, Andrew. This repo will be on GitHub. I will show it earlier in the course. So you can grab it and then you can just grab the parts to have par. So So like this thing, if I'm using it throughout the course, which I don't know yet at this point of time, then you could grab that code and use it. Okay. But it says export a single format message string. And that looks good. The only thing I would say is like it's pretty close. Good. But I plan to use this library in multiple uh folder projects. So maybe it should live in um a lib directory at the top of the project. and make sure to give me a readme so I know how to import it for uh projects within this repo. Okay, so we'll go ahead and do that. And that's the only change I'd like. And so yeah, you have to read your plans if you want to get code that you like. Um and so we'll give it a moment there. I didn't tell it to go execute. It's supposed to update the plan, but we'll give it a moment to come back here. Okay. All right. Our plan is back. And by the way, people don't complain if you see me doing this. When I made my clock to essentials, people were like, "Andrew, you're right. You're using the thing and then you're pausing, whatever, whatever." Like, "What else would I be doing? This is what we're going to be doing." So, you know, don't don't give me those comments, okay? Because that's the work. Anyway, let's take a look and see the plan updated. So, here is the lib SDK parser and we have the net formatter and the readme. Uh, I don't know what the output is. Like, it'd be nice to be like, what does the output look like? Um, but I would rather just test it and find out. Explain what the library does. Yeah, I don't know what the output looks like. And we have a verification uh set up here. So, we'll go ahead and say yes. Um, auto accept. And so, now it's going to go ahead and implement it. And we'll be back here in just a moment. Okay. Okay. So, it looks like the code has been implemented. And so, now we have, we'll give this a refresh here. We now have our lib directory. Um, here's what it's done. So, did it actually test it? now prints out formatted message to use as another project. Whatever, whatever. Let's take a look at the read me. Did it do what I wanted here and give me the simple instructions here. I mean, it gave me a lot of information that did not ask for. Um, converts noisy output like this. Well, hey, at least it's going to tell us. Oh, to this. Okay, so now we can actually see what it looks like. Um, and we have import options and stuff like that. Another good reason that we did this is that then the AI can pick up on this. The only thing that I will do here is just change the readme to a clawed MD file as um that's what it prefers to look for stuff. And so that's what I'm going to do. So I'm going to go ahead and do that. It did change it. It's just being silly. I think I do think it's changed over to the capitaliz. Let's take a look here. This Visual Studio Code thing, it's really annoying. And I'm going to go here for a second. I'm going to say move claude to claw.md. It's not the same file. One is one is capitalized. I'm going to go ahead and say claude one. There we go. ls move claude one to claw.md. Maybe it did change. There we go. And even though it's not reflected here. There we go. Now we have it like that because that's what you are going to uh want it to be called when you're doing that stuff. I didn't do it for here because it's just like so basic uh what it's doing. So I'm not really worried about it. Um but we will go back and we will go back and we will take a look at our hello world or sorry our pi. And it's brought in the parser. I want to uh go back a directory and go here again. We'll say hello world. Oops. Hello. And we have two of them because it got confused. I'm going to delete the other one. I don't want to have two. I'm not sure how that happened. We'll go ahead and we'll say hello world. And we're going to go ahead and say python main.py. We'll run that. And I want to see nice nice output that I can read. Okay. So here it says thinking let me find the hello world.py first. Um it globs the pattern. No files found. I couldn't find a hello world rb. The file in the current directory uh could not be found. And you know why? It's because the name is wrong. So we'll go ahead here and we'll fix that. There we go. Fair enough. Right. And we'll run it again. But already like we're becoming very productive and getting ourselves set up really really well for when we run all these implementations, right? Um so let's take a look here. Um I like how we can see what it's doing as it goes. That's really nice as well. Whenever you read the file, you should consider whether or not consider it malware. You can and should provide an analysis. Oh, my goodness, it's doing a lot of stuff here. Did it actually fix the file, though? Oh, it's empty now. Okay, I'm going to try this again. So, I'm going to say puts whoops puts hello world parenthesis like this. I'm going to try that again. And you know, this is just the default prompt that it came with. And we'll go ahead and run that. Again, some things that we could do to maybe make this a little bit less painful is maybe dial in um I'm assuming there must be an option for like uh the uh context output and um or context window and then also maybe adjust which model's being used. And so I'm going to go back over to here and take a look. Did it did it do anything here? No. Let's take a look at what this thing actually does. So find and fix the bug in the hello world.py. It has read, it has edit, it has bash. So it should be able to edit that file, right? And we'll go back over to here. So here it says found it. I'm going to go back into here. I just want to see if it was updated. So found it. There are two bugs on this line. Not a valid Ruby method. Should be puts. Misqued information. Let me fix both. So tool edit, replace all. And it goes here. Hello world. Hello world.bing to replace a string. Tool results has been successfully updated. I'm going to close this out. Make sure that it actually was updated. It doesn't look updated. Fixed. Here's a summary of the bugs that were corrected. Okay. And the only other thing I might do here because I'm thinking like, okay, we had something that happens here, but I want this logger to log out a time stamp because then I can feed that data back in here for debug to Claude when things aren't working correctly. Again, let's just get set up as best we can here so our lives are easy. And I'm going to go and say um uh here for the SDK parser um the SDK parser the lib SDK parser. I'll just sell it. I want my lib SDK parser uh to dump logs in a log directory uh relative to the project that is using it. So um let's say I run my hello world hello world uh main.py. I want a log in the um hello world logs and I will have like time stamp like human ISO 20 ISO date um human readable time stamp.log log. Okay, we are for each run of main we get a new log. Okay, so um that's what I want. And so when I run so I run in hello main. So basically anywhere. So yeah. Okay, there we go. So we'll go ahead and hit enter. And I want it to go and update that. And so that will give us an easier way because right now it's not working and I want to know why it's not editing. And so that will uh make that work really well. I'm going to say yes again for these. Um I tend to just kind of accept these as they go. Um it's just a means to how we can do that. It's weird because I said yes and then I thought oh maybe for that session that's what it was saying. Okay. But we'll be back here with the newer code and then we'll test it out. So here we have a code update and again remember this thing here. uh you can make your own but if you want to have par with me so things are one to one when you're doing the other parts I mean your code's not going to be the same but at least this part will be the same then uh you know just grab this from my codebase and put it in your your stuff here so capture the time stamp get the logs and write um sure yeah that seems fine we'll go ahead and do that and yeah and so now it's just we have format message log message right so we have two different things which is fine and then it's bringing it in here. So we have log message. Okay, sure. And we will go ahead and print that. Yep. It's going to test it as well. So that seems fine. I'm going to go and quit out of this. We're already in the hello world. We'll go ahead and run that. And I want to go here, give this a refresh. We do have logs. So there it is. And so now if that file has not changed, we can now feed it back into it. And so that's going to make it really, really useful for debugging. Okay. So here I'm going to go back into I'm just going to go back a directory clot. I'm trying to stay in that one. And I'm going to say debug. Um so I'm going to provide the log. So say um describe the issue. So um I am using agent SDK. It's supposed to edit a file. It does not. Um here uh here check the logs and help me. So we'll go here and say hello world logs like that. Okay. And the idea is now like it has logs. So like it has all the information about what it needs to to figure that out. Um and so we will wait a moment here and see what we get. Okay. All right. Let's take a look here. So um what do we have? So the edit actually did work. The logs show the edit was successful. The file currently confirms this. It already has this. The likely reason it doesn't edit uh when you run it is because the bug is already gone. No, that's not the problem. So, I go over to here. Oh, it's fixed. What? [laughter] Well, whatever. At least we have this set up really really nice. I'm not sure what happened there. Maybe it's just like a um a caching issue here with Visual Studio Code, but it did force us to have this nice setup and have a debugging process. So I would say that we are set up for um agent SDK and cloud code. So if you're at this point too, then you are set up as well. Um if you need more setup instruction, if this is not enough, I got more in that cloud code essentials course which is very specific about the tooling where here we're looking at um implementation of the stuff that um anthropic wants us to learn. Okay, there you go. Let's talk about what is claude code. So claude code is an agentic coding tool and it reads your codebase, edits files, run commands and integrates with your development tools. You can uh find cloud code at code.cloud.com. It's available in your terminal ID, desktop app, browser, and more. So it's across multiple services which we'll talk about. Uh and so it's going to look a bit different and work a bit different depending on where you use it. Here is the most common way to use it which is via the terminal and probably the most natural way to use it because it is a CLI tool. Uh its use cases include things like automating your workflow uh uh uh you keep putting off. Build features and fix bugs. Create commits and pull requests. Connect your tools with MCP. Customize with instruction skills and hooks. Run agent teams and build custom agents. Pipe scripts. Automate with the CLI and work from anywhere. The thing that people are really interested in is the agent teams where you basically have a bunch of um agents working together in a team uh to accomplish a task which we definitely cover in this course. Um so look forward to that. Uh the main thing is that cloud code is a CLI program. It's a code harness. It's an agentic coding tool but at the at the end of it it's just a CLI program. Okay. And so by nature it runs in your terminal. Um, cloud code is specialized to write code, but it can also write docs, run builds, search files, research topics, and more. And cloud code uses an agentic loop, multiple models, specifically the claude code models. We have tool calls uh to achieve your desired goal. We are going to dive into all of these things. Okay. All right. Let's take a look at the agentic loop. If you've learned about Asians, you probably already know this, but we'll cover it anyway and specifically in the context of cloud code. Um, so there's some very specific things or configurations for it. Um, and so with an agentic loop, the idea is that you are going to invoke cloud code. You're going to ask it to do something and that's going to start the loop. Uh, and so the loop is over here. And the idea is that at the start of your request, there's going to be a very specific model being used. It's going to be opus haiku or sonnet probably sonnet as that is the default and it will continue on from there. Okay. And there are three phases that um uh the cloud code utilizes to execute its agentic loop. We have gather context, take action and verify results. And it loops in on itself. So it's going to continuously do this until it achieves its goal. Um, all of these things can call out to tools. So that is the idea of where it will call out to something that it doesn't know how to do um or knowledge that it does not have and it's going to reach out to be able to do more or just interact with your system, right? Because the LM is in its own little box. It would have to call out to a function in order to interact with uh your developer environment. Okay? And the great thing is that at any time you can interrupt this loop and give it corrections and then eventually it will decide that it has met the goal or needs more feedback or it doesn't want to run anymore to not waste your money. Uh and that's that. But we will dive in a little bit more on the tool calls and the models for this. Uh okay let's make sure we understand what tools are. So tools are code functions that an agent is aware of and can invoke to complete their tasks. And when I say they're code functions, I literally mean it's just a code function. If you know cloud computing and you've ever uh used a llama before where it's an isolate piece of code, this is what it is. Um, and so the reason why uh an LLM needs to interact with a external function is because it can only do so much within uh itself, right? It can just produce text. And so it needs some way of interacting with external programs or maybe there's something that is uh something that is deterministic that you can use code for and that's what it will use tools for. So let's use an example of uh a tool that might be called in each stage of the gentic loop for clawed code. So let's say it's trying to gather context. Um and let's say the prompt is trying to fix a failing Python unit test. So for gather context, it may attempt to read a file. So it's going to try to read the test payment.py. The um agent knows what tools are available to it. It knows the name of the function, what its inputs are, and what it expects back as output. Okay, so that's already rigged up for it. But here for gathering context, it's going to read a file, which is the test file. And now it's going to take an action. So it's going to go ahead and try to edit the file. So it will need to know where that file is and what change to be made. Then it's going to verify the results. So it will run the command pi test and then it will expect an output and track what that output is. Okay. But uh that's just a very simple example of one prompt through there. If it helps, we're going to just look at more examples. Not the functions themselves, but just what could be in each category. So for gather context it could be reading files, searching APIs, querying databases, uh codebase scanners. Technically this is rag right here. So retrieve uh retrieval augmented uh generation where it's going out and grabbing data from a database to enrich its context. That's a rag. Okay. Uh we have system state queries for that. And I don't really even talk about rags in this course because it is the concept of agents and stuff like that, but it just kind of seamlessly happens here. So we don't even think about it when we're working with cloud code. Okay. But for take actions, it can edit code as we saw, run a command, write files, call APIs, execute scripts. We have verify results. So we can run a test, we can compile code, we can query output, we can expect logs, we can compare results. So the cloud code has built-in tools uh in five categories. They have file operations, search and find, execution, run, web search, uh code, uh code intelligence. So within cloud code, can you make your own tools? Um I believe so like in the context of skills you can. I literally can't remember at this point, but if we can it will be covered in the course. If we can't then you just won't hear me mention it. Um but anyway that is what tool call is and it's happening underneath and it's really driving a lot of the interactions without tools no code would be changed right nothing would be happening it would just be talking to you but there you go okay all right let's talk about u models in particular for the agentic loop specifically for clawed code and that's the fact that when it executes it's going to use the same model for all phases of the agent authentic loop and so you have that opportunity to change it at that point in time. Uh you have different model choices. You have the default option which is just going to do its best guess in terms of what it should use. You have sonnet um which is great for daily coding tasks. You have opus which is for complex reasoning. You have haiku which is fast and efficient for simple ones. You have sonnet 1 million. So this is where you use sonnet with a 1 million token context window for long sessions and then you have opus plan. This is a special mode that uses opus during plan mode then switches to sonnet for execution. Okay, so there is some variation there but for the most part they're always using a single model. Um there are three levels of of models and we basically just covered it but we'll cover it again. So you have claude opus. I I think of it as really slow, really smart, great for difficult tasks. You have Claude sonnet all around well balanced the goldilocks of models so that's what you're going to be mostly using and haiku really fast really dumb great for general tasks if you are using the subscription model it's very hard to gauge uh usage between these three models whereas if you are using the API you're getting token usage information so you have a better idea of that spend we do have this graph over here which is a bit dated because it's saying like three and 3.5 and three you already know we have something newer But generally, Haiku is, you know, intelligence and cost all the way down here as it suggests for Opus. Um, it's probably way higher now. So, it's probably way up here now. And, uh, Sonnet is probably in the middle. Okay. But, um, to really understand these, you just really have to use them and figure out their tasks for them. For the most part, I've just been running Sonnet and have been having no issues. But, some people say that if you move over to Opus, it's extremely good. But again, you need to drive this stuff and figure it out. Okay? All right, folks. I'm just going to say it again, just so you know, we are walking the exam guide. So, notice here at the start, domain one, they were talking about stop reason. That's why we're talking about stop reason. Um, and I just want to make it clear like this is going to be the best way because as we work through this, we're going to uh like talk about it then use it, talk about it, then use it, talk about it, then use it. And then that will accumulate and it will make total sense to you. Okay. Um, so I know feels really random just jumping into stop reason without talking about agent SDK and everything around it, but I promise you this will work. Okay. So let's talk about stop reason. So stop reason is the reason why the claude agent has stopped executing its loop. And there are two different values that can come back from uh the uh the cloud agent. Okay. And when I say cloud agent, I don't necessarily mean agent SDK. I mean whatever the thing is uh that they have on their server that we're not privy to that is running their agent. Okay. And there's two values that will come back. We have tool use uh tool uh use. I already have a spelling mistake. You know it's not an Andrew Brown course if you don't have a spelling mistake right off the bat. tool use and end turn. Okay. And so the JSON data returned from a request to the agent will have that stop reason value. So let's take a look at some returned output. So here's an example of of um a stop reason. And so here it's saying it stopped because of tool use. So this is when the agent stops with the intention to call an external function. If you do not know what a tool is, I cover this in my Claude code essentials. But the simplest way to understand it is that it's an external function. Okay, the idea is that you have uh the agent and the agent uh is in its own little sandbox and to reach out it has to talk to um uh tools functions over uh communication channel. Maybe it's gRPC or uh HTTP. I'm not actually sure. Uh it doesn't really matter. But the point is it's calling those functions and then those functions are able to do something and then bring back output, right? And so the idea is that um the idea is that you prompt your agent saying hey I need you to go do this stuff and there's tools that it's aware of that it can do and it's going to trigger those tools and if it does uh behind the scenes it's going to return the stuff saying tool use and then we will see um that stuff there. Okay, it doesn't make sense it will make sense and we go to implementation. Another reason for stop will be end turn. So this is when the agent has decided to return you a result because it's done. And so here we have if you carefully look at the tool uh clearly someone's asking about the weather. So it says uh like I'll say like I hey can you tell me what the weather is in Winnipeg. I don't live in Winnipeg by the way. I'm in Scriber Ontario. That's a different Winnipeg is a different province but that's what I used. So here it says let me uh let me check the weather for you. So that's the tool uh replying or maybe the agent replying there. And then it's calling the tool use and there's a tool called get weather and the input is Winnipeg from what it extracted from the user and later on like it will end the turn and return that information. Okay. Um so the thing is like how does how does this go from here to here? Okay. And this is going to come down to the appended tool use. So the idea is that here we have a message from the user. It says what is the weather in Winnipeg? And it says, "Okay, let me check the weather for you." And so the idea is that we do that and we're doing the tool use. And the idea is that this is going to output data and then we uh append it back into the conversation, right? That's all we're doing here. Okay. So here you can see the tool use. Uh then we have our um this is the tool results. I feel like it's supposed to say uh let's go back here a second. Oh, stop reason. Right. So some reason will show up somewhere else. But anyway, the point is we'll we'll see that when we look at the code. Okay, but the idea is that whatever the result is, we're appending it to our message conversation. Um because what's in the messages is not the same of what is being outputed, right? And that's why we don't see um stop reason within our message thread. That makes sense. Okay. So um anyway, so when Claude returns a stop reason uh which tool use to the program, the program needs to parse and send the data to a function. The the function will return the data. Then you append the result of that data. So, let's go do that now. Okay. Hey folks, it's Andrew and we are going to learn about stop reason. Uh, and I want to point out again that we are walking uh the exam guide as the method to which we will learn. Um I'm doing this because again I think it'll be the best outcome for everybody here and I do believe that it's more important to make sure we validate all these things actually work as expected and the only way to do that is to do it. So uh we'll go ahead and make a new folder here. This will be for stop reason and we're going to attempt with uh the API right now. So right now I am using the API with anthropic. I have some money loaded up on there. So if you're not doing that you're going to have a hard time testing that out. As far as I'm aware of, there's no free tier for the API usage on the platform. Cloud.com. Um, and so if you do not want to spend the money, even though maybe I don't know, like maybe we can cover this all in five 10 bucks. I won't know till the whole course is done, but you know, I would strongly recommend load up five or 10 bucks and see what mileage you get because it'll give you an idea of how fast the consumption is. I think I was already I had like 10 bucks loaded up and I'm already halfway through it because I was doing other stuff with it not related to this course. But um we will try to monitor our spend as we go here. And so what I want to do is I want to show off um stop tool use or or sorry like uh stop reason. And we'll go ahead here. We'll make a new main.py. Since we already have some base code here, we can go ahead up to this one. I'm going to copy it just to get us off the ground. Uh and it didn't cost us any credits either [laughter] or tokens. We just copy paste it. Right. if you can do it, save yourself some money, right? Um, but anyway, so here we'll load in the anthropic key. Um, and we do have a function here. I'll just take it out of the function so that it's a little bit easier to work with. And let's go and pull up the API. And we might be able to ask it to um uh give us information, but I would rather just go ahead and uh take a look. So here, we'll go over to here. And what I want just a moment. What I want to find here is the documentation um specifically for tool use. And I know it's here somewhere. I would I would say I just do not like uh the way any of this is organized. I do find it very hard to find anything in the API. Um but give me a moment. I will find it quickly for us. Okay. One thing we probably should do so we just get better code is we probably would want to put it into um uh something that's async as I know that's probably more ideal. And I think I'm just going to go ahead and do that uh very quickly here. here. So, I'm just going to grab this code. Again, don't have to spend any tokens. It's right here for us. Um, and we will go ahead and grab this here. Okay. Here. And I guess we'll be ending up putting this back into a function. So, I'll just grab this like this. Okay. and we'll indent that. Um, and then we have our little async call here. So, this one's a little bit different. In fact, we could probably just grab the whole thing to be honest because we're just going to be working with something basic anyway. I think it's actually the same thing. The only thing that's different is the name of the um model that's being used, right? So, again, you know, try to maybe use one that's cost effective since we will be testing out a lot of stuff here. And I'm having a little bit of trouble copying this. I'm going to go here and just paste it up as a value like this like model like this and then I could just do equals there. I'll have less of an issue copy pasting. Okay. Um and we will go ahead here and grab the stuff out of here like that. Okay. And I think this uh this is a little bit different. So we'll grab this line. And folks, we are learning by doing it manually. It helps us see what's going on. Okay, great. So, we now have one that is using async. And I'm going to go ahead and just go into our stop reason. And we will go ahead and execute this. Um, I don't know if async is part of Python. Let's go find out. We'll just run it and see. It is not. So, I'll go ahead and just grab this here. Requirements.txt. And we will drop this in here. I'm going to assume that's what it is. Like that. Okay. And then we'll go ahead and do a pip install. pip install-r requirements.txt. And we will get that installed. Now, let's go ahead and run that. See what we get. Um, AIH. Okay, maybe I called it the wrong thing. I think it even told me that's what it was called. So, we'll try that one more time. We'll run it again. To use this, you must have installed the package and extra. Okay, let's go ahead and do that. All right, let's ask how to install this. Okay, so I'm going to go here, claude debug, and maybe you can help us out here. So here uh this error is a Python dependency here. Anthropic. Oh, that's why. Okay. So what I'd probably rather do is take this approach. Sure. We'll grab this, go over to here, paste it in as such. I'll just ask like can you Okay. Yeah. Update the requirements.txt. The only reason I I didn't just do that myself is looks like the indentation was wrong and so I just wanted it to correctly put it in. We'll just say yes for the session because it had like a little set value in there and I wasn't sure like oh two. So it's saying move this to to that. Okay. And so that was my confusion. Great. We will close out of this. We'll go back and we'll hit up. Uh we got to do pip install. Pip install. Right. There we go. We'll go ahead and run it again. And so now we are getting output back. All right. So we are now better set up. So what we want to do is set up tool use. And I'm going to again find that here for us. Okay. So we've scrolled on down here and we have tool use. So the SDK provides support for tool use also known as function calling. And the SDK provides helpers for defining running tools as pure functions. So you can use uh the beta tool option. Okay. And so here we have it here. Um and that's probably fine. I'd rather do it at the lowest possible level. So let's see if they actually have that as an option here. Okay. And so this is the actual isolate page about tool use that I was looking for before. Okay. And so what I want is a full example of the tool used. So that's what I'm looking for. I know there's that beta tool, but I would rather if we can have the full thing. So the smallest possible tool using program, one tool, one message. Okay, so this looks promising. All right, so here we're defining a tool and then in here we have our tool choice. And then we describe that here. Okay. And so what I'm trying to figure out here is how does it align up the function with the tool, right? Because here we have a tool and the idea is it's going to call this and it's going to provide that input and then we're going to get that information back. Oh, right. because this is where we would leave the agentic loop, right? And then we would parse it. Okay. Okay. So, what we'll do, um, I'm not a huge fan on how complicated this tool is, but we'll try to write one that is very, very simple. So, I'm going to go all the way to the top here and, um, I'm going to just fix the indentation here. I'm going to go ahead and write tools. Again, the reason we're doing this by hand is just so that the information syncs in. Of course, we could just generate this out. And I just want a very simple tool. So, I want a tool. So, this will be a tool that adds two numbers together, right? Very straightforward. And then we'll say description. Oh, that's that is the description. And actually here it should be like uh use this tool to add two numbers together. So, I'm being prescriptive to say like, hey, make sure you say it this way. There's actually a reason for doing it that way. Uh that way it helps it to know how to select the correct tool. I think we I know we covered in the cloud code essentials, but we might also cover it in this course. And here I'll just be like add to numbers. This is obviously something that the agent would be capable of doing. So it might make it hard for it to know. So maybe what we might rather do instead is is like um uh magic like magic eightball instead. Uh when the user asks a yes or no question um that is uh what's the word like just know fortuneelling question call this function. Okay. And so it doesn't matter what the input is because we're not really going to process it. Um but we'll get the idea across here. So here, by the way, we have to do this. Bring this up like this. And here we need to provide the input schema. I'm literally just looking off screen of what is going on here so that we get an idea of it. Input schema. Don't worry, I won't be typing everything by hand, but I just figured like early on here that it wouldn't hurt for us to do this. Uh, and then once we've done this once, we're not going to type code out like this because it'll take forever, right? So, say properties. Can't spell that word here. Properties. And from here, um, we just need question really. Okay. So, we'll have the question here. Type string. And so really it's just feeding in the question. The question actually doesn't matter. We're not going to actually use it. And then down below here, uh we need to have our uh whether they're required or not. So we say required. And this is going to be question. This looks a lot like um pedantic or schema whatever the schema format is called. And so this is looking fine. There we go. Common missing there. And I'm just checking if there's anything else that it needs for this. Nope, that looks like it. And so we have tools and tool choice. Okay. So we will go back over to here. And in here we have uh some options. I rather have the model on the top here. That's just me. And we're going to say tools equals tools. And then we're going to have tool choice. Here we will talk about tool tool choice later. But here we can um force it to use it. So, it's auto. I don't know what the other one is. If it's um whatever, but we can actually force it to use a tool. We'll talk about that later. But we'll just explicitly set to auto. And so now we put a question. So, hey Claude, uh will I be a billionaire living on the moon? uh living on uh on Mars in 2026. And so the idea there is that it's supposed to help it uh trigger that. And so we have a single tool here and the idea is that we want to see that tool get called, right? Um and even here you can see that they are outputting the stop reason on the response but we will um output the entire response not just the um message content. So let's just carefully look here. Actually the message content is that they just call it response. And so I'm just going to change a response. I kind of prefer that as a name response. And then we're going to get a uh a mess of of information here. Okay. So, and this one says it's not completing. Was not closed. We talking It's right here. Is it that one? Is that the problem? Nope. Anyone see? Oh, you know what? Coma's missing here. There we go. Okay, now that we are good, um, let's go ahead and give this a run and see if we get a tool call out here. So, we go ahead here and we're going to run the the Python.mmain. and we get information back. So we have our message content tool use block. Notice there uh will I be millionaire magic eyeball. So it is calling the message. Now we can make this a little bit easier to read out. Um if we were to format it. So there's probably a way to pretty print the structure. I'm going to go ahead and ask Claude for that. Um I am printing the response from uh anthropic in stop reason. I might already be in that directory main.py. Um, can I pretty print pretty print the response so it's uh formatted for easy reading? I don't want it to like go ahead and make a whole thing like we have the parser for the agent. I just want something that is uh a generic pretty print thing. Ruby has it. So, Python has to have it. And maybe it might be dumping it to JSON. Yeah, okay. That's exactly what it did. So, and that's fine. That is a method of of doing it. Um, other other ones have like actually a pretty print feature, but here it's just going to dump it to JSON. Okay. And so, what we'll do is we will stop that here. And we'll go ahead and run this again. So, now we actually have something that's readable. Okay. So, let's take a look at the code here. Um, and so this is the response that's coming back, right? And so here, will I be a billionaire living on Mars 2026? And it figured out that it should call a tool. So here we can see it's going to call tool use here. And notice at the top level here, stop reason tool use. It reasoned that we should call a tool. And so it's going over and doing that. And notice that it figured out what to extract out to put into the inputs. Okay. So that is what is happening there. Um so now what we need to do is we need to do the next step. Okay. So that's good for the first step. The next thing is we want to um do something with this. And I'm going to assume that we're going to have to parse it like saying oh the tool is this right? And they probably have this right in here. Um, so we go here. And so they have a run tool function. Right. And so I'm just kind of looking through here to see how they've decided to do it. Ah, here we go. So we have create response loop until the claude stops asking for the tool. Okay. And so here is a way of doing it. Pretty sure this course talks about looping. I'm pretty certain that um this is the way that you want it to work. So, we will uh just carefully look here. And so, I'm just trying to make our code a little bit easier to work with. So, um I'm thinking about this. So, what I'm going to do is paste this here like this. And I'm going to see if I can just refactor this out really quickly. So I'm going to say defaf um this will be call or send message or invoke. I'd rather have invoke here. Invoke. And we'll go ahead and do this. And we'll bring this up here. No, I don't know. I'm going to leave it alone right now. I'm just going to keep it nice and simple. Let's not complicate things. Okay. So, um what we want this to do is we want this to loop uh until it has this. But I don't see any external loop here. This just says while this loop until Claude stops asking for the tools. Well, where's our loop? Oh, this is the loop. Oh, I see. Okay. So here we have a response that's created. Actually, no, I don't understand what just give me a moment. Okay, my confusion with this code is that this is a this is a for loop, right? And so here it's returning back a response. And so that response structure to me is a Python object. And so at least that's what I think it is. And so it's iterating through this. And the thing is like while there, oh, as long as there is a tool use, continue the loop. And if there are no more tools, then stop because there could be more than one tool returned. Okay, so now I understand what's going on. That makes total sense to me. So what we'll do here is we now have um our loop here. It's going to iterate through this um this dump here until we get that information. And we still want to print out our client here. That's fine. I'm just going to indent here. So we are on the uh interior here. Okay. And so this is where we want to start processing our results. So they have this block here which is getting the actual two use tool use extraction assuming that that is correct. And then I'm just going to go ahead here to say print tool use. I think it's uh was it S? What is it? S parenthesis S like that. I don't know what it is. Um and so just say print tool use. I'll just keep it simple. I'm not trying to remember my uh my Python right now. And from there then we have the results and oh that's where it run the tool. Okay. So this is where I want to stop right now. Okay. So, and this is stuff that goes in the loop. There we go. Okay. So, here the idea is that it should loop and we should get one tool return. So, we'll go ahead and run that. And it's looping forever. So, I'm just going to stop that there because it's never ending. And I think maybe the reason why is that it might not be processing it. So here, that's that's why I was confused. I'm like, how's this ever going to stop? So this is what I don't understand. So I'm going to go ahead and grab this. Go over to Claude and ask them. Actually, we'll give it the whole code sample here. What will stop the the while loop? Because to me, like right away when I looked at I was like, what stops it? And I thought maybe oh when it hits something that it doesn't have it. So the while stop is when the stop reason is no longer tool used. This happens when cla decides it has enough information to get the answer. In this specific example, this occurs when claude has the create answer for. Okay. So but if I go to mine here like this. So why did mine loop forever? It's like I'm missing something here. because you never update the response inside the loop. Oh, okay. So, we will go back over the code. I did not notice that there, but we'll go all the way down here. Where is it getting updated? Uh-huh. I I don't see I mean, maybe this I I guess because it's calling it from within it. Okay. So basically what we'll do is we'll keep this a little bit simpler because I think we're a little bit too far ahead of the game here and their example is not really broken down to be simplified. So I think the thing is that we're going to get the data and we'll ignore this loop thing for now and I want to go back up and look at our actual data that we had from before. I'll just have to run it again to actually get it because I cannot see what's going on and I think we should just process this uh step by step. Okay. So, we'll go run this again. Okay. And so, in here in our data structure, I want to get back the fact that this um is a type of tool of tool use. Okay. And so in the response there is content and so it's response content tool use. Okay. And so here I'm going to say print response content tool use. And then the idea here is that you know if response content tool use equals tool use then we will do this. I need a period here. Uh maybe parenthesis. I don't I'm not again not person that normally works in Python. And so the idea is that if we have that then we would want to run the tool. And so here um I'm going to take a look here and see how they are running it. So you have run tool name tool input and then it says if it equals that then we'll run that there. And so just to keep ours really really simple, um I'm going to go up here and pretend that we already have our function. So I'm going to see if I can do it here. So we'll just say um I don't know why I keep getting dra uh I don't know why this keeps um drifting. Do you see my mouse? I don't know what's causing that. It's kind of annoying. But we'll go here. There's something there's obviously something doing it. But uh we'll go here and say magic eightball like we'll say tool magic eightball uh eightball eyeball. And so this will have the question and then down below here we'll go here and it will be based on the name of the tool. So for theirs uh do we have the name of the tool here? It is under name content name. Say response content name. The only problem here is notice here that we have this one and then that one, right? So you do kind of have to iterate to get to the um correct one. And so probably what we do need is this line here because then it will return the actual block that we want. Right? So we will place this here um as it is trying to find it. And so now we don't really need to check whether there is a tool. It's just this either exists or not. Right? So here, so if the tool use exists, then call the uh tool and pass it uh the Okay, so I might just go ahead and ask it to implement this for me. So I'll go back here to Claude. Can you implement uh hooking up the tool use call on line 46 for main.py. Please use the s uh simplest solution to hook up the function to the function. Okay. And hopefully it doesn't try to implement the whole thing. Uh, we'll see. Yes, sure. It's just because I can't remember how to do the if call checking of the thing, like if it's undefined, and I just don't feel like doing that. What I expected to do is like have an if. So, yeah, that's what I wanted. I want a random thing. I don't like it how it keeps some of the imports in there. Uh, and so that is technically correct. Yes, you can edit it. And then it should check whether uh the name matches. And then it should call that function. And so then we go here. So call the tool and send the result. And that's the input. Yes, that is correct. And then it's it's using it as a splat to open it up. That is correct. We have our tool result. And then here it's doing the followup. And that would be the next step of like how we feed it back in there. So this is good. Um, okay. Where is it? And again, I'm not sure if this is just a problem with uh Yeah, there we go. I just reopened it. There's some weird caching thing that's going on here with Visual Studio Code. Okay, great. So, what do we have? We've grabbed that block of information. We then input the results of that information there and then we're following back up into uh this here and we have RO user uh content uh you know whatever whatever and and we're chaining it along. Okay. So I want to do a little little refactor here. So can you refactor the calls to um was it create into its own function for main.py. And we're just cleaning up the code a little bit here because it's a little bit hard. We should really be tracking the messages here. Okay, here we go. It's calling it follow-up request, initial request. Um, no. I mean, okay, but shouldn't they shouldn't they be a single function and messages are passed in, right? I don't know why I just created two separate functions. We're using Son of 4.6 here. Why is it being dumb? Okay. And so, we'll go back up to here. And I don't know why it's not showing us the latest, but we'll go ahead and open and close it. Oh, here's our create function. So, here it's just passing information in. And so, we got, hey Claude, I want I'm a billionaire. We are passing in the messages. Here we are waiting our response. Okay, we get the the the uh we iterate through that block until we find tool use and we only expect one right now, which is not a good way to code it, but it's a good way to show this here. Then here we have our tool results. Um so whatever is coming back here and then notice that we are putting back into here the actual tool results. So see here we have type tool result like we saw earlier. Um and then we have a tool use ID. So we are bringing back the ID of the tool so it can map it up very easily so it knows exactly what it's doing and then the results itself and then we can follow up and see the next one. And so what we want to see in that followup is um the end result. Right? So I'm going to go here. I'm going take this one out because that would actually break our code and I want to redump this out. But I'd rather call it response twice to be honest. Okay. And so now we should have two. And so I'll go here. This will be uh followup. And then this one will be here. It will be the uh original. Okay. And so I'm going to just stop this here. We'll type in clear. We'll type in Python main.py. And we'll go up. And so here is our original And then in our followup, we are just observing that it ended the turn. Okay. So, I know there's a lot of setup here, but we are going to reap the benefits of this code going forward as we are going to iterate through this. Okay. Um, but there you go. Cha chia. All right. Let's talk about preconfigured decision trees. So, these are when you hardcode the logic and the code decides what happens next. A very simple one be an if else statement. So uh uh if this then do that or if you want to have something that's more complex that would be a state machine where it's saying what the initial state is and you can transition to other states and stuff like that. Uh you might hear the word tool sequence um used uh through anthropic uh and so they're just really talking about a state machine or a series of steps. Um the thing is that when people were first trying to figure out what an agent looked like, they would implement state machines because that was the way they would set up the complex logic. But we don't really consider that to be really agentic as um uh something that's agentic is that go that goes through an agentic loop where each time the um the decision is being made by the agent itself and not by the code. So here the decision-m is the agent uh sorry is the uh code. If the code is making the decision then it's not exactly agentic now is it? But if the agent is deciding then it actually is agentic. Okay. So model driven decision-m or basically an actual agentic model is where you you hand claude a set of tools and a goal and claude figures out the sequence itself at runtime based on context. You don't tell it uh what to call or when. Okay. So an example here would be like you are a helpful assistant that helps users manage their work work tasks. You have access to the following tools. Now you'll notice that when we did the the stop reason video, we never put in the prompt in the system prompt that these were the tools that were available. So um if you're getting into this now and you uh weren't working with uh um coding these things a few years ago, uh if you were working with these earlier, then you would have experienced this where you would have to write them in. But the agents or the models got smart enough that you didn't have to do this anymore. Or maybe there's something in their API. They're doing some abstraction for us and we don't actually have to do this anymore. But I might just do it as um a uh uh exercise just so that we have an idea where that code would be. Um but when we're using the cloud API, we just literally specify these are the tools we have. We don't have to literally tell it what tools are available. Um, and so something we're going to hear a lot about is the hub and spoke architecture for setting up a coordinator agent. Um, and so this is where you will have a single agent sitting at the center and it's going to talk out to other sub agents around it and it's going to um, uh, intercept all communication between it. We will talk about that later. But right now, I just want to take a look at the um the decision- making not for model uh model driven decision-m since we will figure that out here shortly, but mostly the preconfigured stuff. And both options are uh valid and useful. It's just depending on what you're doing. Okay? But obviously um in this course, Enthropic wants you to be model driven, right? Because that's what they're trying to sell you on. But I'm telling you that both are useful. Okay? Hey, this is Andrew. In this video, all I want to do is uh explore that decision- making. So, I'm going to make a new folder here. We're going to call it decision- making. And uh what I'm going to do is grab our existing code here for this one. And I'm going to make a new one. This will be preconfigured. Uh we'll say uh what is it called? Preconfigured code. So code, we'll say code driven. That's actually a better word. I don't know why they called it preconfigured stuff. I swear to goodness the uh marketing material is being done by um an agent. And so basically what we want to show is not tools in this one. We wanted to show um I guess we could, but anyway, I'll go ahead here and we'll ask Claude to uh we'll back out for a second because it's in the wrong place, but I'm going to go into um the top level here and we're just going to ask Claude to change the code. So here I'm going to say um I want to demonstrate um preconfigured uh what are they called? Preconfigured decision trees. Uh and so where the logic is hardcoded handling the uh information coming back from the uh LLM. Can you adjust my code and remove the tool use? Okay. And so in the decision-making code driven file and so hopefully we will get something that is a good example here. But we will see what we get because I'm already 91% up my session. I've barely done anything today. People have been complaining about that quite a bit here today. But uh maybe maybe it will be 3 p.m. soon. Let me take a look here. Uh nope. So that's okay. I don't mind taking a break. And so we'll give it a moment here to rework the code. I almost feel like I should have just write it by hand because sometimes it's slow. But here we have something. And we will take a look at what we have. Okay. So we'll just say yes. Sure. There was a lot of stuff in there. So I'm not really sure if I like it. But we'll go ahead and take a look. And I don't know why it's still doing this, but I'll just I'll save this file here. Whoops. Nope. Don't save. I don't know what it's trying to do here. There we go. And so what do we have here? So we have your customer support classifier. Classify the user message into exactly one of these categories. Billing, technical, or general. Respond with only the category name and nothing else. And so here we have the hard-coded decisions. Handle billing, handle technical, handle general. We'll go down below. And so here you can see it's going to route that information. So let's take a look here. So, I was charged this twice a month. Can you help? My app keeps crashing after the latest updates. Uh, what are your business hours? Okay, that makes sense. And so, here it's going to iterate through the messages. Claude, classify as category. So, it's telling Claude, this is actually something that we were told to do really early on with LMS is like have it output as like a like either structured output or or something that it can act on. And so what it's going to do is output a very specific category. That makes sense. And then it's going to go and route it. So it puts the category and the message in here. And then we go up to here. So we have our category and our message. And depending on where it goes, it's going to go to these different locations, right? And so that's a hardcoded solution. Let's go ahead and run that. So I'm going to go into decision- making and we will type in Python and we will choose code driven. Okay, we'll run that. And so here we can see some routing. Let's take a look at what it's done. Routing to the billing team. Pull account record and check payment status. My app keeps crashing after latest update. Okay. And so we actually have multiple runs here. Maybe I wasn't paying attention. Oh, there was three. And so it ran three different ones and so it's showing us that it went two different places. And so that's a way to route it. Um, you know, like a good example of where you might want to implement this and maybe this is actually a good example. This is an example that I would use. So like imagine you're creating a multi-user dungeon text adventure game and you have very specific logic that you want to play out, but you want to have some flexibility. This is where you can get a trade-off where you have this logical structure that keeps the game working in a very particular way where you're not worried about things hallucinating and you're not consuming lots of tokens because you're expecting it to handle a lot of the instate logic where um the logic or the state is being handled by the code. And so that would be a good use case for that. Okay. Um there might be better use cases that are more practical, but that's what I can think of off the top of my head. Let's go over here and I'm going to make a different one. And this one's going to be um model driven.py. The only thing that we didn't see there was um the specification of tool use. And so we're going to go ahead here and copy this. And I'm going to paste this into here. And I'm going to go back a directory. I'm going to type in clot here. And here I want to say I want to I want to demonstrate model driven uh uh decision- making uh I want to can you modify the code for model driven you can change the the tooling to meet a simple example that shows the model is driving decision. Can you show in the system prompt uh the tools defined? I know uh Claude doesn't need it, but showing uh for uh demonstration of where it used to go. Okay. And so we'll go ahead and let it do that. It's going to keep complaining about that. That's totally fine. Actually do have some overages. So I like paid for some credits. So it's probably fine if I hit um 100% here. It's not a big deal. And so, you know, we're going to hope that we have a bit of uh rewrite. Also, other things like I don't know if my wife's using Claude. Like sometimes my computer's open. She doesn't know the difference between chat GPT and Claude. She just uses what'sever there. And so maybe she's she's consuming my credits right now. Who knows? Um but you know what we're trying to see is that loop, right? And so, uh we'll give it a moment here to output it. Okay. All right. And we will uh just say let Yep. I thought it was done editing, but I guess not. We'll give it a moment here. Oh, it is done. Okay, great. Uh, is it done? You're talking a lot. Okay. Oh, I think it just ran it maybe. Did it run it? No, it's just saying what we will see. So, system prompt added. Yeah, we'll just read it together. And I'll just close this out. There seems to be some kind of weird caching issue here. So, we have our tools implemented up here. And I think it's just following the pattern that I implemented. So, it's not necessarily that this is the way you have to do it, but I think it's taking cues from our original code here. And then it's just calling here. I really don't like constants, but that's fine. That's what it does. And then it's expanding out. Okay, so this is a reference to these functions. And then this is the actual schema of those functions and what they'll take in here. So, we have check inventory, place, order, send notifications, and then we have our system prompt, right? And normally what we would see here, it didn't do it, but normally we would literally see the name of the tool. It' be like send notifications, right? It would literally tell you the exact name of it like this and do that. Um, but anyway, in our prompt here, we have you are an inventory management assistant to tools to check, stock, and place orders, send notifications when handling requests, always verify inventory available before ordering. And so basically, see these descriptions here? Usually what would happen is they would get picked up over here. So the agent would know about these and that's how it would reason. And so that's probably why we don't need to have these here. Okay. Use your tools step by step in the order which calls that uh uh in uh the order in which you call them matters. Sure. I don't like the fact that it changed the model on me because I don't want to consume more credits. I'm going to change this back to this. Okay. And um we'll do that. One thing I might do here is I might just create a claude claude MD say please use haiku model so our costs are low for API usage and I'm hoping that that way um this will get picked up and so it will it won't do that in the future here. But let's take a look at what we have. So we still have our create function and we have our messages. So I need five units of widget A. Check if they're available. Place the order if so. Right. And then here we have our loop. Okay. So while true. Is that a good loop? I don't know about that. I think the the tool use uh loop was a little bit better. But here if it if it ever becomes false within the loop then it would stop. I'm not sure where that break would uh occur. Probably at these points like break that might return the false. So I would say the code here is not great. But that's okay. We'll leave it alone for now because I think uh we actually have um slides that addresses where that might be an issue. But the point is is that the idea is that it's going to loop through this and it should call uh the create multiple times. Here it calls it with one step and it's going to iterate over that over and over again. And if it needs to use it's going to stop and do that. Okay. So we'll stop this here and we'll CD into decision-m into our model driven code here. Oh, we don't we don't have to CD into it. Have to write it. Run it. Okay. And so we'll go ahead and do that. And it's off to the races. So stop reason tool use stop reason tool use and we can see that it's doing it and figuring out and turn and then we have the completion of it. So yeah the only part of the code that I I think that is probably not great is this while true loop. Okay, I think we could might have better logic here but we'll see as we work through this course and we might come back to this code and improve it. Uh but there you go. Let's look at some antiatterns that anthropic wants you to know about. Um when you are designing I guess your loop basically. So um the first thing is that when you are going to decide that the loop is over uh you do not want to just parse natural language to say like looking for an indicator from the text that it is complete. What you want to do is check on the stop reason uh for enter. And that makes sense because the output for the text could be anything or um the thing is is that maybe these words task complete have something to do not with it being complete but just in general in the text. So there's a lot of points of failure that can happen with parsing natural text specifically for stopping the loop. And obviously um they have a a very specific structure like stop reason. And so that's going to be a lot more reliable and give you a better indicator and not be thrown off by the text content. That doesn't mean that you cannot use um uh text and to use regular expressions and includes to make decisions on information though those are brittle. But when we're talking about stopping the loop, we want to use stop reason. Okay. Um another thing is that you can set an iteration number um to cap as as a means to prevent from this overusing. Remember in the last follow along when we were uh going through that while loop, we just had a true statement on it. So basically um if it never hit a false, it could go forever. And so you might think, well, let's put an iteration on that. And that would um partially help the problem. But what if it needed to stop sooner, right? Because now you're consuming uh 10 iterations as opposed to if it only needed one or two or three. And so we can still use um the max iteration, but we are also going to use that stop reason and then we're going to provide it that break to break out of that loop. And so that is a another combination method of stuff that we're can doing. You're probably noticing a pattern here which is use stop reason and turn. Okay. Uh another one is uh maybe you think okay well if I get text back right then surely it must be done. It's not calling tools. But that is not necessarily the case. Okay. Uh because that structure can return back text in both cases or maybe it might not in some cases. So again we are using stop reason and turn to determine it. So you know the the text could be a misleader. Using natural language could be a misleader. Using iterations could be a misleader. Um and yeah we just want to make sure we do stop reason enter. Okay. Okay, folks. Let's make this a quick one. What I want to do is improve our little loop here. And so, I'm just going to go ahead and make a new folder as per usual. I can just commit whatever I had before here. Great commit message. Um, so my team will love that message there. And we'll just say um end loop end loop correctly. Okay. So, I'll call that. And what I'm going to do is go into our uh decision- making one because that's where we actually have our nice little loop here. I'm going to go ahead and copy that code. Model driven model driven decision-m and notice how much we are reusing our code. It's great. Eh, we'll go ahead and type in main.py. We'll paste this in. And so the main thing we want to change is the loop here. So here we have a while true. It's counting steps which is fine. Um, but here there's nothing that's going to prevent it from stopping. Now, we do have end turn here and we have our break. So, this is the thing that's going to break out um, uh, and end the turn. Okay. And so here, the only thing I don't see is like what happens if uh, it gets to the end. I think that the end it would just return a false if there was nothing else to loop. I would imagine. So that's the only indicator that I have here. So I'm going to go ahead and just uh we'll we'll go back a level here and we'll tell it to ingest this particular file. So uh end loop main.py. We use a while loop. But I would like to um have a max iteration of 10. So we set an external var. Okay. Uh is there any uh other case where the end loop might not end? Uh we won't even put that in there. That'll be fine. And so we'll go ahead and we'll do that. And so that should be enough to fix it. I really should have moved that to Haiku. I'm using sonnet 4.6 for simple coding tasks like that. I think ha ha ha ha ha ha ha ha ha ha ha coup could handle yeah there does that max iterations. I don't like constants. Uh if you're a good programmer you don't put stuff like that. I feel like people in the developer or sorry the the the data space might have done that because their practice wasn't coding but more handling data. And so you see the kind of amateurish uh coding methods in my my opinion for this language. Um, if we're talking about C++, different story. Those folks are are champions over there. But we'll go over to here and that's it. So, I don't think I need to test this. It's pretty straightforward. But I just wanted to show that we updated our code um and what we would have done in that case. And just to point out that break and I'm still like, well, is there still a little edge case? And we could waste the tokens. I just don't want to waste the tokens. Okay, let's take a look at hub and spoke architecture. So, hub and spoke architecture is a pattern where one coordinator agent sits at the center and all sub agents talk to the coordinator. I highlighted that word word coordinator because you're going to be seeing a lot of coordinator agent. And when you think of like um claude uh claude code, I have a feeling that this is at least one of the means at least when you're working with sub agents for communication, right? So this is going to be something really really useful to learn. Uh it's going to be really fun and something that you can apply um like immediately. Okay, so sub agents never have direct lines to each other. So if you have like a research agent over here, it cannot directly talk to the review a reviewer agent. has to go through the coordinator. Um, and so that is pretty clear. And the coordinator is going to own the routing. So it's going to decide how to route things. Context sharing, so what will be shared. So the research agent is not going to be aware of what everyone's doing unless the coordinator passes that information along and it gets injected. So um it really won't know. Uh and any kind of error handling, any kind of observability, any anything like that. Okay. Uh and obviously that would make it really good for observability because now everything's passing through there and we have a choke point where we can check and collect information, right? Um and so here we have kind of the uh task life cycle um of like okay we have something that needs to be done and uh how is it going to get executed out. So the role of that coordinator is task decomposition. So break uh break um the task into subtasks, right? Then we have test delegation. So who is going to be working on that problem? Result aggregation. So bring it all back together uh to produce a final result and decide which sub aents to invoke based on query complexity. So um you know we have a a lot of things going on here, but let's just kind of walk through it. So imagine you're a coordinator and when given a task uh it'll break down a subtask um uh for each of the available tools and we're saying do not do the work yourself. So we're basically here defining you know that you are a coordinator and this is what you're going to be doing. Okay. Um and then here it's like you're coordinator and use your judgment. Simple factual questions use a single agent multi-step task delegate out to a sequential passing the results forward independent subtask delegating in parallel. So we're basically defining okay what does the routing look like? So it's not just like static routing it's you know use the routing you need to route based on the use case right which I think is really really interesting and then down below here it's like okay you've gotten all the uh outputs from multiple agents combine them into a single uh coherent response resolve any conflicts and make the data pretty. So uh that's the most basic thing when we're talking about this coordinator agent. Um there's a lot of stuff we have to consider when implementing this, but we will go and set up a super skeleton one really quick quickly here and then we will iterate on it. Okay. Okay folks. So what I want to do in this follow along is implement a very simple coordinator agent. So we'll say coordinator agent simple or basic. And in here we will make a new main.py. And I suppose that we could um pull up some code. I'm going to see if we can switch over to Haiku and save some credits here because it might be able to do it. We'll see. Hi coup. There we go. And so now it switched over to the haiku 4.5 model. And so I'm going to tell it uh um create uh a very basic coordinator agent um in coordinator basic main.py. Please follow our general um coding example would be uh what was one we did decision- making would probably be one uh model driven model driven pie and so I'm hoping that by giving it that reference it will know how to reference that stuff and produce something that's going to be generally okay u but we'll see how haiku does I really should run haiku a lot more I just kind stick at Sonnet. Um, and that's my that's my fault there, right? And so we will give it a bit of time here. Let it accept here. And then we will decide whether Haiku could even do it or not. And does it have all the components we need? And there it is. That was pretty darn fast. Maybe it needs a little bit more work to do, but we have the start of it. Let's close out the tab here. Sometimes it helps to close out the tab and reopen it for whatever reason. It's already done. So here it says I've created a basic coordinator. We have create task, get task status, complete task, uh, task list. And so we have the basic stuff. Let's take a look here and see if it's any good. Um, so we have tool implementation. So tool create task task status. And so it's talking about how it has to manage the tasks generically, right? Um, then down below here. Yep. So we have that create a task with an optional list of task IDs. Um, get the current status of the specific task. Market is complete. List all tasks as completed. Um, so it seems like it's pretty simple. Your role is to manage and coordinate tasks. Well, a coordinator does that in general. But I guess the thing is like this is literally it sounds like it's managing tasks. Create tasks as needed for the workflow. Check this task status and dependencies. Complete tasks when appropriate. So what I'm trying to figure out here is what is the use case? So set up a let's go down here for a second. We have user message. So set up a workflow create a task design and then create a task implementation that depends on design and then complete design task first. This is so generic it's really hard to make sense of it. We have our while loop here. It brought in the while true. So we don't have that max iteration. Um and it might might not be a major issue but we still might want that in there. I probably should have referenced the other code. And so I'm just carefully looking here at what we have. So we have our tools over here. And so I'm not really sure if that really fits our pattern exactly. I'm going to go take a look at our uh diagram here. What do we have? we have de demp uh decompose uh the routing and the aggregation right so um I don't think I see all those steps here okay so what I'm going to do is I'm going to go back to our smarter model here sonnet okay and I'm going to go and ask the coordinator or I'm going to ask uh it to improve our coordinator code so uh you know for a coordinator agent We should have uh decomposition tasks. Um just a moment here. Routing. It says assess complexity but we have routing. um we'll say assess complexity complexity and routing and aggregate results. The use case here is um to generic need a better use case. Okay. And so we'll go ahead and we'll see if it can improve that code. And if none, I might have to write even more detailed prompt. Um, I'm just kind of low on our usage, unless the window has rolled over. Let me take a look here. Nope, I still got 15 minutes for my time to roll over over here, but we'll see. And so, I just want to kind of see it uh mimic these patterns here. And so, it's not to say that it's not exactly doing it, but it's definitely uh not that sophisticated, right? because I would expect there to be a prompt for the routing component here and I'm not seeing it here. Right. It does say set up a workflow. So technically that is that uh that right there. So maybe maybe it is kind of being implemented but we'll give it a second here. Now write a concrete use case technical due diligence decompose a complex software review. Oh, I don't like that. No, I'm gonna stop this for a second here. Stop. Stop. Stop. Stop. I I don't like the use case. Oh, it already stopped basically. So, it says breaks the request into five fixed areas. Well, I already got the code, I guess. Let's just take a look here. Um, so here it says a user submits a software system for technical review. The coordinator has a decompose of requests, assesses the complexity per area, routes and and and does that runs an appropriate handler, aggregates all findings into a single report. So that sounds good. Uh we have uh tool decompose request tool assess complexity. Um I don't really like the use case because I want something that's gonna be easy for us to validate and test. And this will be too complicated. I don't like the use case. Can you propose to me uh 10 possible use cases? I want something that uh is not super complex that will be like super computational but would need complex routing and choices. Uh, don't implement, just suggest ideas. Okay. And so I want to see if we can pick something a bit better. If it can't, then I might have to uh decide on myself here. Here's so job application screener. Um, event planning coordinator, bug triage, restaurant order customizer. I mean, I like the travel one. That might have to go to the internet. I don't necessarily want to do that. Okay. Okay. So like with dumb what would be the subtasks the sub aents used because that's what I'm trying to figure out and this comes back to you know this idea where we have an idea and it's doing a bunch of stuff right so like coder writer researcher planner data like so I'm trying to see what we have and so we go over to here and so we have re request to composer so it takes the job posting resume and extracts it out. Looks at each criteria and decides the routing. Okay. Execut execution phase um the actual routing targets aggregation phase. So it has two different ones here. So I guess my question is like is the ownership I mean like should the coordinator be routing to a decomposer and uh router a routing because I thought the composer is supposed to own it in a hub and spoke architecture. And so that's the only thing I'm I'm just making sure like maybe just these are just tools and it's calling out to them and so it still has ownership. So you're right in a proper hub and spoke architecture the coordinator is the hub. It owns it. The decomposer isn't a separate sub aent. That's why the coordinator owns its responsibility. So we have that sure that looks like something. So the coordinator decomposes assess complexity decides where aggregates the spokes just execute. This smells like something belonging to the coordinator versus sub agent. Does it need a full pitcher? Does it need the full pitcher to do the its job? Decomposition is always routing always needs the full pitcher. Uh I don't I don't I don't know what you mean by full picture but we are implementing hub and spoke model architecture. Okay. So I don't know what it's trying to say there but um maybe means like does things have to have context. You're right. Okay. So it says you're right. Oh yeah, of course I'm always right. Um receives the requests call spokes aggregates the results independent workers each job does one no knowledge of each other. That's right. Okay. So for job app application screener now we have keyword scanner deep evaluation red flag detector score aggregator takes all the spoke spoke outputs. The coordinator owns calling each spoke with the right input, deciding which spoke to call, collecting and combining their outputs. Yes. Okay. And so now we're getting something there. Just because it said it did it does not mean it did. And this is me looking at going that doesn't seem right. Right. Um and so we will let it go ahead and do that. I'm not getting any more warning. So oh it says now using extra credits. So, I am over my usage, [laughter] but I I should be okay. You'd be surprised how long or how far five dollars will take you here. Okay, so it says it's completed the architecture here. Um, let's go take a look and check out the code. So, now we got lots of stuff here. Okay, so keyword scanner prompt. You are a resume keyword scanner. Check whether required skills from the job posting uh appear explicitly in the resume. For each required skill, output one line. Be literal. Do not infer or extrapolate. Report only what is explicitly stated. Okay. And so then we basically have all the ones here and they're fine. Of course, if we're doing this for real, we would be tweaking this all by hand, of course. And then here we have the actual um I guess they're saying the spokes. We could say sub agents if you would or they have them called as spokes and each of them are individually calling uh this stuff. I'm not sure why they're doing it this way. It seems like this could be easily refactored. This seems a little bit uh messy. Maybe they're doing this so that you could improve it later on, but to me this um seems like this should all be just one function. And then we have the spoke aggregator where there actually is a little bit different. So they do have that there which is fine. Then we have our dispatch tool. Okay. So basically like where should it go? We have and yeah whether it should go there or not tool schema. So what the coordinator hub sees. Mhm. So we have run keyword scanner. Oh like these are the actual tools deciding whether they should get triggered or not. That's fine. Then we have our coordinator prompt. So you are a job application screening coordinator. That's fine. Your job is to orchestrate three independent screening agents. Mhm. Uh your job is to orchestrate the three independent screening agents and then aggregate the results. You may run three screening agents in order. Do not skip any of them. And so here it's defining that saying you have a explicit order. And so obviously there could be more complex routing than this, but this is all there is. Then we'll go down to here. And so here we have our job postings. I was going to wonder where this data was because I was going to be like, is there a are the résumés generated here? And they do. So, or we have our job posting, then we have our our resume. We only and we only have a single resume, which is fine. Alex Chen, that's interesting. Okay. So, we go down here and we're passing that data in. It's going through that loop. Again, we have this while true. So, I'm not sure if that's the best idea to have that while true like there, but I will run it. And uh take the risk. I think it's fine. Uh you know what? I do want a max iteration. So I'm going to go here and just say like uh the while loop is true. Do you think we should have a max iteration or any other suggestions so it doesn't go on forever. Okay. And so that's what I want it to answer there. I we had the max it might just do the max iteration because now I basically told it to do that. So here it says um a while true loop with no exit condition. I mean there is an exit condition. It's the break right here. Um and then we have a timeout for this use case. So a max steps caps is is the right fit. That's what it's suggesting. Fair enough. How is it counting the max steps? So the loop executes only when the condition becomes false. Max steps and not when and not when the break is hit. So it cleanly catches runaway loops without needing an extra flag. Okay, that's fine. The cap is 10. Double the expected five steps. Give the model room to retry. I just don't see where it's counting them. Oh, I guess it's right here. Oh, sure. I I guess so. But I mean, that's the same thing as a max iteration. Um, so max steps is the same as max iteration. I guess it's fine. I mean, I'm sure it will still work. So, if it doesn't, we'll find out. And again, you know, you can just watch and see what my outcome is before you do this if you do not want to waste credits because I've made a poor decision. Um, you know, like I'm loading my thing up with like $5 at a time. So, I'm I'm not that worried about um small losses like that. So, we'll go ahead and go into here and let's go ahead and execute this. And yeah, I'm not using my subscription. Now, we could probably port this over to agent SDK. Um, and this would be greatly simplified. We might do that later to see what's happening here, but we won't do it right away. So, here it says, um, coordinator routes to the spoke. Okay, so it's found stuff. Something's missing. Coordinator routes to the run a deep evaluator. Uh, strong alignment with the senior level role with seven years of total experience. Cool. Strong fit. coordinator routes to the red flag detector. Imagine someone uh just coded this and this is what's keeping people out of their jobs. That that would be a bummer. And then we have step two of 10. So match keywords uh strong no flags decision hire. Alex demonstrates strong alignment with senior level requirements. Coordinator for final recommendation for hire. So it's recommending it six out of the seven strong. No red flags. all core required skills present seven years experience whatever whatever and so we just implemented our own coordinator again the only thing that's really simple like I still not confident about the while loop but the only thing that is um very simple is the routing but the routing obviously is being handled here um and so you know like in that diagram it just seems like it's a separate step like you cut them up and then you do that um and so I'm not sure if that should be separated out but the point is we did implement coordinator agent um and that's something we could decide later on if we wanted to have an individual step for more intelligent routing. So that's the only thing that I might um consider like I I would probably ask it right now like if it should be ran twice but I'm I don't know I don't want to because I don't think it's going to just tell me. I think it's going to actually try to do it and so I don't want to muck with it. And so I'd say that's fine but just consider that that's an uncertainty that I have right now. And so I'm going to go back a director here. just say get at all get commit-m uh basic coordinator. I think that was kind of fun. I thought the results were pretty good. Okay, and I will see you in the next one. Okay, chowo chia. Okay, let's take a look at narrow task decomposition. So when uh claw de decomposes a task, it can only delegate what it thinks to ask for. Okay. So here we have an example says give me a comprehensive analysis of the EV market. Break the user's task into subtasks and delegate them out. And so here we see the subtasks. We have research EV sales figures. Research EV battery technology. Research major EV manufacturers. So if the initial decomposition is too narrow, entire topics never get researched. It's because each sub aent only sees its o it its own isolated context. None of them can flag what's missing. So what got missed? Charging infrastructure, government policies and subsidies, secondhand EV markets, consumer sentiment and adoption barriers, supply chains like lithium and cobalt, grid capacity implications. Okay. Um, so you need to be very specific on the task so it fully covers what you expect. So here it says give me a comprehensive analysis of the EV market again. And so as the coordinator when decomposing the task of course we're generating out the the subtask but ask yourself you know more information ask subtasks to cover those gaps only. Then begin delegating and for research tasks specifically consider this information. Now, what's interesting here is like we created um our our job application thing, but this thing is talking about research. So, they they might have just a single sub agent that just does research. And so, the idea is that all these tasks are going to the same sub aent as maybe separate um instances that are spawned and they're being tasked with doing different things. And so, this is where you have a little bit more complex routing, right? Or different kinds of routing. Um and so one thing that we can do to catch weak decomposition is uh because like let's say for whatever reason in here uh this coordinator uh that you wrote here to help it be very specific uh it fails or you just don't do a good job then you could implement a tool and so the tool um can try to catch it because now when the court or when the agent goes and does a task it's going to say oh did you submit a subtask breakdown for review for delegating Well, then trigger this tool and then make sure right here that you do this stuff and this gives you a guarantee um you know of this or maybe you want to be a little bit more flexible what the input is from the user and uh so this thing being decoupled might do that. Um another way uh that you can fix this problem is at the aggregate level. So after you're aggregating the results, it can check here and say, "Hey, um did you make sure before writing the answer that you uh met these things?" And so you now have basically two different safeguards for um improving over uh narrow task decomposition. So I'm not sure if this will work in the one that we're building right now or we'll have to build a new little coordinator. Um but we'll go and try it out. Okay. All right. Okay, so we are back and um what we'll do here is we'll try to figure out this narrow task decomposition. I don't know if it's going to work for our case because um for research it's a really good um use case, but will it be for this one? I don't know. Um so I'm going to go ahead and just copy all this code here because we already have something that's good and Claude's going to have an easier time working with tweaking that that we're gonna have an easier time working off of this. So um let's go down to where the main coordinator prompt is. So here it says uh you're a job application screening coordinator. Your job is to orchestrate three independent screening agents and the aggregate their results. Run all three screening agents keywords deep evaluators detector. So um let's go ahead and just ask it. Okay. So we'll go here. We'll say um for our narrow task compion main for our coordinator prompt is the uh decomposition um is our task decomposition too narrow and what do we need to ask for a better decomposition. Okay? Because this one's pretty darn simple, right? It's just like there's these three things. Feed it into those three things because it's not conducting research, right? Um it's not going out and looking at large bodies of text and trying to figure it out. So, you know, maybe if there was like more than one source, then that would be useful. And so, maybe that's what we might recommend here in just a moment. And I might say, hey, like, you know, assume that you're ingesting more than one source of information. Um, and that might be a better example. But let's see what it comes back with here. And then I'll tell you whether I agree with it or not. Just because it will produce something doesn't mean that it's useful. So, we will find out here. Okay. Also, I was just thinking about this. What we should have done is just taken the coordinator information and provided it uh to here with the basic information because I feel like it's consuming a lot more um tokens than it should require. I mean, it's not saying there's that many here, but it is taking uh some time here. And I again, I'll just wait. But I should have really just extracted out that individual information. So, let's take a look here. And oh, yeah, we can edit the main file. That's fine. Yeah, I thought it was done. I guess it's not done. Okay. So, let's take a look at the problem here. Spokes are narrowly scoped but appropriately interpretive. That's actually reasonable. But if you're designing new coordinators, well, I'm not designing new coordinators, but we we'll take a look here. Spokes answers, "What is X? Python found but without access to the resume." Um, spokes answers, "What does X mean for the hire? Receives pre-interpreted signals and can make the uh integrated judgment." So I guess we're trying to determine like is it fine? So what to ask? So so is it narrow? So is skill X listed? Does experience demonstrate the skills X required? So if it's narrow saying like is it just listed or is it actually telling us? So that would be better. That's true. Uh narrow resume only. And so this is what I was talking about where we would have more than one type of um information feed. But here it's saying feed in the resume and the job posting for the fit. context what gran granularity so one spoke per keyword one spoke per uh decision dimension whatever so this file runs both the coordinator of the same candidate so you can see how the narrow decomposition loses the 50 million requests per day nuance while the better one catches it. Okay, so we'll go back up to here. I'm just trying to make clear the this thing that we're looking at. So narrow anti pattern. What is X? Python found six years, three no gaps. That's probably like how actually recruitment people work. The aggregator receives new facts. It still has to do all the reasoning but now without access to the resume. So spokes answers what does X mean for the hire? Strong trajectory risk. Okay. So one thing I I was thinking of was like you need to crosscoordinate this information, right? So um I would say you know one thing one thing I noticed is you know can we validate the number of years based on based on the resume information? Can we mock other data sources that uh that we would feed in where uh if we didn't do better task decomposition with very specific things to check we would run into an issue because that's I think what's going to take it but like that was one example of like okay well you know if you had to validate how many years someone had experience, you'd look at their resume, but you might also look at uh projects or references or other stuff. And so let's just see if it can, you know, consider other data sources. Uh maybe we should just want the Eevee one because research is a really a really good one. But I mean in this sense like we are researching if there are multiple things like maybe they have blog posts and stuff like that. But we'll we'll see what comes back here and I might make s uh suggestions for data sources. Okay. All right. It is back. Let's see what it's done. So, we'll go up to here. Key addition. So, show activity since 2018 from uh a Git profile. Let's see. All all assessed skills are above senior threshold. Verified 7.6 years experience. Um, okay. I mean, did it run it again? I didn't tell it to run it, but um I guess what we should do is just take a look at what the new coordinator information is. Your job is to coordinate uh three independent screening agents and then aggregate the results. I mean this isn't this is showing steps which is fine but we're not seeing it doesn't seem to understand what I'm trying to tell it. Okay. So no I don't think it understands. So what I'll do just give me a second here. I need to give it an example and I just need to extract out. I'm going to give it a better example here. And we're just going to clo I have my screenshot. I just don't have the raw data. And so I'm just going to uh chat GBT or something here off screen. Be like uh get me get me the text. Okay. And just give me just a moment here. Just getting the text here off screen. See? So getting the text. And I'm going to feed it as an example of like more information. Okay. So, like we'll go back here. It's like you you know I don't think you understood uh to improve narrow task decomposition we should be giving it specific considerations. Okay. Oh no I didn't say to do that yet. Okay. We'll paste that in as an example, right? So, I don't know if it knows that's an example, but I think it might know. So, hopefully it understands because we're talking about this this area here. Um, and if this fails, then we could just again just make it it might even try to change it to EV, but we'll see what happens here. Um, and wait a moment and see what it comes back with. Okay. So, some of your examples general through this now, did it change it to Eevee stuff or is it actually changing it to uh a better part here? So, let's take a look here. So, what did it change? Let's take a look here. So, here's what changed the domain. EV. No, I didn't want you to change the domain. I just wanted you to use that as an example of uh specific task decomposition. Okay, so there it's already kind of messed up and I had a feeling that it would do that because it literally did not put eg or stuff in there and maybe it's just that what we're trying to do does not work for our use case, right? Maybe. But like I I still think it is because you are doing research, you're collecting information and and gathering it. But we're just assuming that we already have these things and doing analysis on that information. But uh you know when you're doing broad research and there's a lot of information, then it can do do more there. So revert the domain name, but we'll do self-reflection structure into the hiring coordinator. Um and so we'll take a look at what it has and maybe we still will do the Eevee example separately. Um, I mean it still has these in here, so I'm not sure what it was saying. I just don't say it because I'm not trying to change that right now. Yeah. So like you are a research coordinator [laughter] and uh I don't know this is the way that makes money where you tell it something and it doesn't do the right thing and it's making more stuff here, but we'll wait a little bit. Okay. All right. So it's back and so we say okay um back to original domain right in the pattern. What changed? Narrow coordinator mirrors the agent basic tells the model exactly the three checks. Fix the pipeline. No self-reflection. But that's not what I want. Better coordination. Same domain, same spokes, general initial screening angles. What am I missing? Fill the gaps. And you know, I think I think it's struggling here. Let's go back down here. So, we'll go and take a look here again. Well, here we have the narrow coordinator. So, it says here, screen the uh the uh candidate by running the following checks. And then down below here we have better coordinator. So generate an initial list of screening angles. Ask yourself what perspective stakeholders or dimensions are missing. Add screening angles to cover those gaps only. Then begin delegating to screening agent tool. For hiring decisions specifically consider technical skills and soft skills, hard requirements, what candidate has done and etc. After all screening angles are covered. Synthesize a report here. So now I would imagine that it's basically just hitting a single agent. Yes, it is. And so before we had those separated out tasks, right? But just as I thought, it's like in order to do it, um the idea is that you say you're you're a screening agent and then you are contextualizing each one of it. So in a sense each of these are basically turning that into a specialized um a specialized one as before we literally had three separated ones out right. So that I think that's what we're getting at. So that is what we want. That's actually good. So we'll go all the way down here and what we'll do is we'll go it says both the screen agent is identical both the only variable is the coordinator prompt. So with a hiring specific checklist of what the coordinator opportunity looks for. So let's go ahead and run that. I believe that's going to give us a better result. Okay. So, we'll go here. We'll say python main.py. We'll run it. And so, here it's going through it. So, and we're seeing the numbered values of what it's checking for. Okay. Does the resume demonstrate all the required skills? Does the candidate experience depth? Are the there any red flags? Has some rails experience though limited? Um uh in the 58 senior range, no employment gaps or job hopping detected. The career directory is logical, etc. Um and so we have that there. This is the narrow one, right? So fixed checklist, no gap check. Okay. So, let's go down to the more complex one. Um, so we'll go down to this one. So, now we have way more information. So, instead of those three individualized things, um, and remember there those were three separate things before, now we have, um, these. I just want to compare the old one quickly here because I just can't fully remember. We go here. Yeah. Notice that we have three individualized prompts. And even with the narrow one, I guess it's still only passing it through those three. And so, um, that's interesting. But anyway, so here, does the candidate demonstrate mastery of, etc.? Okay, so we go down here. And I guess we can't really see the individualized results. So that would be something you might want to do is like output all of them and then save them and then save the generated uh final one to to exactly see what it is. So core stack matches. Excellent. Okay. Okay. Risk and gaps questions for interviews. Final final recommendation. Now we have a maybe. Alex is qualified candidate but has some gaps for a true senior role. Higher if your team values this pass if whatever. Bottom line, Alex is a strong backend engineer. And then we have coverage. And so it's way better in terms of its information. But really to test this you'd actually have to um you know create sample data, right? and test it and then and then adjust and say hey look uh this is not how I would have judged it right based on that information but this is the example that we wanted but really that works when you know there's a generic research agent and then these individualized things are going in and kind of helping to specialize that research agent for its task uh but yeah that was cool all right let's talk about dynamic selection so the idea here is that when you have your coordinator and you sub agents. Um you might uh find that if you run the entire pipeline for every single possible spoke uh in a sequence that you are consuming as much as you can. And so with your coordinator, you probably want to tell it to think about what kind of pathing it needs or what kind of routing it should have and give it ideas of kind of routing that it can perform under certain circumstances so that it's doing exactly what it needs to do. Even here it's saying like you know only invoke it if it makes sense. Um and a way we can catch that problem. So if we have a a poorly designed um uh dynamic selection system, you can set up a tool just like how we talked about with the narrow task decomposition. You could set up a tool that says hey did you do a good job here? You can do the same thing uh with a tool as well. Um, and I mean it's really going to depend depend on what we're doing, but that's something that uh you know we'll want to consider. Okay. Hey folks, we are back and we are going to try to do some dynamic selection. So um you know for ours uh our our job application um basically we are taking in um information from from one thing but basically uh it's just checking everything and so you know the question is like can we even think of any kind of select dynamic selection that would be need to be performed for a job application because I feel like it would be more if you were to ask certain questions to the agent along with this coordinator then that's where I would want to choose different types of pathing. And so I'm not exactly sure. We'll let it help us think of an idea, but I do want to remind folks that we are just doing this to learn. If you are doing this for real, write these things by hand yourself. Use your brain. That's how you're going to get the best result. Garbage in means garbage out. So just because this thing works doesn't mean that this is welld designigned. We're just going through this uh to learn these concepts, right? Okay. Um, I'm not saying that this is the best, but anyway, we'll go ahead here and make a new folder. This one will be called dynamic selection. Okay. And I'm going to go ahead and make a new main.py file. And I'm going to go ahead and select this code and we're going to copy this and we'll paste this into here. And so I need to give it a concrete example of what we're talking about for dynamic selection. I do not have my text here. I put it in there. I'm going to get uh chatbt to extract it out just how we did with the narrow narrow one. So just ask it to, you know, extract out the text for me here. I'm just doing this offscreen here because I need to give it a practical example and try to describe what we're doing here. Going to CD back a couple and we'll open that up. And so we'll go here and just say, you know, I want to implement dynamic dynamic selection for my uh uh uh coordinator. um so that it's not running the entire pipeline but trying to choose the best uh things to run based on use case. Here is an example of good dynamic selection where we have different pipelines. Okay, you can use to uh help you. Okay, and the other thing is like edit the dynamic selection main.py file. Okay. So, it's going to go off and do that and uh we'll see what it comes back with. So, hopefully something that is useful, but you know, if we don't kind of guide it and say like these are the use cases, you know, I'd be surprised if it doesn't come back with anything good. But, we will try here just for learning purposes. Okay. All right. It's come back with something. Let's take a look at what we have. Um, so dynamic coordinator. Oh, we still have that narrow coordinator in there. We should really remove that out of there because it probably is confusing. We now have like three coordinators. Um I don't want to have three. So we'll go here. I'm just going to tell like look I I only need a single coordinator prompt. So uh well I'm being lazy here. If we don't need the other ones, we can just delete them out. Right? We have this narrow one. So we know this one is not something we want. So we'll take that out. Then audits the gaps for delegating specific domains. And then here we have the dynamic one. So we'll take this one out. Okay, look at that. We wasted no tokens. There's no reason we can't do that. We don't have to prompt everything. Then we'll go down here and take a look. So this coordinator reads uh the roles then decides which dimensions actually matter. So routing the logic. So strong technical match or whatever whatever let's take a look and see what we have. So routing guidance adapt to what you observe don't apply mechanically. So simple factual match skip keyword scan go straight to this non-traditional background transfer skills. Oh this is cool. I like this. Never invoke a screening agent unless it's answers a real question. So I think that actually um worked out perfectly. That's a great example of of that. And so we'll go ahead here and I'm just going to go and run it. So we'll CD into dynamic selection. This has actually been quite fun. Um is it useful? I don't know. Depends on what you're building. And oh yeah, we don't have the narrow coordinator. So I'll go here. Just make sure. Narrow coordinator. Um I want to get rid of these other ones. I don't want to waste all that here. And so, uh, I'm just going to go back a step and just say, uh, this should be fine. Let's just do that. I didn't realize there's more to rip out. I think it'll still work, though. This is all three coordinators. There's only one though, right? Because I ripped them out. So, here it says, describe the most complex screening angles delegated. Okay. And the only the only way to really know if this is different. What happened here? Oh, we have narrow QS. So, we still have some of that remaining remaining code there. So, it's just some of this stuff. And so, I'll go ahead and try that again. I'm not sure if that will work if it's just a single item, but I'm hoping that it does. Um, but here, um, you know, my best guess is that it's choosing exactly what it needs. Because if we go back up to here, that's what it looks like it's doing. Oh my goodness. So, I'm going to go back a directory here. Um, because this is very frustrating. Uh, remove the better. I only have a single coordinator. But I removed some of the other code uh because I only really need a single coordinator here. Can you fix fix the code? You know what's funny is that sometimes like I will type things and every single letter will be wrong and it still knows what I'm saying because it like it does the off shift which I think is really cool. As someone that's dyslexic, as long as it understands me, I I love that. Um, yeah. And so I'm just asking it to clean it up. I just want to make sure it's in a working state before we move on here. All right. So it thinks it's cleaned it up. We'll go into here again and we'll run this again. So screening angles detected. What I'm trying to determine when it runs here is like how is it selecting stuff? So in your current role at the fintech, what is the scale of your system that you worked on? You transitioned from this, have you designed or refactored it? So what it looks like it's doing is it's actually uh generating out uh possible angles based on this information. And so it's literally creating dynamic routing on the fly. So it's not like here is a list that we had before here, but literally like here are things that you can check and then choose what you want to put in here. So it's not always applying the same thing. Then we'll go back up to here. It's still a conditional maybe. But yeah, we're getting something that is uh it's again very interesting to see this play out. Um again, you know, we don't know if it's actually useful, but it's fun to see the system working. Um and there you go. Okay, let's take a look at partitioning research. So if you give three research agents the same brief, you get three overlapping answers and wasted tokens. So if you're trying to paralyze things, right, and say research CV market, research CV market, and they're all doing the same thing, that's going to be nonsense, right? So carve up the scope so each agent owns a distinct slice. And so here we are seeing partition information where um we are creating structured data and we're providing detailed information like topic cover excluded things like that and providing that information there and as per usual we can create a tool that would check and make sure that we're dividing the research scope into non-over overlapping assignments before delegation. What's really interesting here is that it's making a structure. Um and I mean you know in the last thing that we did technically it is already kind of assembling um its own way of doing stuff but um I suppose what we could do is we could generate out into partitions um in this sense and make sure that it's even more detailed in terms of what it's covering as an intermediate step um to make sure that it's not doing the exact same thing. But this one's more focused on very specific things that it's researching. Um but yeah, the question is like does our current one even if it's not the exact same one is it having overlapping tasks and that's what we don't know and so maybe um putting a structured structure a structure with partitions might help uh but we'll have to experiment. Okay. Okay. So let's see if we can implement partitioning in here. Um so what I'm going to do is make a new folder here called research partitioning. partitioning and we'll go ahead and make ourselves another new main.py file. We're having lots of fun here. And so we'll grab this uh wasn't this one. This is the last one we worked on, right? Going to grab this here. Copy it and um go all the way down and oh wait, no, no, this one's empty. Here we go. Okay, so now we are back with our dynamic one. So here we have offscreen here I just told it to extract it out right and um I'm going to just say here like you know I want to make sure I want to make sure um my uh research what are they called what did they call them here my research agent agents aren't wasting credits uh tokens by having time by having uh overlapping tasks. And so I would like to have another step where we have uh partitions. Um and I mean like the thing is like you could manually make this up but I rather just generate it out so it makes easier for us. So we have partitions uh uh have a step where we generate out partitions based on a JSON structure and then we can determine if there is if they are truly not doing the same task. Make sure to print out the structure. So the human can uh see it on the run of the coordinator agent. Update the research partitioning main.py. And here is an example of partitioning uh from a different use case. Okay. And so I'm gonna copy this over. Bring it on over here, right? And I'm hoping that this will work, right? But I mean, like this also could just be like a static way, like if you were just statically uh building a research agent, um that this would be a means to which you could do it and you don't have to delegate so much out to the agent, if you will. But then now we're kind of relying more on um code driven logic. But you can mix them. By the way, we didn't we didn't mention that. But you can take a hybrid approach where some of it is the coordinator and some of it is code driven. There's nothing wrong with it. There's no rules here, folks. There's no 100% bad. It's what you want to do, right? Um and so we will see if it can come up with something here. And then we will review that code. Okay. Okay. Okay, let's take a look and see what it thinks it's doing here. So, uh, narrow. We still got this language like narrow versus better. I probably should get that out of there. I really should be taking this out so that uh it's not getting as complicated here. So, screening agent prompt. You are a specialist hiring analyst. You will be given specific screening uh questions about a candidate. Answer the questions two to three focus sentences. Be concrete and specific. So really changed it in this case. Um, oh no, no, this is fine. This is still the same. Runs a specialized agent. Calls once per screening, etc., etc. Um, I don't want Oh, I do not want multiple agents. Look, I don't want more more than one coordinator. Uh, we don't need the narrow coordinator. Okay. And so it's just because we copied it and I had some of the code still lying around and that's what's Oh, no, no, no, no, no, no, no, no, no, no, no. I just realized I was editing the wrong file. [laughter] Okay, so I went back there and I'm going to make sure I didn't muck that one up. Uh, yeah, I don't want to muck with this one. Oh, now I don't know. Did I break it? Good. Um, I think I can just go ahead here and discard the changes. I think it'll be fine. Okay, so we'll go over to here and this is the one we actually wanted. And so it still has that logic in here which is kind of a problem. But I we'll see if it actually is an issue because we only have one, right? And I'm just going to remove I just don't want it to get confused and I don't want to explain any of that here. So I'm just going to take that out. So let's take a look here. Says for both coordinators. So spoke system prompts. I'm just going to take that out. It keeps talking about like okay and now let's take a look here. So you are a partitioning uh a screen partitioning planner given a job posting resume output a JSON array of non-over overlappinging screen partitions. Each partition object must have an agent a scope um rules design partitions so that together they cover all relevant hiring questions. No two partitions may share the same cover uh cover aspect only partitions that are genuinely needed for this candidate. I feel like uh we lost uh information here. We have oh this is the planner part. Okay. So this is actually a separate part. Okay. So that just generates the partition. All right. And then down below here we have um the actual dynamic coordinator. So you you're here. Invoke exactly one screen partition call per partition. No more less formulate the questions for each cell. Do not invent additional screening angles beyond the partitions provided. They were designed to cover all relevant dimensions without overlap. And so I mean like that's another way where it's just specifying it in a different way, but I guess it's generating out the partitions. So in the other one we literally listed out possible things and here it's generating them out. Oh, here it is. Um, is this good? Because before we had a list, right? So, we go back over to our um we'll just split this for a second and we go back to our dynamic selection here, right? And so here we had this, but we lost our routing guidance. So, this is what I'm going to ask. I'm going to resume the last conversation we had. Got make this a bit larger here. No. So, it doesn't we don't have it anymore, unfortunately. Or maybe I ran into a subfolder and that's my problem. So I'm going to go here and ask it like we have uh we have a dynamic what is it that we have? We have a uh research partition so that we don't have uh overlapping uh researchers doing the same thing. Did we lose uh selective routing based on task? Uh and do we need to bring that back in while preserving our uh partitioning? Okay. And so I'm going to go point to dynamic selection has the original prompt that had routing. And then here we have research partitioning is our um new prompt with partitioning but the routing was removed. And so how would it know to do routing like do uh like how would it know to choose the appropriate dynamic selection? Okay. And so that's where I think there's a bit of an issue. Okay. Because sure like we now it will generate out that structure and things but how does it know to drive what to generate because it doesn't say that right and so D the both selects the angles matters and delegates it has routing that skips beyond the scan and strong matches now owns the selection step but it has no routing rules it just generates non-over overlapping partitions well it guides which uh on which one will skip and so here. Okay. So, I hit tab here. Okay. You are moving it back in, but are you thinking about how it will work or are you just dumping it back in? Okay. because I could have done that. That doesn't mean that's a smart approach. And maybe that's all we need to do. But let's take a look and see what it comes up with. I'm telling you, these things aren't smart, folks. You got to think for it. So, here we go. Fair point. Let me think about it. So, we have partitioning that sees the resume and then the dynamic coordinator which sees the partitions. Where does the routing actually live now? So, in dynamic selection, the coordinator was doing two of one things. deciding what to check and calling agents. Uh and the research partitioning now splits routing partitioning planner's job and then the coordinator's job. So the routing rules do belong to the partitioning planner but they need to be reframed. In the original one it says never invoke the rules unless here we should say only create partition if the rules govern partition creation. The coordinator in the new architecture should stay as is. It's correct to be dumb selection because the decision was already made upstream. Uh giving it routing logic. Again, we create a conflict of two places fighting over what gets evaluated. Um the partition planner currently says only include the partition genuinely needed. That's vague. Adding a specific horistic routing. I mean like I would have thought and you might agree with me is that in the dynam coordinator we had that list. Uh but the thing is is like it was saying like okay if you do this then then do this or do that. But maybe the problem was is that when we looked at the EV research it literally had pipelines where in this dynamic router it just had things that you could choose from that you might want to consider. Okay but it wouldn't run them all. So here it says we receive a set of pre-planning partitions as JSON. Invoke exactly one screening agent. Uhhuh. Okay. Well, let's just see what we get. Okay. I'm not sure if I like it, but we're trying here, right? And we'll go main.py. We'll run it and see what happens. So, what we have? We have core stack proficiency assess rest API capabilities. Okay. So we have here um core sacrifices evaluate mastery of required technologies uh directly matching the job stack. Uhhuh. Access REST API design capabilities. Evaluate exposure to scaling patterns and nice to have technologies. Confirm senior level experience. And then here we have screening angles delegated. Does the candidate demonstrate mastery of required stuff? Uh okay. And here we're getting partials. So we have a maybe recommendation. Alex is qualified to mid to senior and we have different coverage. So I still don't know if this is better. I mean like we should be dumping all these logs out and then comparing them and then and doing stuff. So obviously we're just trying to meet the requirements of uh learning this stuff and kind of having a sense of it. But is it good? Is it is another question that will take more time and I'm going to keep repeating that because I just want you to know just because we're doing it doesn't mean it's great. Um, and you should be thinking about like, okay, if I had these three, four different ways. Um, you know, determine usage, determine outcomes, have your examples. Don't have them for you here. That'd be a lot of work for me to set up for you. Um, but, uh, no, it's interesting trying to try out these techniques and apply them. Okay, let's take a look at a refinement loop. So, the idea right now is that um, everything's been one shot. The idea is it goes through it. it produces an evaluation and then then it's over. But what if we could feed it back in the loop and refine it until we are happy with it and that's the idea behind refinement loop to make our research system really really good. Um so if you look at this prompt here for our coordinator the idea here is that we are telling it that we can have up to maximum four refinement iterations and that we are going to redelegate the information uh back into here. And so you'll notice here we have like an evaluation coverage and when to submit final uh and uh uh creating the synthesis and things like that. And so we will go ahead and try to apply refinement loop to our um our agent. Okay. Hey folks, it's Andrew. In this video, we're going to implement our own refinement loop. Uh, so what we'll do as per usual, I'm going to go ahead and make a new folder. This will be my refinement loop. Okay. And then what we're going to do is we're going to go ahead, let's just grab our code here, main.py. We're going to go grab our last one, which was research partitioning because we're building off of it every single time, trying to make this thing a little bit better. And we are going to implement refinement loop. I need to extract the text out because again I I don't have it on on hand. But uh let me go grab it from that slide. Okay, there we go. I grabbed it. And if you want to grab it too, all you got to do is take a screenshot, feed it to Claude or Chat GPT and extract it out, folks. Um because you can you can make sure you do that. Okay, it's not hard. Just build up those skills. Okay. Uh so I'm going to go ahead here and just CD out here. We're going to go into our claude and um you know I need to implement a refinement loop um uh in my agent for research partitioning main. Here is uh a example from another use case you can uh use as inspiration as guidance. Okay. And so I'm going to paste that in there. And so the idea though is that with that information I'm hoping that it can develop that refinement loop in here. So we will see what it produces. Okay. All right. So in here we have um changes. Let's take a look. And well, it's still trying to edit stuff. So yes. Um and let's see what we have. Okay, so it is bringing in um evaluate coverage. Okay, so we have that uh submit final. So it's setting different states based on whether you know high or maybe or pass. only call this when the evaluation confirms uh sufficient coverage and final recommendation. So we have that in our loop here. It is adding the evaluation agent. Okay. And we have some tweaks here. So we have initial screening invoke exactly one screening agent call per partition. Formulate each question. That's fine. Phase two evaluate coverage after all initial partitions agents have reported call uh evaluation coverage with plain text. Then here we have refinement max reiterations if the evaluation coverage returns sufficient falls. Invoke screening agents to fill only identified gaps. Uh call submit final etc etc. Do not call the submit file before evaluation uh if it's only once. Okay. So here it's obviously done a lot. I'm kind of curious to think like maybe it's just like you're brute forcing to make it either that you really want this person or you really don't want this person. It'd be interesting to have a larger data set like let's say 100 applicants and you ran it through and to see if it just skewed it to one location or one side or not. Um, but it would be very interesting to find out. But we'll go back up to here and so we can see the changes and let's go and run this thing. Notice as we are progressing it's becoming easier and easier for us to update our agent. And so far we've been just using the anthropic um SDK, not using the agent SDK. The agent SDK is awesome, but um we will just continue on here. It'd be interesting to convert it over and see what the code looks like. And we'll probably do that. U let's go ahead and do python main.py and we'll go ahead and run that. And the idea is it's going to run. It says dynamic coordinator. Obviously, it's the uh refinement one. We don't change those names. And so here reads candidates first routes to the relevant checks only. So evaluate depth access to database caching verify API confirm senior level experience and is the candidate senior level. Okay, great. So now we're going into iteration one. Okay, so we have coverage score, code quality, practices, no evidence, etc., etc. And so it is going again here asking questions. They are I think they are different questions. It's hard because we have the this up here, right? And then down below. Oh, look the the coverage score is going down now. Interesting. And so we are done and over with. We'll go and uh look up here. So it did two iterations and their score went down. So yeah, that's an iteration loop. Is that good? I don't know. It takes a lot of work to evaluate this stuff. We would spend hours, hours upon hours tweaking this to figure out is this valuable information? Is our data set good? etc., etc. There's no magic here folks. We can uh code these out very quickly, but to make sure they actually work good is a different story. I'm going to keep repeating that because it's true. Uh but that is what the refinement look uh refinement loop looks like. Okay. Hey folks, we are back and I'm going to make a new folder and this will be uh coordinator observability because the idea here is that our coordinator should act as an observable layer and so I want to make sure that it actually is doing that. So, let's go back here and we'll uh uh go into um well, we'll type claude here, right? And we already have the refinement loop over here. So, I'm going to go ahead and grab all this code. Okay, I'm going to grab all this code and we'll make a new file called main.py. You're starting to get the pattern here of what we're doing, right? Very repetitive, but it really is good in iteration. So, um, what I want to figure out is, do we actually have those values? Is the coordinator acting like a coordinator? So, um, I'm just thinking about this for a second. So, what we want to do, so we're going to say, uh, I have an agent, uh, a coordinator agent, uh, here. So, we'll say, uh, coordinator observability Here I'm going to put this into plan mode. Here are the questions I have. is my coordinator operating from observability level observability and uh uh I'm trying to think of the word like and controlling controlling flow of information uh you know is it uh managing you know like is it I'm trying to think like here I have a coordinator agent right here are the questions I have is my coordinator They're operating uh operating from uh uh operating with an observability layer. So we can capture uh any errors all messages that that that are being uh sent to our spokes sub agents. Is it controlling context and what is passed uh to my um uh spokes and only those sub agents can talk to the coordinator. Right. Is there something I am missing to make my coordinator like a coord coordinator, right? That's what we want to know. And we'll go ahead and hit plan there. You're thinking, well, you know, you're just writing whatever out. But that's that's a fine prompt. You can't make perfect prompts here, folks. I mean, you can make better prompts yourself and spend time engineering them. But this is good enough to start getting some information. So let's see what it comes back with. And I'd be curious to uh layer something here on uh there. So I'm just curious what we can do um to make our observability better. Um but we will wait for that generation. Okay. Okay. So let's take a look and see what it thinks. Um so we go all the way at the top here. So the users coordinator uses a partitionbased hubspoke pattern for job screening. They want to know does it have proper observability? Does it capture all messages of spoke? Does it control past the spokes? Is uh is the spoke coordinator communication isolated? What is missing to be a good coordinator? So it says observability is weak. I absolutely agree. We haven't done anything for it. Um could we do something better than just Oh yes, says only print statements. I agree with that. Um uh error handling anywhere. It says JSON loads. Yeah, that makes sense. API level tracing, no token counts, no latency, no request IDs. Yeah, token counts would be really useful. uh no persistent audit trail of all output and epheral std out. We have message capture partial. So delegated list. We are printing some stuff right because I told it to do that. But um tracks questions sent to spokes. Spoke responses are never stored. They go straight into the tool results and are lost after the coordinator. No record of partition. Each question addressed X. No log of coordinator's own reasoning. Texts between tool calls. Mhm. every spoke receives the full job posting and so saying context control loose resume regardless of its partition I mean it would need it anyway right like all of them need it so we're not really giving them separate data uh regardless of its partition scope so cover exclude is only advisory only passed by JSON to the coordinator prompt but not enforced at the spoke level the coordinator could ask any question no mechanism validates the question stays within the assigned partition. Fair enough. Spoke isolation one direction one direction law enforce. So spokes are stateless functions called by the coordinator. No cross no cross spoke communication. So that's good. But spokes have no awareness of their assigned partitions. They can't reject out of scope questions. Oh, that's actually a good good point. No. Uh only these folks can talk to coordinator mechanism. It's just a single plane one. So where are our gaps? Can't debug or audit the run. Silent crashes on failures. Can't replay or inspect what's wrong. Coordinator doesn't know if all dimensions are covered mid-run. Recommendation may be issued before all uh angles are addressed. Spokes are all data even if relevant. All partitions even if some obviously irrelevant. A single pass cannot fill gaps during it. And also our data like if really if we may want to make this better, we would be sending like different payloads of different information to specific research agents. But right now everyone's getting the same job posting. Um, so here they have recommend fixes. So structured logging with time stamp levels. That seems good. Uh, that's fine. Sure. And it's going to log that out. Error handling. So wrap the JSON low generate the partition. Uh, persist spoke inputs output. So extend beyond the tracking. Add coverage evaluation tool at add explicit gates. Force the coordinator to call submit final. And so these are fine. Um the only challenge here is I don't I feel like there's a lot of tasks here. So I'm just going to go here and say there is a lot of of work here. I am concerned uh you will uh not be able to remember all the tasks. Can you create this uh plan in a readme with a task checklist and can you check off the tasks as you complete them? Okay. And so the goal there is to help it out a bit. Um that's not exactly spectrum development, but the only thing is like if we really wanted this to drive and be really good, we would want something that would clear context each time. But we're not set up that way. I'm not here to roll a a small spec driven development little thing for us here. So that's totally fine. And um read me with tasks and checklist. As long as it knows where it's doing that, that's fine. But where's it going to put that file? Yeah, I'm just going to trust that it can do it. Let's go ahead and let it rip. Okay. Um, and so the idea again here is to improve observability and we will uh see how that goes. Another thing is like I would imagine that if you were to put this into production, you want to productionize it, you might want to contain these sub aents into containers and then you might want to use hotel as another observability layer. That's how I'm kind of thinking about it. But we're keeping it all monolith for now and we're not going to overly complicate it at this stage. Um, and I'm going to let it go and burn away all my credit. Look at that. 6.2,000 2,000 credits. Wow. Let's go over here. It's like the worst time to do this. People are like there's on Twitter they're like, "Oh, it's down and the usages are gone and stuff like that." It's me. It's me. I'm the I'm the problem. So, we go over here and right off the bat like we are uh Oh, resets in 9 minutes though. That's really good. But only 33%. Well, let's burn burn, baby. Though my week is is is uh getting up to use very quickly there. Um, but anyway, oh yeah, it's it's going up. So, yeah, we're going to consume tokens like it's nobody's business. Um, but I think it'll be worth it for this stage of the uh thing as we are continually refining it. Okay. Uh, that was fast. I feel like it should have taken longer than that. All six fixes are implemented. I mean, I would rather it have been more granular and clearing context between it so that we would have um, you know, better stuff, but that's fine. So, is my coordinator operating with observability? No, it had only print statements, etc., etc. What was I missing? Error handling, midrun gap detection, no exit gate. And I'm not even saying like this is the best, but um you know, it's pretty good for us throwing things here together. Let's see if we can see what code I mean, it probably will just tell us what code changes were made. I suppose that's the easiest way to check. And um I'm just going to go all the way up here. Let's take a look here. So, we've added logging. Okay. And we are implementing the logger here. It says scope to each partition part agent name uh is the names the question belongs to from the partition JSON. Okay. So it's being very particular to make sure that it's scoped. That's good. Evaluate coverage. So midrun gap detection tool. Evaluate whether the screening finds are efficient to make a confident recommendation. Um confident that all partitions agents have reported. return a coverage score, etc., etc. Okay. Submit final explicit exit gate. Submit the final hiring recommendation only. This call this only after evaluate coverage. Fair enough. So, we'll go down below here. Mhm. Uh, fix error handling. So, here we have uh here's down the error handling down here below. Fair enough. That's very basic. That's not really that important. And then we have the screening agent. So we are seeing oh to scope it into the boundary. Right. So making sure that it's scoped. Fair enough. Here we have rule changes. And so it's about passing that information and it's talking about that evaluation coverage in the final recommendation. Okay. And then we got logs, logs, and more logic. Now, this thing is pretty wild. I would probably want to take it farther and refactor it, but I don't really want to uh like this is just this is a mess. Like this is not how you should have your codebase, but I don't want to go overboard at this stage. I just want to make sure that this works. Okay. So, what we're going to do because I'm expecting logging to appear, right? Um, and so I would probably say like we could just run it, but the other challenge would be like we need actual ways to test that this stuff works. So, probably would would have been better. Um, but it would have taken a like this would have took an hour or two and you folks don't want to wait around that long to test that. But what I would have done if we had the time and you wanted to go through it, what I would do is I would stage um examples and and and I would want to see if like we could pollute um uh pollute the context between agents and make sure that it is only receiving proper questions and it rejects it and those would be things that we test for. So we really are skipping a lot of that stuff and that's stuff that you would still have to do. But just because I'm not doing it here doesn't mean that I wouldn't do it. Um it's just I'm not doing it because you folks don't like when I make like two three hour videos. Um even though that's the actual effort for the work and I can't really just you know fake that along, right? So we'll go ahead and we'll run that. I think it's called observability wrong which is fine. And so what I'm interested in is do we get any logging? Where's our logging? I don't see it. Okay. Oh, I mean it's just going to st out. So, it's not logging to anywhere in particular, which is fine. Uh, so, you know, I'd probably just have it logged to like into in a log directory. And that's the only that might be missing here. Okay. And I'm just going to wait for it to run. Oh, there we whether it's done. And so we have our final information. Did it call that final evaluation step? Yeah, final recommendation. There it is. So there you go. That's all it took to improve it. Definitely better than what we had before. Um but yeah, I would probably want to refactor this. So that's like you shouldn't have one big dumb file like this. Um and so we might do that in a separate video, especially if we want to convert it over to the agent SDK to compare. That might be something we might want to do. Okay. Um, but yeah, now we've added observability. Hey, this is Andrew. In this video, we're going to look at how to handle errors when we have multiple agents being coordinated. Um, and it's interesting because they have this later in 5 uh 3, but we covered about sub agent stuff earlier. So, I'm not sure why they uh like we have sub agent failure recovery here where we have this example. Um, so maybe what we'll do is just um go ahead and say make a new folder. We'll say coordinator um failure handle handling. And so I'm going to go ahead and find that folder here. We'll go ahead and say main.py. And we'll go back down to our um one where it was with the sub aent. This one here. Okay. We'll go ahead and copy this and we'll go all the way up to this one and then we'll take a look at what we have. So what is it that this agent is doing is I don't remember this is is errors and so it's about checking for inventory placing an order tool notifications. Um and so what we want to do is go plan MD and uh so uh coordinator error handle error handle handling um uh uh test. Okay. So we want to turn our sub agent into a coordinator with multiple sub aents. The goal is to demonstrate um error handling by sub aents. So we should have at least uh three different sub aents. Um our goal is to do the following. uh return back structured uh error context. DG failure type attempts. Uh approaches be clear about the well I mean like it says distinguish between access failures invalid empty requests. I think like the type would indicate that. So that's kind of redundant here. Um we don't want generic errors. So avoid avoid generic errors. Says while while silently suppressing errors or terminating uh why silently suppressing errors or terminating entire workflows in single failures are both antiatterns for obvious reasons because that would be bad. You know returning structured error context including failure type when attempted and partial results distinguishing access failed uh for valid empty ones. having a sub agent implement local recovery for trans transit failures. We already have that technically. Um structuring synthesis output with coverage annotation indicating which findings are well supported versus which ones. I'm not sure what they're trying to ask for that. Um so I would say like we have a lot of this but basically we're just doing this. So um what we'll do is go ahead here. I'm just going to save this file. We'll open up Claude and I'm going to say main implement my plan. Here we go. And off to the races it goes. We'll be back here in just a moment. But you can see like as we're reading through this like some of this is just fluff and so we need to really identify what it is that we're trying to solve for. Um but we'll be back here in just a moment. Okay. All right. So it's back and it's done a bunch of work. So it says beta tool decorator function replace the JSON tools. Uh, make tools factory creates tool closures. Oh, what the heck is this? This doesn't sound right. Maybe I'm in the wrong context. Oh, yep, yep, yep, yep, yep. Here's a problem. So, we are we are not in the correct location whatsoever. Um, and I have just mucked up my last one here. So, let me just give this a refresh. I'm gonna have to undo that. One second here. Last one here. Um, sorry. Can you undo the changes? I'm in the wrong folder. Okay. So, I'll just undo those changes and then I'll go into the correct folder. Just be back here in just a moment. Okay. All right. So, I was able to revert the changes and I just have to go into the correct directory um, which is coordinator coordinator fail failure handling. We'll go ahead and do this. I'm getting a little bit tired of uh low quality code here. So, I'm going to go over to Opus. And we are on X high. I don't want to be on X high. So, we'll go effort. Um and we'll switch this over to high. They keep changing it on us here. You got to be very careful when you're using it because it just like for usage otherwise you burn out on stuff really quickly. So, please implement uh plan MD. Okay. And we will wait for it. Okay. All right. So, let's take a look here. Um so, end to end works. The coordinator delegates to all three sub agents each return structure JSON report notification sub agent recovered from the permissions error. What was implemented? Three sub aents. So inventory a uh inventory agent order agent notification agent. I'm not saying that we should be breaking them up like this but it's just for our example as these are obviously very simple tool calls. Coordinator delegates each uh via the tool calls. We have structured error context. Okay. No generic errors. So which we already had before demonstrate recovery. So the notification sub agent hits a permission error on the executive team and recovers it. So it's still sticking to our original uh one when we utilize this if you remember this use case and we will go over to here and we'll just take a look here. So we have make error make. Okay. So every error is typed. Cool. Okay. And then uh domain tools. And so we have inventory up here and our main tools. And so there they are. And then here, scope tool set. Each sub agent only sees its own tools. Okay. And so here, these are the tools that it's allowed to use. So check inventory, place order, and notification. Um, sure. Okay. So this is just tool handles to map to that. Okay. And so they each only get one tool, which is fine. We have structured report format. So returns only a JSON object. Um and so here we have status, sub aent, summary, attempts, failures and then its information and more information here. Then we have our inventory agent. So here you can see it has its detailed rules on how it should recover. Um and same thing for this one. Same thing for this one. Then we go down to here. We see our coordinator. So we have coordinator tools, right? That makes sense. And then we have the coordinator. So you delegate to the three specialized sub aents. Each sub aent returns a structure JSON report plans the workflow from the user request from delegating. Okay, makes sense. After all delegations, give the user uh user a concise summary outcome. Okay, and then we have our max steps. And so really that's all we're doing is we're just structuring the data and making sure we are covering our use cases here. And then we have our sub aent registry down here wondering how they're spawning them. And then down below it has run sub agent. So let's just take a look at what that is. Oh, it's up here. Okay. And so then it'll just spin one up here. Um, and I'm just trying to look here what it's calling. Is this using a sub agent? Double checking. Double checking. Or is it just putting everything through a single pipeline? So report await sub agent. So the only question I have here you know based on this code you know is is our sub aents actually implemented as sub agents like they have their own context and are unaware of um any other agent. They are independently running uh running separately also like what are we using? Are we using the um agent SDK? I mean like should we not use the agent SDK? Uh and that way we can leverage um agent definitions check docs and so I'm going to see if that makes a difference. There could be like a reason why we don't want to do that. We'll find out here in just a moment. So yes, be back here in just a second. All right, let's see what it considers because maybe there's a reason why. Um so here yes architecturally per uh the agent SDK own doc sub agents are defined for properties concept isolation tool restriction specialized instructions we have handrolled as functionality the same pattern the agent SDK agent uh definition abstracts what the agent SDK gives us what we don't have this is actually a good layout so hand roll coordination built-in stuff 50 lines of manual response context handling a query resume sub aent mint conversation okay so we can't do that parallel sub sub aents uh built-in file system structured reports and so we don't get sequential sequential or sorry we don't get concurrent stuff for this use case sequential is fine stick with the manual pattern hide the uh exact mechanics we're teaching dropout or structure the agent SDK shines when you want file system shell sub aents that's what it's built for um so for a domain specific coordinator then we should use the rise to fair enough sure why not Um but uh what we'll do is go ahead here like they they I mean obviously agent SDK is leveraging cloud code stuff. So things that are code code related make sense but you know sometimes we will get some conveniences utilizing it as well. So now that that is there let's go ahead and see if we can run it. Before we do that I want to make sure do we have end dot? We do. Excellent. So we'll go ahead and say python main.py and we'll run it. And here we see the the coordinator. So a coordinator delegates to three specialized sub aents. Each sub aent has its own scoop, domain and structure. The executive team notification triggers permission error. So user request I need five units of widget A and it goes here and then it returns back the report that it was successful and then we go to this one and this one's successful and we are looking for the failure is probably this one here. So here uh we send a notification and it comes back with oh that that looks successful too. Executive team agent direct uh direct executive team notification denied. So I'm looking for it in here. And where's the bubble up? So, I'm going to go here because I can't see it. It's just it's just very hard to see. So, I'll go here. Where is the error uh information being shown here? Actually, you know what? Let's make it so that it absolutely does break. Um so, what I'll do here is I'll just change the inventory to zero. That might be a better example. And so, we'll go here. Oh, no. Not yet. And then we'll just run it again. see what happens because this will be probably a lot more clear and fail quicker. And so here we have an error and here it reports back. Whoops. We reports back status completed sub aent inventory summary. And so that is the information that we're expecting to see um for that to understand if we're running into an issue. So I would say that's pretty good. And so hopefully it's very clear what it is that we need to do. And I'll bring up the exam guide just one more time. So the idea here is just providing structured data that bubbles up, right? And being very clear on what to provide in terms of information. But yeah, there you go. Hey folks, it's Andrew and in this video, what I want to do is I want to refactor our coordinator that we've been working on up to this point as I'm going to want to port it over maybe to agent SDK to just take a look and see what that looks like. And so we're just going to say um uh coordinator refactor here. And I'm going to go ahead and grab the code here. And we are going to ask it to refactor. Um and let's just see if we can make this a little bit more maintainable. Okay, if you are not a programmer, you might not know that this is not good code. Okay. And it like it works for this point that we've been able to hold this all into memory. But if we came back later, we wouldn't be able to really make sense of it. And just because the agent can make sense of it and summarize it to it, that's not good enough. We need to make it so that it is more human readable. Um, and that is what we are going to do. So, I'm just going to uh cd out of here and we're going to go into claude and uh we are going to get some refactoring going on. So, what I'm going to do is I'm going to make a new file called refactor um refactor md and I'm going to go say refactor um tasks. So, this is this document um is the tasks I want completed to refactor uh this uh our coordinator agent. Uh currently all code sits in the main.py and we need to uh break it into multiple files. Okay. So uh let's go ahead and start making some tasks. I'm just going to make my observations of uh what I don't like. So the first thing is um the prompts. So all prompts should be uh stored as um all prompts should be stored all prompts should be stored as markdown files in a prompts directory. Okay, so that's step number one. The other thing is like tools. See how tools is very uh wieldy. So uh tools should be uh individually defined as their own files in the tools directory. We should have py files for each actual tool code and the um tools dot the tools. I mean like can we that's just JSON, right? Um uh can we I don't think there's anything special about this and the um tools JSON for the long tool right I think it will understand what that is for the uh gets passed to create so that is definitely something I would like fixed what else what else um junior partition S we do have the partition system. So we'll say partition uh generation should be in lib as its own file. That's something else I would do. Um that's a function that is that run coordinator. Um the logging is inconsistent. I don't like how the logging is. So um we should have a logger that um refactors all the logs to be consistent in a file in a file called logger in our logger pi in our uh lib directory. That'd be another thing I would want. Um, yeah. So, I think that's a start. And so I'm going to go ahead and just say uh coordinator, I want you to refactor my code based on that markdown files tasks for the main.py in the coordinator refactor. Okay. And so we will let it go do that and we'll see if we can really reduce and organize that codebase because it should be really easy for us to read, right? Like I know we can make sense of it because we've been carrying forward it, but we really need to be 100% like yes, absolutely I know what I'm looking at. Okay. Um so I'm just going to accept everything that goes along here and then we will take a look and see what we have. So it's already off to the races. We have our prompt, our partition planner, our screening agent MD. For me, like I probably want these to be templates that you can inject stuff into, but there's no reason for that right now. We don't really need dynamic injection, but it's definitely something that would be uh interesting to do. We have our tools directory. I think we only have the one agent here. And then we have our tools JSON. So, that is uh working out pretty well so far. It's going pretty quick, too. Man, these things are getting really, really better. Here we have our logger. And then we are going to have our partitions.py. I really don't like that we have constants. I do not like using constants whatsoever. I think they're just it's just bad bad code. Um but we'll continue on here. And check it out in a moment. I'm going to just check how my usage is going. And oh it doesn't matter. It just reset. I'm back at 2%. Look at that. Lucky me. Eh. Okay. So we are just chilling out here waiting for this to generate. I'm going to pause here and we will come back here in a moment. I think it might be done. I didn't even really wait that long. And so we'll go up here and take a look. And so we have our main.py. We have our prompts. We have our tools. We have our libs. Let's go take a look here and see if this is reduced enough. Okay. And I probably should have told it to check box off these. Uh which is fine. So, I'll just go here and just check them off myself. I just didn't feel like telling it to do that. I don't know. I assumed it would be fine. I could also ask it like, "Hey, is there anything else that we could do to refactor to make it more human readable, but I don't feel like it would know because it's not a human and it's trained on garbage repos." Okay, so let's go into our main, wherever that is. Hold on here. Charming and I I usually just have a sense of like is this readable, right? Um and it's still yick. It's really really long. So there's still some stuff in here that needs to be refactored. We'll go over to here. Um so say coverage report Coverage report should be its own file in lib called coverage report. Okay. Um the other thing is like the data. So right now we have hardcoded data. Make a data folder and store data artifacts and load them into the app. Okay, that's another thing. Um, I really dislike the logging. Yeah, we got trace append. It's still very very verbose. And there are still things. It's like I'm noticing here like um there are uh there are templates for uh content for messages that should really be uh templated uh files that take variables and load it in. Maybe um okay like is that a prompt? I mean like we have this technically are prompts. So technically technically they are prompts are prompts for content and so uh prompts. So move them them to prompts folders. Okay. So, there's that. There's a lot of those. Okay. And so, we'll go back here. We'll save the file. Um, all the way down to here. There are new tasks in the refactor MD. Okay. And so, we're going to have it go off and do those tasks. And so we'll give it a moment there. I'm going to pause. And I mean, I really should tell it to check them off. I didn't tell it to do that, but we'll come back and take a look. And then we'll ask it to do a general refactor. I'm still like I really don't like this. Like we see how we have like double lines and stuff like that. I don't need that kind of level logging. Um but I would have to explain to it um why that's an issue. Yeah, it's still just making them MD files. is not marking them whether they're templates or not, but we'll just treat them as templates. And here we're getting a lot more in here, so that's better. But I just know what good code looks like. And I I know that's not good code. Um, but there's only so much you can do with Python. Certain languages have um the ability to have better readability. Like Ruby's really really good at that. I'd love to port this over to Ruby. I just didn't check if the agent SDK is available. I don't think it is available in Ruby. I just think that the Santhropic one is. And so if the agent SDK was in Ruby, I would absolutely be using it over the Python one as I really do not like Python code and um it it just you just can't get it to be extremely human readable. Um unfortunately we were all kind of using it because of the way the industry is um as they've adopted it not because it's good just because of mass adoption in the uh data data science and stuff like that. So, it just became de facto. Oh, look. It's already done. And so, we have uh that there. And so, we will again look at the main file. I'm just going to close it and reopen it. Sometimes it doesn't always show me right away. It didn't check box these off. I really should tell it to checkbox them off when it does that. So, we'll go ahead and save that. We'll go back over to our main Pi and we'll scroll up. And again, I'm looking that looking at this for uh for refactoability. And I would say like they haven't done a good job with logging. So I'd say you haven't done a good job refactoring the logging. Right? So for example, we have log log info partition like partition. Uh you should be making helper functions. Uh so these logs you like log partition um or you know like log right log warn and they will add uh the you know tags. The uh other thing is um you have superolous logging that is great for human readability but we want to focus on logging good for for uh logs and uh we should be outputting logs to a log folder relative to the uh folder. of this agent. Okay. And so that, you know, that's one thing that's really bothering me. I really hate constants. So that'll be another thing that we fix here in just a moment. But again, we're just trying to get this to be in shape. Um, did also move this out of here? Like what's this big thing? Like why is the tool use so large here? Okay. Um, and while that is sinking, let's go review our other parts of code. Okay. I mean, this is fine. I think I wouldn't mind if we had like this is a big JSON object, but I wouldn't mind if we had a shorter syntax for this. I don't want to do that right now because it's totally possible that um uh we will be able to do that in agent SDK where it probably already has like a shorthand to make that code smaller and so I don't want to uh muck with that. And we'll look at the partition here. Really hate those constants. And also I really just like how it's loading in the prompt template. So there should be a way to uh manage that. Look, look at all this logger logic. Oh, no, that's the logger file. Yeah, here now we're starting to get those things that I'm that I was asking for. That's good. Um, okay. The other thing that that's and I mean we don't need to do this, but like technically, you know, we have all these sub agents they're calling create. We could technically delegate them out to different models if we needed to. Um, or we could even say like, hey, can you try to choose the best model as it's working through there? But yeah, I guess the next thing on my task is to fix that. Um, like I'm not updating the refactor. We could keep updating that as a means to keep keep track of stuff, but I just don't care. Um, and so yeah, I want to fix those constants. And I want to get something that loads in the templates. I'm just going to take a look here at our usage. 9% doing okay over here. Okay. And so now that is uh fixed up. We'll take a look here again. I'm looking at my main seeing if it's shorter. Yeah, it's looking Yeah, this is way less messier. Um I don't like using constants. Eg. Like this is a var. Please don't use these in the folder for the coordinator refactor. Fix the code. Okay, so that's something I really dislike and so we will get that improvement there. This this to me is like there's a big issue with the loop. So I feel that we need to give it a better instructions on like how to better refactor the loop. I mean it's using just a big elf is elf blocks block. There might be some kind of uh state flow machine or something that could improve that loop. Um as I'm not happy about it. Before we do that, I want to fix the template reading and loading of files. Um and so there it's just making basic changes for names right there. So those are getting changed. Good. And it'll be done here in probably just a moment. It's just updating the main.py. And then we will have those fix. Come on. Come on. Hurry up. Hurry up. And also like loading these templates and populating them probably needs to be um its own thing. Yeah, great. Thanks. Okay. Another thing is uh loading loading files and templates where you uh inject variables. Um you can make a new uh uh template template um template file in the uh lib directory. And this should uh refactor having you know large load code eg like this. Okay. And so that's another thing that's kind of bothering me. So we will get that cleaned up as well. Um there's other things like this like see how this is like something's happening here. So that should be refactored out into a function. Uh like everything here like just the units of code is is just not explainable. So the run coordinator definitely needs to be broken up into tons of functions. Every single of these if else blocks should be functions. Um and I would probably prefer stateless classes. I really prefer stateless classes as that makes it really easy to track inputs and outputs of stuff. Um, and Python's pretty good for that because of the way it defines uh these label tags. I can't remember what they called the prop named properties. And so that will be good. We're making a lot of changes here. So there's a high chance this might not work, but that's fine. Uh, we can always work through that. Uh, it's fine. You're fine, Claude. You're fine. Okay. And so now that's loaded. I'm not sure if uh that actually changed. We'll go back over to here. And so with that now when it needs it, I feel Yeah. like load prompt. exactly like this. Um so yeah the big problem still is the run coordinator. So the run coordinator file is giant uh we should refactor um into a stateless uh uh a stateless function and all the parts of code uh should be chunked into functions. So the functions basically act as documentation. You know for example the contents of if if uh if blocks are really uh should be uh function calls right we'll go ahead and we'll see if it understands what I'm trying to say. But like when you write good code, you know, like this would be a function, this would be a function, this would be a function. Um, whatever this is, right? These if blocks and we'll see if it understands what I'm talking about. Um, but I feel like that's a really important component. In fact, this run coordinator could also be in the lib directory. Um, and we might suggest it to move that in a moment. But right now, I want to see if it could even handle what I'm asking it to do. It might not understand. Uh, cuz if I don't have like an example, it's just not going to know what I'm trying to ask for. Again, checking my coverage here. Uh, we're at 11% usage. Some folks were suggesting that like when it's high peak usage, it depends on like if you overlap with eur European time. I'm not uh obviously in Europe and so um they said like just try a bit later when everyone's sleeping and it's way later so uh you know it would be maybe u off peak usage time but anyway we'll just wait here and see what happens. Okay, it's back with functions and again we could call plan to ask it to do this before but I don't really care that much. So we have plan partitions validate index partitions run. I've seen stuff like with partition information. Almost wondering if that should be really part of the partitions pi, right? Um log coordinator reasoning handle this information. And so those partition ones, there's three with partition ones, right? And so we'll go over to here. Um I mean like sure you could do it that way. That's not what I asked for. I need to verify this. So, I got to go over here like what does a stateless class look like in Python? Can it be a class with static methods? Okay, because that's what I was asking for. Yeah. Okay. So, look, I don't It did not do what I wanted. I mean, close. So, okay. We'll go all the way down here. you know, I wanted a stateless class that is a class with static functions. Okay? Right? So, you didn't uh and I noticed some of the functions were handling partition logic. Is that something that should really be part of the partitions uh pi? Right. So that's something I'm noticing as we are shaping that code. Okay. And so we're going to give that a moment to shuffle those things around. Now, is it thinking about that or is it just shoving things over there? Index by agent for partition. Sure. Build initial messages. Again, is that for partition? Is it actually asking that question? Does it belong over there? Or is it just that it's handling partition data because it moved it and didn't actually question whether it goes there or not? Um, but any we'll go over to here and we'll take a look of what's changed. What's is still working? So now this is looking a lot better. Um, because now we can see what is going in, what's going out, right? Okay. And so we have all these steps. So we have call. So create a message log reasoning again like it does this logging stuff belong with the logger. Handle screening agent. Handle evaluation coverage. Handle files. handle submit uh final process tool calls run. Did they put these at the bottom? They did. Sometimes people put these at the top or sometimes they put at the bottom, but like the one that obviously is the big one is this one here. And so the idea is that we should be able to easily see what it's doing. So we have generate partitions, partitions, validate overlap, index agents, right? And so this should be self-documenting as you read it. We go down here. We call the coordinator. We do the log reasoning. Why are these functions? Are these just loose functions? They are. Well, no, they're part of the partition. And so I would go over to here and I would say, you know, give the um give the partitions pi the partitions pi like all of our lib directory. Now I'll say our partitions pi should be a stateless class I so a class with static functions please update and that's just the way I prefer it. Okay I like to group them into domain. I don't like having loose functions where we don't know where they're coming from and who who respects them or owns them. um people in the data space are very much used to just randomly importing a bunch of stuff. So they have a uh less sensitivity to to that kind of thing. But to me as a very professional developer, I I want to see where that stuff is coming from. We still have some of our if else stuff here. And notice in here like these again, these should be functions, right? All they all they're doing is calling these things, but still I want these as functions. If there's an if else statement in here, especially in our main loop, that's what it should be. We have a range of 1 to 31. So that's kind of defining how many steps it can take. Um I would rather that uplifted as a variable, but we're not going to go too crazy on this. I just want to get it in enough shape here and mostly just to show you like what good code looks like um and what you should be doing before you move on stuff. You might say, "Well, Andrew, why? Like this is more work to read." Yeah, but if if you want to write test code for this, then you have an input and an output and you know exactly what to mock going in there and out of there. The only thing that I would also change is like if these are complex um objects, I'd want them to be dumber and only pass in really dumb data so that we could mock it a lot easier. And this is pain points if you've spent a lot of time writing uh code. And you might say, well, you know, the AI can write the test code for us, but that doesn't make it good test or reliable tests. And and you'll only know that by uh writing that stuff. But we'll go over here. We'll take a look at our partitions. And so that is fine. There's still lots of little improvements to be made. like I'm looking at like why is that like that? I don't like hardcoded stuff like that. Um there's just a bunch of little things but I'll just say we'll move the coordinator over. So uh the coordinator uh can be in its uh coordinate class should be u in a its own file in the lib directory. Okay. And we'll move that over there. That'll be the last thing we do here. Um, and then what we will do is we'll just run it, make sure it still works. And then we'll call this, you know, doneish, right? But again, you know, if this was something that I would want to put in production, I would take the time and fine-tune it. I take the time and fine-tune it and and because that's about getting um uh the word I'm looking for is um uh technical ownership, right? that you have ownership of the code and and you know exactly what it's doing. And when you shape it like that, then you have a better sense of it. So now the coordinator is over there. I want to just run it to make sure it works. So I'm going to CD into the coordinator refactor and we're going to go ahead and run python or python.mmain.py. Okay. So we're going to run that and we will take a look and hopefully it still works. There we go. I wonder if it's going to make the log file. We do get our logs. Excellent. coordinator.log. Okay. And see, that's what I meant when I said I want it to be nice and uh and whatever. I might even suggest like I'd probably prefer to log out JSON structure because then we could parse that information. Um yeah, I think I that's what I would prefer especially like if you're data driven, you have JSONL data as logs. It's super super useful. Um, so instead of having like coordinator or delegate, um, I would probably just have JSON objects and then I could parse it and ingest it into something else. But again, these are little tricks that you learn building applications of all kinds. Um, but the point is that it is running. We just want to see it to completion and then we will call this done and then we will move on because the next section of stuff we are looking at is um, stuff that I feel like agent SDK is going to be uh, very useful for. um they'll all have to decide on that. And so it did run, worked great. The only thing that I'd probably ask it to do, which it's not doing right now, is I would have it dump the coverage report into its own file. So that'll be the last thing that we do here. Okay. And so I'm going to go here because that would actually make it useful, right? So, I'm going to go and just say, um, you know, for my coordinator refactor, uh, it currently generates it generates a coverage report in the logs, but it really should be outputting outputting um, uh, the a a report timestamped uh, in a reports directory. um and formatted nicely for uh human to read. Right. And so that's the last thing I would absolutely say we need to do. I just realized that that's a little bit um gross on how it currently is. Uh and we never looked at our data, but yeah, we have our job posting and stuff. And this we could enrich these later, but they're fine. It's really excellent data here. Uh, we could have made a research that would go and grab job postings and make it for us. Not that anyone really should care about job postings anymore because agents are just going at it, but we'll wait for this to finish. Okay. And then we might run this one more time. Okay, there we go. And so, um, it says it's there. The other thing is that I don't think we're logging uh, usage. So, that would be nice to be able to log that information out, but again, these might be things we get for free when we use the agent SDK. So, I'm not exactly sure. Um, and so now that it's done, I'm going to go ahead and run this one more time. Clear. And I have no idea how many um, credits I'm burning. Like again, I haven't hit my I have like $5 or whatever. I haven't hit it yet. And Beco is not going to get mad if I load up another $5. So, so far it is not a pain problem. People don't know Beo is the other Andrew. Andrew B. I'm Andrew B. And so we call him Beo. So it's not confusing. He's definitely a real person. He's not um an agent. Or is he? We don't know. No one ever sees him. Uh, so we're going to run this again. I'm going to pause here and then I just want to confirm the reports are there. But again, you can just see my thoughts of like what would be good to do. Okay, we still have the coverage report being logged here, which I don't like, but that's fine as long as we got a I didn't we didn't sell tell it to not do that there, but we'll go here. And then here is our report. We can go ahead and view it over like this. And so there is our final coverage assessment. Um, I really don't like how long it's written this stuff. Like if you were a human, would you want to read this much information? Probably not. Or you'd want it summarized in a different way, but we never gave it a coverage report template. So that's fine. We will consider this done. We'll say get add all get commit refactor. But that wasn't bad for a quick refactor. Still lots of work to be done there, right? Um, I'll see you in the next one. Chowo chia. Hey folks, it's Andrew. We are back and it's time for us to port our coordinator application over to agent SDK. And the reason why is that we're going to be getting into um uh specific agent SDK um arguments. And if we want to know how they work, we need to have an example over there. And I think we should just continue this project forward. And I think it's not a bad idea. So what we are going to do um is we're going to call this uh port to to agent SDK. Okay. And so what I'm going to do here is I'm going to grab the contents of all this. Not the logs. We don't need the logs or the reports, but we will grab this, this, this, this, this, and this. Rightclick, copy. We'll go down over to our port agent SDK. We will paste this stuff in and we're are going to let it rip and see if it will allow us to port it over in one go here. So I need to port the my codebase uh of anthropic SDK based on uh for my agent that uses directly the anthropic SDK to use Claude agent SDK for this folder port SDK. And so we're going to ask it to go ahead and do that. That's a big thing. Again, we probably should have put it in plan mode and ask it what it can do. Uh but I'm just going to go off to the races and do that. And if it works, we will explore it. And um we'll have time to look at the codebase quite a bit as we walk through other features. Okay. All right. Let's take a look here and see what we have. So, we have the run updated. I'm not sure why it did that. It's not really that big of a deal. Uh, we've removed the async, anthropic, and coordinator. These are now internal to the coordinator. Sure, it has a complete rewrite. I was expecting that. That I assume that would be the largest rewrite for us. And I guess all those are unchanged. That's really interesting. And then we need to do a uh a update here. I mean, you know, you know, can you make the requirements txt for me? Because that's what it should have done, but we never copied it from a prior one. That's probably why. Um, yeah, we didn't. So, let's go take a look at the the major changes. So, we'll look at the main.py and um here we can see async anthropic. Oh, so there's where it's different. Default AIO uh HP client. That's why there was a change there. This is the new one, right? There we go. Okay. Um, and so this more or less looks the same, but we'll go into our coordinator directory here and let's see if we can make the difference here. Okay. So, I'm going to do scroll up here. What I might do just so that we can really clearly see the difference, we might refactor a smaller one because it's very hard to see the changes. They don't even show us the code changes here, right? Um, so what I'm going to do, I'm going to make another repo where we have uh make another folder here. Let's see. Port to anthropic uh port to agent SDK small And the reason I want to do that again is to really clearly see the difference. And so I'm trying to think of one that we were doing before like narrow task decomposition. Yeah. Where we have this one. This one's a lot simpler, right? And we actually might want to go one step before that where we are using tool use. Um could be decision- making model driven. Right? So this one here is a very simple one with multiple tools. So what we we'll do is we'll copy this over here. I'm going to go into this directory just so we can clearly see um the difference. And then also maybe just have another one that we can work on though I don't really like this use case per se. Okay. And so um I'm going to go and say okay great. Can we can we convert the code for port to agent? uh SDK small over to agent SDK. And again, we haven't tested if these actually work. Hopefully, it knows clawed agent SDK, not just some generic one. Um, but anyway, I think it knows. I hope it knows. We'll wait here a moment. Okay. All right. So, we have the refactor already done for this one. Didn't take too long. Let's see what it's changed. So, the imports are different. Yeah, it is using anthropic the correct one. No, no, no, no, no. Yeah, it is. Okay, here it is. So, here it is. And here instead of handling tools here, we have a decorator and then the functions are probably defined a particular way. See, this whole big thing is probably gone. Yep. And so, we have decorators on top of our functions, making this code a lot smaller. Okay. Um, the call's a bit different. So that's one thing and we are creating the SDK MCP server to pass the tools over. So that is another thing that's changing. Okay. I mean we have new modes and we're setting our MCP server uh with our tooling in it. Um okay. So basically we basically have an internal uh internal MCP. That's really interesting to make that super super easy. And this call is a little bit different. So basically the big thing that we're seeing is that tool use. Um so let's go back to our larger refactor. And I want to take a look at our um tools. And so that tool JSON, do we even need that anymore? Does that even make any sense? So what we'll do is go back over here because now we know it was refactored, right? and we'll say um do we even need the tools JSON anymore and shouldn't we be using the decorator for port to agent SDK Okay, based uh for clawed agent SDK and I imagine that you can probably pass in that JSON tools because it's it's doing it. No, we don't we don't know if it actually works or not. Um if we go here, tools.json, like I don't see it loaded in here. Maybe it's getting loaded in the main. It is refactoring probably right now, so we wouldn't even know. But we'll see what it says here because we do have tool right here, right? So it is it's right here. So maybe just has to delete it out. But if the tools here, then why isn't that defined or does it have to sit in the same place? Right. So we have this one here. Is this just a repeat? Okay. And like look at all this inline stuff. E object maybe pass rationals key strings. That's the structure that we actually wanted from before. Um, and so here all three tool decorators are now using the simple param. Okay. But like does the coordinator still have them in here? Do we have to have the tools in the coordinator.py Pi or can they act they live in the um tools directory as separate functions or it doesn't work because tight coupling of the decorator which is this part here. It might be the reason why they can't do that. And I mean I hope it knows what last directory we were in uh as we have more than one but uh we'll ask that question and you know this is what I'm trying to figure out what's it says here. So the key insight tool is a decorator runs at call time not import time. So you can apply it it inside the factory function. It captures state via normal closures. Okay. Well, speak English to me here. Can we move it or not? Coordinator class tools screening agent. Look, look. I'm trying to keep my stuff lean here, folks. Did it move it out? Did it even tell me that it moved it out? Uh, okay. So here coordinator state make coordinator. So it did move it out from tools. I don't like how they're make coordinator tools. Okay. And then we have coordinator state. Okay. I see. So they they have a state file separately for I mean state wouldn't belong in tools now would it? So that doesn't make any sense unless it's coming from that file. Oh maybe it's part of it. That's why. Okay. And so we go over to here and we have make coordinator tools. Oh, and they do have it in here. Okay. So, they were able to move it out. And so here we have um our multiple tools. Okay. And so to me, that's what I would like it to be. Um so I'm going to go ahead and we're going to stop this and we're going to CD into the port to Asian SDK. And I just want to make sure that this still works. So we'll go ahead and say main.python Python dot uh we got main or main. Python I got it backwards. Python main dot whatever. Whoops. Okay. And I just want to make sure that it still runs because we've changed a lot of code or at least with large file to another framework and um it's logging. We'll pause here and see the end result, but I'm pretty certain that it's going to work. Okay, so it ran without issue and we are in good shape. Um yeah so we are set up and the question will be like you know do we use this to test out all the agent SDK stuff or do we come back to this project we will see but at least we made it to this point and I think the key takeaway here is the fact that uh the tool use call got easier and it's setting up an MCP server okay so literally it's an internal NPC server um and so clearly uh Enthropic is obviously making that a priority tool but anyway There we go. And we will move on from that. Okay. Chow chow. All right. So, we have the agent tool. And so, this is where you are able to basically spin up an agent. Um, it was previously called the task tool. And I was really confused because the last time I used it, it was task tool and then the agent came along and I didn't realize that they're basically it's just a name change and so task is just no longer there. But there are um uh parts of the code that where you will still see it. So you'll see when I do the followalong that I'm under the impression that we are implementing task and then I realized that oh they have changed the name and I figured it wasn't worth um re-recording that video because I thought it was really interesting how um uh the uh claw did not know exactly itself and the documentation did not have proof of it. I just wanted to make that as a proof of point that you can't just trust uh what agents say. You have to go out and test them and then draw a line back to your information. But anyway, when you spin up an agent, it has its own isolated context, its own system prompt and its own set of tools. You can see that here. Um I believe this is the JavaScript implementation because I think the tool names are underscore lowercase whereas in Python they are title cased, which is fine, whatever. Um, but one thing that I need to point out is that though you're spinning up a sub agent, it's not necessarily going to be paralyzed. So, it depends on how scheduling is set up and how you are prompting Claude to do the work. But generally, it's going to block uh until it's done and then report back to the like block the parent from doing anything until the um the single sub agent is done and then come back. So, it really depends on uh how it's set up. Okay. And this should give you an indicator that um we are using basically hub and spoke architecture within cloud code. That's probably why uh they they wanted you to learn that specific uh you know coordinator agent. Uh and by the way when I say cloud code agent SDK I'm talking about the same thing. Okay. Um and so you know because this is basically a sub agent uh and we should be thinking of it like we have the um the uh coordinator architecture that the spokes to our hub they're not going to be sharing context. They're not going to have the parents context. And so if you need your your uh agent says task here but if you need your agent to know something you need to provide it. Otherwise it only knows what you tell it. Right? So it has the same uh feature of a coordinator agent. Okay. Um but there you go. Hey folks. Uh so now it's time to try out the task tool. So what I'm going to do, I'm just trying to think here for a moment what the task tool can be used for. Um because it would have its own uh tools that it can read. And so I'm thinking back to our um research agent. I'm just thinking like, you know, should we attempt to uh extend it and do that? But maybe we should just do a simple example first. So, what I'm going to do here is just say task tool um task tool. And I'm going to bring in some code just so that it has something easy to work with. So, I'm just grabbing the small port SDK agent. That way, uh it can work off of something and it'll our lives will be a lot easier here. And so, I'm going to go ahead and paste this in. And by the way, I've been working uh everything off. so far off of the uhv file. Um, and you know what I could do because we're using agent SDK now is I can comment this out, right? And we don't even have to we don't have to use the file. We don't want to here because if I'm logged in as my subscription, it will use it. Um, it's been a whole day since I've logged in. So, I'm going to go ahead and just type in claude uh claude. And I'm going to log back in here if it doesn't prompt me to do so. So, I'm going to go ahead and just hit login just because I feel like I'll probably have to. And so I'm going to go ahead and do that. I don't like this Chrome thing it opens. It's completely useless. Doesn't really work. Um I'm going to go ahead and copy this into a browser tab. I'm doing this off screen. Okay. And I'm going to to accept and authorize there. All right. We'll copy that. Go over here. We'll paste it in. We'll hit enter. And so now we are logged in. So um the idea here is I want to use um task tool and it shouldn't be too complicated. So well actually here's a question. Are we already using it? Well we do have tool here. So we are defining tools. Um but we want something that's demonstrative of just task tool. So we're going to CD into well actually you don't have to CD into. So I'm going to go say task tool main. I'm going to say here um I want to use the built-in task tool uh for uh part of agent SDK. Uh, can we rework this entire file to make a simple demonstration of the task tool? Okay. And so I guess the question is does it come down to calling it or is it going to come down to invoking it? uh because we know that like when we use cloud code, we can just say something and it will automatically invoke their built-in tasks. But what will it look like in code is the real question. So we'll go ahead here and now it's trying to call cloud API which is fine. Um and we will see what it comes back with. We'll be back in just a moment. Okay. All right. So we are back with some code and it's greatly greatly simplified. Um and so we will go and take a look at what we have here. as our simple implementation of getting just tool here. There we go. Okay, so let's take a look what we have. Um, it seems like it's stuck with the code. I mean, I told it it could go change. I'm going to close this tab out. I don't trust it. There we go. Okay, now we definitely have something different. So, I'll bring this on down and we will take a look. We have I really hate these constants. I hate and I also hate all this commentary. I do not like that. But that's fine. It's in here. You know what? I don't care. I'm going to remove it. [laughter] I'm going to remove it. Goodbye. It really likes to do these uh constants. Just cannot stand them. Um okay. So, we'll go down here. We'll take a look. So, here is the topic. Well, what first of all, what does this thing do? So, uses the researcher agent to gather three key facts about the topic. Use the writer agent to turn those facts into short paragraphs. return the final paragraph uh as your short answer. So we have the James Web telescope. Write a short article about that topic and that would be the topic and then we're going to print uh this 50 times. So a line over and so the idea here is that we have a query function. Okay. And it's passing parameters in. So I'm going to assume it's going to be called that create message there. We're passing a prompt and we have our options. So we're bringing our system prompt here. You are a coordinator that that produces a short article on a topic. Sure. We have the haiku model. Good. Allowed tools agent. So, it's going to use the agent tool. Um, and here we have agent. So, we have researcher and writer. Here we have researcher and writer. And then the permission mode is bypass permissions. Uh, I don't think we should have that. No, we're going to [laughter] take that off there. bypass permissions means that it can just do whatever it wants. And that is a no no. So it's good thing we're reviewing our code and not just letting it do whatever it wants. So I'm removing that. And here we have um the message. And then it's saying, are you an instance of this type of message? And if so, then we're going to print that information. And up here we have task start message, task progress, task notification message. And so it's the type of message that's being returned back. So it has these structures so that we can uh check that. Okay. And so I'm looking at this, I'm going, okay, that's something. Where's the task tool? Right? Maybe because everything is a test tool. So here's my question. So where is the built-in task tool, right? And maybe we can observe it by logging out that information. But that's what we're trying to find. I hope it doesn't try to do something. Let's see what it thinks that it is. Uh-huh. Let it search. All right. So, it's basically failed so far. I'm going to just hit tabs. I'm going to tell it to stop. It's just It's being silly. Okay. No. No. Sorry. Look. Look. Do you know? Uh, if you don't, just let me know. Don't go out to the internet. It probably doesn't know. I have a built-in tool that listed as agent and that's what I I have allowed in the tools. The task tasks are listed as emitted when a sub aent task is completed which implies it's from the agent tool. There might be distinct task tool cloud itself has one internally but I don't have confidence of the documentation. So I'm going to continue on. I just want to make sure we can find that. Just give me a moment. Okay. All right. And so I think I know why we cannot find it. Um and if we go over here take a look here. We're trying to find it. I'm saying hey can you find it for me? And it's showing uh it's saying like you can add task. It's talking about agent and then you're checking trying to check the docs cannot find it and it's saying well it's an older unofficial name for it and they're still using agent. Um and so you have to understand that when uh I'm going to find this here in just a moment. I just want to show you what I'm referring to. See here knowledge of the task tool as the mechanism for spawning sub aents and the requirements that allow tools must allow task. But notice we cannot find anywhere in the docs that say it even the internal cloud code tool cannot find it. So agent is task and up here we can see we are bringing in uh this and so we're seeing that indicator this is task. So task is agent agent is task. Isn't it great? We always confirm and we don't just go based on this stuff. If you were to generate out your lesson plan based on this, you would be in poor trouble because you know you have to test these things and concretely know. But even their docs don't make it clear. Uh and that's a frustration here, but that's why we explore every little thing. Okay. Um but anyway, so task is agent, agent is task. And right off the bat, we can see we are getting agent definition. We haven't talked about that yet. That will come up uh very quickly here. And so, uh, going back over to here, it says, use the researcher agent to gather three facts, etc. Write whatever, whatever. It's going to call the query function. Um, and the query is just getting imported here. Interesting. Okay. So, one thing I'm confused about, if we go over to here, if we go down to this one, oh no, it calls query. Oh, it's just the way they're doing it. All right. And so here they import it as client and then they call it off of that where here they're directly importing query. And that was my confusion. This is something I don't really like about um Python is ability to well I guess you could do this many languages but I just don't like the uh how it's ambiguous and I I just couldn't tell that was client query and I thought that was something else. Okay. And so then basically we define our agents. We have the researcher and the writer and then we have our model down here. And uh because my uh my usage for my claude is uh getting up there. It was saying like 75% usage for the week. And I guess I could upgrade to max if I need to. But I think what I'm going to do here is just put back in the API tokens. So now we have it. And that answers our question, right? So we'll go ahead here and type in Python main pi. And we'll run that and we'll let it go and do some research. Notice it has access to the web. So this one has the ability and this one does not because it does not need to. And we will see how that runs. Okay. And it comes back here. And so we can see the three tools running uh the progress. Okay. I'm just going to scroll down here. Yeah, the logging is coming from here. Okay, good. And then we have a result. Is it a good article? No, but it was able to do and go grab information. So, that was kind of cool. Um, so yeah, I think that pretty much demonstrates the task pool. Now, you could see if we wanted to add this to our um uh our larger application, the um job screener, we could go out and say, "Hey, go research this person. Go check their LinkedIn or whatever or try to find information on them." Uh, and that might be something we might try. Uh but we will leave this right now for what we just did. Okay. Hey, this is Andrew and let's take a look at agent definition. So the agent definition is the blueprint for the sub agent. It defines what the agent is, what it knows about itself, and what is allowed to do before a single message is sent. And so here is an example of an agent definition. I want to point out that I literally made this video four times. And the reason why was that, um, I had used this before. I wanted to know all the fields. I could not find it in the docs. Um, and so, you know, I said, "Okay, Claude, can you tell me what it is?" And it said, "These are the fields." I couldn't confirm it anywhere. So, I said, "Okay, I'll go test it." I thought it would work. I went out, used it, and the fields didn't match. And in fact, there were fields that weren't there. Then I found out that there are some fields that are only available in the TypeScript SDK and some that are not available in the Python SDK. So I literally found out that the Python SDK can be hind in features. And not only that, that the TypeScript one can be behind in features. So they don't have one to one SDKs that are being released out here. It's very sloppy to to tell you the truth. Um, and then the other thing was that, you know, I had to validate that all the fields worked. And I could not tell you how many times Claude hallucinated and gave me fields that did not exist. Um, and it had a really hard time finding the docs. Eventually, I did find uh docs. And I did also have it go and explore the actual codebase to find out the solution to it. And it's just wild to think that, you know, you you know, like if the docs are bad and the generation's bad, um then you just have to kind of muddle it through. And so I'm just going to tell you that this is my experience throughout the course. I might complain a few more times about this, but that is what it's like. Um so understand, make sure you test everything and do not trust what the agent generates or sorry like claw generates. Do not trust uh what the docs say. You got to go and test these things yourself. So anyway, where's the name of the agent? The agent is up there. So, see where it says research agent right up here. Okay, that's its name. These names matter and we'll learn uh as we go through this that um that can cause it to trigger or not trigger and stuff like that. So, this name is very sensitive in terms of what it's named. Same thing with the description. This is what's going to trigger the agent. So, this matters and we need to write it in a very particular way. Then, we have our prompt. Notice it just says prompt, but it's actually the system prompt. And so it's a system prompt. Uh tools is just allowed tools. At one point I think it might have been named this. There's other APIs like that. So I just have it here called allowed tools because that just makes it more clear. Then we have disallowed tools. And then we have max turns and models. And so some of these fields are not available at the time of this video in Python, right? But they are in Typescript. And so just so you know the SDKs are not one to one. They might not match and some of them may not have current features. I don't understand how they have all this compute and they do not have matching SDKs. Makes no sense to me. But anyway, let's continue on. Okay. Hey folks, it's Andrew. We are back and I want to take a look at agent definition. So, we'll make a new folder here. We'll call it agent definition. And we're going to go back to our last one, which was uh this file here, task tool. So, I'm going to go ahead and grab this code. We'll make a new main.py. Got lots of these going on and we will CD back here. We'll just ask Claude, I want to show all the options in an agent definition, uh, can you modify my agent definition file to show us that? Okay. And so what I'm hoping is that we get all that information. What I'm mostly interested is testing the constraints. Um, and notice like in that documentation it said allowed tools and here we have tools. So there's going to be some variation on how that's defined. I think we would have to go look at um the agent SDK. I'm going to go take a look here. And while it's thinking here, I'm just trying to find uh that example because sometimes what it will do. So you see here it says like allowed tools over to TypeScript. Well, those ones are title case and this says options here, but this one says allowed tools, but that's query. Okay, but we're looking for agent definitions. So agent definitions. Uhhuh. Like where is it? Isn't it great? Like I cannot find really basic stuff. Um, and this is my complaint when I say I do not like the docks. Um, the docks are it's not it's like they weren't built for humans. Um, so I'm just going to have to rely on it and assume that it can do that. So we will go take a look here. Sure. Yeah, we'll say allow and just close this out here and we will re reopen this up. So we have tools. We're going okay. Is that all its fields for agent definition? Are you sure? Just make sure. Okay. And so the reason I'm confused here is that I know there's more fields. And if I go over to here, take a look. We have tools, disallowed tools, model, MCP server skills, max turns, critical reminder. So why am I getting more fields here? Is that there difference? Okay, what about the TypeScript implementation? Okay, because right now we're only using Python, right? And uh this is where there's a bit of a confusion. So we will go. Yeah. Sure. Yes. Yes. Yep. And it what it's literally doing is looking at the code. So it's not going out to the internet. It's And maybe because I told it earlier not to do that, but I don't think in this session I did I did tell it to do that. And so I'm really trying to get it to um take a look at this. And I could feed this information in here over to there and see what happens. Here it is linking to the docs over here. So I can click over to here into the docs. And I'm just looking for Yeah, here it is. Right here. So I go here. Okay. Okay. Stop. Stop. Stop. Stop. Stop. Look. Look. Look, the docks show it, right? So, I want to know where those other ones are. Okay. I mean, we obviously have tools and then there's disallowed tools right here, which is fine. There's skills. There's Mac turn max turns. Okay. Okay, so the type set has significantly more fields in the Python. If you need these capabilities, you need to use the Wow, isn't that interesting? But I mean, hey, look, it's good that we know, right? So, if I had not checked that, then, you know, I would have thought that's all there was, right? So, I mean, now we know. Um, do we need to run this? No. I just wanted to see if there was any critical difference or, you know, why that discrepancy was there. Um, but I would say that's good. Okay. All right. So, something you're going to want to take advantage of is being able to have parallel tool calls. And the way you do that when you're using the agent SDK is you just simply tell it that you want to do it. So, somewhere in here, I'm looking for it. Um it's you say so examples of tasks that can be run parallel. So we're not just we're not just saying that it can do it but it's also here saying like this is a case where you would run in paral uh uh parallelization and here would you do sequential. So it's up to the coordinator to decide if they want to do them all at the same time or not. Um we just want to remind you about the agent tool because that's what we're talking about here. We're talking about agent SDK, right? agent SDK with the um uh the agent tool, but each agent tool runs in their own loop. Uh each agent is running at the same time or can if it if you specify it here obviously in parallel and we might not be able to see what the internal loop is doing. You're going to find this out as we work through um the follow along. So that followalong was only long because we had an issue with structure JSON output. Um, but I wanted to get logging for the internal loop, but you can't get it right now with the SDK. And so I believe you'd have to drop down to the anthropic SDK, but the agent SDK is challenging if you're running um agents with the agent definitions. And so I was waiting a long time and I just wanted to know it was actually doing something or at least track my spend or or or help reu it if it's going off tracks, but you can't. Um, and so that is just a limitation of how it works right now. Okay. So, in this video, what I want to do is I want to show off parallel tool calls. And so, I'm going to make a new folder here called parallel tool calls or parallel agents, which is probably more uh or parallel parallel agents or parallel tool calls. I will say parallel. Yeah, parallel parallel agent calls. Okay, agents agent tool calls. I'm really uh being too particular about that. And we'll make a new folder here and we'll call it main.py. And so I'm kind of liking the last one that we did there uh which was under um the findings. Right. So we're going to go over to here. I'm going to go and grab this here and we will paste it into this one. And so what I want to try to do is figure out a way that we can coordinate multiple agent tool calls and why we might need to do that. Um, so I'm going to go all the way down here and we'll just CD back for a second and we'll enter here and I'm going to go, you know, I'm going to make my life easier. I haven't been doing this, but I'm going to just go into findings like this and then it's going to have context a lot easier and won't look at all these other repositories and cause me a bunch of issues as that is a growing problem is it's trying to use the context of the entire repo. And even though this will create another project within our um home directory, I think that's okay. So I want to uh make use of uh uh parallel uh agent calls in that run at the same time. So what would be a good use case uh for our current main.py where uh let's just make sure that it's selecting the right thing. Yeah, it is. Okay, main.py. I mean, it was trying to go up a directory though. main.py. Can you propose to me a new coordinator prompt? Okay. and new agents. Okay. And so that's what we're going to look at next. See what we get here. Okay. I can't think off the top of my head why I would need multiples in parallel. Um I mean like if there was multiple films and we're like okay each of you go out and grab multiple films that could make sense here. Right now, the coordinator calls research agent sequentially one at a time. Since no access depends on another, all five can be spawned at the same time. Oh, well, how useful is that? So, we have research agent. So, keep as is per access deep research, receive all findings, remove duplicate overlapping uh films, returns a finding list, uh receives duplicate findings, ranks top 10. So, the new coordinator would be parallel research in a single response simultaneously for all five axises. Do not wait between calls and go across all of these. Oh, well, there we go. We already got a benefit. Uh, call record findings. The current code already passes allow tools and supports multiple named agents via agent. Uh, adding to dupe just means adding two more uh agent definitions. Okay. Um, sure. But I guess my thought here is like is that going to paralyze tool calls? Just give me a second. Okay, I'm just trying to look at the exam guide. What is it? Task tool in a single coordinator rather than rely on separate turns. And so I think that will satisfy what it is that we want. Um and so we'll go ahead and say okay, great. Yep, let's do it. Okay, because I'm just trying to like satisfy what the exam guide wants. Um but we will be back in just a moment. Okay. And we'll say yes to the session. And so I'm just looking for what has changed. The dupe agent. Uhhuh. Rules. If the same file film appears more than once, uh keep the best uh best entry. Do not drop films. Return this object rank. return JSON object with 10 films in uh ranked to most to least similar. Okay. And then there's our multiple agents. How do we know that's being paralyzed? All in five one turns. And so the key thing that I want to find out in this code is what is causing the the parallelization. That's what we want to know. And so I'm just carefully looking here and trying to find. So here you are parallel. So in a single response call research agent simultaneously all axis of one. So see here we're telling it to do this. do not wait but delegate to all of them. Right? And so that's the key thing that we were asking it to do. We have bypass permissions on again which I don't like. So I'm going to remove that again because we did not request it to do that. Um I'm not sure that would cause us any trouble, but we will go ahead and just say take that bypass out there. bypass means go do. Well, I guess it's not really that dangerous because we know exactly what it's doing. But you have to be really careful with this because you have to think about like what it can do. If it's just going to go and do web search, then that's not that big of a deal, I suppose. But I still really don't like that. There's probably a better security model than just saying bypass permissions and thinking more about like what it could use. And so really, it doesn't seem like there's much of anything else to do other than to let it go off to the races here. So, let's go ahead and execute it. So, we'll go ahead and type in Python main.py and Oops. No, no, no, no, no, no. Wrong, wrong, wrong, wrong one. Wrong one. Wait, hold on. Did we just update our findings in place? I thought we were going to go update this file. Uhoh. What did I change? So, we changed uh this one by accident, right? This is the paralyzed one. which is fine. I can just like swap their places. So, one second here. Let's go rename here and old. I just don't want to muck things up. And I'll move that here like this. Boom. Not a big deal. Not a big deal, people. And we'll rename that one. I just wasn't paying attention. Um, and I'm going to make sure this is the correct one simultaneously. Okay. So what we'll do, I'm just going to cd back parallel agent and we'll go python main.py and we will let that run. The only thing that will be hard here is to really observe that they're running all at the same time. But it says the agent is saying it's starting them all simultaneously. So at least we have that indicator that it's doing it. I'm not sure exactly how we would monitor that. Uh it's not an exam guide to ask. Again, if I did a boot camp, this is where this is something that I would want to know because I'd want to keep track of what is going on. But for this, as long as it comes back with a result, I think we'll be happy. Um, I would suspect that it would be faster than what we did before. I didn't track what was happening before, but I'm just going to trust that it is simultaneously working. Um, and we will be back here in just a moment. The only problem here is I I have no sense of what's going on. I've been waiting for quite a while and so I'm actually going to stop this and I'm going to just go here and be like you know when I am running when I am running uh the agent and multiple agents are running in parallel I have no I have no uh output or logging and so I have no sense of you know if the models are going to or if the agents are stuck in a loop or if they are going to finish soon or what they're even doing. All I see is this. Can we get better uh logging and visibility? Because that's going to drive me crazy. Another thing that I was thinking is that um we didn't do this in the finding sections, but I would like to enrich the source URL just because they go here and say like source URLs, docu document names and page numbers, which I didn't uh I didn't really provide, right? So, we'll go ahead here and um why does it need more more access? Sure, fine. I I don't know why it would need that. It's in the folder it needs to be, right? Uh, I'm just making sure it's not going outside of that. Look, no, I don't know what it's doing. Okay, hold on. Sorry. Just focus on the main main.py. I'm not sure why you are looking up a directory to implement logging. Okay. So that's me paying attention being like why are you doing that? You don't need to look at that to stay focused on your task. Okay. So we'll say yes allowed. Okay. And we have some results here. Okay. So now our agents first you'll see research agent first 80 characters status. Okay. This will give a live trace into flight without needing external instruments. The findings and coverage prints inside the MCP. Um I noticed our findings doesn't contain uh things like source URL or or like document name or page number. Uh so we can't like we can see we need to have better findings information sourced information. Right. So we'll go ahead and we'll do that. Give it a moment. All right. Let's go back here and take a look here. And I'm just going to close this. Sometimes it doesn't update. So we'll just do this. This is like a problem for my machine. So here we have the URL, the document name of the database, page number, and so now we have better source information. We really should have done that prior. So now we are going back and doing that now. So that is good. Um, and so you know, I don't know if the logging is going to be that much better, but I guess we'll find out here and we'll see. Um, because before it's just like we didn't have a whole lot of information. Okay, so there's the coordinator. So now we can see all the agents are starting, right? So they're all firing up. That's a lot more useful. The only thing is that we can't see what those agents are doing, but they are running. So that is good. Um worldwide featuring featuring mind control, the blend of etc. And so I I just don't know if those are like single actions or they're looping or like what are they doing? So, while that's going there, I'm just going to take a look here and take a look. Yeah, I think they're really just doing one thing. They're just going out and then doing a single thing maybe. Mhm. I guess we will wait. Okay. I mean, it makes sense that if they're agents, they have their own agentic loop each of these things here. And so, the only thing is that uh and again, I don't know if this is true or not. we'd have to verify it, but it's suggesting here that uh sub agents you have to enable streaming where the parents uh they already stream the information to you and sub agents don't. Um because right now it's like what are they doing? I can't really tell. You know what I mean? And um this is not helpful. So I'm going to go stop this here and I'm going to try this again. I'm going to say can you um I can't I can't see what the sub agents are doing. Okay. Uh example, uh is there a way we can we can monitor streaming information? So we know that something is happening. Maybe we can uh uh dump logs to um each uh agent run each run of our pipeline of our of our coordinator. and then in there have individual logs for uh for each sub agent that is spun up. So like spun up. So, eg logs uh you know run uh you know time stamp you know ISO ISO time stamp uh sub agent name log. Okay. And so I want to see if it could do that because again this is just because I don't like waiting forever and I just want to make sure it's doing something. Um, I know event should come back to us, but let's see if we can get that single improvement here. Um, I don't know if it's later in the course, so I can't remember, but um, I know. Let's just make our lives a bit easier, right? All right, let's take a look here. So, what do we have? Um, we have logs. I mean, if this works, that'd be great. Um, gets everything echoed to the ST out. And then we obviously could just tail our logs. And that would actually let us tail. Well, that would only tail one. We actually can do a um an asterk on that to tail them all to be honest. So we'll go ahead and we will now run it again. I'm going to see if we get output here. And I'm just going to split this vertically. I'm going to give this a nice refresh here. And I want to see if the other logs pop up here. And there they go. There we go. I wish that they were named a little bit better in terms of what they are, but the very least we can see that. And so now what I can do is I can go and say tail f um logs run asterric.log. And so now it will show us all the logs, right? And so if there are any changes that are happening here, they'll get propagated. But it seems like they are propagating here now. Are they? So that's all it's doing. It's just going out and doing that one thing. Well, I mean, hey, look, it's an improvement of of what's happening before, but uh yeah, I just I I still don't know. Like, I guess it must be doing a tool call. Um I feel like there should be more going on there. Is that actually streaming the information? Uh I'm just going to be patient. I'm going to pause and it'll be back here. I'll give it like 5 minutes, but if it goes over that, I'm going to stop it and um I will just very much try to get something that is logging a bit better, but I'm not exactly sure what it did to change um the logging here. So, I'm just going to check and see if that's the case here. So, that's what I'm looking for right now is I'm trying to find where in the codebase it is doing that. You might say, "Well, Andrew, why don't you just ask it?" Well, because it's it's used up right now and also I just I I rather just look myself and find it. So, run logger. Mhm. Agent. Yeah. Another agent. Yeah. Uh-huh. Okay. I don't think I don't think it's doing what I'm expecting it to do. Yeah. I I can't tell from that code anywhere that indicates that it's doing that that's going to log it more. But it's running, so I guess I'll wait. Okay. All right. The results are coming back here. Um I'll just close this one. This one's not that useful here. And I'm just going to close this log and reopen it. I don't feel like it's streaming. I feel like it would be like I'm making this tool call and I'm doing this and I'm doing that. Um you know what I mean? So, you know, maybe that's a separate thing to do is try to get more verbose. uh logging. I feel like, you know, the agent SDK should just have that built in where it's like they should just make that opinionated because it's already they're already making the agents opinionated. So, why do I got to do extra work to get that logging out there? If there's a library out there, I don't know of it. Um it might be interesting. Um but yeah, we're getting a results back. And I was just hoping to kind of get a sense of how long something takes, but it seems like this is working. Uh one thing I am interested in seeing is um if our findings data is updated so that we actually have better outputed information. Um so we will uh see that here in just a moment. Okay. So just pause here and wait. Okay. So we are back. Um and so now we have results. Let's go give this a nice refresh here. I want to take a look at our JSON. Why is our JSON empty? What the heck? >> [laughter] >> Um, well, great. But where's my findings? Am I crazy here? Is this just empty? Okay, so my findings Jason. So after running oh we'll say debug debug after running my uh agent for main.py it was supposed to log results to results.json but it's empty. Do you think this has anything to do you think when we do you think when we added logging or changed uh it to run multiple agents at the same time? This is where we uh lost the findings JSON data. We still want logs and par uh parallelized agents. Where's my results? Okay. So, we'll let it do that there. See what it comes back with. And you know, so far it's just talking about the sub agent. And so, we're having issues with the hooks. Um, and so there are issues with getting uh actual information. At least that's what it's suggesting. Again, I'd have to dig myself to figure out why we only get the final prompt for logging, but we're clearly missing a lot of information. Um, you know, again, that would require a deeper investigation of, you know, reading code and looking at code. But anyway, we're still trying to figure out why we're not getting our findings. And so, there could be many reasons. I can see the problem. Let me check the research agents actually return uh to understand the format mismatch. And so, let's see if it figures that out. I really hope it doesn't try to fire off the agent as I don't really want it to do that. Um but uh we will see what we get. Okay. All right. So we have a reason for failure. So the chain agent ran the file record finding on everything to duped it. Y fails um which expects it to be this format but the coordinator passes a plain list like this. Add error logging so the failures aren't silent. Handle the coordinator's natural output format as a fallback. I don't understand it should get formatted anyway into paidantic, right? Okay. Well, let's apply it. I'm going to have to run this whole darn thing again. And I don't have observability for sub agents, which is not great. Um, but I will run it again and then we will see. But now it kind of makes me want to just roll my own using the anthropic API if the agent SDK is not really providing the tooling that we were hoping to have. Um, still going here. Fields were passed a string but got iterated character by character. Okay, so tries the strict fine settings finds list parse which it should still works on failure should log falls back to converting it uh to the quarter's natural format uh returns a proper thing rerun the main and you'll see your results okay so let's go ahead and we will run it again I'm just going to I don't know what will happen if we run it a second time so I'm going to delete out that I'm going to pause here we'll be back when this is done running Okay. Okay. So, we can see our results printed out here. Let's see if it actually filled out the results. JSON. There we go. And so, I'm just observing um the information. So, we have a URL the document URL document. What would probably be also really good here. I'm not going to do it right [laughter] right now, but like I would probably ask it to like whatever excerpt it took out specifically that it used, I would probably say like, "Hey, can you provide that information?" Because I think that would be um like site your sources, literally pull the piece of content that you're citing, not just literally put a URL there. And I think that would provide a better thing. But the question was like parallelization. And so, um I yeah, I don't think our logging was an issue of paralyzation. was a formatting issue there. But now we know that there is an issue with uh sub agents at least with the SDK at this time that it's an internal um at least that's that's what it's purporting is that it's an internal um loop and we do not do not know what it's doing until it reports back and that's not great from a uses perspective right so I would imagine you know if we're going to build something for production and we need to track stuff we're going to have to roll this stuff ourselves using the lower level anthropic uh client but for that case it actually would have been probably fine for what we're doing. Um but anyway, yep, there we go. Let us take a look here at fshot prompting. Okay, so uh the idea here is that um we have something we want. We want to extract the measurement uh from each ingredient. And so um now we might say roughly three teaspoons of olive oil and we want to format it in a particular way. So here we're saying format it like this. But to make sure that we get it the way that we want, we're going to provided examples. Okay? And the reason we do that is that it's going to provide consistent results and it's going to reduce hallucinations. Um, and this works extremely well. Some other things that you can do is you can provide both good and bad examples. So like when I'm trying to get my Japanese language learning app to help with grammatical structures uh for output, I will provide really good ones and and bad ones. Um, and in fact, I will even score them and that will help them a lot more. Uh, but yeah, it's not a complicated concept. Add in examples um or or examples of of the results and you'll get better results. Okay, let's take a look here at goals and criteria uh driven uh results. So if you have procedural prompts uh that make the coordinator rigid. If a step breaks or the task doesn't fit the script, it will break. So here's an example. You're a coordinator. Follow these steps exactly. Call this, call that, do this, do that, return the reviewed output. Always follow these exact sequences. And so you know something fails along the way, you know, the thing is done, right? So uh a better way is to give the coordinator a goal uh or a criteria. So first we're looking at here and we're saying you know you're researcher coordinator your goal is to produce and uh the response that fully address the user request with accurate wells supported findings this is your quality criteria these are your available agents which we don't need to do that because in agent SDK it already knows when we're passing them in but the point is is that um this one is going to be very valuable to to us the quality criteria and then we have guidance down here if needed be but really the major thing we're looking at is this quality criteria, right? Um, and so we can go further by specifying that uh quality criteria. And so if we go back here for a moment, we have that, which is fine. But here you'll notice like we have very specific uh checklists of of that information. We even take it further and say like what we're delegating out in our research goal uh or when to stop. And so we have a lot better information about goals and criteria. So that's something we should give a try. Okay. Okay folks, let's continue on. So I'm going to make a new folder here. And this one is going to be for uh criteria criteria driven. I believe that is uh the name we were looking for here. Technically it's goal and criteria driven. Where'd it go? Where'd it go? Where are you? Here we are. And did I even spell criteria right? It looks kind of funny. I don't know, but that's what it's going to be. If it's no good, you just tell me in the comments and be like, "Andrew, learn to spell." I know. I wish I could. So, what we'll do is we'll go all the way down here and remember, we know how to refactor code. It's interesting because we worked on that other use case uh and we never came back to it in the agent SDK. I don't know. I just had no interest in it. Um and and we spent all that time refactoring it, too. But at least I can read this one still, so it's fine. Um, so the question is, is this thing using criteria as a means to drive? That's what I want to know. So I'm just going to go back and look at my slide so I can have an idea. Quality criteria. Quality criteria. That's what this should be called. Quality criteria. Okay. And so, do we have that here? I'm gonna type in to Claude. Nope. Nope. Nope. Wrong one. Wrong one. We'll go back and we'll say Claude here just because we're ending up with too much stuff here. And uh, you know, for my main, I need to ensure the coordinator has a goal and a quality criteria. What can we do for that? Right. And I'm going to go down here and look at our main coordinator here for I almost want to refactor this because it's becoming quite the headache. Okay. Over here. And so we have these. We actually do have in phases, right? Well, hold on. Um because here's the thing is like if you go back to here, like look, we have you are coordinator. follow these steps exactly and this thing is going through phases which is not necessarily a bad thing. We can do that, but you know, is there a way that we can be more criteria driven? Okay, so we'll go here and say yes down to this one here. We'll see what it comes up with. Okay, but maybe we should have given it an example as that might have been better. Even the code that I have would have been a better example, right? So goal block at the top and then inline coordinator evaluates against concrete standards update the uh evaluation coverage tool description. Okay, so here we have our goal and criteria. So what do we have here? By the way, our prompt's getting kind of long, too. I'm not sure if it's too long. We say uh produces a curated source back list at at least 15 distinct films. So that's being very clear as to how much. Um then a fan school could uh could watch next. The final output must cover all five similarity axises. And we have quality criteria finding is high quality when all are met. So content one specific information sentence about the film high film etc etc etc. So that is good. I like that actually. That is pretty good. I don't see how it would loop back though. So, that might be the only um thing that's not good here. The other thing that I would want it to do, because we didn't have this before, but I needed to actually extract out the findings information. You know, we are we are citing sources. Go back to our findings. Okay. And so I would say like, you know, we have our findings information. We have our findings information, but it seems like it's just focused on on uh finding a very specific movie and listing like let me go back over to here. Is this IMDb? Just IMDb information. just IMDb information where findings is really collecting the research parts that justify its choice. Um also findings you know should actually take the small expert uh that it's sourcing. So we can see not just where the source is but what we are borrowing, what we are referencing exactly. Okay? Because that definitely is an issue, right? And so to me, because like if we're just going to have a bunch of IMDb stuff, that's not that's not helpful, is it? Right. Um, and we are using Haiku. It's not the best model, but it seems to be working okay for what we are doing. I'm actually quite surprised to be honest. Uh, but it'd be very interesting to see what kind of different results we would get um if we used another one. All right, it's back. Let's see what it's decided to change. So, here's what's changed. Key infrastructure. So, used to hold name film making it double as the film's identity card. Now, the film director are top level fields. uh on finding items in source only describe research documents being cited. So uh finding of the most particular information print findings. So here it might be like this. A telegraphic teenage girls targeted by her peers. Yeah, but the problem is is that if it's always from the same darn place, that's not going to help us, right? So I got to go check this a little bit more thoroughly here. And so name of source here. Each finding is one piece of evidence of of why it's similar. The source is the research document you are citing, not the film itself. Um, the excerpt is an actual passage of text quote if possible. The only thing is like if everything comes from IMDb, it's going to be bad, right? And so I won't know until we run it. Uh, but at least we now have something that's a little bit better. And so I hopefully that fits better into our criteria. I'm not sure if it actually tried to update uh the quality criteria anyway. So, you know, I can just ask like does the collecting of findings tie into our quality criteria for evaluation. Okay? Because that's what it should do, right? And I just want to be explicit that it's actually thinking about well whatever thinking it can really do but thinking of that. And so I just want to go down here. Not really. There's a gap. Yeah. Just parses and stores it. It returns records with no quality feedback. So the coordinator self assesses against the criteria. It's a pure model judgment. The tool just logs and echoes whatever the score coordinator provides. The quality criteria is the coordinator prompt. So nothing enforces or measures it. So the coordinator has to mentally remember the criteria at the evaluation time which is unreliable. To fix this record findings, compute a quality breakdown per finding. Uh is that what we really want? Score against a quality criteria so the coordinator gets immediate feedback. And so we have director source whatever whatever assess coverage using quality already returned from records finding score zero. The only thing is like you know I would just I would just suggest that in the evaluator um if if it's just IMDb that might not be enough as a source. So the sources need to be varied. Okay, I'm not sure if it's the evaluator, but you can s see what I'm saying, right? Like if it just brings me all black IMDb information, even if there's information there, um that's not the greatest and it's pl it doesn't justify why it's similar the similarity claims or, you know, things like Yeah. Yeah. Exactly. That's why we're using our brains here. Um, and so we will go up to here and take a look. So, what do we have? Um, so yeah, weak sources. Uh, I maybe it's not the evaluator per se because the coordinator has to kind of like tie that in here. Still going here. Mhm. Okay. So, we have something new. Let's run it. Okay. We'll go Python main and it's off to the races here. We'll see if we run into any issues. Um, I'm not sure if it will print out whether the criteria is happening. Again, this is all about logging, right? And getting that C uh keen information. If I was building this for real and not just for this because again this would double or triple the time. Um I would be stepping through everything a lot more individualized. All this would be refactored. I would make sure every area is captured and then I can make sense of it um to get the results that I want. But anyway, this is fine. We will sit back and see what happens. Okay. All right. We are back and um it's not fully done, but we do have a bunch of findings, right? Right. And so we have plain covered films, 27 findings, and notice it actually has more than one round of findings. So it's doing way more more source documents, which is really, really nice. Is it actually storing the results? If it's not storing the results, that's going to be frustrating. And it's not storing them right away. Huh. I don't like that. [laughter] And now I have to wait till it finishes to find out if it actually stores them. Okay. And that's agent six. Yeah, it's not writing the the logs. Do we at least get the logs in here? No. Okay. So, this is one problem I have. And I'm going to just adjust this. So, um I'll give it back some of the feedback here. Okay. So, I'm going to go here. It's a real bummer I had to do that. I can see my agent uh collecting collecting findings, but it's not writing the findings as they find them. And that's a problem because if my agent loop quits or my program crashes, I lose that findings data. Okay, so that's one little change I'd like to make if I can make that improvement. Um, as this is getting bigger and bigger to run, I'm not sure how much it's consuming. I don't have a means to track. I I'm sure we could figure out token usage if we really wanted to, but I'm not doing that right now. Um, and so we will just wait a moment here and see if we can make that improvement after each batch. Sure, we'll say yes. That'll be a little bit better than than what we have going on here. Okay. And so now that should be a major improvement. I'm going to just stop here, type in clear, and we will go ahead and run it again. And so I'm hoping this time I'll actually get results, and that will be much more useful to me. Um, and we should have a new run. There we go. And we will just hang out here. Okay. The other thing is like the results should be named on the run and probably should go into the into the the run folder, but that's fine. We'll worry about that some other time. And we are getting findings back here. I'm going to give this a nice refresh. And now we're getting results. The only thing I'd probably ask it to do now is not dump everything. Again, we're not trying to build a full full app here, but I'd probably dump this somewhere else. So, here we have the excerpt of the information where it's sourcing it from. So, here we have Wikipedia. Um, here's another one from Wikipedia, another one from Wikipedia, another one from Zapped. And so, you can kind of see a pattern here where it's not going out to anywhere else. And so, I mean, it's fine. Oh, here's an IMDb1. That's totally fine. And so like if I wanted something that was good, I think I would also needed to go out to like independent reviews and things like that. And I think to really make it work, we would have to be even more specific and say like you should go here, you should go there, you should do this, you should do that. We're getting some errors back now for some of the findings. Okay, so it's missing fields, but at least it's doing what we want it to do. Um, can it work through these errors? I don't know. Oh, it's it's formatting it. Okay. So, it didn't get back what it really wanted to. That's really interesting because we're we're forcing it through pyantic. So, it should always come back with the results that we want. So, we have high quality results. I wouldn't call that high quality, but again, we are using haiku um as our model to keep cost low. And I can already see problems with my data, which is fine. But we'll come back here. I'll have 710 sufficient false and I have only one Japanese film. Mhm. And so we are just chilling out here trying to see uh the follow following one. I think it's the last one. We'll be back here in just a moment. Okay, we have our final results here and so we'll take a look here. Um, and so it's just telling us what it found here. I I kind of wish we had a um a report or summary here because obviously we have lots of data. And so now it's coming back with excerpts of information. So carry fury scanner zap fire starter carry twice the fury. So we're getting repeats here. And so it's not taking these findings and really condensing it into an aggregated result, but we didn't ask it to do that. I would say that we have satisfied our criteria at least. The only challenges here is that I don't really see it in our Oh, wait. Hold on here. Covered areas, 24 duplicated films, top 10 ranked list, seven out of 10 coverage. Oh, and so here's the top one. So before I was just I was confused. It was just reading it was just showing me all the findings. Okay, so we did have a summary here this entire time. And so it's really suggesting a Kira, I guess. So, I like I wouldn't really agree, but it does have those telepathic stuff. Um, so we'll go back up to here. Yeah. And so, does it really meet our criteria? And that's the only thing that's kind of hard to tell. And so, I don't want to spend any more time with this. We're only 16 minutes in. But you know if I wanted to improve this a bit better I would try to again figure out okay how do I know that it's meeting this criteria right and so we have that criteria there and again it's just the logging in the agent SDK is not great but anyway we put it in there that's it for now okay cha chia let's take a look at how we can help um enforce our rules that we actually want the pro uh the agent to do. So if you prompt an agent like in the coordinator and be like, "Yeah, we want you to always research before synthesizing, right? Always research before synthesizing and never call the delegate synthesis before delicate research has completed." And you think, "Okay, well, I wrote that in there. Is it going to do that?" It might not because when cla has long conversations or unusual inputs or it's just having an off day, it will just not listen and will do something else. Okay? And that's an issue because you know we want it to do the things that we're asking it to do. So how can we get enforcement through uh some programming stuff and so we can add prerequisite gates things that have to happen or have to be met before uh it can proceed forward and it makes it structurally impossible for them to skip. So look at here we have our route function. So imagine it's going off. It's like okay who are we routing to? What's happening here? And we're going okay so if we are in this case right uh and the context is this and we have research right then it's like hey you didn't do this first so you must go run the synthesis agent down here right and so we are enforcing it that way um and so that is fine uh a even better way to organize it is using hooks right so what we can do down below here is as we have our tool block coming in or information coming in. It's like what tool to call before it calls a tool. Um it can look at those hooks and so it says okay before you do delegate synthesis um and if you if your context is research then you must do the research first or if it's after this then do that. Okay. And so the idea here is the prerequisite gate is don't let this run until it is done. And the hook mechanism is a function that fires automatically before or after a tool call, which is where you put your logic gate. Okay, there you go. In this video, we are going to set up some enforcement gates. And I think in this case, we are going to use anthropic uh CLI direct or SDK in this case um enforcement gates. And the reason why with hooks, the reason why we're going to do it that way is because um I know that agent SDK has um probably hooks built into it. If it doesn't, well, that's a bummer. But I feel like this will be just a lot easier for us to do if we are using um that there. So I'm looking for one of our prior projects. Where are we doing that? Maybe task use where we have something very simple. And so here we have uh but this is with agent definition. So that is two new. Okay. And so I'm looking for something. This is task tool. I guess I chose the wrong one. And I wish I kind of numbered these as we went so it'd be a lot easier for me to find stuff. Um we have narrow task de composition. Does this use tools? This does use tools. Okay. And so what I'm going to do is copy all this here. And we're going to go into [laughter] uh here. Okay. And we'll make a new main.py. And we will paste this in here. And I'm going to go here and we'll go into enforcement gates. We'll type in clot. So I want to ensure that um we enforce tool calls in the expected order uh in the expected order or requirements. Um in the case that the prompt guidance simply ignores it and I want to have uh hooks for before and after tool calls uh to have this enforcement. Okay. And we'll see if it can figure out exactly what I'm trying to ask for. Again, providing examples would be better. We have example code. I can do that, but I want to see what happens if I just tell it if it understands what I'm trying to say. But we do have examples up here. Okay, that would help give it good context. Um, and I mean like in the the example I had had like literally a route um function that it would call and then decide on the tools. I mean that's no different than saying like call tool, right? And so in here see how we have like our steps and stuff like if if stop reason is this or whatever whatever then maybe we do that. Um I only see screening agent here. So maybe we need more than a single uh tool. If we went a little bit farther back, that might have been better with a pre-post hook around tool calls in the coordinator loop to guarantee ordering and requirements even when the model might not follow the prompt guidance. Okay, so I think it knows what it's talking about. Uh I don't know why it always wants that. Fine, we'll give you the top directory. I don't see why it needs that. Why? Why? Why? Why? Why? Why? Why? Why? Why? Why? Why are you going into the directory prior to it? Stop. I wish it would stop doing that because it's wasting time when it does that. It doesn't need to look at any of that stuff. It just needs to focus on its own codebase. We will pause here. We'll wait and see what we get. Interesting. It's decided to make a gate.py file. Let's take a look here. So, we're getting Oh, we got another file going on here. What's going on? Look at our main.py. I'm trying to figure out where it's adding those gates. Pre and post tool call from the gate enforcement gate. So, it creates a gate. Then, we can add a hook and a pre- hook. That's kind of cool. I actually like that it did that. So, maybe that's why I wanted to go up and look at my code because it's trying to match my uh coding practices, which is fine. I mean, like I do like that. So, I cannot complain. But, I would like it to not go into the extended repos and consume a ton of tokens. See like how we have 8.8 tokens because that's just larger on my consumption. But it is actually getting uh the coding style the way that I want it to be or closer to what I want it to be. Um and so I'm going to go all the top here. Let's see where the gate information is. Oh, it's going to give us a summary. So we have start uh at the start of each coordinator before executing any tool call. We'll do a check pre. Then we will have this check. Then we'll have a post check and then we have a summary. We have four built-in factories. So max hook calls, no duplicate arguments. A lot of stuff going on in here. When a pre hook block is called, we have an error if there's an issue. But let's take a look and see if we can make sense of it. We only have a single tool. Um, so I'm not sure how useful this is going to be. I want to follow through to wherever this is. Enforcement gate. Okay. And so it's here being passed to the run coordinator. Uh-huh. And so here, okay. In our actual loop here, when we check the tools, it says check pre. Uhhuh. But where where's our gate logic? Okay. So, um pre and post hooks. Uhhuh. Okay, cool. So, add a gate. Add a pre hook. Okay, where is the logic? Where do we store where do we define the logic when a gate is uh a hook is triggered cuz here we see like um in your tool you'd have this like check pre pre 179 190 So, we'll go over to here. Oh, right here. Okay. So, uh is that how it should work? I mean I mean is that how it should work? Shouldn't uh we have the code listening and then it triggers a function. It seems uh it doesn't really seem like a hook architecture and that's probably because I mean like I'm used to TypeScript and other languages but like it's not like it's like calling a llama or something. So we define Ruby or like a proc. So I might have to tell it like hey where's my llama? Where's my proc 42? Mhm. So, the loop shouldn't look like this. If else is it should look like Yeah. a llama. There we go. Okay. Like I don't know what it is in called in Python, but it either be a proc or a llama. And that makes a lot more sense. The the gates fire prehooks the and they block and then they fire post hooks all internally. Let me redesign it. Sure, why not? We are back to look at the code. And so now it kind now looks like that or it should look like that. So we go back over to here and if we look at our tool gates now it's using a llama and it's calling it that way. And so that looks better. Um I don't know this would be a lot better in Typescript I think. I don't really like this in Python but you get the point right. The idea is that we have um a gate and the gate should get called and make sure that it meets whatever requirements. Um but again, I'm not happy with this. I'm not going to go and re-record this and do TypeScript. You get the idea of uh what it is and just remember why that's important. Okay. A handoff protocol is a structured package that the agent assembles before escalating. It ensures whoever receives the escalation has everything they need without having to dig through conversation history. So the idea is that you have this handoff information. Um and then you can escalate it to a human over here. And we're finding that uh maybe we should have been using TypeScript this entire time because um this looks a lot better for um uh this build stuff. But anyway, we will go ahead and give this a try. Okay. Hey folks, we are back and I want us to implement this handoff protocol. So I'm going to make a new folder here. We'll call it handoff protocol. And what I'm going to do just to make it a little bit easier and go back to this whole taking screenshots and making sure this stuff works because I have that slide, right? So I'm just going to go here and I'm going to grab that slide information that I have that I made. This is because I just um I usually put them in the notes down here, but I didn't do that. Okay. So, we'll go ahead and actually just going to grab all the text here. I'm not even going to goof around. I'm going to dump that into chat GPT. I know it's a cloud course, but don't want to waste my credits. Give me the text. It's what I'm writing here off screen. Getting chat GPT to generate out for me. Okay, let's give it a moment here. And I'm going to CD back here into this directory. handoff protocol and I want this information. Oh my goodness, I just want all of it here. So, we want to grab it. Copy the response. There we go. And so, we'll go ahead and go to plot. I want you to implement this using uh using TypeScript. No. Will that work in this case? um using the anthropic SDK directly. Um I guess we just let it use whatever it wants in the main.py. This is what we want to show off which is the handoff uh functionality. Okay, we'll hit enter and hopefully they'll figure that out and just write it into the main.py. Pi just trying different approaches here to get different kind of quality though we were doing okay just copying prior code bases are obviously getting quite a bit here but yeah the goal here is just to make that handoff and so hopefully with that reference even though it's not exactly the same code that we're doing here we will get something that looks like that and that would be really really nice. Okay. So, we will just hang out here for a little bit. Okay. So, we have our and we'll say yes. And I'm just going to close some of these out here so we can take a look. Where did it go? Where is it writing? Well, hold on. Write me the code. Where's my file? Here it is. Okay, great. And uh probably because it's not loading the same way. So here we have lookup order, attempt refund, clear fraud flag, simulate backend, lookup order. That's fine. So it really did pull from our older codebase. Attempt refund. And here build handoff. So here we're building the handoff. Ask them all to synthesize a structured handoff package for the conversation. Escalate run the agent. Good. And here we see in the loop as it loops through the tools if it needs to escalate to a human that's going to build that handoff and hand it out that way there. And so then it stages it down below. Um so it does have a little bit of an issue here with the call and I'm going to go all the way to the top here because it's not loading in the um uh the environment variable. I'm going to go over to this one here. It's missing um maybe not that Hello World. It's the Anthropic SDK. We'll go to another one. We'll find one here. Here we go. There's one. And so uh because we we actually need it for this to work. It won't work without it, right? And we also need env. It didn't bring that in, which is fine. It's fine if it didn't do that. And we need path. Okay. And so now we'll try to run this again. It was already trying to run it, but we'll we'll run it. It was trying to be uh it was being a little bit too um aggressive there. Uhhuh. And this is what we get for not starting from a base. Maybe because of where where and how it's loading it as we should have that anthropic key somewhere. I'm just going to type in key here like key. There it is. And then does it have this one key. And that's our problem. So we'll go over to async. No, that's not going to help us here. Uh, you need to fix the um authentication for main.py. You can look at narrow task decomposes main.py uh for a reference on how to fix. Okay. And so I mean authentication API key, right? um for setting the API key to the client and make sure you are configuring the client correctly. Um and maybe we should have copied it because we do have this like asyncthropic stuff in here and it's not doing that right. So maybe that was my my mistake. Mhm. I'm going to tab here and make sure you use async. Okay, we are helping it along there folks. Okay, we'll take a look at its refactor here for our handoff. I'll close that out. Reopen it. Cancel. Cancel. Not moving anything here. Uh, sure. That's fine. And um I don't really need that main there, but that's that's okay. Um, okay. So, that looks like they may have fixed it. We still have client messages create which is fine. It's fine if they want to do that. Let's go ahead and run it. Okay. And so see here it attempts it and then it has to escalate to the customer. There you go. Let's take a look at pre-tool uh use and posttool use hooks. So this is part of agent SDK where uh you can basically add uh oops add these hooks uh for pre and post tool for your tools so that you can go and uh intersect them. So it absolutely does work. Um, you obviously saw we rolled our own hook system, whereas I mean this would be really nice if you need to um do that there. Notice that it's matching on all hooks. So technically, if you wanted to, you could tell it to match on a very specific uh tool. Okay. And then have different types of It's not like you just only get these two, but you can set exactly what the pre and post tool hook is for each individual allowed tool. Um, but yeah, pretty straightforward, but obviously better than rolling your own if you're using the agent SDK, right? Hey folks, in this one we're going to look at pre and post hooks. I'm going to go ahead and make a new folder here and call pre and post hooks. Okay. And um we'll create a new main main file here. And I believe what we're going to want here is to use the agent SDK. Okay. So, I'm going to go into our hello world. I'm going to keep it nice and simple. And we're going to grab the most simple implementation that we have. Okay. Into here. And what we're going to do is cd into the um pre and post hook directory here. And we're going to go into cloud. And I want to implement pre and post hooks uh for demonstration. Here are code samples to help you think of uh what to do. Okay. Or actually, you know what? Let's just I want to uh for demonstration. Does agent SDK have those built in? I'd rather just go ask it to do it. Um because we do have the code samples. If it does need them, we can provide it. But I figured, hey, let's just uh let's just go see what it can do. Okay, we're getting some code output. It is uh again going up the repo and taking a look at other some stuff. And I'm just going to close this out of here and see what we have for our stuff. Where did you put the code? Yeah, this is the context we have. does not have built-in pre-post hooks. The query function returns an async generator message. I don't know why I thought there was pre-post hooks, but um that's fine. One second. Okay, how about this? Are you sure? Uh what about pre-post tool uh tool? Are these not part of the uh SDK? Is this another limitation of the Python SDK? Mhm. We'll give it a second. Okay, here we go. So, it's like I was wrong. Pre and post are built into the SDK, just not in the cloud code CLI feature. Uhhuh. We're doing the agent SDK. What do you think? What do you think we're doing here, folks? Okay. And so, here we have the pre-tool use, the post tool use, failure, etc. Um, and I'm going to close this out. Reopen this up. Yes, please. Yes. Okay. Okay. So, it was just researching. First time it didn't uh just go out and do something. It did some research. Nice. And we'll just say yes, you can go ahead and update that. That's totally fine. So, here we have pre and post. Okay. So, done. The hooks will print pre and post. So, let's go ahead and see if that actually works. And we'll do python main.py. Okay. And so we have our pre and post, right? So it it did both of them. And so that's all we're there's no hello world in here, so I'm not sure how it's going to fix it, but the point is that we hooked up our pre and post hooks. Um, and so, you know, that's pretty cool. This is obviously a lot cleaner than the other implementation we had. As you saw before, we created like this whole hook system and it was so complicated. But why not just use this because it's right here and we can use it because it is right here. But there you go. Let us take a look at prompt chaining. So prompt chaining or you can think of it as a sequential pipeline is when you use a series of agents or calls uh to get the results. So here uh what we're doing is we go okay we have our input we run it we put that out there we run it we put that out there we run it we put that out there and so that would be example of prompt chaining so this is good for document processing content transformation ETL pipelines any task where you uh the uh the shape of the work is fixed regardless of the content I'm saying the word agent here but um you know before we were saying agent and putting things in an agentic loop we could do this with LMS and actually um when we were really starting with LLMs and everything was very short and fixed. The only way we could work with LLMs was to prompt chain and so prompt chaining is not a new concept. It's very old. Um but if you're new to it, uh just understand that it is basically setting up, you know, a chain like this. Okay. All right. So in this video I want to show off prompt chaining. So we'll go ahead and make a new folder. So we'll say prompt chaining chaining and we will create ourselves a new main.py and we're going to borrow from somewhere. Uh I'm going to take the hello world just because it's super easy. And I mean it probably be better to use the anthropic uh SDK for this, but I don't care. I'm just going to do it anyway and see what happens. because we just conceptually need to understand what prompt chaining is. Okay, so cd prompt chaining it will let me into this directory. Please prompt chaining. Great. And we'll type in claude change. I'm just going to make sure it knows prompt change. No, no, it's just the main. Okay, we want to uh demonstrate prompt chaining showing uh sequential calls to agents, multiple agents uh uh agents or or queries um to show off a sequential Yeah. for like a fixed pipeline. fix pipeline. Okay. So, we'll go ahead and try that. See if it understands what I'm talking about. So, remember, it's not like it's bad. It's always about trade-offs here, right? Um I'm hoping that it does like the coding sample that I have because that's I mean, I wrote that coding sample, but that's how I would think of it. Um or that's how I would write it by hand, but I'm curious as to what it thinks it's going to write. probably something complicated and not how I would do it, but we will uh see what it does. So pause here and see what we get back. Oh, that was fast. That was fast. We'll go ahead and hit yes. And so we have identify bugs, propose fixes, apply fixes, right? And we'll go back here. Mhm. So, okay. So, we have await run step await run step. So, yeah. Notice I didn't give it any code and it more or less is doing pretty much uh the same thing. So I'm going to go in here and we'll make a hello world. I'll copy this one and we will paste it into here. And I'm going to just break it a bit. So say uh puts put hello world here. And we could have probably gave it a more complex case. You know what? I'm going to do that. I'm going to go over to chatbt. give me um busted messed up um block uh code for Ruby so I can I can test my uh agent that fixes bugs. Okay. And so I'm just asking chatpt here to do that for me and waiting just a second here. Is still generating. Oh, there we go. We'll copy it. I wonder if I can spot the problems just for fun. Uh there's one problem. Is that the only problem we get? A set of 10 tiny broken Ruby functions. Okay. Well, it says there's bro breaks. So, it'll be interesting to see that work. And I'm going to go ahead and we are going to do Python Python main.py and we will see if it runs the pipeline. Looks like it's running the pipeline. Got nothing wrong with this stuff, right? But did we even save the file? [laughter] Is it just working on a blank file? One sec. Let's try that again. Sorry, I don't think I saved the file. Now the file's saved. Otherwise, it's doing nothing. Okay. See, now it's taking longer because there's actually something to process. Okay. One second here. It's applied its fixes. Doesn't tell us what it did, but let's go take a look here. And oh, we got logs. I didn't know it was logging. That's nice. I guess we probably set that up there before. Uh, here we go. So, I'm just curious what it fixed. Oh, it found most of the bugs. Yeah, it said there was 10 bugs, but uh yep, I guess it fixed it. Cool. So, there you go. Prompt chaining. Let's take a look here at dynamic adaptive decomposition. So, this is when intermediate finding should change, what you do next, which agents to call, how many times and in what order. Um, and these are going to be really good for open-ended research, investigation tasks, anything where you don't know upfront how deep or wide the work needs to go. So, look at the example. You're a research coordinator. After each step, assess what you found and decide what to do next. You may need more research, a different angle, or you may have enough to synthesize. Do not follow a fixed sequence. follow the evidence. So, let's see if we can implement that. Okay. Hey folks, it's Andrew and we are going to go ahead and do some dynamic, that's a weird word, dynamic uh adaptive demp. Okay. And so the goal here is we want to looking back at the slide. We want to have um the coordinator say, you know, what should we do next? What ages is it call? How many times? And it's open-ended, right? It's up to itself to figure that out. Um as we work through this, it kind of feels like some of these things we've already kind of done, but I guess they're just in different kinds of variations. And so, you know, to me, it's not always really obvious right off the bat um until we work through it. But we will see how this goes. As it seems like a lot of our other models have been pretty darn good. Um, so I'm just trying to think of here uh a basis of what we can work off of. Um, I probably want to use agent SDK. One thing that we haven't really been doing is using the file system method. Um, we've been programmatically implementing our agents uh in the code and I might want to take a file system approach to this. Um, and that just means how we organize our agents. So they're loaded from a markdown file and they have their own folder and blah blah blah. It'll make sense here in just a moment. So, I'm just trying to decide um what for us to do. Um I need kind of like an open-ended uh objective. Let's just use something like chatbt to think up some ideas. One second. Here we go. And so I just asked chatbt and because it knows it knows me a little bit and it knows me too well because right away it's like cloud code agent dungeon like make a dungeon. This is something that I've tried to spend a lot of time trying to uh implement and um and so maybe that would be a good one. investigate like a DevOps incident commander. That sounds too real world. That's too too much too much fun. I'd save that for something else. Japanese sentence evolution engine. That's something else that um tried to implement. Fix my broken code. No. Community health analyzer. Like this is for my community stuff. Claudeco skill tree simulator. Uh certifications meet progression. H I don't understand how that would fit in there. And so we might go back all the way up the top here. Open and research, investigate tasks, anything where you don't know upfront, deeper, wide. I kind of like the cloud code agent dungeon to be honest. So let's take a look here. You build a a dungeon crawler where each room has a decision. It adapts. You already build games, trading mods. You orchestrate cloud code. you're teaching this uh visual mental model. So, what I'm going to do is we're going to make a new file. I'm going to call it plan.md. And I just want to describe what it is that we want to do. And I'm going to grab some of this text here. So, we have cloud uh code engine. And so goal uh like technical goal is to implement and I got dynamic decomposition uh when uh when when intermediate finding should change to do with next agents how many times to call right um so anything where we don't need information to go up front and so here is a business goal we will uh implement dynamic adaptive decomposition for a agent dungeon. Okay, so we will construct um a mud engine and the agent is you build a dungeon crawler where I'm just trying to see what they're suggesting here. uh spawn debug agent if unclear spawn research agent if too complex. I guess the idea is like so an agent dungeon. So the idea is that we are generating the world as we play uh play the game. The agent has to figure a way to uh build the static world in code as we play along. Okay. And so I guess the question is like is that a good use case? I'll go back here over to here and say like you know is that no no no no no. Okay. I want this text here. I want to ask if like if it thinks like that's a good idea because that's what I'm thinking, right? Oh my goodness. Just let me paste. Can't paste here today. It's really frustrating. Now look, now my whole thing's messed up. There we go. So, we'll go here, rightclick, paste. Would this make sense? Because I think that's kind of what it's leaning towards, right? I bet it's just like love bombing me here, but the live discovery world. Okay. Well, anyway, what we'll go do is move this over. So, we'll say implementation. So, technical technical considerations. Uh, we want to use claw agent SDK. We want to use the file system for agents eg agents directory instead of uh coding them using agent defaf. Okay. And so those are the things I want to enrich this so we have a spec. Um you've probably heard of spec driven development. You don't need those frameworks. You can just kind of work through this and tweak it as we go. So what I'll do is I'm going to go ahead and type in claude. Wh not there. Maybe not there. We are going to go to our dynamic. As we've been working through this, we've been learning to isolate these folders. Dynamic. Uh, adaptive. Oh, we have more than one word here. Adaptive. Oh my goodness. I'm going to change this to No, I'm just going to copy this. I guess we'll paste that there. Great. Um, and so we'll type in Claude. So, I'm going to go plan. Can we can we uh create a text spec MD a technical spec to see its implementation or you know what can you can we create a yeah a tech spec y trying to decide here do I want to X spec because what I'm thinking right now is okay I have this and I feel like it's kind of fuzzily defined in terms of what it's doing. Um, and so I wanted to do a little bit more research and try to better describe the um, text spec of not necessarily the implementation of it, but like I I I I like we know we know how to implement agents, but the trick is does our business goal uh goal uh, fit uh, dynamic adaptive decomposition. So, can you try and see how it fits? Uh, writing a tech text back. Okay. And maybe I shouldn't be calling it text back. It's really more deeper research, but I don't care. It will still do it. And we will come back here and we'll see what it has and then we'll review it. Um, and again, we're just trying to conceptually understand, are we driving this thing correctly for uh the solution we want, right? I bet people really wanted me to do to do the DevOps one, but I didn't do it. All right, we are back and we have something here. We'll say yes. We'll take a look here. Uh I saw on effort, medium effort, so I'm not sure why that was so darn long, but it really went off off on the rails. It was consuming a lot of uh credits, unfortunately. I'm actually going to go take a look at my subscription and take a look and how it's doing. And right there, look, I've just basically started my day and I'm already halfway through here. So, this is where uh we got to be really careful. uh and maybe restrict how cloud is working. I've been having a lot better results working with the API where I have more direct control over the exact context use usage, but we'll take a look here. So, agent dungeon is a textbased world so damn ver verbose powered agent and each player uh demands new content. Static replanning is impossible. The number of rooms dynamic adaptive decomposition is not an optimizational optimization choice here. It is the only viable pattern. They they make it sound like it has to be that way. Uh where is it genuinely required? So unknown branching of generated rooms when the player moves north. Why static planning fails here? Pre-planned generated five room produces a flat contextfree world. The generator cannot know that the player is three levels deep in the necromancer's tower. Encounter depth is non-deterministic. Um okay. Code generation for the world artifacts has unknown scope. Mhm. And so here player moves world generation for a new room sub features uh agent ident inventory. So all agents live in the agents directory. This is something that would like to do. So we have the orchestration orchestration one the central coordinator. So I don't know why they just don't call it coordinator but that's fine. Coordinator the only agent that maintains the full decomposition state. It reads the current state world state JSON which is interesting because that's how I've always implemented these things. I've always had like a world state file JSON file. Decision logic is the orchestrator at runtime. So in the room it's structurally simple. Does the room have an NPC? Does it have this etc etc. So it sounds like it's going to try to maintain the world state. Then we have the room builder. So generate the uh structural descriptions. Uh so we have the blueprint. Okay. So that makes sense. We have the code writer. So produce TypeScript code in a single game artifact. Avoid redeclaring it. Lore consistency. Cool. Combat. Cool. Puzzle. Great. World state model. The world state is shared artifact that makes the the place coherent. Um, so we go look at the world state. The key subtypes incremental build. So each player turn starts with the open branches. is the orchestrator adds branches and determines them and then the orchestrator decides decisions. Okay. Agents world a static dungeon generator creates an affinite graph uh before a player begins. A player who never goes east never has that stuff. Um a static system assigns NPC. So the question I have here is I don't want the whole thing being driven by the agent. Uh so like if there's an area that we've been through before, all agents will use the haiku model. That's good because that's cost effective for me. Um okay. So I guess my my my main one question so my question about the text back and I actually don't mind it. So, it's an okay text back. Is are we only generating rooms when we go? Is will this only trigger the agent when we enter a new room? Because we want to not use AI to power the whole game. right? Just for its uh generation of places it hasn't been. And the game engine is controlled by code. Right. Right. That's it's going to do that. Right. It's just a really long dock. And so there was nothing in there that told me that it was not going to do that. So it says good catch. The spec is written as ambicuous about this. So the spec currently implies agent could fire on any player action which is wrong. What you actually want is two-layer architecture. So game engine and then world generator and then the correct gate is that. So the room blueprint would be this chain all happens inside one generated room. Once it resolves that room is permanent. The AI never touches again. The spec needs a section clarifying this boundary explicitly. And yeah so I would say yes add that line. And you know, maybe that might make the game a little bit boring, but like um I think that we have to be a bit careful where we're adding that. And so this is where I would like to see video game devel games games play out where it's like, you know, it's 90% 70% uh code driven, but then the the fun parts are uh that create spontaneous uh experiences, you know, calls out to an LLM. I think that's kind of cool. Or an agent. And there could be key areas where it's like, okay, now we have a boss or like we decide there's a special thing and then trigger it. But um we will go ahead and let it uh make those little updates here assuming we do not blow through all of our um usage here. The other challenge right now is that uh it also has to do with when you're using cloud. So like right now I think everyone like both North America and Europe are using at the same time and so consumption will be uh quite higher. But what I do find is that tokens like when we're using Hycoon and stuff like that have been going really really good. Like I still haven't had to reload up stuff. Also, you know, having my extra usage over here has been really really good as well. I'm not sure if this is built the same way as this, but um this consumption has been actually excellent uh handling our uh over overload. So I have no idea. I feel like this top part is totally different from this part. That's what my experience has been. And so we will just see as we go here. So section one reumbered the key uh line is explicit. AI fires once per unvisited room never touches again. Okay, cool. And so there are two parts to this where we need the um the game engine. So I'm going to scroll up here. Okay. So Okay, great. Please build me the game engine. Uh, okay. Just to clear context here because this is something we should constantly do. So, please go build the game engine uh for text implement text back. Okay. And so the thing is is that um again it would be better if we were carrying code over like if I was if I was being a little bit more diligent if we weren't on a timeline I had to get through this course I would probably spend more time making my components reusable and keep pulling from a base uh template probably something I'll do for my um my my more expensive courses. Um, but anyway, it's going to go ahead and uh implement something and as long as it works, that's all I care about. And we can observe this a dynamic adaptive decomposition. And we're going to be mostly interested in looking at what the prompt is going to be. So, go ahead and say yes here. And we will chill while this generates out. Okay. All right, folks. So, um, it's gone and done the work. I think that it might have gone into extra usage. And I'm going to just go take a look here as, uh, whatever. But also, I was talking to my friend Anthony. He used to do the the GC GCP courses. He's like use this tool called monitor. The only problem is that it's not reflective exactly of of it. He's saying it was like one to one perfect, but in my experience, it's not. So the biggest problem is like monitoring costs and the only way that I can reliably monitor my cost is to constantly open up this window. So here it says 99%, but look, it says 123% here. Doesn't match. The other challenge is like I have this over usage. It didn't even hit the overusage, but um notice I was like 99% for this one task here, but we did ask it to do a lot. Um and you know, I think like the other approach of me always pointing to another codebase and setting up the boiler plate for them is obviously reducing the cost greatly. So, we really should continue on using our boiler plate and pulling from it because I'm really keeping my cost low uh doing that. But let's go take a look at what we have generated. Um so, what do we have? So here we have uh agent dungeon implemented complete dynamic adapted demp rundev. So we have all our types. We have um our agents. We have our branch resolver. Um a bunch of cool stuff. Let's go take a look here. Again, this is not how I want to fully code it, but it did do in Typescript. Um I do have another repo where I actually do this in Typescript. And Typescript's a great language when you're building this kind of thing because um you can make identity um object identity system or whatever it's called. I'm not saying that's what it's using, but so here I'm just looking at it and there's something. Yeah, let's take a look at the orchestrator. And so what we're looking for in here and again your code's going to be different, but what I'm looking for in here is the actual prompt. So I'm going through here and I'm trying to find the prompt. I'm not seeing a prompt here. So, if it's not there, where is it? It's under agents. Yeah, the orchestrator here, which is fine. Like, I do like Well, I did tell it to write it as agent agent folders. And I don't think this is actually run following the agent SDK because the agent SDK would usually have um front matter on the top of it. And so I think literally this agents is really now just a um uh a prompt folder, but that's fine. Whatever. I mean like that's not what this is not what I wanted. But um and I'll just point it out here. Like if we go agent SDK, it's it's a very specific pattern that is used. Um agent SDK uh agent uh front matter. I'm trying to find it here. I guess it's called like um agent skills. Is it this spec? Well, anyway, the point is is that this is not what I was expecting, but it it still probably will work. So, the file documents the orchestrator agent in our dad, our dynamic adaptive decomposition. Um it is central coordinator to the world receives a player action determines the sub agent uh passes each agent output how it's going to uh the dad decision tree. So they're going to move to a new room. It'll generate a blueprint. It will determine NPCs, the puzzles, code writer, lore agent, lore consistency, world state persisted game response. Um we have stopping conditions. So like room generation, quest expansion, lore consistency, overall turn. that we have here. Does that mean it's going to do more than just rooms needs to be invoked? So here, move to unknown room. Okay, so it's defining it right there. It's saying move to unknown room, but we don't have any guarantees that it'll do that. Remember earlier we talked about programmatic gates, programmatic gates to enforce things. I doubt that this has it in here. And so we're not going to do that, but that would be something that we would want to do to really give a guarantee that it's going to do what it says like guarantee here. That's not a guarantee. We need to give have programmatic guarantees. My room is return to the player with the completed status, NBC, etc. Uh we have down here agent token budgets. So I guess here it's saying like you can't go over those budgets. And then we have the key files it needs to know about. And then we have all this individualized stuff. So, we got a lot going on here. Let's just run it and see if it works. Okay. So, how are we going to run it? Uh, npm rundev. Wait, hold on, hold on, hold on, hold on, hold on. How does it know what it's using here? Like, where is the actual um uh what do you call it? Um, like haiku. How do we know that it's using haiku? Where is that here? Before we run that, haiku. Haiku. How do we know? Where do we know? You know, agent runner. That's probably where it is. Ah, here it is. Okay. So, here it is. Haiku. And so, they have each one that's going to dynamically load, I guess, um, or load in those files. Yeah, it's just reading those files. Read the agents markdown file as a system prompt. And so I guess that gives you kind of some flexibility to uh uh change those out and load them in. So we'll go down below and that's all I really cared about was whether it was doing that. Um the other thing is like is it using our environment token? Because we have this here where it's using anthropic. Um but I don't see it loading. If we go to package.json, this is where we might be able to detect if it's doing that. It's not using token. So um are we using the ENV file? Um so we can uh use the anthropic API key for our uh dynamic for our project. I don't see it in places like main or agent runner and I don't see uh EMV in the uh package JSON. So I think here it probably consume my subscription which I really don't want it to do. And uh we're going to go ahead and have that fixed. I'm probably going to go over my budget now just for this one change. I mean it's it's one level up. Look, the EMV is but the EMV is one level up. I put what level up? I just said one level up. I wrote what level up. So it's going to go There we go. And so that's what it needed to know. And so this will allow it uh to know So yeah, now it's going to make sure it's installed. So it definitely was missing. And so these are things we have to kind of catch, especially when we're generating large pieces of code. I would I would probably not want to ever implement something this way. I would really walk through stuff here while doing stuff. Um and so now it's adding that V. There we go. Okay. So now it's adding it in. And we will say yes. It's just doing um a a TC uh TypeScript compile. So, and so now we are in good shape. So, what we'll do, I'm going stop this uh tool, the cloud monitor, which is completely useless for me. Dynamic, we'll do dynamic. Um, we'll type in clear. And I can't spell or I can't autocomplete this easily. So, we'll just copy this like this. And we'll paste it in. Hit enter and type clear. And then from here, we will go ahead and do mpm install if we haven't already done that. Then, npm rundev. Okay. And so I'm assuming there'll be a game loop or an interface or something. So here we go. So a world that builds itself as you explore. Um enter your name. We'll say uh Dano. Uh that's sometimes the name I use for a game handle. Sometimes Omen King probably know that. So we have this. We have the dungeon entrance. You stated at the threshold of an ancient dungeon, etc., etc. So what we're trying to observe here is it going to start building out our world. But right now, we're going here and we're not seeing any items and we have uh room information. Right. And nothing. So, let's go ahead. You stand at the threshold of ancient dungeon to torch light flickers against uh moss covered stone walls casting uh dancing shadows. This the small air whatever the paths are broken. A dark corers uh corridor stretching north and a heavy door to the east. Um, so do we want to go north to a dark corridor that leads deeper into the dungeon or a heavy wooden door slightly a jar? Uh, let's go east. Okay, you head east and the orchestrator is now generating the room. The only thing is like how does it interpret these inputs? Again, we want this to be really static, but I have a feeling that every single input it's going to evaluate um there. And so that would be something where I might not want in the loop. And so it says you head east generating room dungeon whatever whatever. So I'm going to go here and I want to see do we have any rooms generated. I don't see nothing updating here. But if we go here it should add the room. Okay. So the watch or a cloak figure uh their face obscured by shadow etc etc. Um and so the thing that's missing here like it's generally the person lore entries. Uhhuh. It didn't generate the person. Okay. So, already this is failing. This is not working good. If we go back up to um our orchestrator in here, and this is probably the reason why we shouldn't have generated out on mass. So, here player action builder room agent. And so the idea is that that should trigger the builder room. You're a room builder in a textbased dungeon game. Your sole job is to generate a structure blueprint JSON object. You must respond with valid JSON. And it does that. Okay, which is fine. Generation rules, use zones and depths for exits. And then here it's specifying the depths of stuff. And here's our example output. And so right off the bat, this isn't working as expected. Um, so I would probably say that this is a bust. We could spend more time trying to fix this up, fix this up, but I'm already um out of uh cloud uh for right now. And the key thing was just to really understand the concept of like uh dynamic adaptive decomposition. The idea is that each time we are telling it to choose what agents to use um and determine right determine uh what to do next, right? And so in theory we conceptually understand it and we've done a lot of uh projects here. So I don't want to uh hit us over the head here with a complex project. Um but yeah we can see that there are issues and I again I think going forward I'm going to be more diligent about not generating from scratch like this and pulling from an existing codebase that we know um already has good good observability and things in it. Okay. Chowo chia. Let us take a look at an adaptive investigation plan. So this treats each finding as input to the next decision. Not just data to collect, but a signal that reshapes what needs to be done next. So here's an example of a fixed plan where you say, "Hey, we need to do these three things. The only change challenge here is that findings don't change uh after the plan's executed." So having an adaptive plan, the idea here is that you are giving it room uh to make change. So I'm getting my pen tool out here so we can read it. you're an investigative researcher coordinator. Uh after each finding, what does this uh raise that I don't know yet? What could uh would have would change by conclusion if we turned out differently? What claim here needs verification? So, generate targeted subtasks from those questions. So, the idea is that you're asking and it's generating subtasks based on that. And then the idea here is that now we can go perform research on those subtasks. Okay. Let us take a look at raw findings dilemma. This is when you pass raw findings between agents as a single blob of text and attributions get lost. So here um the synthesis agent can't tell which claim came from which source and by the the time the final output is written uh the provenence is gone. So, provenence is a really fun word of like let's say you buy um a very old antique and you want to make sure that it comes from a particular place, then we use the word provenence. Uh it's a fun word to use. I don't get to use it very often, so it's thrown in there. Okay. Um but anyway, here you see it says EV adoption grew 40% in 2024. Battery costs have fallen. The EA report on page 14 says charging infrastructure is the main barrier. uh routters also reported that the BYD overtook Tesla in Q3. And so you should be asking things like which source, what page number, uh what document? It doesn't have attribution anymore. It's just gone. Okay. So what should we be doing? We want structured formats to keep content and metadata traveling together. So here we have our findings information, where it came from, the source, and stuff like that. Okay. Hey, this is Andrew and in this video uh or this follow along, what we're going to do is um tackle the raw findings dilemma. The idea is that we get raw finding information, but we aren't keeping the findings of that information, right? Um and so what we'll do is we will make a new folder. I hope you're having fun making folders called findings. And uh we'll go ahead and make it a main.py. Pi and I keep doing the main.py even though Typescript has more features because at some point we're going to run into something where it, you know, doesn't have those features. Um, and so I'm thinking of one we recently did, but remember not the forkbased one because that that one's in Well, we could grab that one, but that one got converted back into original Anthropic SDK. And so I'm trying to think about what we were using before that. I think it was task tool. Yeah, it was task tool. And so I'll go here. I'm going to copy that co code [laughter] and we'll go into findings and um I'm just going to go ahead and screenshot, right? Sorry. Sorry. Sorry. Okay. So, I just use I like I don't like wasting my cloud credit, so I just go over to chat GPT and I I generate out that example. Um and so I'm just copying this example here that we have uh so that I can give it an example of what I want. So let's go ahead and type in Claude. And we have a new one called findings. So in here, you know, I want to uh have my research generate out uh findings uh here so that uh we can remember the source of information. Here is an example of uh of findings. You need to adjust this based on the use case. Okay. And so our use case our use case will be trying to find uh 1980s late 1970s films uh that are similar to there was a movie I watched recently that I thought was really fun. Um it was like 1981 School in the Crosshairs. Okay. like and so similar to 1981 Schools in the Crosshairs. Uh, okay. Japanese film. Okay. And so I'll go ahead and do that. If you've never heard of it before, I it was on Tuby for free and so I really enjoyed it. But like it's um uh I guess they have these films that are I guess like in Japan they have idols and so these are I don't know if they're singers or whatever. I I don't get it. But the the point is that the in the 80s it just reminded me of a Canadian film and so that's why I really enjoyed it. But like it seems like a normal like uh uh like young adult or or you know like teen teen movie and it just starts getting weirder and weirder. Um like first the first half is normal and then the second half just like gets really trippy and I just thought that was really really fun. It's mostly wholesome. 99 99 99% wholesome and 1% uh you know Japanese strange but um I liked it and I thought it'd be fun to try to find more uh films that are like that. Um but yeah, that's just generally out there. But yeah, I'm just trying to convince you to [laughter] watch another another thing you've never seen before. But um but yeah, it it uh yeah, this girl, she goes to school with this this guy and he is in kendo so that they do like wooden uh stick practice or like wooden fighting with sticks, but she ends up having telepathic powers. And for some reason, I think the Japanese really like to give people uh telepathy in the early 80s for some reason. I don't know why, but we'll go ahead. We'll just say yes here, and we'll take a look and see what we have, and then we'll review it as it's almost done. But it's it's a recommendation, right? uh if you're interested uh in a film and it's 99% wholesome and 1% Japanese weird if you know what I mean. Okay, so um so we have the uh results returned here. I'm just going to close this because I never really edited the file. I just want to make sure I have the latest and we'll open this up and we'll see what we have. So research and summarize key facts. You are a research instant with a topic. List three bullet point facts about it to be brief. Turn research notes into short paragraphs. Uh oh, this is task tool. That's why it makes no sense. We'll go over to here. So, we'll go over to here and we'll take a look. You are a specialist film researcher with deep knowledge on the 1970s uh 1980 cinema. And I mean, I would like it to be like N television. N television. And uh we'll go here. And so, we have like Yeah, I like how put psychic powers right on the top there. That's great. So, you know, high school setting, cult mind control antagonist. I mean, it doesn't have to be exactly that. It's more like a like a a thematic thing, but that's fine. You are a film researcher. And so, it's really anchoring to that because I gave it that example. And so, here we have our tools. Why is it this old school way? H why did it why is it using the uh it this way? Okay. Okay, here here like so I'm going to just ask it here like why did you choose to use uh anthropic SDK instead of agent SDK right like there has to be a reason and I mean I guess because it's like and here maybe this is the distinction of like what's a one-off task and what's something that you are continuously talking to as I defaulted to the majority of examples in this repo use it directly. So, but that's not a good reason, right? So, you you drive the loop manually, you stop it, you explain it. That's 50 lines of boilerplate agent SDK. Okay. But but conceptually, but what makes more sense to do, right? Not what have we been doing. Reason, choices, and then I'll decide. Okay. Like what are you thinking there, Claude? Okay. So, we say is the repo is actively moving that direction. Yeah. Yeah. Yeah. The tool that's not the point. The tool boiler plate is exactly what uh the agent SDK eliminates. Um, I mean I I was thinking I was thinking more conceptual like maybe a may like maybe agent SDK is for agentic agentic uh I mean like technically it's agentic anyway. So yeah no I would you know make it make it agent SDK. Okay. So, yeah, we got to pay attention. Just don't vibe code it. Review your code. Make sure there's nothing dangerous in there. Uh, we'll be back here just a moment and it'll make it the way I'm expecting it to make it. Okay. Okay. So, it seems like it may have changed the code back or like not back, but it's now using agent SDK. Let's go take a look here. And again, we're just reviewing it to see if there's any gotchas. Um, and yeah, it's going to use the API key, which is fine. We're still using Haiku. So, again, we're not using the most intelligent model, but it serves our purpose for this. And it changed it from film, so we don't have television there anymore. That's fine. We could just stick with film. Return only valid JSON array. No mark up markdown fences, no commentary. Um, I'm pretty certain that it can produce um, like if we use pyantic and pass it in, it probably would be better. We have the research agent over here still. Okay, good. Evaluation coverage. Submit complete coordinator prompt. Um, so we're going through here. So the only thing that I would say that's a little bit off here is the fact that uh I would think that you know if we're val so you know we are asking for structure JSON output back for findings. Can we use pyantic or does uh or is there a field specifically for enforcing structure JSON output. Are we logging are we saving the findings to a file so we can uh so we can see what they are at some given point. Okay. And so those are the two things that I'm I'm wondering about because um normally when you're building this stuff, it has a hard time enforcing that pattern and the only that's enforcing it is uh within here, right? So and normally we don't usually have to tell it like oh you need to do this structure. We usually just um pass it as a parameter. It's still using the anthropic key here which is kind of annoying. So we see this here like why do we why are we still using anthropic? So did it understand my request because we have call research agent and shouldn't shouldn't agent be an agent? So we have tool but it's not defining that we've already learned uh about that right. So that's going to be another issue that we have here. So actually I have to hit tab here u I just get uh tab tab shift tab tab. Can I write there's two answers here? Okay, but hold on hold on hold on hold on hold on stop. Okay, you know I I do want uh structure JSON output uh validated if there is a field but I noticed uh you are still using using the anthropic SDK. Shouldn't we be using the agent uh agent SDK uh and uh agent definition for the uh where is it here? call research agent and I think might because this code base is getting so large it might be getting confused. Okay. And so we'll help that along there because we know that it exists, right? So why are we getting the thing that we don't actually want, right? And we'll give it a moment here to figure that out. Okay. And I did notice that it was doing that note put down validation on the sub agent. Uh so we'll do that and we'll see if it takes it here. Okay. Okay, so it looks like it has updated our stuff here. Find item, find list. Um, switch over to SDK. Let's make sure that's correct. Okay, so we'll go all the way to the top. And again, I'm going to give it a nice scan here with my eyes and determine it. So we have Pyantic models. Good. So that it's forcing that structure. Um, it has the research state. So, it's holding I'm not sure what data class decorator is for, but um I'm assuming it's for creating data structures in Python. Um and so we have our findings and our counter and what's next? We have our information there. Where is our agent definition? [laughter] Is it like is it messing with me? Does it not know what agent definition is? Because, you know, I want it to be an agent. Let's go back up to here. Okay. Okay. I still don't see you using agent definition. Like I I don't understand what it doesn't understand. Like I don't know why I won't do it. So we'll go over to here. Like we'll go over to here like this. Shouldn't you be using this for the research the call research agent? Okay, like literally we have to pull the code code forward and it's becoming a big old dum dum here and let's see if it can figure that out. Okay, so we'll give it a moment to figure it out. Okay, let's take a look here. So the architecture now matches the Asian definition and we still have the MCP tools as that is what it's going to do which is totally fine. And so now we literally have our Asian definition researches topics and summarizes facts. Your research assistant um lists three concise bullet points about the fact your copyriter. Uh well no no no no. What did you do? You You destroyed the entire use case of the 19 like the 1980s '8s film. Why? Why did you do that? Okay. Like it literally just destroyed it. So now we've lost that code. I'm going to see if I can roll it back there, but we'll try. And so, you know, again, this stuff is imperfect and every time they say it's better. Yeah, you're right. The I shorten the research and prompted moving into the ancient definition, losing uh all the detailed film features. Let me restore that. Uh-huh. Yeah. Okay. Well, d like and also where's the findings information? It also got rid of my findings. The whole point of it. Oh my goodness. Let's go back in here. Where? Where is it? I don't see it in here. Is it actually in here? I'm in agent definition. Let me go over here. Findings. Here we go. Oh, maybe I just had the wrong file open this entire time. I don't know. But here we go. So, we have our agent definition. Maybe that's I was getting so upset because I was looking at the wrong one. Okay. So, I'm a I'm just a dumb dumb. Fair enough. So, um we have our agent def agent definition. We have our finding information. What I'm interested in is like where is this going here? So, we have this findings um and that is stored in our research state. Okay. And it seems to be validating it directly. So, you know, I could have swore that um the agent SDK had a direct way to validate. But anyway, we've wasted enough time. Let's go ahead into our findings and we're going to go run this and let's see if I can get any recommendations for other shows that I can watch. One big challenge is that, you know, when I want to watch these things, I want them in the uh with good subtitles and then the movies might only be like 10 bucks in Japan, but when you ship them to Canada, it becomes like a $100 $100 thing. And I I don't have a strategy for bringing them over uh to Canada where if I want to watch them um unfortunately. But so here it says, I'll help research 1970s '80s films similar to schools in the crosshairs. Let me systematically cover all similar axises through focus research. And so I'll launch agent research. I'll launch a research agent for each major similarity axis. Okay. Now, if I did a boot camp, I would probably try to do this for real where this we're just having fun, right? But I would try to make something that would actually be useful if that was my goal. Um, but yeah, I actually don't know how long this is going to take. But thankfully, I'm using the Haiku stuff, so it's not giving me full visibility on what it's doing though right now. So phase one, use the agent call with a focus question. Immediately call the recordings. Notice I have like no visibility on how many runs it's doing or anything. Like how do I know when it quits? I don't know. So this might be something that we might want to tune tune in. I know like with agents you could say like max turn whatever whatever. So maybe that's something that we should have been doing in our our agent settings, but it can't do it in Python. So we'd have to convert it over to TypeScript, right? So remember that agent definitions had like a max turn option. And so yeah, am I just losing all my credits? Let me go over to the cloud platform and take a look here. Cloud platform. I mean, maybe I'm already out. Maybe that's the reason why it's it's hanging here because it is using my uh tokens there. And so I'm going to go over to my usage. I'm just opening it off screen here. Uh 301,000 tokens. So it says 301,000 tokens here. And I'm going to go look at my limits maybe or uh API keys costs. Can't really tell here. I haven't used a whole lot in the last few days. I'm actually surprised how cost effective this has been on it. Very expensive compared to Haiku. Haiku is like costing me next to nothing. And uh yeah, it's been really good. It's actually been more cost effective than if we were to use our subscription. Um, but anyway, we'll go here. And so we have a bunch of findings. That's cool. Is it going to save it? I guess it doesn't save it as it goes. Uhhuh. Is it going to save the findings? I wouldn't mind keep the findings here. So, I'm just looking to see if it actually saves it anywhere. We did ask it to do that earlier. pen print. Uhhuh. Save findings right here. So it prints it and then it saves it into results. Jason. Oh, okay. So this thing finished running. I have no idea why it's doing this. It's really weird. Limited Eastern Europe, Soviet cinema, beyond whatever. Whatever here. So let me see assess the research coverage across all access. So here we have Akira, Virus, Brother and Sister, Carrie, the Fury. There's obviously some things that are not Japanese related like Invision of the Body Snatchers. Um, excellent coverage is sufficient. The research comprehensively covers all similarities, axes with strong representation across international cinema. I don't want international cinema. I just want Japanese. And so here we have uh stuff sits within a broader traditional including kiji whatever whatever so I think this is another obashi fail maybe like this one here take a look at this just going to open that up I'm just curious what it is here we got a movie called 1980 virus interesting post. I mean, not really totally even close to being the same. We'll go down here. Um, and yeah, it's just describing particular elements, right? So, let's go down here. So, I successfully completed a comprehensive research. Um, so phase one research. So, Japanese supernatural uh psychic school films, international team psychic tele telekinetic films, mind control, coming of age, visually inventive director uh directors, coverage evaluation, so seven out of 10, geographic distribution, thematic saturation. Yeah, like I really like the mind control stuff. Comprehensive analysis submitted identifying 30 comparable films. Key findings. So, Japanese supernatural, um, international psychic youth, fire starter, phenomenon, mind control cult, coming of age, hybrids, visionary directors. Um, and so all the data has been recorded and synthesized. And so I guess this is what saying is it's like the best match it can find. Combine science fiction with an ensemble cast with psychological phenomenal uh uh confined institutional settings echoing the school environment and mind control theaters. Yeah, but it's also not lighthearted like I would say well I guess the the movie that I was suggesting is not fully lighthearted if if you look at it but it does feel that way. Scanners Fire Starter. Oh that that could be interesting. Actually I'm surprised I don't know the Stephen King one. I I really like Stephen King. I've seen Sus Spiria. So it does its best effort here to find stuff. Um and then medium confidence. So basically these are the ones that are the closest matches. Let's go over to look at the actual finding data and see if it's actually useful. So we'll go over to here. And so we have its contents. We have a confidence high. We have a claim. We have the type, the name, the author, publish it, access it. The only thing we don't have is like where did it get that data? Okay. So that would be where we would just say, "Hey, look, that's great that you have this information, but um where did it come from?" [laughter] So anyway, it's cool. We did it, but we had to fiddle a bunch. Um but yeah, we'll see you in the next one. Okay, chowo chia. Let us take a look here at forkbased session management. And so fork-based session management is the pattern where you take a single conversation at some point and then you're going to branch it off into their own sessions uh uh and so the idea is that they can explore those things independently at the same time. Uh this feature is available in the agent SDK. You can also I guess implement it manually but you'd want to use agent SDK because this is the reason why they're probably talking about it in um this uh this course. And so the idea here is that we will have a separate session history uh per branch with its own UU ID and we can resume that history because the the state is being saved. Uh they run in parallel so things are returned quicker. They are isolated from each other and they're not sharing knowledge. Um and so the idea is that we have a function called fork session that's only available by the way in Typescript at this time. It's not available in Python. I have no idea why the Python one is so far behind. And we have session ID. I wanted to give you a code a code example. And so I thought, okay, well, I'll use Claude. I'll use Claude and maybe he can help me get a code example. I'm trying to find this here. And I literally was arguing with with it for like 15 minutes and it just refuses to make a code example despite me actually already having like look at this. I'll show you this. Like look, I'm saying can you use fork session? It just refuses. It keeps using this options fork session option no matter how much I ask it though we're going to find out when we do the um the actual lab wherever that is here right that we're going to find out that it uh that there is a actual function here right so you know just understand again I'm going to just repeat this a few more times that uh what we uh read and what's generated out is not what is actually true and I'm going to show you the truth that's why you have to follow through on these follows. Okay. Don't watch do and verify yourself so you have that knowledge. All right. Okay. Let's go ahead and try out fork-based session management. So, we'll make a new folder here called forkbased um session management management. And we're going to go ahead here and make a new file called main.py. And um so I'm just thinking about this for a moment. Okay. Um and so what I want to do is we're going to grab um I suppose the agent code is fine. So we'll go ahead and just grab this. We'll just keep working off the last thing we have. I'm still using myV. You can get rid of that if you want to use your subscription. It's just um I'm trying to manage my pro level the best I can. I can upgrade to max, but then I feel like I'm not experiencing what you're experiencing. And so I want to be able to work around those issues and and uh share that experience with you. Okay. So I'm going to go ahead into the fork-based session. Actually, not yet. Um and so we're going to go ahead here and we'll launch up Claude. Okay. And I want to tell it uh what it is I want. So um I want to implement forkbased uh session management where we have one point of history in oh resets today. That's good. Well I got to use up my credits. I was thinking of a project where I'm like hm maybe I should tell my computer to wake up and then in the off hours uh use up as much as I can. But I guess the other thing is they have a weekly limit and if I'm using pretty much all of it then I suppose having it work throughout the night doesn't really matter. But anyway, so I want to implement fork-based sessions where we have one point in history. We have one point in history um uh uh and it branches off in its own uh isolated states. Uh can we implement this in cloud agent SDK? Here is example. Okay. And so I just took you know as per usual I just took that screenshot dropped it in here. So just drop it in here have it extract out. I know it's my own text but I didn't save it in the slides. And you'll have to do the same. Good practice for you folks. And we'll wait a moment here u and come back with um some code here. See what it tries to do. And then we'll look and say okay that's good or that's bad. Right. Okay. Looks like it's more or less done. So here it says uh one shared API call that builds the common history. Um each branch gets its own copy. Mhm. Why direct API calls in agent SDK? The agent SDK query is designed for agentic loops with tools. It owns the session state internally. So when you need to explicitly control and branch messages, then we want to use the native one. Okay. Well, that's fine. I thought that we would be utilizing um agent SDK, but I suppose that doesn't fit. So let's take a look here and see what we have. Okay. Um so we have our client, we build a baseline, we have our branches. So start with this exact point share it up to here. What is the most optimistic 5-year EV adoption scenario? What is the most pessimistic? How could upcoming government regulations reshape it? Okay. And we're going to run each branch. Where is the baseline? Oh, build baseline right here. And so we go up to here. And so analyze the EV market briefly. Mhm. And then it comes back with a response of what it researched. And then down below here, it's going to go again based on that information. Okay. Interesting. All right. So, let's go ahead and run that all the way down here. We'll stop this. We will cd into forkbased sessions python main.py. And we'll go ahead and run that. We'll see what it comes back with. I think I would have preferred to pick a topic I'd be more interested in, but that's fine. We'll see what it does here. Okay. And um so we have the optimi optimistic. So aggressive EV mandates, growth projections, uh risk assess adjustments. Okay. And so that's something that's interesting. I don't have a use for it, but um I mean I get it. So like I guess we're just trying to compare this to um what we were doing prior where we had a research agent and the idea was that we would define all of its um angles. But here we're basically we have one and it's like we are just pushing that down a little bit so that we are seating with information then to go look other directions. So just it looks like a very similar pattern but a little bit different but there we go. That's forkbased session management. Um I'm just trying to think here. Uh but I guess the thing is that the only thing is that I wonder I'm just trying to think if we are done because we had a result but is it actually man managing sessions separately? That's what I'm thinking. So hold on. Okay. But are we actually managing uh separate sessions? Because they've just gone off and did stuff, right? Like like how would we pick up a conversation from before? Oh, sorry, sorry, sorry. Let's stop this for a second. So, I'm going to go try this again. I'm going to just go in here and just say for we'll go back to resume. Uh yeah, resume. Come on. Let me resume. Show me something. Show me history, folks. It is conking out here, folks. Let's try this one more time. I'm just trying to think like what is the use of this over the other one? And so I want to definitively know that we haven't missed something. Yeah, we don't even have the history anymore. That's great. Okay, so for the forkbased. Why won't it autocomplete? Am I in the wrong directory here? Oh, no, I'm not. I Well, let's go up one. Sorry. I mean, I am. I am. But we'll go back to this conversation here. Oh, is this actually um if you wanted to use the agent SDK session system instead, TypeScript has the fork session session ID which branches a session at its current point, but that isn't in the Python one. Oh, okay. Great. Port my code. Port my code to Typescript and let's use that feature. Cool. Just can't trust anything here. Why is the TypeScript one up to date, not the Python one? I'm fine. I can work with TypeScript, but there's a little bit more setup with it. So, we will let it port it over and see if we can get fork sessions in there. Okay. All right. So, we are back and we should now, if we refresh this, have our main TS. I like that it kept the main PI around. So, that's really nice. Um, and we do want this to be using the SDK, which it is. Okay. Okay, so hopefully you're comfortable moving between languages. I am. I have no problems with that. Um, and so here we are analyzing the market. We are passing our model. Which model is being used? Haiku. Good. Because I want to save money. And then we'll go down below and we're seeing the forkbased session information. So we're seeing run branch here. And in here we have fork session and that is being imported uh by the cloud agent SDK. So that makes a lot more sense, right? Because if it was just simply what we were doing in Python, then it's just like okay, how's that any different in a different or uh way of organizing stuff than how we were uh creating those different angles. But here the idea is that it's going to literally have a session state. So basically you are keeping a conversation along those three things there. Okay. So what we'll do is we'll stop this and uh you have to have JavaScript installed on here. So node hyphen version, right? I'm not teaching that. You folks need to learn that. Okay. Um I got other courses on that somewhere. [laughter] And so here I'm going to do mpm install to make sure everything's installed. Probably already is. And we'll do mpm run. Uh is just mpm run start. Usually just mpm start. Let's try that. Mpm start. Is that what it is? I didn't check it, but that's usually what it is. It is. And so it's going to go ahead and execute the TypeScript. And we are going to just watch the results. Okay, I'm now getting in the habit of always doing the labs first. Um, and sometimes doing them two or three times before I'm doing the lecture content, which is better. Um, but anyway, so here it's forking into three isolated branches concurrently. And so the idea is that it's having a conversation with each of them and then it comes back with our results. Okay. And so I would imagine one of the advantages would probably be uh that they're being paralyzed at the same time. And I will look that up and put it in the lecture slides and we will find out if that's the case. But the idea is that it's holding three separate sessions. Also just going to go here and add a get ignore. These node modules are always really giant. Uh get ignore or sorry node modules. Okay. Want to ignore that big big folder there. And so again, just going to carefully look at this here fork session. And so the idea is that they're basically running it's I know it's really hard to see here in the code, but they're basically running uh each their own loop, right? So build the baseline, build the branches, iterate over the three branches here, right? Iterate over them, run the branch for each one. Okay? Okay. And then we go up here, we run the branch, we have fork session. All right. Um, and actually, you know what? I think in my cloud code essentials, I think we looked at fork session, but we might may have not have ran it now that I think about it. Um, let me just go take a look here in one moment. Just a second here. I mean according to Gemini it's saying that um it's saying here par they're running in parallel and we are basically have their own session with their own UU ID so that we can pick up a conversation later and so that basically tracks of what the advantage would be here. Um I mean paralization obviously is going to give us a huge advantage in terms of getting results quicker. We're going to burn through more credits. Um but yeah so we have our solution and there we go. Okay. Hey folks, this is Andrew and in this video I want to test if we actually have resume and uh fork session. So these are features that I know cloud code has. Um but the question is does agent SDK have it? Um I'm getting reports that it might do it but I need to absolutely verify that. So we're going to go down below here make a new folder and this will be resume and fork session. Resume fork session here. And so we will use that as a basis to find that out. We're going to go ahead and make a new main file. We know we're going to have a much easier time, a much easier time if we uh bring in some code. Now, I do have a little bit of a problem here because I had a prior project uh under the under this one. And I just got to make sure I ignore u the do.getit ignore. This is just something I forgot to do. Nothing you got to worry about here. Get nor Okay, we'll type in node modules and we'll just make sure just going [snorts] to add that there. I know it's not something I should be doing right now, but I got to do it, folks. And there we go. So, now our change is a bit smaller here to say fix that. There we go. Anyway, so back on task. The idea here is that for the uh resume fork session, I want a basis of content. So let's look for the hello world assuming that this one is using the agent SDK, which it is. And so we will go ahead and copy this in here. And we'll paste this in. And so now what we'll do is we'll cd into we'll cd back here into the resume fork session. Okay, we'll type in claude. And so what we want to do is we want to demonstrate using resume and con uh and fork session via the agent SDK assuming that it can do it and or the other question is like is it available in in in Python? So because I don't understand like how would it know where to write um that repository. So we'll go ahead and say yes and we'll see if that works. The only thing I don't like is when it goes and it checks everything above it. I want it to stay in this uh particular uh folder. I'm not sure. No. Like why? Why? No. No. Please just focus on the main PI file. Has this problem where it aggressively searches other places and I can't seem to prevent it doing that. I'll be back in just a moment. And so here we have uh some code returned. I'm going to go say yes. And now we have an individual.cloud here. We'll close out some of these tabs. Okay. All right. So, let's take a look here. We have session one initiate a query. So, it's going to fix uh the code. I'll go ahead here and we will make ourselves a hello world. Um I remember we had a larger code sample before. I'm just going to go generate out one with some bugs. You know, can you generate out code uh Ruby code with deliberate bugs? deliberate bugs to test uh so I can test my bug fixing agent. I know I'm doing this offscreen. We will go ahead and generate that out. Just give it a moment. Okay. So, we'll go ahead and paste this code in here. I'm going to go ahead and save this and we will go and give this a run. Well, before we do, let's take a look here. We have the first session and it's going to read that file, right? And then it's going to log out the results. It's going to resume the session here with the session ID and then we're going to have a forked conversation where it uses the fork session. So starting a completely new session and we'll see if that works. So I thought this would only be for clawed code but I guess I guess it's for everything e. Um so we'll go ahead and type in main or python main. Okay. And that's going to initiate uh that query there. Okay. And so it looked like it did exactly what it said it would do. Good. And so it's now fixing the thing. What I'm going to be interested in is where is it storing this information? That's what I want to know. I think it actually just said here, too. Resume fork session. Hello world. No, no, that's not it. Um this is almost done. So we'll just wait till it's done. Okay. All right. All right. So, this seems to be complete here. And I want to go ahead and take a look into a new folder. And I'm going to go over to here and I'm trying to figure out where this could be. So, like this is the project we were running and so I'm not sure if it would um pick up in the same name. So, let's go in here and see what kind of sessions we have because that might also be an indicator of what stuff is. Okay. And so we have three sessions here. I don't think that we would have had three sessions before. One thing I'm going to do is I'm just going to delete these files out and run it again because if they generate in here, then we know absolutely that that is what is going on here. Okay. And so I'm going to just do an ls ls type in LA. And we still have one more here. I think it's because this is the active uh there might be an active session here. Okay. And so I'm just going to stop it, clear it, and we'll go over here, right? And we'll say remove. And that will be removed. Okay. And so we'll go ahead and run that. All right, let's talk about cla code sessions. So claude code session is functionally a conversation to the claude code agent. And resuming a session is the same as resuming a previous conversation. So when you type in claude, you are starting a new session. And there are two types of sessions. You have web uh and local. And it really depends on where you started that conversation. So um basically if you start it via remote control or via cloud code for web then it will be a web session. But what I found was interesting is that if I was using the VS code IDE I would be able to um resume a a web conversation to local which kind of makes sense because with remote control the idea is to trigger it over web to then run your machine or in your development environment on your machine. So uh but where it originated is stored is different. Um, but we'll talk about resuming in the upcoming slide here and show you that. But, uh, there you go. So, this is going to be very straightforward and it's the resume command. So, you can resume a previous session by using for/resume and then you can just choose it like a separate conversation. You probably saw in the last slide that in the ID you literally just click on conversations which is the same thing as sessions and that was a way to change it. Um when you do kill a a session um uh via the terminal, it will give you this line for resume with uh a session ID. I have no idea how you get the session IDs or list them. It's not really a big deal as I feel that most people are driving this stuff through this way. Maybe if you had to do something programmatically, you'd have to do it in the lab. We'll see if maybe there is a CLI command in the non-interactive way to grab uh those IDs, but there are session IDs for that. Uh but there you go. Hey folks, it's Andrew and in here I have a project u which is the claw task app. Not a whole lot going on in this one, so we might be limited in terms of uh what kind of sessions we have or I could try to switch to one that had more. But if I go up to here with the SDK um uh the SDK the the the Chrome one installed, you can see up Chrome, what am I saying? The Visual Studio Code extension, you can see we have local and we have web. So, here are some previous conversations. What's interesting is like I did these ones for um very specific projects. And so, it's just generically showing me all web sessions where local seems to be scoped for this specific one. So, if we go over to here and we click on this one, it seems like it's going to teleport us in here. And we're having a bit of an issue. To be honest, I haven't really continued web ones here prior. Um but here, what could be the issue? Um missing file or encountered settings.json. JSON path etc. So I'm not exactly sure what the issue is here but we are trying to continue something definitely in the wrong directory. Um here we go. So this session was created with exam prodev cloud code example. Open that folder. Okay. So here it's telling us to go ahead and do that. So I'm going to go back here and just kill this. So that's what I figured which would be an issue if we continued one on. You probably wouldn't have it unless you did the web version here. So, I'm basically just showing you, but we'll go here and uh I think it was like claude code. I already forgot what it was called. [laughter] So, we'll go back over here for a second. We'll try that one more time. The session was created in Examprodev Cloud Code example. open that folder first or continue in that current workspace because that is my in developer account, right? And so I don't think I have it here. I'm going to say continue here and see what happens. Oh, there we go. Um but that was a um that was in the web. So I'm not exactly sure how we continue on to that stuff. I'm not really that interested in that. I just wanted to show you that this dropdown does exist. Um and so if I go to something where we have a bit more going on. I think it was called uh grocery store monitoring. I never showed you how to build this during the app. It was something I was just building on the side while I was waiting for things to run. But if I open up this one, this is going to have a lot more sessions in it. So, if I go here, you can see here I have Whoops. A bunch of sessions. And I thought there was more than that. I could have swore there was more. And then you could just click it and then it would continue on. But generally I I like using the CLI down here. So we type this and we type in resume. We hit enter. And here it's showing this is show all projects. Control B to toggle branch V to preview. I'm going to do control A because it's showing me which folder was I in when I did that. Hold on here. Hit escape. We got to be really careful and pay attention to where we are. That's why I'm not seeing it. Okay. So, we go into grocery store here and I'll try this again. And now we'll do resume. And so, now we can see um the sessions here. Notice that it shows you the size of it. So, you have an idea of how much of the um I guess the probably the conversation is at that given point. Okay. Um but notice down below here says show all projects, toggle branch, controlV to preview, rename, things like that. Um, I'm curious what it would be if we did control V control V control shift V control + V. Nothing nothing. Okay. What about control A? Now we can see all projects. So if I can click on to bath bombs form.com and so now we're in the context of this one. Okay. So I mean it's pretty straightforward. It's not that complicated. When you want to continue a conversation, you just go to the conversation tab and change it or use the resume. Okay. Let's talk about forking sessions. So, this allows you to resume a previous session without affecting the original session. The way it works is that when we uh perform the fork, it's going to basically branch off uh as a new conversation um with its own session ID. Very straightforward to use. We just use the hyphen fork session uh to do that. And if you notice that there's continue, resume, it's the same thing. I just have a hard time typing continue, so I never ever show you that. I always just do resume. Um, but yeah, pretty straightforward. There you go. Hey folks, this is Andrew and in this video I want to take a look at forking a session. Um, just so you know, I'm jumping all around with these videos and so sometimes things will look a little bit different. So, I do apologize, but I have a project here that has basically nothing in it. I'm going to start up Claude, and I want to have some kind of conversation with it. So, what I'm going to do is I'm going to tell it to uh code me Flappy Bird uh in a new folder using JavaScript. So, that's obviously a very easy task for it to do, and we'll go ahead and allow it to do that. And so whatever it wants, I'm just going to say yes, yes, yes. Uh until it gets to a point because I'm just trying to have a conversation. Uh continue on here until we have something. Okay. And then when that's done, we're going to then try to do a fork. Just a moment. Okay. All right. So after a little while there, um it's finished. And so I'm just going to hit escape. And uh what we can do is we can go ahead and Whoops. Hit escape here. And Yeah, it's fine. There we go. I'm not sure why I can't type. I'll turn I hit shift escape to go back into normal mode. Some of this just happens. I have to like type a little bit to get here. So, obviously there is the resume command. Um I'm not sure if they have a fork command here. Do they have a fork command? They do. So, that's obviously one way we can do it. In the screenshot or in the the slides, I didn't show you there was a fork command here like this way, but there obviously is. We'll go ahead and do that. And so, now it's forked that conversation. And we can see there's original one here. And so I'll just say um you know, can you check the Flappy Bird game for bugs, right? And so it's going to go off and do that. I'm just going to click into any of this. And the reason I'm doing that is just so I can see there's more than one conversation. So here you see code Flappy Bird and then you have this one. And so clearly they're different. We could probably rename it so we can distinguish it if we were working on another fork. But really that's all it takes to fork something. So that is not a complicated concept. Obviously we just have two conversations or two sessions and there you go. Let us take a look here at the context command. So context shows tokens consumed in the current session and available tokens broken down by category. And so here um we have a completely brand new session and we are running the context command. And notice that uh when we have a new session that basically all the space is available. In fact, the only thing that's taking up any room is um the skills being loaded into here. And then you have your autoco compact buffer. Let's talk about that. So autocompact buffer is cloud code um reserving a portion of the context window. So 22% of it uh that ensures there's enough headroom to summarize conversation history when the limits are approached. So very very useful feature. Um, if we were to look at an older session here, uh, you'll notice that we're getting actually a breakdown of information in terms of what it's utilizing. Okay, so uh, there's obviously more going on here. So, we have the system prompt, how much room it's taking up, skills is really small here, and then that there's our actual message. Um, so you'll find that that's really, really useful um, to keep track of stuff. And later in the course, you'll see me use it a lot more as I start to think like, okay, how much usage do we have? Um, and one thing I want to point out is that a really great way if you want to see this command is when you're using the resume or the uh the resume flag to to continue a previous session. Then often you'll run the context here to see the size of it. Okay, but there you go. All right. So, let's take a look here at uh the context menu. So, or the context command. So, I'm going to type in claw down below and we'll hit enter. And so now that we're here, I'm going to go ahead and type in context. So as far as I understand it, that when you type in Claude, you are definitely creating a new session. If you're over here and you have previous conversations, I imagine that those are separate sessions. Notice it says search session. So to me, these are previous sessions that we could resume. It's interesting that we have either web or local here. So I guess we could pick up a um something that we were doing in the web and then bringing it on over here. Actually, you definitely can because I'm noticing here that carryover. I'll probably make notes of this. One moment. All right. And so, one thing that I'm surprised is that we have 7% use uh 7% usage because I thought this would have been scoped uh per the session. So, I'm not exactly sure what we're looking at there. Um and I'm not sure how you would tell if you're an existing session. So, I'm going to go ahead and hit escape. Okay. Let's see if there's any way in here. Let's see here. Um, so what I'm looking for here is I just want to know I type in for slash Whoops. Can I type? Nope. Nope. Nope. We'll keep hitting escape. Uh, that's not working. I'm going to just control C out of there. We'll type in clear. Oh, we just actually saw some session information. We uh we recommend medium effort for Opus. I'm actually surprised that it did this. I didn't even prompt it for that. And so what I'm carefully looking for here is if there's any session information efforts to determine how long it thinks or whatever. Um I I don't know what it's doing. So I'll hit enter. I'm not sure why it was asking me that. And I'm just going to make sure that whatever model I'm on, I'm on the default one because I want to have standard usage right now. I'm just going to type in default. There we go. Um but I'm just wondering if there's anything for sessions in here. We don't. Um okay. What have we do? We get uh we do have resume. Okay, then we have clear. Okay, so maybe this would help us see because we'll have some options. Okay, so here we have some options for sessions, right? So I can go here and take a look. Notice that like the amounts are uh bigger or larger here. I'm wondering if that's going to affect some stuff here. So I'm going to go ahead and hit enter here. And now what I want to do, I'm so tempted to type clear, but clear is going to clear the conversation. and it's not going to um clear this here. So, you really don't want to type that. We'll go ahead and type in context. And so, what I'm trying to figure out is that, you know, if I switch to different conversations or sessions, does this change? Right. I also, it's interesting how we have skills and messages here and they kind of stack up so you have an idea of usage. Um, and it's cool that we have like a little buffer here. So, that's kind of interesting. One second. I just wanted to screenshot that and I want to go re-record the context one. But anyway, um, so it's not really telling me what I want to know. So I'm going to go ahead and we'll try this again. Resume and we will switch to just anything that's different, right? And so what I'm looking for. Yes. So it does. So it absolutely does change with your session. So if you switch over to a previous session, you're going to get different information. Okay. So that's pretty darn clear. Um, yeah. So I think that answers that and uh yeah okay there we go. Let us take a look at the compact and clear command. So when you have larger conversations that means they're going to consume more tokens that equals to greater cost with your uh API usage or um you're going to run out of your subscription usage that five hour window a lot sooner than you think. So um cloud code is going to do autoco compaction. So technically it will take care of itself at those larger sizes but there could be cases where you just want to automatic or manually trigger a compact or you just want to clear the thing entirely. And so they have two commands for that. We have the compact command and then we have the clear command. So it's pretty darn straightforward. Um clear will not clear out your cloud MD files or your automemory. Uh this was a thing that a lot of people get mixed up on. The other thing is you got to be careful not to type clear as in to clear your screen superficially. It's very common in Linux to type in clear or cls, but this will literally clear out like delete uh the conversation and start it start it over from scratch, right? Um and I'm just going to again iterate this because I say this a lot of times, but um there are cases where conversation or sorry your environment like WSL 2 might get halted. Um, I was having a like a conversation that was at the max and then all of a sudden my WSL 2 hung and I had to restart it completely. Uh, so just be mindful of that. And the way that we can do that is with that context command which will actually show us, right, which we saw in another video, but there you go. Okay. Hey, this is Andrew. In this video, I want to show you the compact and clear command. They're pretty straightforward. Uh so what we'll do is type in claude and we can uh do it over here but I noticed that sometimes when you use commands here they work a little bit different. So for instance context would tell us um information about uh you know how large your context is. But you notice here that it's not as nice. It says you know how much we have here but it's not as nice as the one in the CLI. So you just kind of learn you know over time. Probably at one point in the course I told you I preferred the the ID. Now I prefer the the terminal. But here this gives us an idea of the size of our context usage. So we can see here um system prompt. So how much the system prompts taking up the skills and the messages. So not a whole lot. There's not really any need uh to compress this. But maybe what we'll because this is a new uh a new session, right? Or it should be a new session. But what we're going to do is switch over to maybe an older one like bathmoms.com. And then we'll try this again. We'll take a look and look at our session. Is this any larger? It is. It's a little bit larger. It's not a lot, but it is larger. So, we could kind of fiddle and try to find a very long conversation. Um, I probably could do that if I just go back to one of my prior projects here. So, if I go into this one, and again, if you didn't have such a long conversation, you just have to prompt until you did. But I can go here and then we'll type in resume. And I want to see, can I find a really big one here? Thought I was seeing megabytes in here. somewhere, right? That one here. Can you read read me and define what is expected to be called? Yeah, it seems like there should be something larger than that. Nope, that's my largest one. Okay. And so, let's go ahead and take a look here. I'm assuming that's the largest one, right? No, not that much larger. So, I'm not really sure where the long conversation is, but you know, if we did fill this up, we could do that. So, what I'm going to do is I just want to fill up the context. Um, so I'm going to give it some kind of complicated task that's going to take forever um to get done just so that it fills it up quite a bit. So, I'm just thinking about this for a second. Um, I'm going to say I want you to port the app over to Rust. Uh, I want you to port the back end over to Rust. and the front end over to uh TypeScript I guess because I I wrote these um this is a JavaScript front end with myithil and then this one here is um a Golang app, right? And so actually I might just save it before I do anything else just so that I don't have to meddle with it. Say add all. I don't think we want to add this one. We'll add all the rest here. Save changes just because I don't want if I ever want to come back to this code, I just want to have it in a good spot. And so this is a very large task. Um, and so I'm going to go ahead and ask it to do that. And this is going to take a while, but the reason I'm doing it is just so that I can get a larger context menu and to show you the compact and clear. So I'll be back here in a little bit. Okay, there we go. So after um 9 minutes, it uh rewrote our stuff. I'm not actually trying to make this work. I was just trying to give it a large task that it needed to do, but it's fun to give it large tasks and and let it run off to the races. I'm gonna go ahead and check my context and let's take a look here. And so, yeah, we're getting uh a lot more usage here. Clearly, there is still more room to be had. Um, and while I'm here, I might as well just check my usage, right? So, I'm at 28% for the session. So, that is good as well. Um, but anyway, so I wanted to show you two things. I wanted to show you compact and also clear. So I'm not sure what is going to compact for this, but we'll go ahead and give it a try. So we'll say compact and we will wait for it to compact. I don't remember it taking very long for it to compact, but basically what we're interested is is what is this going to look like afterwards, right? Okay. So, I'll just pause it and we'll wait till it's done. All right. So, our compaction uh appears to be have completed. So, here conversation uh compacted control O for history. I guess we do control O for history and see what we get. Uh it's not very useful. Um we'll go all the way back down. I guess just really scroll this all the way to the top. I'll just hit escape here. And what we'll do is look at context and see if it's any smaller. It is much much smaller. Okay. So, now let's try clear. So clear the conversation history and free up context and that instantly executed. We go check the context and now it's basically just one thing. So there you go. That was um our two compacts and clear. Okay, let us take a look at the rename and rewind commands that affect your session. So rename as it implies let you rename uh your current session. Um I think this is a habit I need to get uh better at doing because I do find it very hard to distinguish those conversations. Um just remember that you only have 30 days till you have those sessions and there's some way to back them up. I'm not exactly sure. I'll have to look at that separately if that is a concern. But yeah, that is something that we'll need to look into. Then you have your rewind command. So this will restore a session to an older point in time. So here I was just trying to do a loweffort. You can see I set to low effort and these are the prompts that I did. So we can go to that prior conversation and basically it's just like literally you are clearing out to that point and continuing on from that point. Um so if you cannot afford to lose that other stuff, you know, just don't go too far back. Um but yeah, uh there you go. Not complicated, but we will give it a little try. Okay. Hey, this is Andrew and we are going to take a look at uh rename and rewind. Very straightforward and we'll only take a moment of our time. So, um again, it's hung up on me here. I don't know why that happens, but I'll just close out the old one and we'll go ahead and type in Claude. And so, we've started a new session. I'm going to rename it right away. And we'll just say uh maths. Okay. And so, now that's the name of our session. I'm going to go ahead and maybe we could just take a look at um uh resume because I'm just curious what other ones we have here. And so none of them those ones are named. Okay. But we're going to stay in our current session. And um what I want to do is just do some basic logic. So we're going to set the mode to low. We are oops mode not mode. Um effort effort effort to low. And then the model here will make sure it's high coup. It's already haiku, but I'm just doing it out of habit. And now just say 1 plus 1, right? 2 + 2, 3+ 3, 4 + 4, 5 + 5. Nothing super exciting here. One thing I want to do is check context just to see what size we're at. So there we are. We haven't really used up a lot, so we're probably not going to notice, but it does say 822 tokens, right? And I'm going to go here and rewind. And so if we rewind, we can go in the past. We'll go to now 2 plus two. And here it says restore conversation or summarize from here. Interesting. We're going to restore the conversation. And um now I'm going to do context. And notice the token count is much well, it's not that much smaller, but is smaller. So obviously we had a couple options there. Um and they're pretty straightforward, but there you go. Okay. Chowo chia. All right, let's take a look here at Claude Code setting scopes. So, there's a settings JSON file, but there's a little bit more to it because you have to take in consideration uh at what scope it is being utilized at. And you're going to find these level scoped settings files for more than just the generic settings JSON file, but other ones as well. Um, so just consider you'll need to apply that in other places. But anyway, let's work our way from the top to the bottom. Starting with manage settings. This is the highest level of settings for cloud code. This is for organizationwide instructions and it's going to be managed by your IT and DevOps team. The next level is user settings. These are your personal preferences across all projects. Then there's project specific settings. And then there's local settings. Uh with the last one being project specific, but it doesn't get checked into your git repo. So, where do these things live for the manage settings? Uh, it's going to be on your servers. And there is a special uh settings file called a managed settings JSON file. And there are some settings that only go in this one. So, it will take all the other ones, but there are some that specifically only will work in the manage settings JSON file. For user settings, that will live in your home directory. As you can see the tilda uh I'm not sure what it be for Windows but for Linux machines it'll be tilda which is your home directory/cloud and then it will be there. For projects it's going to be very similar but it's going to be in your project your repo wherever that is and it's going to be in a similar folder and then local will just have local JSON on it and that's how you're going to distinguish it. And the priority of um what takes precedence is what's higher in scope. So something higher in scope is going to take precedence over uh settings in the lower scope. And there you go. All right. So now that we understand scoping for uh clock settings, let's actually go look at all of them. And we are going to look at all of them. But my goal here is not to make you remember them here. That's not important. What's important is to get exposure to understand what settings are available to us because we're going to repeat it out throughout this course when we need to look at those settings. Okay, but there are a lot of settings here, but I think it'll be worth our time. So, first we're going to look at authentication settings. And by the way, all of these are going to go in the settings.json file. There are going to be some settings here that are manage settings only, and we'll point that out. So, obviously authentication has to do authentication. And you'll notice right off the bat, we have some things that are specific to AWS. Um, but let's go take a look here. So the first is API key helper and this is a custom shell script to generate a temporary API key. Um then we have for adabus o refresh. So that is going to be the trigger to refresh the authentication and I mean you'll probably leave it alone but it'll be just adabus sso login. So to do SSO login single sign on login. Um then we have the auto select for the uh UID or so. So you can force the exact value that you want it to be. You can also force the login method. So if you only want to use cloud AI, you can do that. If you only want to use console, which would be the for the API usage, then you can do that. Uh so that's something you can set. Um and then if you need to export native credentials uh uh with the grant there, you can do that and set the script for JSON output. Let's take a look at session and storage settings. So uh we can set a cleanup period. And so the default is 30 days. Um but the idea is that you know those sessions aren't active. They're going to get deleted. So you might want to have a strategy to back that stuff up. Um but the point is and we showed you how to export somewhere in this course how to export um individual um sessions, right? Um or if you just have go to the project files, we know that they're literally JSNL files, so you could just uh back those up as well from there, but they're not as easy to parse. But anyway, so if you set it to zero uh to delete all transactions at startup, and it will disable persistence entirely. Uh and so when it's zero, there will be no new JSON files written and resume shows nothing and hooks get empty transcript paths. Okay, so just a consideration if you do set it to zero. For automemory directory, this will be a custom directory for your automemory. So you can change it to a different path, but it's not allowed in the project cloud settings uh JSON file there. Okay. Um and then for the plans directory, you can change where you want to store your plans. Pretty straightforward. Let's look at environment variables. This allows you to set environment variables, right? So if you need to set them to be applied for every session, you can do that in your settings.json file. For model settings, you can override uh the default model for all sessions. U you can restrict uh exactly what models you can choose from. So you're saying what available models. Okay. You can map model ids to very specific provider IDs. So example here to Amazon Bedrock. I can't imagine that you can set this to anything outside of the cloud models, but maybe there are different variants of cloud models on Amazon Bedrock and you might want to set those. Um, you can set it so it's uh thinking is always enabled by default and you can set the fast mode per session optin if you want to. So fast mode resets each session. Users must reenable fast each time, right? And fast mode is um I believe that's the opus feature, right? where it gets expensive. So, um that's why you'd set it in here if you don't want to keep setting it and you're comfortable with the cost of it. Uh let's take a look at uh output and language settings. So, you can set the output style. Um and so that would be to explanatory. Um output style, we cover this somewhere else. Yeah, we actually have a section where we cover it, but that's going to change um how it's going to work. So, explanatory means I'm going to not just only solve the problem, but I'm going to explain it as I go. So you understand that you have another one called like learning which will uh let you um it will stop and then let you learn uh like your pair programming with it. Um and again we cover that in the output styles language for setting language pretty clear. You might want it as English. I I don't I don't know why mine set to Japanese but um I never noticed it in Japanese but that's fine. And then we have in include get instructions. Um so yeah that will be for I guess the PR workflow. I don't think I've used that setting, but it's there. Let's talk about get attribute uh attribution settings. That's usually when you're saying who the author is. So, you here you can set it um in terms of what the commit message looks like. Um and this option is now deprecated. So, you're not going to be able to set include co-author by. Let's take a look at announcements and update settings. So, here this will be shown at the startup of multiple entries um that are cycled in. So if you're a company, maybe you want to cycle these things to remind people like hey remember uh you know don't do x y z or you know like whatever companies want to do. Um and then you can set the auto updates channel value to whatever you want it to be. Um for the UI itself and spinners we have quite a few options. So uh for show turn duration we can uh change that value. We can set the spinner verbs. Actually, you know what? I'm so glad that I know where that is because I really dislike these verbs, right? So, I think I'm gonna make a lab where I change the settings so I do not ever have to see all these weird words again because I cannot stand them. Um, yeah, we have whether you want to show tips or not in the spinner. Uh, we can override the spinner tips. So, again, if you're working with a team, maybe the suggestions you want them to see periodically, you can show terminal progress for iTerm Iterm 2. This might actually fix. Well, we're not using iTerm 2. That's a Mac specific thing. But you notice that in our WSL2 my version that the progress bar in the terminal is not great. Need to be fixed. And then we can reduce spinners, shimmers, and flash animations for accessibility. So if they're bugging you, you can set that to false. Okay. Um, for agent team settings, we have the ability to set the teammate mode. I think this is how it's going to work. So whether it's going to split pane or run in line or run in split panes in T-Mox. T-Mox is terminal. Actually I don't know what T-Mo stands for. I know what it is, but I don't I don't know what it stands for, but it's a it's like a terminal extension that lets you do uh split screens natively in terminal, right? So a lot of programs these days let you do it at the OS level, but it literally will do it within the terminal um like the terminal shell window. Let's take a look at permission rule settings. And this stuff we're going to dive a little bit deeper because I have to explain the wild card logic and stuff. But the idea is that these are the things that are allowed to do. So whether it can read files, write files, utilize bash, and then there's there's some logic um in terms of how the wild card works, but that's where you don't require permissions or like it doesn't have to ask you to do it. than the things that you want it to uh ask you before it does it. Things that it will deny for very sensitive uh files or dangerous commands. If you need to include extra directory access beyond the project route, so maybe there's some shared files that you want to include or shared documentation. Maybe you have a um coding guideline across all your projects, then you could maybe reference that information, let it know that it's there. Um here we can set the default mode. So here it says accepts edits. Um, yep. So you know default mode there and then we have disable bypass permission mode. So this would be yeah set to disable to block the data permission flag entirely. To block the flag entirely. Uh, so that means we can't use it. Anyway, we cover it. I can't remember off the top of my head. I think it means to disable the feature, but we definitely cover it in that specific slide because I remember talking about it. We got MC server setting controls. So, auto approve all servers listed uh in the MC uh JSON file. So, if you want to enable them all, then you just say true. Approve only specific servers. So, here we're saying we approve memory and the GitHub uh servers. Disable specific ones. So, specifically reject certain ones. Um and then we can allow them based on uh server names. These are based again this is manage setting only. So, just pay attention to that. So, allow lists for MCP servers. Um yeah so for specifically manage settings. Okay so that's all they're saying there. Then all of these settings here for plug-in marketplace are for manage settings. Okay so for your orwide level settings and here we have the option to strict uh uh restrict to known marketplaces uh or block marketplaces or it says appended to the plug-in trust warning to show it install time. So just a message there. Uh then we have uh manage settings uh only lockdown uh flags. So here we have allow manage permission rules only. So whether we can set that there for MCP servers and hooks only and again this is for manage settings. And then we have hooks. I don't know if this is the last slide. I think it might be the last slide. And so whether hooks are enabled or not uh what are allowed hook URLs? um the envirs that will be allowed to be interpreted and then the actual hooks themselves and we have a whole section on hooks. I guess we're not done. We still got observability status line IO and miscellaneous settings. So here you can set the OTL header uh headers helper. So I guess if you're using uh O telemetry to export your data, you can utilize that there. This is where we configure status line. We already covered this when we did status line. Um and then for file suggestions, we have a custom script to power the autocomp completion. Uh which is interesting. And then we have respect git ignore. So whether the file picker hides files matched by the git ignore or not. So there you go. That's all the settings as of today. And again, do not worry about remembering all that stuff. Uh we will figure it out as we go. But I definitely want to change those darn spinner verbs. They I cannot stand them. Okay. Chow chia. Hey folks, this is Andrew. In this video, what I want to do is fiddle with settings. Now, obviously, uh there's a lot of settings and at a lot of different levels, but I personally just want to change something for myself. And I know that we already have a settings.local.json. If you don't, go ahead and create one. But I'm pretty sure when you uh do claude there at the start, you're going to get one. Or you could do claudit as that will set one up initially for you. Um, so I'm just thinking about this for a second. Let's go make a new project because I just want to test this for sure. And we'll say um mkdir and this will just be uh settings example. And I'm going to cd into that one there. I'm going to do claude. And so as I hit enter, okay, it's entered into settings example. And so whenever you do that, it generally is going to create a new thing. But notice here it says in settings local.json. So I think that it might have already created one. So I'm going to go ahead and type in code period just so that we can get into this context so we're not confused. I'm going to give this a refresh here. I want to see if there's any kind of file here. That's what I'm looking for. Do we have any settings file yet? Okay, we'll go ahead and do terminal. New terminal here. I'm just going to go ahead and make a readme file just so there's something here like hello world. So it has something to look at, right? I'll even make a Ruby file. We'll go ahead and just say um hello.rb. RB and this will be puts hello world because I noticed that when it was empty it didn't prompt us for anything like do you trust this directory which I'm used to seeing. So maybe there has to be something for it to do that. So go ahead and do that. And it didn't it didn't prompt us for anything but um we see this. It says inhello.rb. That's its context right now. Oh because that's the page we're looking at up here. Okay. Um but it isn't. Let me just see. It isn't telling me anything else. Let's go ahead and stop that. So now I have nothing in context up here. Let's go ahead and hit claud. It's not asking me to trust anything. So it says tips for getting started using the init. Okay. And notice there is no cloud directory. So we could obviously create that manually. I'm going to go ahead and use the init. Okay. So we'll go ahead and do the init. And I believe that's going to go ahead and create it for us. So here it's searching if there's anything in that project directory. We'll give this a refresh now. And I still don't see anything. So, I'm going to stop this here. I'm going to do ls- la. And we still don't have a claw directory. So, I thought I for certain thought that was going to create for us um uh what we wanted there. And so, we'll go ahead. We'll just launch this up again. I'm going to do for/init. Initialize a new claude MD file. It didn't even make one for me here. Am I not in the right directory here? I am. Okay, I still going to do this. I just want to see if it generates out a settings JSON file. Okay, because I don't remember creating that other one. Maybe claude changed it at some point. Maybe I tried to change permissions. And so we're just trying to observe what it creates here. Okay, like I don't need a claw.md file. We'll go ahead and just say yes, that's fine. Um, but what I do need is that uh page. And so again, just trying to verify if that's correct or not. We'll pause here and see what happens. Oh, looks like the file is already here. We'll say yes. We'll refresh. And so we're not getting that directory. So we have our cloud.mmd, which is fine, but that's not going to do anything for us. So we'll go ahead and we'll make a new one here. This will be cloud. And then we'll make a new settings file. I always forget if it's I think it's settings.local.json. It is. And because I only want to apply to me, do that. The reason we went through all that init stuff is I just wanted to see if it would actually make when it apparently doesn't. Okay, so now we have this. And so I'm going to go ahead and we'll do uh curlies. And um the thing that I want to get rid of is that the the spinner verbs. You heard me already. I really don't like the spinner verbs. They drive me crazy. And so I'm really glad that we have this option. And so I'm going to go ahead here and change it like this. And I'll go here and put verbs. And so I'm going to list it to very specific ones. So I'm just trying to think of um well, by the way, if we want this to work, we're going to have to name it correctly. So it's going to be local.json.com, not JSON.local.com. That makes no sense. But I'm just trying to think of of a verb that will uh not infuriate me. Um and so I am thinking um Um, computing. We'll just put computing. Okay. And so that's the one I have. Um, we might need to set the mode. Just a moment. Let me take a look here. And so we'll go into the settings JSON um, claude and see what the exact specification is for this. And so what I'm looking for is the possible settings. So we want spinner verbs. Spinner verbs. Spinner verbs. And there's the mode append. I'm not sure if we have set mode to replace to only use your verbs or append to add them. Oh, I do not want any other ones. So we're going to go here and say mode and replace. [laughter] Okay. So now we have it. And so the question will be will this work also you know if I change my settings does it automatically take effect? So uh can you um create me a simple Sinatra app that has a hello world endpoint. So that's what we're going to do. Very simple request. It says bone boonding. It's also giving me tips. So it doesn't seem I'm just hitting escape to interrupt it that it's taking effect. So, how can we reload our settings thing sign thing sign thing sign thing sign thing sign thing sign thing sign thing sign thing sign thing signal without having to completely go out there is there like a reload it's hanging there a bit and notice I'm hitting control c mean to to quit that session I'm just re re-entering it there um so this how it says settings local JSON okay and uh I'm just curious re refresh or reload reload plugins remote environment I don't see any option there so really seems like the only way to reload it is to exit it out. I'm just not convinced that changing settings takes effect until you um go in and leave again. But anyway, what we'll do here is we'll go ahead and go say build me a simple hello world endpoint in a Sinatra app. Sinatra is Ruby and it's a very small framework. And notice it's now just saying computing. So now my sanity is back. So, I'm very happy about that as I've been getting so sick of those commands. But I want this to take effect everywhere, right? Because, you know, I really don't like that uh those verbs. So, I'm going to go ahead and grab this and copy it. And what I'm going to do is just cancel out of here. And I want to go to my home directory into Claude. There should be a directory here. And there should be a settings. If there's not, I'm going to make one. So, I'm going to go here and say touch um settings.json. JSON and then I'm just going to say code claude here so I can open that up very quickly and in here we have a settings JSON and apparently we already have one even though I don't recall there being one there but that's fine and I'm going to paste that in and we're going to merge this stuff together and so now across all my projects for me I should never ever see uh these again so I'm going to go ahead and delete this out permanently okay and we're going to type in claude And I'm going to resume a previous conversation we were having. So I uh I interrupted you. Can you continue? Can proceed? You can proceed again because I can't spell the word continue. So [laughter] we have computing which is great. And that file is not there anymore, right? So, I'm going to stop that because all I wanted to see was that worked. We'll go over to here. And so, this is one is uh settings example, which was the folder we just created. But this is actually grocery share monitoring. And so, this has its own settings.local file, right? And so, if I do claude, and I'm just going to say uh you know, what version of claude am I using? Just a really simple question. And now it's saying computing. Okay, great. And we don't have it set there. So there you go. That is uh something I think the most practical setting we have. I'm also kind of tempted to try out language. As they say, uh you can switch out uh language. So preferred language. And um I know folks here probably don't know Japanese. I know enough Japanese, but I'm not very good at it. But um I'm going to try and then pretend that I know Japanese even though I don't. And we'll go ahead and put that there. And so I'm going to run claw. I just want to see do we get Japanese text? So, we'll go ahead and type that. Oh, you know what? To make it work, I think you got to spell language correctly. Do I have that spelled correctly? We do. Claude codes preferred response language. Oh, that's how it's going to respond. Okay. So, what we'll say, what uh Claude Code version am I using? Is it going to reply in Japanese? because I'm using English so that might not help right. Oh, it did. Perfect. So, we have cloud code. No. Um, bajing bajin wades. Okay. So, I kind of know it. But that's cool. So, if I want Japanese, we could just swap it to Japanese. Uh, but there you go. That's our fiddling with settings. Okay. All right, let's take a look here at permission rules. So, Claude uses a tiered permission system that is toolbased access controls or tabback. And uh you won't find that anywhere on the internet because I just came up with it. Um so, we all know uh arbback. So, rolebased access controls, but the way the permissions work with claude, it's all around their tools. Okay, but here's an example of a um uh permissions. that this would be in your settings.json. We saw it earlier in the settings.json section, but we're going to go deeper on this stuff. So, permission levels are allow, ask, deny. It should be straightforward what they are, but let's just cover them. Allow means um it's allowed to do it, right? Ask means ask the user if Claude's allowed to do it. Deny means you're not allowed to do it. Okay. The rules are evaluated from deny, ask allow. So, what will be applied is what's either we could say least permissive or most restrictive. That's the same thing. I'm just saying it two different ways. So, a deny will always uh rule over an ask and allow. And an ask will uh happen before an allow happens. So, there you go. Um where are the tools? Well, they're here. It's bash, it's read, it's edit. Those are two separate ones. I just have an editing issue there. We have web fetch, MCP, and agents. And specifically, we're talking about sub agents. Okay. So, now we know that. And the next thing we need to cover is all the syntax sugar here. so you can configure this perfectly. Okay. Hey folks, this is Andrew and in this video I want to go ahead and just test all the types of tools in our permissions and see if they work. So right now we have a settings.local.json file here and we have some allows. Um so we can install anything we want. Uh we have this database information and we have this to fetch from bright data. But I'm just going to back out here for a moment. I'm gonna make a new directory. I keep doing this. This would be like hello world tasks. As you can see, we just keep making new ones to whatever whatever we need to to work our our use case here. And um I'm going to go ahead and make a new folder called clot. As we learned, and it's not going to help us there. We're going to have to make that ourselves. And I'm going to apply this all at the settings.local uh JSON level. Okay. And so in here I'm using permissions. Yes, I know we can use cloud to help us write permissions, but folks, we got to do a little bit of work ourselves, right? Permissions. And in here, we have our allow, right? We have our deny. Okay. And we have our um ask. Okay. So, right now we don't have really anything in these, of course. Um, and there's obviously different tools. Oops. Tools uh that we have here. And I'm not sure why it's complaining like that. Maybe because there's nothing in them right now. That's probably why because they're empty. Incorrect type for array. Oh, sorry. Array. That's why. Okay. So, there we go. So, now we are set up to start working with them. And technically the order is uh deny ask allow or ask allow you know however you want to order them. This is how I'm going to order them. Okay. So now we have our permissions in here or the starter permissions. So um let's take a look first at bash. Okay. So I'm going to go ahead here and just say bash and we're going to deny it. And I'm going to go ahead here into a new terminal down below. And we will type in claude to start it up. I'll just say, you know, can you run a bash command in the project directory for ls? Okay. And so we want to see what happens here. So I explicitly told it just go ahead and run the single command. So I don't have access to the bash tool in this environment. I can use the glob tool to list files. And so the project directory contains only one file. So it found uh a way around it because it obviously has other tools available to us. But that is something uh that it could do. How about how about we just make a new file here. This will just be data.json. Okay. And I'm going to go ahead just make some data in here. So I'm going to go and say um HP 100. Make a value there. MP 300. Um class mage. Okay. So just random data. I mean obviously for RPG but random data that we have here. And so I'm going to go back here and say uh can you um use jq to return backhp data from the data json file. Okay. And so it might try to find another way around it. So it says I don't have a batch tool available to run jQ but I can read the file and show you the HP directly. And so it found another way around it which is awesome. Um so what we'll do is we will take this and we will permit it. We'll just say that uh we yeah we'll go and move it to ask and let's see what happens here. Okay. So, we'll go back and try this again. And it didn't ask us, right? So, I'm thinking that maybe the data is cached. Okay. So, I'll go back over here and say, can you use the jq file to read MP data? So, it might be trying to work around the problem and it didn't ask us. So, are you using the MP uh the JQ tool or are you relying on something like cache? Because I'm trying to test it for that, right? each time. There's no cache involved. Each executes the thing. Okay, you can verify this yourself. But it's confusing because we've told it that it has to ask us if it wants to be able to do that. But maybe it has to do with our mode, right? Because I think it's the first time it asks a tool. That's where we run into an issue. So I think what we need to do is figure out what is going to be our mode setting. Now we can toggle with shift tab here. here says accepts edits on or plan mode on. But I think the challenge here is that um we need to make it a little bit more explicit. So I need to figure out what all the permission modes are. Um I know we have a slide on it. So let me just go grab that slide really quick uh uh quick so we can compare it. Um I know it comes later on here or maybe we've already done it. We'll see here. But our permission modes is default. So standard behavior prompts for permissions on first use of each tool. Okay. We have accepts edits. Automatically accepts file edits. Plan claude can analyze but not modify files and execute commands. Um, auto denies unless preapproved via permissions. Auto denies tools. So, let's go ahead. Well, this is don't ask. We have bypass permissions. So, skip all permissions. And so, it's strange because if it's been asked once before, it's not going to explicitly ask again. I'm not sure how we force it to ask. Let me see if there's anything we can do to make sure we can test that behavior. Oh, you know what? I think the problem is human error. Look, there's a colon on the inside. You probably saw this the entire time. So, we'll go back here and it was probably me. Okay. And we'll go back and ask it to do this now. So, now ah, here we go. So, permission rule, do you want? We'll say yes. Okay. And so, now another thing we learned was that it's not caching it every time, right? So, it's going to ask it every single time. So, we'll go back over here. Can you return the HP data? And so we want to see if it prompts us. Right. We'll say yes. We get the data back. We'll move it over to here. Okay. And we'll try this again. And so one thing, another thing we confirmed is that we can update our settings JSON and will take effect immediately. Um, there were some cases I think where if we hadn't created it and we created after the fact, it didn't work. But clearly we can change this file and it's reading it every single time. So that is really useful to know. Um, so we have those. Let's talk about the read. So we'll just say we'll deny read. I'll make another one here. This will be player data. So we'll rename this to player. And then I'll make a new one. Uh, we'll call this world JSON. And in here we'll just say location um like current location town, right? So we're in a town and we'll go back over to here and so we're going to deny all reads. So can you uh return the contents of world uh JSON for me? And maybe it'll find another way around using bash. Okay. Okay. And so it's returned back that data. So what I'm going to do is I'm going to take this bash command. I'm going to put it over here. Okay. And so in theory, it won't be able to use bash. So it can't use cat or anything else to get to it. So go ahead here and then we'll try this again because we've denied it on two things, bash and read. Okay, it's thinking. It's thinking hard. I also should start typing clear here because we're just experimenting because it's adding that context every time, right? And there we go. So, here it says tool use um import JSON world JSON allow allow whatever whatever. So, it's trying to execute code in a very roundabout way. I'm not exactly sure. So, it's ID execute tool. So, it's trying to find another way to work. That's really confusing. So, what I'm going to do is stop this. I'm going to clear this out. So, we have no context. We can check it again. Just make sure that it's emptied. Okay. See, it's nice and emptied. We're going to try that again. Okay. Because I think it's trying to find a way around it, right? It's trying to search the file. It's not allowed to read it. See what it read it. Um, but we have those on deny, right? I'm going to stop this and restart it up as we're again we're just trying to get a reliable sense of reading it. Okay. How how are you able to read the file when I have deny for read bash and read? Okay, that's what I want to know. Can it even answer me that I use the GP tool, not read or bash. I searched the the pattern for it in the file which effectively turns it. So GP is a separate tool from read. Oh, okay. But it's not under bash. Grab his own dedicated tools. Okay, tools. How do I get a list of all available tools? Because I didn't see that in the docs. And so we have this here. Look at that. Docmaps skills.mmd. It's trying to f It doesn't even know what tools are available. This is where I would probably like start going in the codebase. So we go cloud code GitHub. Isn't that interesting? We have a tool that we're not aware of. It's not in the docs. And so I'd go in here and I might just go search this codebase. I'm going to hit period on my keyboard. I'm logged into GitHub. And I'm not asking Claw to do it. I'm just doing it myself. I don't want to wait around uh asking it to look in the codebase. And so I'm going to go here and I'm just going to Yeah, it's fine. Let's just get me logged in here. I just want to quickly search across this repo. So, finding files GP, right? I'm just trying to see if that finds us anything quickly here. So, here we have Glob, we have GP. Oh, I didn't cover these. I'm going to have to go make an additional video just to cover the ones that are missing. Okay, but we have docs here that explains it. So, you know, I would have thought that there would have been a very specific place for this. How did I miss these? Am I crazy? Here we have read, write, uh, GP, glob, bash, agent, web fetch, uh, web search, task, notebook. Okay. Uh, claude code tools. Oh, hold on here. Permission required. Oh, wow. We have way more rules than I thought. Okay, maybe my confusion was when I was doing the permissions, I didn't realize how many tools there are. So, I guess I will need to go back and correct that. But it seems like we have a lot more tools available to us. And we'd have to go here and say like no glob, no glob, right? And then we would need um no GP to get this to work, right? So go back and I'm going to ask it again. Cool. More slides. I got to make more slides. Looks like you've denied it as well for bash. So what I'll do is now I will bring in the readme just the read. We'll say allow. But you're basically getting the idea of how this works. It's not complicated, right? Um but I guess you'd have to really test it and make sure. So with bash and read, can you read it? I don't have the remaining tools I can use to retrieve it. Ah, so it needs a combination of tools to achieve its goals. Um, so that's really really interesting. So I will need to go back and retroactively update this. So you'll know by the time you watch this that there is obviously a bunch of tools or I'll follow it right after this this video here. But you were getting an idea of how this works, right? We didn't uh deny the bash stuff. So we can go here and you know deny very specific tooling. But I'll just go here and bring these back and we'll just do one more test here. It would be like uh JQ JQ is denied or maybe just like J question uh um asterisk. So, okay. So, go ahead and I'm just going to go back and say like read with the um JQ tool. And so, it should be denied here. So, it's denied. Okay. So, I think we got some experience here. And I have a missing spot here. Probably the next video we'll literally start talking about tools. I'll see you in the next one. Okay. Chowo chia. Let us take a look at permission modes. Okay. So, permission modes is going to change the way um claude is going to work with you in terms of whether it will go ahead and do something or ask you. And so in the lie of having permission rules, this is what it's going to do. Okay. So, the first is default. So, standard behavior prompts for permission on the first use of each tool. Um then we have accept edits so automatically accept files and edit permissions for the session. We have plan basically which is plan mode. This will uh make claude analyze but not modify files or execute commands. And so you can have it where you can have it do a plan but then you probably want to get out of that mode next step. Right? So you wouldn't want to run that all the time. We have don't ask. So auto deny tool unless autodenies a all tools sorry unless pre-approved via the permissions or some kind of allow rules right we have bypass permissions so skip all permission prompts um obviously uh you shouldn't do that but um that is an option that you have and if you want when you launch up claude you can tell it what mode to start in but you can obviously toggle away from it so you're not like locked into it um and when you're in the interactive shell you can use shift tab to change through some modes, not all of them, but some of them. And the first one is default. You'll be in it because there'll be no message there. Plan will literally say plan mode. And then except edit will be on accept mode. And as you hit shift tab, it will toggle between those three. So there you go. All right. In this video, I want to take a look at permission modes. Um, and we will get to tools in a moment here, but I figured this would be a very easy one to uh jump into. And so, uh, if we want to start up in a different mode, we can go ahead and do permission mode plan. That's going to bring us into plan mode. I do have one little issue here. So, I'll just kind of fix this and update my old uh settings file here. So, I'm going to stop and try this again. Okay. I'll just say like uh, you know, can you read the uh, player JSON data using jq um, with for the HP? Okay, very worded, but it's in plan mode, so it shouldn't be able to execute it. So, what we're looking for is to see what happens. What I really like is um plan mode when we're using it over here because it'll open it a markdown file. And so, that's a lot nicer. Um but here, I'm just carefully looking at it. So, we have explore so we can read it. We'll do bash. We'll run it. And we'll go down below. Find all visible files in the project. Do you want to proceed? So, I'm assuming that this is the plan, right? Okay. But it's hard to see it because of the way we're looking at it. And we could talk about plan mode later on, but if we go over to here, I'm going to switch it over to plan mode. There we go. I'll just say uh can you read the contents of player JSON and return uh HP? Maybe use uh the jq tool. Okay. And so this way it's a little bit better. It'll make a um markdown file. We're obviously covering plans sooner than I want to, but that's fine. It's okay. And so it should output a markdown file. Uh it's in plan mode. Where's my plan? Where's my plan? I should have written a plan first. Wow, that's a screenshot we're going to take. There we go. Escape to cancel. So, I'll take a screenshot for that for our plan stuff. So that is very interesting. Okay. All right. So that's kind of interesting that uh [laughter] that was the result uh for the plans. But I mean really it just came down to me showing you that this will enter you into different modes um for that command there. And of course we can change our setting for this. So maybe we'll do that as well as I guess that is the second half of that part. I just looking for the list the slide I have here which will uh help me know which ones we can change to. Okay, it's somewhere here. There we go. Permission modes. Yeah, I just can't remember the names of them. So, there's also accepts edits, plan, and don't ask. So, maybe try don't ask. Don't ask. And so, it shows don't ask. What's interesting is that when we toggle on this stuff, it only toggles on those two. So, we want to get to a mode that's not there, right? We have to do that. As soon as we toggle out, we don't have it anymore. And I don't plan on running it in this video, but we'll go ahead and try bypass bypass permissions, assuming I'm typing that right. Let's see. We get a big big warning, right? In fact, they have their own flag for that, and we'll cover that in a separate video because obviously it's a a big big deal. Um, but yeah, so I guess just that one one or two modes that we cannot access any way. But it was interesting to find out that our plan didn't stick to its plan mode. So, you know, if you're expecting it not to muck with stuff, just be aware of that. Okay. Chow chia. Hey folks, let's take a look at um syntax sugar for the bash tool. Um, and specifically we're talking about this wildcard function. So here's an example of permissions. And these are all bash commands. And you'll notice that bash takes a parameter. It's just a tool that can take inputs. And so what it's taking as an input is actually a bash command. So running mpm run or git or whatever you could think of it can do. Um, but the thing that is a little bit different here is the fact that there's that wild card there. That's that asterisk. And so basically anything can be substituted in there. You can put a wild card before or after or in the middle as you can see here. Just get my pen tool out so we can point to it. So it's here, here, and here. So different spots. Um there's only one catch with this thing is you have to just be aware of spaces. So spaces do matter. So like if you have the command here ls space asterric, it will match this ls la, but it will not match lsof. Okay, so that's just one little caveat. Pretty straightforward. There you go. Let us take a look at the read andedit tools. So here we have a bunch of read and edits and let's talk about um the pattern for pathing that we can pass in here. And so there are four ways that you can do your p uh your pattern matching here uh for your paths. The first is with a double forward slash. So this is going to be at the root of your file system. So normally when you're in Linux just a single forward slash would be at your root but when we're doing this we're using a double forward slash. Okay. If you want to work from your home directory you were using tilda. That's a very common practice in Linux. Okay. Uh then we just have a single forward slash. This is going to be at your project route. Um and so that can trip some people up but that's what it does. Then we have your relative one. So that's your dot/ period or just nothing there. And that's pretty much it. Okay, let us take a look at the web fetch rule technically tool. Uh, and so here's an example of us using web fetch across allow ask deny. And the only thing it really needs is a domain. And you'll notice it says domain colon and then whatever it is. Um, maybe in the future they'll have more things you can put in there and that's all there is. Um, and you'll notice one little thing down below here. Notice that we don't have any input for this. There's no parameters. And we'll probably make a separate slide on this just to make sure that you know, but if you have that, that just means that um it's it's like a catch all for everything. It's saying deny all for web fetch. Or if you had it here, it' be like ask for all or if you had it here, it' be like allow for all. Okay, there you go. All right. Let's take a look at MCP rules. So for the MCP tool, we have many examples here. So if we want to accept everything from a very specific MCP server, we do MCP and whatever the name of the server is according to Claude's directory. Um then we could have a wild card to um say we want to match all possible tools uh in there. And then we have one here for a very specific tool that we're matching. One thing I don't understand is like why wouldn't the wild card be the same thing as the server? Um there's probably some distinction there. I can't really tell what it is, but we will continue on. Okay, let's take a look at bear name tool rules. So here we have our tools uh as rules, but notice that there's no parenthesis or stuff like that. So when you have a bare tool name with no parenthesis, that's going to give you total coverage. No domain filtering, no pattern. So web fetch is going to do all fetches, all domains. Read will do all reads, all files. Edits will do all files, all all edits, right? Uh bash will do all bash commands. You're getting the picture here. MCB is the only one that's unusual where you'd have to say the name of it. So it's not just MPC_. That's not a thing. You still have to do an individual name. And I still don't know why there's one with a double underscore asterisk. It doesn't explain it in the docs, but there's a variant. Um so just be aware of the bareame tools. Sandboxing or a sandbox is a security uh mechanism for separating running programs for your operating system. And a sandbox provides a tightly controlled set of resources for your guest programs to run in storage and memory scratch space, limited network access, the ability to inspect the host system, and disallowing or heavily restricting reading from input devices. So, um, you can use sandboxes with cloud code. And so, if we were to type for/andbox, depending on our operating system, it's going to need certain programs installed because they won't be there by default. Since I'm on WSL 2, it's asking for bubble wrap, soat and s comp filter. And so it gives you the commands right there and you install them. And then once you have that uh you'll be able to go into sandbox mode. Notice that we can have a few options where it says sandbox bash tools with autoallow, sandbox bash tools with regular permissions or no sandbox. Um, and so the reason why you'd want to use sandboxing is it's very, very useful when you're running a session with dangerously skipped permissions where you want a bash command that's not going to happen. So, um, the key thing you have to remember about sandboxes is that sandboxes only apply to bash tools, right? So, that is what we're limiting is bash. Okay, technically it's bash tool. And so, let's say we wanted to read something from the internet. If we used a curl command through bash, um it would get restricted, right? But if we tried to use um web fetch, uh it sits outside of the sandbox. It's a tool outside of it. Um it's not trying to utilize the host system directly. And so it can go out to the internet and grab it. So just be aware that it's about limiting bash tools. And so I'll definitely be trying to find a use case that is safe for me to use with dangerously skip permissions. Um, but there you go. Hey folks, in this video we're going to take a look at sandboxing or just getting it enabled. So, let's go ahead and get into the interactive shell. We have Claude. I'm going to go and type in sandbox. It's going to depend on what you are running, right? So, I'm on WSL 2. I never installed bubble wrap. I guess it just came installed on this Ubuntu um uh virtual machine. Uh but you can see it really depends on what it is that you want to do. So here it's giving an instruction saying do app install socat. Okay. So I'll make a uh new tab here. We'll go ahead and do that. Um and so I'll just go up and say pseudo app app install. Okay. I guess it just wants that. And we'll just say yes. So it's going to get that installed. It looks like there was one more. So here it says the sec comp filter required to block Unix stuff. And so we'll go ahead and do that separately over here. Okay, we'll hit enter. And it looks like it's been installed. I'm going to make my way back over to here. I'm just going to uh hit escape. We'll go back up to sandbox. And it shows that SOCAT's not installed. So what I'm going to do is I'm just going to get out of this here and I'm going to try this again. and just open a new terminal to try to get a new session. Okay. Because maybe it doesn't know that it's installed. So go ahead and do that. And we will say sandbox. Okay. And so now we get um this mode. It's not even showing that we don't have anything installed. It's now showing us um the steps for us to configure. So let's take a look at the modes we have. We have sandbox bash tool with autoallow. Sandbox tools with regular permissions or no sandbox. And then down below autoallow. commands will try to run in the sandbox automatically and attempts to run outside of the sandbox fallback will fail. So what we'll do is choose the first one and so now we have it turned on. Um how do we know that it's turned on? I wonder if we could do like status line status line show if sandbox mode is turned on. I had a status line earlier when we did the cost but I ended up removing it right away. So if that's why you're wondering why you haven't been seeing it, it's because I keep fiddling with things. But we'll go ahead. I just want to see if I can add it there. I don't know if that's something that's available in the uh status line API as I don't know what is being returned and I never figured out how to well I just never put any effort to figure out what's being returned but I'm just curious if we can get that information there or not. And so here it looks like it's trying to grab is sandbox mode. So we go ahead and say yes. It looks like it's bringing back all the old code too um that I had from when I did the last status line. Okay. And so your status line is now configured uh and to display a sandbox label to magenta when sandbox mode is active. Uh-huh. I don't see it, but maybe we need to um exit and re re-enter here. So I'm going to go ahead type in clear. We'll re-enter. Okay. I'm going to go sandbox. It says we're on right now. So it obviously didn't set it. And so maybe there is some trick to it. But I guess if we want to know that we have sandbox mode, we'll have to do that. I'm just going to check one second. I just want to see if we can actually get it in status line or not. All right. So, apparently what it's piping to us is JSON uh JSON session data. So, apparently this is all the data here. So, I'm curious, is there sandbox in here? And we do not see it. So, maybe that's just not an option and it made it up. Okay, because this apparently is the data that's available to us, which is fine. And so when we want to check sandbox, that's how we're going to have to do it. Um commands will try to run in sandbox automatically. Attempt to run outside of the sandbox will uh of the sandbox fall back to regular permissions. And so it just depends on what we have set for there. So I would think that if we want this to work, we would need to set something to deny it, right? So we'll fall back to regular permissions. Explicit ask or deny. So, my question is like, how do we set up a scenario to test that? That's what I want to know. So, just give me a second. I'm going to go ask Claude offcreen here and see if it can give us some code to put in our settings file um to make this work. Okay. Oh my goodness, it's so hard to uh make sense of whatever Claude is outputting for instructions. I guess that's why I'm here. But what we'll do is we'll go ahead into our settings local. It's saying settings JSON, but it doesn't really matter here. And I'm going to grab in the deny for deny all. So, I'm going to grab uh this one here. Okay. And I'm going to paste it in. And the idea is that we're saying you're not allowed to curl wget look at environments or secrets. Okay. And so then for the sandbox, apparently we have configuration for that. Um it says configure to catch what escapes the deny rules, allow unbox sandbox commands, false networks, uh allow domains, GitHub, and whatever. So, we'll go ahead and we'll grab this as well. Okay. Oh, we have it right here. So, uh I'm just going to grab uh this command here. Okay. And we'll save that. And it says test testing the stage flows. So, here we have claude p run curl command. I mean, we shouldn't have to do this headless, but we'll just go ahead and grab it here like this. Also, I'm just going to stop. I don't know if those permissions will take effect immediately. They probably do, but I'm paranoid. So, I'm just going to go ahead and restart that there. We probably actually could have just checked them to be honest. So, here I have runcurlacample.com. Okay. And so, here they're saying this should hit the deny rule before ever reaching the sandbox. So, permission to use bash with a command curl has been denied. This command has been denied. This is likely due to the sandbox restriction. Sorry. Okay. [clears throat] And so, that's what we want to happen. And so then here we have um this test the sandbox catching something and the deny rules missing it. So let's go ahead and give that a try. Okay. So we go ahead and do that. And here network requests outside of the sandbox. Did you want to allow this connection? So it's asking us if we want to allow it. And that's fine. I'm just going to hit escape here. Uh, we'll say yes. Sure. That's fine. Okay. And yeah, we'll say yes. Yes. Yes. Yes. Okay. And so here we have a message coming back here. So the sandbox prevented the cloud CLI couldn't create its session directory due to file system restrictions. If you want to check SSH config files, you could run it directly in your own terminal. So the idea is that it's trying to check our SSH file which is on the exterior um on here. And so here you can see uh that working. And so yeah, the sandbox is working expected. And so hopefully that was clear. Um I think it was, but I'm just going to revert these for now as I do not need these set. And I'll take these rules out as well so I do not forget. Um, and I'm going to go and turn sandbox off. And we'll say no sandbox currently. Now, should I have used this with dangerously permissions? Probably to show you, but I just also don't want to make a muck of anything. So, I don't even feel comfortable using it. I'd probably launch up a virtual machine and then we would try to do something destructive. Uh, I might do that. We'll see. But for now, I think we've shown how sandbox works. Okay. I'm starting to notice at the beginning of videos I keep saying let us take a look at. So I'm going to try to break that pattern here. Bingo bongo. Uh we are checking out dangerously skip permissions. I don't know. So dangerously skip permissions is a setting which will tell Claude for a session to stop prompting you to ask for permissions. So basically go run at it. And if you want to use it, you type in claude dangerously skip permissions. Um, and you could even oneshot it with the headless task here, which we haven't talked about headless tasks, but that is something that you can do. You can set it in your um, settings.json. Of course, it is not SJ or SJ, it is JSON. It's just a spelling mistake there. Um, and that is a setting that permission default mode. So, bypass permissions. We saw it earlier. I just didn't say anything about it because I was waiting to talk about it. Now, um, let's have a serious talk about this feature because it can be dangerous. as it says, dangerously skip permissions. So, why would you use it? But you probably shouldn't because you're getting annoyed that when you walk away and you come back, your task is not completed due to a hanging ask for a permission request. Um, so you should avoid using dangerously skip permissions because it says it's dangerous. A lot of folks say that they can avoid this issue by doing a lot of planning up front and then working their permission files. Uh, but it's just going to be different other people in practice. Or one really strange thing, I don't know this is a good thing, but some people what they do is they take their uh their clawed API key and they put it in AENV in their root directory. And they say that helps avoid a lot of um waiting around for them. But again, that sounds bad to me. I don't know why it just does. Um so when should you use it? When you are running a dev container in a VM and there is no concern of risk. You know exactly what it's doing and it's handsoff. It's in an automated system like a CI/CD pipeline and uh hangup's going to cause you issues. Uh it's very low risk stuff, well scoped. You know exactly what it's doing. It's linting errors across hundreds of files. It shouldn't be deleting files, right? So how you can make it safer? Well, at the very least, if you're going to use it, run it in sandbox mode. And this will limit the amount of risk on a host machine where serious damage could be done. And we will obviously talk about um sandboxing. Okay. All right. So, I want to use sandbox and also uh the skip dangerously permissions command. And so, I want to set up a dangerous scenario for us to um do. We're not actually going to do anything dangerous, but this would be a good area of exploit. And I just want to prove to you that even if we have these two layers of protection, we can still run into a problem. Okay. So, one thing is MPX. So MPX is um a utility tool part of the node ecosystem and what it can do is download and execute arbitrary code from the internet on the fly very often used to set up projects. So like mpx create react app or mpx uh maybe like create or initialize a vtjs thing. So there's many uh mpx commands you uh come about but the idea is that when you don't want to necessarily install a library but you want it to execute and do something in one go. So even if you think you have it completely locked down um uh there are still trap doors with MPX where uh those restrictions don't matter. So you might think okay well how do I protect myself from this? Well, um I can set up a rule on bash that denies MPX, right? That would be one thing I can do. And then uh we can enable a sandbox account, right? So we believe that those two things are going to protect us, right? But the only problem is that the sandbox cannot protect you when Claude actively reasons that the sandbox is the obstacle and decides to remove it. Um, and so when you're using dangerously skip permissions and autoproves, um, the sandbox becomes something Claude can simply opt out of whenever it completes a task, but also it's just like when you have like 20 commands, you're going to miss that, right? So unless you're sitting there uh, watching it, you're not going to see it. And the whole point of this thing is to be able to walk away, right? So the next lab we're going to do is I'm going to go and set up an EC2 instance. We're going to implement these two things, right? We're going to do this and this and we're going to download an npx thing and we're going to see if um Claude will go ahead and try to remove the sandbox. I'm going to tell you first try and it did it. So I'll show you here. Sandbox is enabled. I asked it to run an MPX command and it wasn't able to do it because we uh blocked it. It did ask us and prompt us and say hey do you want to run this command? So I was able to do that, but right after that I failed and it just figured out, hey, if I disable the sandbox, I can get around that problem and then it ran it. Okay, so this is where you can run into uh serious issues. Uh but again, this is not this isn't really a dangerous thing that we're doing, but we are pretending that we're executing a dangerous MPX and uh we are either missing it or we don't have the guardrails in place to keep us safe. Okay. Hey, this is Angie Brown. In this video, what we are going to do is go play around with sandbox uh and dangerously skip permissions in a virtual machine. So, generally, when you're using dangerously skip permissions, you're supposed to use it in an environment where you do not care if anything goes wrong. And so, I think that running in a virtual machine on a is going to be a great place to do that. Um, and so I'm going to go over to EC2. And what I'm going to do is launch up a new instance. Of course, you can do this anywhere with like Google Cloud or Azure, wherever you want, but I'm going to do it here. I'm going to go with Ubuntu because I want this to be an easy install. In fact, I'm pretty sure Amazon Linux 2 or Amazon Linux 3, whatever version it is now, uh, is not going to be an easy install. I ran into problems with that. And technically, we need to have four uh 4 GB of memory. So, I'm going to launch a T2 medium. you can run it on something smaller, but I'm going to just go with the uh that there as I don't plan to run this very very long. Um, but you know, just be careful of cost there if you're concerned about it because there is a cost associated with running that, especially if you forget to turn it off. I'm going to choose my EC2 SSM RO. This is a RO that I've created. I've had forever. Um, and I'll just show you what it looks like if you need to create it yourself. Um, and so all it is, it's a RO. uh EC2 role here and it has um the key thing it needs to have is this managed instance course. So you can create that yourself by creating a rule and then choosing EC2 here. I'm not going to fully make it here but I'll give you some of the steps and uh from here we'll go next and then it's that SSM core. Okay, I type in core to get it half the time. Here it is. Create that. Attach it. Okay, so what we'll do here is we have that uh attached and we are ready to uh to go check this out. So just say sandbox test um cloud code cloud code. I got to remember what we're doing here. And so we'll go ahead and launch that instance. I do not need a key pair as we have oops uh as we have a sessions manager. That's how we're going to get into it. Okay. And so we'll give that a moment here to get spun up and uh get going. Okay. All right. And so let's go take a look at that instance and see if it is spun up. So here we have two checks pass. I'm going to go over and connect to that instance and we're going to use SSM sessions manager uh as the means to connect. I think it also lets us specify exactly how we're connecting to it. So that is really good as ads is always making changes on me here. Oh, cool. We got shortcuts here as well. And so I'm going to just say who am I? I just want to make sure that I am uh the user I thought I was. Actually, I need to be uh the Ubuntu user. That's who I need to be. I wasn't paying attention here. So maybe here. Oh, they let you pick it there. But what I need to be is the correct user. So I'll just say um I want to change over to it. So I'm just thinking about the command. It's uh pseudo su-en ubuntu as that is the user that we expect on here. Let's go figure out how to get claude code cli installed. It's a single line install. So it should be pretty darn easy for us to get going here. Um here is the command. We'll go ahead grab it. Paste it in. Paste it in. Let me paste. Yep. And we get a little bit of mess up there. So I'll have to fix that. No big deal. Very easy for us to fix. And so that's going to go ahead and get the CLI installed. I'm going to make my way over to Amazon Bedrock. Actually, I don't have to do that at all. All I need to get this going is Adabus credentials and just set a flag. So, since this is set up, um I guess what we would need is permissions for this to have access to Amazon Bedrock. So, what I'm going to do is I'm going to make a um a new IM role. I didn't think about this while I was working through it. We'll make a new IM roll and we'll just say like Amazon bedrock bedrock access. So, um we'll go here and I'll say managed core because I'm going to need that core and oh, there it is. Bedrock. We'll say bedrock. Just a moment here. So, I'm trying to think of like which one will give me access to it. I'm going to say full access here today. Okay, we'll go next. And this will be um my um claude code EC2. Okay. And so I'm going to go ahead and create that role. And so now I have a role that's going to help us out. So even though we have this installed, okay, we'll go ahead and say claude, right? Oops. Um here it says native installations exists but not in your path. Okay. So, what we'll do, I'm going to open this up here, and I'm going to um actually I'll just run this one line because that will put it into the um Oops. into the No, that's not getting it into the um into our paths. Okay. So, I'll go ahead and paste that in there. There we go. We'll hit enter. And it probably won't take effect just now. Oh, no, it did because it has source source here on the end. So, it does repeat. And so, I'll go ahead and hit enter. And so we have modes here which is fine. But the thing is is that we need to get the right role attached here to get Amazon Bedrock access or this is not going to work. Um so what I'm going to do is go here to our instance or to our actions. And what I'm looking for is the means to change the role. There we go. So I'm going to go here and this will be um what did we call it? It had cloud code in the name. There we go. And so this should still allow us to have access to sessions manager but also Amazon Bedrock. Um, so now what I need to do is I need to go and change a flag here. So we'll go ahead and just type in um I think it's under here configuration maybe deployment Amazon Bedrock. And the command I'm looking for here is not that one. This one here. Right. So they have some other stuff up here. Export Amazon Bedrock keys. We might need that one as well. Let me go back over here. I can't remember. I have a poor memory of this using API keys. View API keys long terms. So, here's one that I generated and it's expired. So, I say confirm here and delete it. And I'm going to uh to delete an IM user owning it if you are using it for any other purpose. Delete. Oh, delete this music user. Yeah. Okay. Sure. Um yeah, sure. We'll delete that. Well, I don't know. I'm about to make another API key. So, I'm just going to ignore that message for now. That's a little bit unusual. We'll go ahead and this will just be um one day You can see they be very sensitive here with Amazon Bedrock uh keys. And so I'm going to grab that, go back over to here. We'll paste it in like that. Okay. So that's one being set. And then the other thing we need to do here is go all the way down here and set uh this value so that it knows. Okay, we'll hit paste. And so now I'll just type in clear. What we'll do is type in clawed off status. And so it says we can use uh Bedrock, right? So I'm going to go ahead and type in Claude. And sure, dark mode's fine. We'll hit enter here. Fine. I trust this directory. That's fine. And so I'm going to say um what version of Claude am I using? We're just trying to confirm if we're having API token usage here. Excellent. So it is working. I just go ahead and exit out of that. I'm just hitting control C to do that. Um and here I'm just going to make a new directory. We'll just call this uh hello world because I just want something to work within. Oops. Let's go to here. I went to the home directory and I'm just going to make a new directory called hello world and we'll cd into that. And so now we have a means to work with cloud. So I want to enable sandbox mode. So we'll go say yes, I trust this folder. I'm going to type in sandbox. And there's a couple commands that we have to do. We need the uh pseudo app install the bubble and the other one. So, I'm just copying these off screen somewhere very quickly. Just give me a moment. Just trying to find a spot to put them. Um, and this copy is very finicky. Let's go ahead and do that. Pasting them off screen here. We will grab the next one. I'm not sure if we can get npm installed that easily there. And then we will grab the next one here. Okay. Because we're staging that scenario we had a bit earlier. I got to copy this. Right click, copy. What a pain. Right click, paste. Okay, so um I'm going to do the first one. So I'm just going to hit control C. Crl + C here or get out of this. Here we go. C. Type in clear. And we're going to install bubble wrap. We probably need to do pseudo in here. We'll try it anyway. Yep, we need pseudo. That's going to install bubble wrap. Okay, so that is now set up. We'll go ahead and we will install SOCAT. Okay, that's another one. We'll go ahead and try the mpm install assuming mpm is even installed on this machine. It is not installed. So pseudoapp install mpm. pseudoapp install mpm. Okay. Uh, install mpm Ubuntu. It might be pseudo snap install. Mhm. Just looking for it old school way. Just give me the command. Here it is. I don't really like taking it from somewhere like that. I guess we could install MVM. MVM install, which is fine. I'm trying to go to the source uh for instructions. Why install stuff? I generally That's how I do it. We'll go back over to here. Do we have curl installed? We do. Um, so they do have that export thing. I believe that's already appended. So, it's already there. I don't have to worry about it. So I'll say m uh do we have n mpm yet? MVM installed node. I don't know what the versions are. So here we have that one. Uhhuh. Yeah. Like mvm like node version 20, right? So I don't know what the latest versions of node is. Node um we'll say mpm uh github because that way we can find out what the latest version is. Right. So we're going to go in here. I'm looking for node and I'm going to go here and see we have 14 20. Are we still in 20? I I don't know. So I'll go back over to here and what we're going to do is say m uh like mvm install 20. I'm going to see if it just takes version 20. I keep thinking there's something newer than 20. Uh mvm list. It's not there yet. Maybe source bash rc mvm. There we go. mvm install 20. And so that's going to install a version of node for us. Okay. And that's now installed. I'm going to go grab up here that last command we needed from earlier. And so that will install all those three things. So now in theory we should have all sandbox stuff installed. That looks like it's installed. That red stuff makes it look like it's bad, but it's actually fine. I also notice it feels like a little bit cut off here on the bottom. There we go. I zoomed out a bit. And so we'll go ahead and type in Claude. And so now I'm going to type in sandbox. So here we have sandbox mode on. So it says sandbox bash tool autoallow. Right. Um so I guess the question is we'll say allow autoallow. The only thing we didn't do is we didn't deny um npx.x.x.x.x.x.x.x.x.x.x. So that's something else we should do. So I'm going to do control ctrl + c to back out of this and hit escape. Escape. I'm just trying to get back to my terminal. And so something else that we're going to need is a um a dot uh like a cloud file. So we're going to say make directory and we'll saycloud. And then inside of that I'm going to touch a new file called claude. And this will be called settings.local.json. JSON. And then now I'm going to use Vim to do this stuff. And we'll go ahead and do that. And in here I'm going to set my permissions. Okay. Permissions. Uh yeah, permissions. Permissions. I don't like how the indentation is like giant here, but there's not much I can do about it. And so I only need a deny. So I'm going to say deny. And we need an array in here. And so this is going to be um bash and then this is going to be npx. Okay. And so in that sense that should work. Let's see if there's anything wrong with our settings file. It seems like it's fine, right? So what is the contents? Oh, actually you know what we can do is just go to permissions. So if we want to check it, we'll go to permissions here and then we go deny and see that MPX is denied. So we should not be able to run MPX. And so in theory this should work. So um you know what is a popular uh you know can you attempt to run MPX for me like uh generate a project um for JavaScript or something. There's a lot of JavaScript frameworks that use MPX to download and run a binary. And so I want to see if it can execute it, right? And I want to see if it fails because now we have two measures. We have sandbox and uh another thing here. And so it's asking here, can you attempt? I'll try to generate it out. We have mpm install. Y. It didn't it didn't use it. Look, it went npm in it. Okay. So, what I'm going to need is a very particular command. So, I'm going to go here and just um say, you know, what MPX tool can we use that will reach out to the internet and uh generate something, make suggestions. Okay. So, I'm not asking it to do something. I'm just asking it for an MPX tool. I could look for one, I suppose. Is it MPX or MP? No, it is. Ah, okay. So, yeah, this is what I'm looking like. Create React app. Great. So um great. So we'll say here and say try create react app. Okay. So mpx should execute a binary. So mpx create react app. We have an explicit deny in our local settings file. Okay. And so we'll go ahead and hit enter. And it shouldn't be able to execute. Okay, it looks like it can though. If we go to permissions while we're waiting here, we'll have to wait for it to queue up. But my expectation is that it can't, right? Because we have that limitation on it. So anyway, I'm going to go back over to um I'm just going to pause here and wait until it does something. Okay. So, what's strange here is it's still going and we have 16 lines, but I'm not sure what it is. And so, it could be generating here. I'm just going to hit escape U because I don't know what it's doing. So, I'm going to just hit control C here. And I want to do an ls. And so, it clearly is using my React app. And so, I'm just going to go ahead and remove this really quickly. And I want to type my react like I want to say um it should be mpx my react app. If we run that, we should get a command here. Um, let's go back up to here. What did it suggest? Oh, it's it's create it's create react app, right? Create react app. And so what if we go here and just say yes like that. Uhhuh. >> [snorts] >> Okay. So, what I want is an example. I'm just going to go over to Claude and ask like over here. So, I want to test We'll go over here. I'll just say like I want to test I want to test uh MPX um on my machine. I want one which will not require any uh prompts but it will generate something. Okay. Okay. So, what I'm going to do is just grab this one here. Well, hold on. What's Cosway? Oh, I know what Cosway is. But the only problem is that I don't want a bunch of this, but we'll try it anyway because I think this one's animated, right? Causeway would be fun. No, actually, that's totally fine. Okay. Okay. So, what we'll do is we'll copy this command and um it's not supposed to be able to use MPX, but I'm going to go back into here. And even though it shouldn't work, I'm going to run it anyway using bash. Execute this. Oh, here's a better question. Are we even using uh the sandbox right now? I don't know. And here it's asking if we need permission for it, right? Which is strange because if it's denied, it should be not denied. So what I'm going to do is just hit escape. Let's go to permissions bash mpx. Huh. Okay. One second. Let me just make sure I have the format correctly. All right. So I'm over here and I'm looking, right? And this is uh what it is. So maybe we need an asterk. Maybe it's not enough to just say mpx. I totally forgot to do that part. So what I'm going to do here is I'm going to go to this rule, delete it. We'll add a new rule. We'll call it bash. Just another way we can do this mpx. And then we'll do asterric. Okay. So or we'll just do that because we do we still have to have a space there for it to work. And we'll update our local file. And so now we have that rule. So, what we'll do is go back to this command here, and we'll run it again. And so, it should get denied. Actually, before we do that, I'm going to hit escape. I just want to check our sandbox. Is your sandbox on? It's currently disabled. So, we'll say with autoallow, and I'll go back here and say use with this. So, now we have both sandbox and that deny rule on. And so, here it says network request is outside of sandbox. Do you want to allow this connection? Okay, so we're gonna say yes. Okay, but it should still fail. So there you have two layers. The sandbox is asking saying, hey, it has to go to the internet because that's what happens to sandbox. And then the second part, it shouldn't be able to work, right? So here it says the command failed due to sandbox restrictions. MPM needs to write to the cache. Let me try let me retry with sandbox disabled. See, it actually disabled it. We didn't even use that permissive thing and it did it. That is so awesome that we were able uh to get that to work. Um, and that is deserving of a screenshot. Just give me a moment. Okay, that's awesome. But my point is is that if you're running dangerously skip things and it's not going to know this. So, what I'm going to do next is I want to put that flag on. So, we'll just go here and say skip. So disable dangerously. I mean the way I notice it is the flag. So what I'll do here is we'll just cancel out here and we'll go claude and we'll say dangerously skip permissions. Is that what it's called? Let me double check. Dangerously skip permissions. If you don't spell it right, it's not going to work. So, it says cloud kill will not ask for approval before running potential dangerous commands. Um, and I'm going to say yes, I accept. Okay. And I'm going to make sure sandbox mode is on. I think it already is on for some reason. It is. Good. I'm going to go ahead and hit up until I get back to my previous command. And so, now I'm going to ask it. We are not doing anything. It's just going to run here. And so it's going to go and attempt to do this. So I still have to ask this something. The one thing I'm surprised is like why do I have to ask for the network out here? So we'll go ahead here and I'll just say um yes. And so it failed here and it's going to find a way around the sandbox. It turned it off. Okay. And so it did that the s prevented the sandbox prevented npm caching partially initially. The cos command executed successfully with that. So let's go take a look at sandbox again. Okay. And so there was this little prompt area, but if you're not paying attention carefully and you have like 20 or 30 commands queued up, you could see how uh the the dangerous part will spin up there. So I mean there you go. I mean, we figured it out. So, let's go ahead and we'll spin down our instance. Um, so that was nice. It just worked. [laughter] Doesn't always work. I sometimes have to do this multiple times, but first try. Uh, we got the result that we wanted. So, I'm pretty happy with that. I'm going to make sure I get rid of my Amazon uh key here. Uh, so I'm just going to go back over to uh the API keys, wherever that is, API keys here, and get rid of that key. Okay, we'll just delete it. I don't need it anymore. Bye-bye key. Uh, I don't care about deleting the user right now, but that's about it. And I'll see you in the next one. Okay, chow chow. All right, so we discovered that there actually are a lot more tools than I thought that they were. I don't know how I missed this earlier, but anyway, what we'll do is go review all the built-in tools that can get the job done for you. And ones that are marked with an asterric are permissions required. So, as far as I understand it, the ones that are not asterisk u which don't require permissions, it doesn't mean that you cannot set permissions to deny it. It's just I think that in default mode, there is a tool that when it first time you use it, it's going to ask you whether it's allowed to use it. But I'm thinking for tools that do not have the asterct, it probably will not ask you in the default mode. But we can still explicitly deny them, allow, or ask them. Okay. Um, and generally if they don't have the asterct, they're probably just readonly tools or they should be anyway or things that wouldn't impact your codebase. But let's take a look here at the tools. It's all al alphabetical. So we'll start at the top with agent. So spawns a sub agent with its own context window to handle a task. We have ask user questions. So ask multiplechoice questions to gather requirements or clarify ambiguity. There we go. I could say it. We have the bash command. Execute shell commands in your environment. Make note of the asterct as it obviously is going to be doing heavy lifting. Crawate. Schedule a reoccurring or oneshot prompt with the current session. Um we have cron delete. So it's obviously going to delete it based on a task ID. We can list the cron jobs. So whether we can see them or not, whether we want to edit a very specific file, uh whether we can enter plan mode. So switch to plan mode to design an approach. Yep. Yep. Enter uh the work tree. So look at an isolate get work tree. Exit the plan mode. Exit the work tree. Utilize glob. Okay. Whether we can GP or not. GP is just a pattern for searching across files. Listing the MPC resource tools. Lots of this stuff is very self-explanatory. LSP, we have a slide on this. So, um, yeah, it's code intelligence tool. So, LSP is a language server protocol. So, whether or not it can use a language server protocol to understand more about a language, whether it can edit a notebook. Notice the asterk there as it's editing something. And that's for Jupyter notebooks. the read command, whether it can read MCP resource tools, uh whether it can execute a skill, uh create a task, get a task, list a task, um task output, uh stop a task, okay, task update, uh to-do, write, um and we got a few more. So, we got tool search. So whether you can search um and uh search tools I guess whether you can fetch something from a URL whether you can perform searches whether you can uh write and I mean they're all pretty self-explanatory. The only one I think I wasn't really sure on was the last one to do right manage the session task checklist. No, no, that's pretty straightforward. Um but yeah, there's obviously more tools there and any of those can be applied. They might even have uh some of them some parameters as you saw like whether it needs a task ID or something. Uh but there you go. Hey, this is Andrew Brown. Let's take a look at the status command. This is going to allow you to know what method of authentication you're currently using. Basically tells you whether you're logged in or not. Here we are using it uh within the interactive uh claude CLI. So for/status, but I normally will use it before I go into the interactive console because it's more useful to know before you go and start using cloud exactly which one you're utilizing. Um, so depending on the method that you're you're logged in with, it's going to look different. And so it's important that you recognize this stuff so you don't end up using something you don't mean to use. So if you're logged into the an uh anthropic console for API token usage, what you're going to notice here, I'm going to get my pen tool out here. What you're going to notice is um it's going to say cla first party. So it's coming directly from cloud. And if you look here, you can see subscription type is null. So that is indicating that it is using the API because it is null. And look, it says manage key. That means that we clicked through and said um the claude code um user within our account to go make it for us. So we didn't manually make the custom key and import it. uh we told it we wanted to log into the console. It made the key and added it to it for us. If we have a subscription, it's going to tell us there subscription here and that's how we're going to know. Notice that it doesn't say manage key, just says first party. Um and we don't see API key source because we're not using API key source, right? So still a first party because it's coming from uh claude directly. That's what I meant to say. And then if we were to create a key ourselves, then it would say first party, but you can see that we're using anthropic API key as our key source. So that's the custom key much smaller. Okay. Um and if we use a third party then we can see that we're using a third party with bedrock and this would be set um with our adabus credentials um the normal way and then we would have another flag that would say hey use bedrock um this would work very similarly for all the other providers. And then down below if we are not logged in at all then we should see logged in false o method none um and then API provider first party. So, I don't I think they've all been No, the only one that wasn't um No, they've all been Yeah. No, sorry. Yeah, they're all uh for most part first party wasn't that was the bedrock. So, that's where that's going to change. One thing I want to point out is that I ran into a case where I actually had more than one token in here. I'm not sure how I had it, but the nice part was is that it prompted me and saying, "Hey, uh you have more than one here, so do something about And so you'd have to log out, check your Envar keys, and then explicitly log back in and fix that issue. Another thing I noticed was that um uh when I had the API token set and I pulled up Claude, it actually reminded me like saying, "Hey, did you know you have this set and you're doing this? Is this what you want to do?" And this is kind of important because when you're using the API key, then you're you're having more direct spend. It's more expensive uh or can get more expensive. And so that was a nice reminder that they had in there. Uh, so I just wanted to point that stuff out. Okay. All right, folks. Let's take a look at the debug command. So, it's a mode that will output verbose information to a specific text file, and Claude will also prompt you to describe the problem as it attempts to investigate the issue. So, I would imagine uh that this is probably for you providing those diagnostic information. And if you find something critically wrong with the way the model's working and provide it to Anthropic, I'm not sure how you would do that. Maybe go to cloudcode.com or maybe you have a customer service account. Not exactly sure, but it's pretty straightforward. You type in debug and notice that it's asking us to describe the problem. There's also a flag to start this up on the start. So you can do hypen hyphen debug. But anyway, you can see it describes uh say, "Hey, help us out here. Tell us what's wrong." Makes a text file. We have an output. says stuff like what it connects to, what tools are disabled or used, all a bunch of stuff. Um, but there you go. Okay. Hey, this is Andrew. In this video, we are going to look at the debug command. So, I saw it. I figured we should go explore it. I'll probably retroactively make the slides so you've already seen them. But, uh, I'm in here and I'm going to turn on debug mode. So, we have debug mode. This is enabled. uh debug logging for this session. So we'll go ahead and enter that in. And now you'll notice that it's outputting to a very specific directory which we will investigate as we're working through this. So I'm going to assume that debugging is when you run into an issue and possibly you're providing it to claw. But let's take a read here. To help debug the issue, describe the problem what you're having. So uh reproduce it, perform it. I'll review the logs and I'll do this. If you can't easily reproduce it in the session, you can also restart cloud code with debug mode enabled from the start with cloud debug. What issue would you like debugging? Um uh I mean I don't have an issue, but we'll go ahead and just say like uh yeah, the code doesn't seem to be, you know, the code outputed um seems to be containing mistakes. like I'm not sure what to ask it, but we really just are here to observe what it's outputting here and try to figure it out. I need more details. What code? Uh floppy floppy bird flappy bird repo. Uh the code should be in go. Um the bird should be flappy. And I'm asking it really dumb things, but we'll see if it can handle it. So here it says permission rules for bash command. We'll say yes. And again we're just really interested in the output of this file. We are asking really dumb stuff but we will wait a little while here. So I found the issue. What issue? You have a flappy bird in JavaScript but you want it in Go. The current bird does have flapping animation codes but since you need a Go version you'll need to rewrite it. What output format do you want the Go version? So, it's asking and it seems like it's a little bit more um asy like as it's trying to debug stuff, but I'm really interested in this particular file. So, what we're going to do here is we're going to stop this here. We'll type and clear and we'll cat this file out. And so, that's going to give us uh debug information. So, is any of this really useful? Let's take a look here. And so, it's just saying like temps files rewritten added original permission file. Um, so I mean like if there were communication issues or other stuff going on there, I could see that might be helpful. But anyway, this seems like something that you would provide to Claude to say like, "Hey, I had problems. Can you help me debug it?" I don't know if there's any sensitive information in here. I don't see any. Uh, but yeah, there you go. All right. So, um, the Agents SDK comes with a bunch of built-in built-in tools, and there's way more than just this, but these are the main ones that Anthropic is going to want you to know. The first is read. So, it's going to uh be able to load files. So, maybe here some of you might say like summarize this uh file and then you have that read option so it can read that file. Then we have GP. So, GP will allow you to search file contents. Um and so it can go uh ahead and do that. So that's what that would do. You have glob which will discover files matching on a pattern. So um similar but GP can like look in the I think in the contents of files whereas Glob is really looking at the names or list of files and it's really for listing uh a bunch of files out. Then uh we have edit. So this is when you want to edit files. If you don't have this, you can't edit files. and you have bash and basically bash can do basically all this other stuff right so I mean you can be you could have bash just use any kind of bash command but when you're working in a sandbox normally bash is um not allowed and it has to go outside the sandbox um uh generally speaking but um these are the key ones that you'll need to know um super not complicated very straightforward if you know basic development or devops um But yeah, we'll take a look at them. Okay. All right. Let's take a look at built-in tools. So, we'll go ahead here and say make make builtin tools. And then from here, we will go and find this folder main.py. And I'll go down here into our main.py here. And we'll go ahead and paste that in. And we'll type in claude. And so here we want to say like I want to demonstrate the builtin tools of agents SDK. Okay. So, edit read glob and bash. Okay. And so that's going to go ahead and try to update that. We'll just say built in um tools cloud code as there is a lot like there's a lot um so if I can find it here there should be a lot. So, here we have agent, bash, edit, chronist, glob. You can see there's a bunch. Oh, maybe there's not as many as I thought. There's also web search, I guess, web fetch. Um, maybe my confusion is that there's other providers that have a larger list or maybe there are more and I'm just not seeing them here. But I could have swore there was more. But we'll go ahead and we'll let it uh go ahead and do that. But if you were to build your own coding harness, these are like very basic ones you absolutely want to have, right? But we'll just chill out and let's see it create us an example of each. Let's take a look what we got here. So not sure why that's crashing. I don't care about that. Found was correctly set up, but I can't run inside cloud code session. That's okay. I want to run it myself. So we have glob uh read the calculator GP uh there bash edit and then spawn an agent, which we don't really need to do, but it's nice that they threw that in for us. And so you can see that we have all of our cases here. and they're just giving you access to all of these, right? So, those are all the built-in ones. Um, oh, yeah. So, it's going to complete those in that order. Okay, great. So, I'm just going to stop that there and we will go have a little bit of fun. There we go. And watch it go off to the races. Okay. And so, here we are seeing a glob and match it's matching a pattern. So, that makes sense there. Okay. We have uh the tool read. So here it is reading a actual file. Pretty straightforward. Um we have our GP. So notice that it is using a path matching pattern. Oh sorry here's the pattern here. So here's the pattern against that path. And so then we get the output. Um and so that is the results of it because we're matching definitions. Okay, that makes sense. So def defaf. And then here we have a bash command where it's writing Python to insert uh something here which is fine. And we have an edit. So it's going to edit this particular file. And then somewhere there is agent here. Agent agent agent. So here it is running an agent. And then it's running it. I'm doing a bunch of stuff. But yeah, pretty straightforward. Let's cover tool choice. So this controls if Claude uses a tool. So over here you'll see that I am using um tool choice with type auto. And notice that we're using the anthropic SDK because you have to use that. It it's not available in the agent SDK which um I thought it was but it isn't. Um and so when we do a lab later on you'll see that I try to use agent SDK and then I can't. Let's talk about what modes we have. We have autos. This decides whether to use a tool. Um and so an option is that it doesn't use a tool at all. Okay. Okay, so if you want structure JSON output and a tool is going to return that um if it doesn't use that tool then it might just return back text and so that is a edge case where things might break and so for structure JSON output that you'll have to consider later on so I'm pointing that out now any means it must use some tool so you give it a list of tools and it must choose one uh one to utilize and then tool is where you must specify a specific tool uh and this is considered forced I think there might have an API that used to call this forced and now it's just called tool. Maybe I'm wrong, but that's what I could recall that it was B or I'm just remembering that is the forced option. But this will never return an end turn. So I was using this and it was just looping forever. I'm like, why isn't it using end turn? Well, this one you have to say exactly what tool to use and for whatever reason it just was never ending. At least in the experience that I have. Or maybe maybe it just means it'll use one tool, but definitively when we were testing it, it was looping forever and um Claude was even saying like use a break to get out of it and it'll never end. Um so I I think that's the case here. And you can also say none. I just want to remind folks that this is only available in the low-level Anthropic SDK. Other providers will bubble this up. Like I think uh OpenAI's agents SDK, you can use it, but for whatever reason, Anthropic keeps it at the lower level here. Um, and this is something that I wasn't aware of when I was working on the code, uh, because I, you know, agents SDK wasn't something I heavily used before. I used to just use the anthropic SDK. Um, but anyway, we find that out in a video when we do the structured JSON output. Okay. Okay. Let's talk about JSON schema format. So, this is a declarative language for annotating, validating JSON document structures, constraints, and data types. Um, and so this is kind of what it looks like. The thing that I want you to pay attention to is the different types of properties. So we have string, integer, boolean, number. We can provide an array of items. We can provide a dum which allows you to choose a value that has to be set and you can have an object of this stuff embedded and it has a required area. Um, when we want to get structured JSON output, usually paidantic is used, which is um, another library. I don't have a slide on it, but it's another Python library where you describe models as basically that looks like classes. And in the end, it's just going to output J uh JSON schema format. Okay. And this JSON schema most if not all the frontier models understand what it is and they use this to understand how they need to output JSON. Okay. So now that we know what that is, let's move over to tool input schema. So tools can have inputs and you can say that it expects a specific JSON structure as input and so um the thing that you need to really pay attention to for the exam is remembered enums. So you can have a property let's say unit and it's a string and it can only take as a value Celsius per Fahrenheit. So now the AI can determine well which one should I input right um and you can also have required. So here it expects both location units to be supplied. They're not optional. And so Claude is going to read that input schema because it's schema JSON. And then it will know what to generate out. All right. Hey, this is Andrew. In this video, what I want to do is see if we can do some force structure JSON output via tools. So, what I'm going to do here is just make a new folder called forced structured JSON. And we'll go into our um I suppose our hello world. Wherever that is. Where's our hello world? Here. Yeah, here we are. We'll copy that and we'll give it a good starting point. And so, um, I'm pretty sure, uh, that there is a way to pass in structured JSON output. At least with other APIs like OpenAI, you can pass something structured using, um, a specific thing. Um, but let's go ahead and just see what it generates out. Um, because there's a few things we need to do. We need to we want to focus on a tool that's going to do this. Okay. Okay. So, I'm going to say, uh, I want to demonstrate structured JSON output via a tool use. Um, can you have a payload, have a tool that takes JSON and outputs a different kind of JSON structure? Uh, think of a use case. Okay? And so we'll see what it comes up with and then we'll just talk about some of our options. We might go a little bit beyond what the um exam guide is asking for as they are saying very particular things like oh well you should use um for like uh not auto but whatever the mode is that forces forces use and uh maybe it's down here but anyway yeah we we'll go and and explore it. I'm sorry I'm not that articulate right right now. We'll get some code out here. Okay. Okay. Okay, so let's take a look at the output. I'm not sure why I tried running it, but that's fine. So, let's take uh a clear indicator of what's happening here. So, we have the anthropic API. Um could we use it? Sure, that's fine. And so, here we are seeing uh a particular tool uh uh tool choice. So, we're seeing type tool name submit triage. Okay. So, you are support triage engine. Analyze the incoming ticket and call support triage with a structured uh record. Be concise and complete. Okay. Okay. And so here we are seeing triage this ticket and so that we have the raw ticket data which is coming from here. So I'd say the thing is like it has to create it and then pass it. So I'm going to go back here and there's a few things. The thing is like um tool choice should be set okay to something any or anything or auto. um the uh agent should generate out um JSON and pass it to the tool. Okay. So, and you should use the agent the anthropic agent SDK. Okay. I don't know why it keeps doing that. It's kind of frustrating, but there's something there's some kind of disconnect. Cloud AI knows what it is, but uh whatever whatever models I got running on the um codec side, they always seem to not be aware of it. But we'll see if it can make those changes. We'll be back here in just a moment as I don't feel like this is going to work for what we want to do. Okay. All right. Let's take a look and see what changes were made to our structure. Hopefully, it is using the Asian SDK because it's just going to have a smaller footprint. It still isn't using it. I don't know why it's doing I'm going to go copy this code over to um claw AI and like can we not use the enthropic agent SDK and maybe the reason why uh the cloudi does better is because it has memory right and so it's literally rewriting it here I'm going no no no the agent SDK So it doesn't seem to know this agent SDK cla and it's weird because the original one was this. So you know you are supposed to use the agent SDK, right? And so we'll see if that fixes it. It's just refusing to do it. Is there any reason why it says it's not doing that? Can it not use it? Give it a second. Here it's suggesting that it may have listened to my instruction. Let's take a look and see if it actually is using the agents SDK. That looks much better. Yeah. Okay. So, here we'll go down and it's just because we're going to get a smaller footprint and we're not really getting much uh by uh directly using the other one. The only thing I'm not seeing here disabled all built-in tools only MCP tools available which is fine. And so here it's setting it to our loud tools which is from an MCP server and that's definitely a way that we can do it. And so here we have our triage server. And if we go all the way to the top, this is our tool and we have a submit triage is the name of the function. Submit a structured triage record. And so here is the structure and these are the required fields. Okay, so that makes sense. Um, so we have a raw ticket and it's unstructured. So I guess it's just different kind of data. I'm not sure how this gets fed in. If it's just fed in as one big blob. So we go down here. It's just dumping the data. So, it's raw raw data, at least here. Raw data. Yeah. And so, they're just saying here is the ticket in the in the most raw format. And so, it's going to have to generate that out. And this tool, um, I'm trying to see here. So, submit triage because we have one here. This is the submit triage, right? And so this thing is going to then go through this function. It's going to record it, dump it, oh, and then return different data. So the idea is that it's going to bring in data in a very particular format. It's going to print it out so we know that it came in this format and it's going to return in another way. Um the only missing here is tool choice. So I'm not sure if we see this like auto or any. And I'll just go back here and just say the um uh there is tool choice with agents SDK. Uh and we want it set to um it's like there's any there's one that's like for like where you can force it. There's auto and any uh to any. Please don't change it. change it back to anthropic low-level SDK. Use the agent SDK. Okay. And so we'll just see if that information is exposed. I mean, I think I'm pretty certain that it's in the agent SDK as well, that feature. So, it is going and fetching information before it does that, but I I just didn't see that tool choice in there. I don't remember where it is. Um, so we want to bring in that option. Okay. And so, we'll go ahead and hit yes. and see if it can add that code. All right. And so here it's saying uh tool choice is not a parameter of the clot agent options. It doesn't exist the agent SDK. All versions including this agent SDK controls tool permissions but does not expose the underlying tool choice flag. So there is my mistake. So we'll have to go okay we need uh we need this code to use tool choice. So, um, please convert it to anthropic SDK. And so, I mean, if if it says it doesn't have it doesn't have it. Um, I mean, while it's doing, I'm just going to double check here. So, I'll just say uh agent because it might and just it's bad at searching. Um, as sonnet is not today working as expected. agent SDK tool choice. Um, we'll say here uh, anthropic. It's frustrating that they call it agent SDK because then they're all fighting for the same name. The underlying API supports tool choice. Okay, the agent has implementation compatibility has constraints and so here it's saying that it can't can't do it. The other thing is that maybe it can but it just can't be done through um uh this. So another thing I might ask I'm just going to go to ask claude here separately off screen here and this is like uh does anthropics anthropics agent SDK have tool choice? check the Python SDK and the TypeScript SDK for uh specifically the agent SDK for this option. And the reason why is that um we learned earlier that there were some features that were just only available in the TypeScript one and not in the Python one. And so I'd like to rule that out. Um though I mean we already did rewrite this into um under the format here. So it's not like we cannot use this more verbose one. Um, did it rewrite it? Well, here this looks the same. Let me close that out. We know sometimes it is uh caching. Uh, did we write it all the way down the ground here? Oh, it hasn't yet. And so I just want to get this answer back before I say yes. Python SDK is fully supported. Cloud agent SDK is not a parameter in the agent SDK. The SDK wraps the cloud CLI. Okay. So, it has to be used within the uh lower level one. So, we're going to have to go lower level here. But when we can use agent SDK, I'm going to prefer it. Um I just did not realize it was a bit lower. And so, we'll go and close up this tab here because it is much much more verbose. And we have our raw data. We'll go down here. Uh it is loading anthropic. Good. And we still have the same structure. We're using haiku which is excellent. And so I'm looking for where that option is. Here it is. Tool type. Tool choice any. Right. And uh tool choice. We have a slide on it. Let me go pull it up one second. Here's our slide. So we have auto any or force. Force means that it has to use the tool. any means uh it might choose to use it. And so the thing is like we want to guarantee uh that it uses it. So I'm going to say forced. I don't even want it to be any or auto. Um but we absolutely want it to follow through and utilize that option. Um but the thing you have to understand is like just because we're using it doesn't necessarily mean we'll 100% get the results that we want. Um but we will go ahead and try this out. And even if it does work, that doesn't necessarily mean it actually is working every single time. um which that like the only way you'd know that is if we did a batch processing and we ran it like a hundred times. I don't want to do that, but I'm just saying if we really needed to test it to see if it breaks, that is when you start to actually see things. Um so we'll say Python and we'll say main.py. And I think I just have to bring in my key back here just a moment. And the reason it's not working, it's not loading the key. So that's kind of annoying. Um I know we did one where we used the Anthropic SDK. So it's up here. And so if I go here, we can just grab this code here that's missing. I don't know why it did that, but that's fine. Space it in like that. And then bring in our ENV and our path. Probably the OS as well if they're not in there. Okay. And um that will load in that uh key. But I think we also need to set it explicitly. I'm just going to do that. So we'll grab that there like this. And I'm going to paste that in like that. And so that will resolve that issue there. It should. And so what do we have? Um error code error invalid request tool choice force bad using type does not match auto any tool or none. Oh, why do I think there's force then? Where is that coming from? Maybe I'm getting mixed up with another provider. Just a moment. Okay. Okay. You know what it is? Um I have the word wrong. So it's technically tool. I wonder before and because there's more than one provider and they might vary on this implementation and so I've just corrected that to tool. I have to reshoot that and also maybe add none. Um so that obviously is bad and out of date. Um but anyway, so we will change that over to tool. No big deal. So we'll go ahead and change that to tool. But let's just take a look here. So Claude decides whether to use the tool. Must use some tool. Claude picks which one. Must use this specific tool. Cannot use any tools. we absolutely wanted to use a tool. So we'll go ahead and run that again. And here field name required. And so here we're having an issue where uh the field is not being provided. Um and so the trick here is like we don't know what is being generated before it passes on the tool, do we? So we'll go back over to here. Are we able to see what is being passed as the param to the tool uh before it's called via aputs for main.py. I'm not sure if that's like hidden to us, but if we can get that data, that'd be really good. Yes, we can print it. Here it is. Okay, good. And so that will help us understand what's going on here because we can have inconsistent usage here. U one thing that we I don't know if we're doing this but like usually you want to provide the structure to but I guess if they can read the structure they generally have an idea of what it is they have to do. Let's take a look here and we'll run this again. And so it's fine that we have that problem. Let's take a look at what it's trying to do. Um, tool choice name. Oh, name required. Okay, so there's a different problem here. It's our tool choice. It's not named correctly. Tool choice. I I thought it was something else. And so here it says type and we have to provide a name field. Tool choice only type. Oh, okay. So, which one do we have to specify? Okay, that's why I was confused. I don't remember ever recalling having to do that, but let's go ahead and do that. Um, again, I'm not sure if this is completely consistent with each provider, but um maybe there's some variance between other ones. And so, here we need to go up and it's submit triage. So we'll go here, submit triage, triage, and we will go ahead and run this again. Let's see what we get. So far so good. And I mean, it's good that we added the additional stuff here. So calling it, here's our tool input, and it's passing that structure and it's received by the tool. It came back. Oh, it is repeating. I was saying before that, you know, you'd have to iterate on it multiple times to find out. And so that's what it's doing right now. [laughter] Actually, how many times is it going to do it? I didn't even realize that was that was there. Um, how many times is it going to run? Is it still going? Okay, I'm going to stop it. So for whatever reason it's looping. So here says while true hit the response and it just keeps looping forever. Um I mean it's consistently working so that's really really good. Um but it clearly doesn't have a way to stop. And I'm going to go back here and just ask like why the uh agent just kept looping. Why did it never stop? And maybe it has to do with with uh what comes back with um the response here. So I'm trying to look at the submit triage here because if it says submitted, right, you go, okay, it has that and it appends it. Well, there's nothing here that would indicate like the only thing I could think of is like it would have an end turn that would come back as the response. Okay. Well, there's nothing really in the code that would indicate that. Oh, there's a break missing. Ah, okay. So, here the the bug forces a tool call in every API request. Oh, any tool any after that tool runs the results are appended in the loop and continues which forces another tool call. OH. OH, AND THAT'S why we want to have any. Ah, okay. Well, that's good that we did that because otherwise [laughter] I would have thought, you know, we'd have another issue here. So, um, let's go ahead and try this again. Now, on any wow, this is turning out to be a really good example. And so, we run it. Okay. And so, this way it actually comes back with um an end turn, right? So, that's pretty good. But I would assume auto is going to do basically the same thing. We'll switch it over to auto. Okay. Yeah. Yeah. It uh it thinks I didn't save the file. I'm going to say don't save. I don't want to muck it up. And we'll switch this to auto here. I don't know why it didn't didn't say auto here. So we'll go here and run it again. It's the same thing. Okay. So, if we go back over to here, okay, one second. Let's just read this section here. All right. So, here it's saying auto because auto can just not use a tool at all. Then, I guess the idea here is that if we ran auto enough times, it may just return text and then it would fail. Whereas any it says must call a tool but can choose which one. And obviously, but if it's on tool mode, then it absolutely has to call a tool every single time and it's never going to get to that prompt end turn and we have to break it out of the loop uh to to solve that problem. So that's kind of interesting that you'd have to force a break. Um and we have strict JSON schemas via the the tool use limited syntax errors but do not prevent sematic errors. What they're saying here is that just because it's generating it can still make a mistake. There's another way that we can um improve that with pyantic uh pyantic formatting. So it's a library very popular in the Python space called pyantic. And so what this does, this is not in the exam guide because they're not asking for it. And this this exam guide is still dated from 2025. Maybe when they release it, they'll update it. But Pyantic uh you define um uh data structure models and then you can pass your uh data into it and then it validates it and if it doesn't match then it can it can say hey you need to go fix it or fail early or or um you can give the structure to the model remember fshot so like this can generate out the structure as um JSON RC or whatever the schema schema RC or whatever the format is and inject it into your prompt and then you'll get better results. Um, but we're not going to add that layer here because they're not asking for it. But in in practice, you know, I would absolutely be using pyantic. This is not enough for me for structure JSON output. But it is it is working, right? So again, we'd have to run this in batch like a thousand times and then maybe we'd see a failure. But now we know the difference that um tool is going to always call a tool and and you'd have to break out of here um on a specific tool. use any means it has to use some kind of tool but it can also hit enter. Um and then auto means it can be none or um or any. So none is obviously another option and so uh yeah there we go. Okay. So one thing you have to worry about when you are prompting especially when you're vague is you'll get false positives. What I mean by false positives is that it's going to try to do the work and it'll start working on the wrong files or looking at the wrong things because it just doesn't know what it's supposed to be doing and so it's just broadly doing many many things. So imagine you're saying hey you got to go review the codebase for issues. What what issues are you looking for specific ones? Because here it'll come back with all sorts of stuff eat up your compute eat up your time and maybe you're looking for a very specific one. Whereas here you're saying oh okay we'll do this very specific thing. it's going to go and audit only the single one and that's going to save you time and compute um and get realistic results. Okay, so beware of false positives because of vague prompting. This is probably the most obvious but the most important prompting technique which is uh be specific when you're prompting. If you give vague instructions, you're going to get unpredictable and probably not good results. It doesn't mean that vague prompting can't work, but it's just not recommended. So, if you say fix the login bug, it's like fix it how? Like, use what email at what address? Is there more than one app in here? And so, more information is going to have the um agent SDK or cloud code perform a lot better. If you can be more specific, that is even better. And so, sometimes you can even use um plan mode or some other things to extract out better tasks. um that you need to go investigate and to review. Um but also, you know, it's going to waste a lot of time looking around for stuff. So, if you want better results, provide better um prompts. And that is just by being specific. Okay. Hey, this is Andrew and we're on 5.5 where we are looking at designing human review workflows and confidence calibration. What this section is asking even though it's not clearly described is that um it's talking about like when you work with data, how do you ensure that the data is actually accurate and a human's able to easily review it. So imagine you're aggregating a bunch of data and you're getting a final score of 90% overall. This might sound like you have a good metric, but when it's a single metric like this, it can be hiding information. If you were to break down the accuracy based on the document type, field complexity, other factors, then that distribution of information is going to look differently. Then you have this thing they call stratified rand uh random sampling. So instead of r uh randomly spot-checking, you're deliberately sampling from each category. Um and so this is way uh you know categories don't get lost in their average. Then you have field level confidence scores. Okay, this isn't just AI saying you know I think this invoice is right. It's saying I'm 99% sure on on the date, 72% sure on the vendor name, 40% sure on the total line items. Um, and so you're getting a lot more detailed information. So in order to do this, we're going to need a data set. Um, and so I think that we will just go use hugging phase as that is a very easy way for us to grab one. And there's something called like q a which are like uh contracts. I think they're for like legal and I think that that might be an approach that we can do. So, I'm not sure what we want to call this, but I'll just call it like um confidence calibration. It's too it's too uh nerdy researching these terms here, but we will try to make it make sense here. So, I'm going to go here and say confidence confidence calibration. Confidence calibration. And in here, I'm going to go ahead and find it and make a main.py. All right. And so we want to bring in uh data set information. So uh what I'm going to do is I'm going to have to do a pip install here. So we'll make a new requirements.txt. I don't use um hugging face that often, but I know enough that I think for memory that I can probably write the import statement. So it's probably like from data sets import load uh data set and then like let's say we call data set load data set and then it's something like this. Let me go look up what it is. Um, so I'm looking up for specifically for this project. Okay, I found it. And so it is the attic US project cuad um trust remote code equals true. Okay. And so even if that's not right, we will adjust it here in just a moment. So we'll just say print the data here and we'll see if that at least works. So, I'm going to go ahead and cd into our confidence calibration and we'll say pip install-r requirements txt and we will let that run here for just a moment and get that installed. Okay. And once that's installed, which it is, let's see if we can run it. So, I'm going to do python main.py. Hopefully, that just works. That'd be really nice if it just works. And so, it's not loading the data set. So, what I'm going to do Oh, it's data set. Uh, that's pretty good for my memory, eh? And did you mean load data set? I'm I'm certain that that's what I wrote. Did I not save that file? Let's try that again. Uh, we'll try this again. Load data set. Oh, up here. Load data set. Okay. And we'll run it again. And so it's pulling data. It's going to put it right there in the folder. I can't remember where this places the data. Has to put it somewhere, right? And so now the data is pulled. Um we do have a bit of an error. So I'm not really sure, but the first thing we want to do is just pull some data. So I'm going to go ahead and we're going to type in claude. I'm going to make sure that I'm on sonnet here. Say model sonnet. And I'm going to just go front here and say debug. And we'll go ahead and do that. Be back in just a moment. So it's saying uh download that doesn't it match the expected size five 11 samples found of this. So add verification mode with no checks and reddownload it here. I don't need a a large set. So to me like I just want a little amount of records but we'll take a look here. I'm not like amazing at data so I can't say for certain. But we'll go ahead here and just uh clear out. Oops. I'm just making sure I'm copying that there. Whoops. Come on. Let me out. We'll go ahead and Oh my goodness. I have uh tabs opening other places that are that I'm not expecting. Um so, oh there and now I have um Claude talking to me off screen even though I didn't trigger it. But let's go ahead and Can I copy this line? Please let me copy. Okay. And then we will go ahead and clear that. I'll type in clear and we will try this again. So I'm just trying to get that data set to print out here. And so we have 511 rows. Okay, great. Um, so the next thing I want to do is I want to bring it over some boilerplate code. Um, and we've learned with the hello world that it actually always has the imports missing, which is kind of frustrating. So I'm going to I mean, even though uh we don't have it, I'm going to have to grab it anyway here. I really should just update the original one, which I never do. So I'm just trying to find any single one that has it. The import statements. Mhm. Uh yeah. So I'm going to just place this here. And I'm not sure why lib directory. We don't actually need a lib directory. I think I just kind of bring that over for no reason. SDK parser. We don't need that. Um, and so I'll go back over to here, grab this. Paste that in. And I already have that. And so I'll let it fix it. At least it knows what I want to load, right? Um, and so we'll go here. We kind of want to describe what it is that we're doing. I'm going to make this a read me just so my life's a little bit easier. say plan. Um I have a data set from hugging face called qad. What I want to do is show we'll just take a look here and see what they're describing here. Um how to make my data more accurate. Um so instead of an aggregate accuracy metric overall ma overall metric um I want to uh show specific breakdowns eg document types or fields um strafield right uh strategic uh stratified random sampling field level confidence scores. Okay. And so that should be enough uh for this. Okay. And I'm going to go back over to here. We'll reference the plan and we'll say, you know, can you uh create a um agent that will allow for human review uh workflow and solve for the accuracy uh issues I have. I don't know what to do with the data. So, you know, make a use case and explore the data. So, we'll go ahead and do that. And so, maybe that'll get us started, right? Of course, if we knew exactly what we're working with, this would be easier. Um, but we're just learning this for certification. And, you know, if I was doing this for real, again, I'll probably make this a separate course in my from zero stuff with a real uh real use case. But, we will hang out here and see what happens. Okay. All right. Let's take a look here. So, let me explore. Now, I have a clear picture. Building a for file system data explorer extract agent accuracy tracker field human review workflow law firm contract intake pipeline AI extracts 41 clause types uh routes low confidence items attorney reviews tracks accuracy by clause types again I'm not a domain expert on this I did work with you know uh law firms and stuff like that but my mind's not in there and usually you need to have that domain expert with you to navigate this stuff but we will pull it anyway and we'll see what we can get out of this. Obviously, it's going to do a lot of work. Um, and it's setting up a lot of stuff, but we will just see if we have something to play with. And really just comes down to visualizing, seeing those metrics, right? Um, and oh, yeah, it's going quick. Let's let it edit. Be back here in just a moment. All right, let's take a look here. So, what do we have? Use case law firm contract in intake pipeline. Contracts come in clawed extracts 30 key clauses routed by confidence attorney only touch when reviews. uh accuracy tracked by fields and documents. We have agent review accuracy main. So claude haiku extracts clause fields. Interact CLI confirms edits defers each flag extraction. I'm not sure if we need that right off the bat, but we'll see. Tracks accuracy per field per document shows calibration gap orchestrator with two commands explore and run. So key accuracy improvements, uh, field breakdown, calibration gap, stratisfied sampling, and I mean, I've already ran this, so I don't think they've added anything additional, but let's take a look. Oh, there is a few things like we have rich. I'm not sure what rich is. So, we will make sure we run this. The other ones are pretty clear. Um, but we'll go ahead and do that. I want to explore the code so I can understand what is going on here. I don't know if they made a read me for this. They did not. We'll go here and just add a readme. And I'm going to go ahead and paste this in here. And we will This is a little bit messed up. Little bit messed up. Um, oh, I think I have word wrap on. That's my problem. There we go. No problems now. And I want to just take a look and see what we have. Okay. Just because it says how to run it doesn't mean I uh doesn't mean I agree with it. So here we have our load data set. We're using I think anthropic directly. It must be over here in the agent. Yeah, it gets loaded into here. So here it loads the file systems and then we are getting the records or splitting them open in terms of their content. We are matching fields. I'm not sure what GT stands for, but I guess it's extracting information out of it. Um, we're matching fields. We have stratified sampling. So sample end documents ensuring each clause type is represented. Okay. Um we are exploring which is whatever. So oh the explore run commands. Okay I see. Um and then we have axi tracker and review session and then we have a bunch of arguments. If we go over to our agent here we're using haiku. We have auto approve threshold or human review. And here are the clause types. Hopefully extract them out correctly. We are representing these data structures. It's not paidantic, but it is some kind of data structures. Um, and so we have the extraction information. I'm just seeing if there's like any bad extraction method. So it says extract content fields, contract fields. So this is the prompt. Okay, it's saying like okay, how and what format. See here, paidantic would be very pro uh probably very useful and enforcing tool use might be very useful. Here it's creating the the client. And so here we have the field extraction which is happening over here. And then we have the contract analysis over here. Let's take a look at accuracy. So this is obviously checking for the accuracy of the documents. Okay. Yep. Okay. Pretty clear. So there's a lot going on here, but I mean I don't think it's it's that hard. And then this is the review. So this probably just generates the review. So let's go ahead and run it. Data set stats. Okay. So I just want to type in clear here and we'll run it. see what we get. Um, and right off the bat, we have a problem. So, go ahead and we'll say debug and we'll be back here in just a moment. Okay. So, remove the trust remote code. This is a standard Parket data set, so no script loading needed. Okay. Fix the data structure mismatch. Um, and we will just get out of here. And then we'll run this here. Uh, where's it? And we'll give it a second. And we have a new problem. And again, I'm just going to keep uh hitting it here. Can you ensure that the uh script starts or that the script starts up without errors? And if it does resolve them dg uh python mainfire uh we'll go over to here explore. Okay. Uh because it's just getting annoying here constantly having to check it. Um and so I'm hoping it feedback it has a feedback loop and corrects it. I don't know if that hugging face interactive will mess it up or it might just not be able to do it. And so it is encountering some issues here. So it has the correct structure, but I'll update the load on the data set. So here it's changing where the data set's loading. So one has a flat parquet data set. The other one is a flat data set, one per QA result. So literally it's changing where the data set's coming from. All the answer fields in the data set is answer start instead of nested set. So it's just trying I guess a different format in nest uh set. I mean I like parkquet files, but you know if it's having a hard time, let it switch it over here as this is not a very serious project. Um the question field is already the cause type name directory. Okay, directly. So here again it's just working through that data set. Now it runs cleanly. Let's go ahead and run it. Maybe because I didn't put explorer. I don't think that's the reason why. And so uh what do we have? Um we have sample document titles. So, I was kind of expecting to go through a review process with this. Let's go back and take a look at what it says. So, uh, a law firm receives commercial contracts for intake review before an attorney reads each contract. This system extracts 30 key clause types and we have 80%. Is there anything being outputed here? No. Actually, extract per field. Satisfied samples ensure the information. Uh, so explore the CUDA data set structure. Oh, this is just the structure of the data. Oh, I see. So here it's saying the clause type, the documents, and the coverage, and how much of each thing is in here. And then down below we have the sample document titles down below. Okay, so this isn't actually doing anything. This is just us reviewing it. So we'll go here. So we run the review with with human review. And then we have one with uh no interactive review, which is cool. So we'll go ahead and do this. I like this. This is nice. And we'll give it a moment. Wow, that looks good. I like this. This is absolutely impressive. Okay, so contract selected. It's extracting the first one. And so here we have the first one. Confidential information shall remain the sole company um IP ownership assignment. So the extract states the information remains company property but does not explicitly address work product IP. This is cool. So we have confirmed or what does edit let us do? I don't know. 73%. There we go. Um, wow. I like that. That is nice. Now, does it make clear those percentages and everything? Probably not, but I mean, like, you conceptually understand what it's doing, right? Um, and how that is a value. So, I don't think we need to see any more. I think this is quite the impressive um demo. I mean, I'm not saying it's accurate, but I'm just saying like uh the plumbing and how it works is really really good. Um, and so I'm I'm very happy with this and I would say that we have uh, you know, completed what we wanted to complete here. Okay. Hey, this is Andrew and we are now taking a look at uh, preserving information uh, when handling uncertainty in multiple source synthesis. So um, we actually did do some synthesis with our Doom uh, our Doom Explorer. So if you remember over here we have uh more than one agent. We have a a synthesizer, right? And what was a synthesizer doing? They were going into our findings, taking these items and then creating a synthesis of information. Um if we go all the way down here, we have sources of information that are specifically providing it. So I'm not sure if we've already kind of solved this. I mean, if we had something that goes out to the internet and synthesizes information, that could be a different story. Um, so let's go back here. So, how source attribute is lost during summarization steps when findings are compressed without preservation of claim source mappings. I mean, it looks like it's right here, right? Um, the importance of structured claim source mappings that this agent must preserve and emerge when combining findings. How to handle conflicting statistics from credible sources. Uh, annotating conflicts with source attributions. So here we do have conflicts uh or contradictions and dedupions but it's not necessarily saying exactly where it is I mean kind of is um but you know is is this a good data source where we're exploring a codebase or is it more for going to external information so we have how to handle conflict statistics for credible sources um requiring sub agents to output structured claim source mappings um let's just see here so compiling document analysis with conflicting values requiring sub agents to include publications or dates. So, I guess really this one might be better if we go out to the internet and get multiple sources. We do have in here our uh agent that goes out and finds information if you remember. Um, which I'm trying to remember which one it is. It is, let me find it. One second. So, we do have this one where we have findings and then it returns back findings with information and confidence score and source and tags and information. Um so I mean there is this right and I suppose we could adopt it where we have stuff where it gathers uh findings and then it synthesizes it and then it produces a result where here it's just collecting um the results of sources in a single location. Um whereas each artifact I mean like in the sense this is artifacts right? So you could think of this as um uh little sections here right? So, I'm just wondering if there's a way that we can adopt this. So, I'm going to go ahead and I'm going to make a new folder and we'll just say uh findings uh findings with synthesizing with findings with uh synthesis synthesis. Is that how we spell it? Um I got to go grab the word. I'm so bad at spelling. I'm so sorry, folks. And so we'll go ahead and paste this in here like this. And we will go and grab this file here. And I'm going to go to this one. And we'll make a new main.py. Well, that's not the contents. That's not the contents. And we'll grab this one. I'll paste it in here. So I'm going to go and make a new plan. And I'm going to go grab uh the contents from the exam guide. So here how source is lost during summarization the importance of structured claim mappings that the synthesis bus how to handle the conflicting. So um I'm going to go here and just say findings improved. Uh so we want to change our agent uh that uh that goes and uh to agent to have a explorer and um synthesis agent reference. You can use the Doom Explore project as a way to uh bootstrap or to take inspiration for Explorer and synthesis agent. But for the use case of our current project, uh we want to change our agent to have a uh what does our project do? uh our our agent goes out to the internet and tries to find similar uh movies. Okay. So uh so you know right now right now it collects sources in a results JSON file. I wonder if we should take a findings approach with scratchpads. and synthesize uh I want to be able to ask questions um to help drive a final solution. Okay, because I kind of like um our Doom Explorer but maybe apply it for data. So, you know, instead of exploring code bases, you're exploring movie contents, right? And so uh we can do that which is I'm going to go get the full path for this. So we have this um which is found at say Doom Explorer. These are the goals or concepts we are trying to learn um or to achieve for synthesis. Okay. Oh, give me this word here. Okay. So, now we have some kind of plan. Um, and I'm going to just CD back here and we'll go into our findings with synthes synthesis. What's really nice is that we build up this large codebase, right? And so we can keep pulling and we don't have to do as much work, which is really, really nice. Though I do feel that um, you know, if I wasn't in a hurry and I was just I would have probably used that refactored codebase a lot more as I really do like it. But you know, just trying to get this out as quick as possible for you folks um, is always the trick. But we'll go ahead here and open up Claude. And I'm going to go ahead and say uh you know, can you create a spec uh MD um to execute out our plan? And probably we should be using um Opus, but I just ran out of my credits and it just refreshed and I just want to make sure that I'm able to do this here. So I think it'll be okay. Um and so I'm just going to pause here and just accept whatever it needs to get this done. Okay. All right. So let's take a look here. Uh so we have spec a movie explorer movie. I mean they could just have generic names that's fine. Deposit structured scrap patch to findings read only to findings. Uh conflicts uh retain table temporal notes section coordinator in main phase all the province goals for the plan baked into the Asian contracts task breakdown. So we will go over to our we'll give this refresh here. Our spec. We don't need spec driven development. is mixed specs here of all the current single agent film research script into a two agent system. Uh the three senses goal is to have providence preservation conflict annotation temporary metadata. Um receives the research uh question uh question and similarly access dispatches movie explorer. Um and we have that information state files. Sure. Um scratch pads. Cool. We have question findings conflicts. Open follow-ups topics source consulted synthesis claim map conflicts retained temporal notes manifest schema. So the thing that runs it all sub subcontract sub aent contracts um coordinator phase for each similarity access do this file layout task breakdown. So you have scaffold, directories, author, movie agent, Ruby Pi, U, resume flow, acceptance criteria. Okay, so I'm not sure where the sources are going to be here, but we will just go let it build it and we will find out. So going to go ahead and type in clear. We'll start on over. We'll say uh implement the spec.md. Be back here in just a moment. All right. So, it looks like it has implemented it. We'll go and scroll up here. And we have 21, two, three, two, four, two. Let's go explore the codebase. I mean, we have a general idea how it works because we did it before. So we go into our main scroll all the way to the top and we got finding sources research state setting tasks our sub agents researches a specific similarity angle for films related to uh to schools in the crossard. I mean those are hardcoded right a scratchpad findings read finding scratch pads and produce a structure synthesis the only problem is like those are hardcoded that's not a good idea but they are using haiku so that's fine um and I mean like for synthesis we might want to use something a little bit smarter than haiku it worked fine in uh the other case it was totally fine um you're a film research orator from the late 1970s 80s these um find. So, it's already kind of set up here and it has the explore, evaluate, fill gaps, synthesize stages. Okay, it's a little bit different. This is interesting. Um so, literally it's telling to go through the phases and then evaluate them with the coverage score and then to fill the gaps and then synthesize the information. you never hold raw data for research text only task ID scratch pads and stuff like that if your findings directory it's just it's just strange to like have another way and then mash them up and go okay do they even work together or should it be one or the other I don't know and I don't think anyone can answer that we'll go over to our coordinator so we already had this from before so it's basically the same thing um let's go look at our agents why does it why do we have this and then those. What's the point of both? We go back to our main here. Oh, it loads it into here. And oh, these are the descriptions to trigger it, right? Okay. Okay. So, that's what they're doing. Though, if it's on the file system, I feel like it shouldn't need to load it from agents, but because it's over here as well, right? So, why is it doing that? Um you know I notice I noticed you are using agents uh file system but also uh agent definitions uh and so the agent definitions overrides the um front matter from the agents directory. Shouldn't Shouldn't we just just use the um agents file system? So that's one one unusual thing that I saw. Again, we're using Sonnet. So I think if we did Opus, it might resolve it or it might waste a lot of our time. So we'll see what it thinks here. But to me, that's a little bit strange. And you know with with the um obviously with agent definition you can uh dynamically load them. I don't care about that though. Okay. Yeah. And it's putting the agents in like that. There we go. That makes a lot more sense. So that was the only thing that I think that was questionable to me. I still don't know if our phases make sense. So I'm going to go over here and just ask um Opus, what do you think of our phases? Does it make sense uh with the way our um synthesis and explorer works? Uh not asking you to change code but just give me perspective. Okay. And so we switch to opus just because it's way more we're not on opus. Oh, okay. So just I because I typed in while we're doing opus there. That's why I could have also just said make a plan, but I think this would automatically go into plan mode. Um and so we will see what it thinks. I'm trying to avoid to use opus. It burns up my credits like crazy. And I didn't notice this, but I think we mentioned it where we had results JSON, and we have a bit of a conflict there. So phase four and three, the synthesizer is only a thing that reads scratch pads. Uh, what feels awkward is phase two. So we have that. There's no phase where the sensor says, I found conflicts I can't resolve. Please explore access. So the pure version would drop the results JSON. So I'd say yeah like I mean let's drop results JSON because Scratchpad synthesis is our way to go. Okay. So we'll go ahead and do that. I know we're running Opus but I really needed to be intelligent here for those prompts. So now um it's back here. So record findings. uh paid model schema now lives in the explore agent research state findings now holds the task ID scratch pads and synthesis or whatever and so I would expect that um our main coordinate well our main uh prompt here would be less gross and yeah it looks a lot better so um let's go ahead and execute it I'm not sure if we can even enter a prompt into it but we'll go ahead and just say main I guess before we drove it from here, right? So, but it is a main.py, right? So, we'll just do I guess that's the other weird part is the other one was like it was driven by the um cloud code, which we could have coded it that way, but that's not how this one is. So, this really is hardcoded for a school in the crosshairs. It's not like I can ask it more questions, but we'll see what it collects out and we'll decide whether we even want to tweak it. And by the way, again, over here, I'm actually uh fixing these things. Something that AI cannot do is work with very um messy people talking to each other, background noise, all that kind of stuff. I would try to do this if I could. I'd have to probably build a custom model for this, but I do not have a computer science degree in data science and stuff like that. So, um like building machine learning models, so I'm not going to be able to do it, but we will wait for this to complete. Okay. Okay. So, here we have some stuff coming through. So, it's scoring it and it's expanding and talking about the gaps and retrieve information. I'm curious to see if it's writing to any of the findings yet. Um here. Nothing yet. It seems like it's going to waterfall and then write to it. So, we'll have to hang out and wait. It is still going here. Um but one nice thing is that it's doing the synthesizing. But now we have our artifacts. I'm just curious what we have as our artifacts. So, uh with Japanese supernatural psychic school films, we have this. And here we have examples. virus, haunted school, occult, and we have confidence claim tags not identified. The research represents documented Japanese films, the Japanese supernatural psychic school cinema. And then we go over to here. What international teen psychic telekinetic films of this? So we have content, confidence, type tags. Does it really work for this? I guess maybe, but like I'm not seeing any sourced information. So like none of these fragments are showing any source information. So how is it going to meet the requirements? So we'll wait for it to finish and then we will ask unless it's saying how it sorts the uh findings and not necessarily the external external information. So synthesis is complete and we're going to go back over to here. Take a take a look here. I thought it' be generated out. Let me write it to the synthesized file. Okay, so it's writing it right now. We'll give it a second. So the research is complete. Um, and so here we have the full synthesis. Let's go take a look here uh at the synthesis. It's the same document. We'll go here. Topic source consulted findings. Um, okay. And so we have stuff here, but like it's I call this junk. Like I don't really like it. Like we do have sources here, but it didn't preserve the original source. So I feel like this failed. And we'll go back to Claude here. you know, uh, we have the results of the, um, findings, but the goal was to preserve Providence, and I don't feel we did because we don't have the original sources. Can you please fix our agent? Okay. Um, and you can see I'm already at 72%. I barely did. Oh, it's on extra high. Those buggers. Those buggers. They're doing that to me all the time. I hate that. So, I got to go here. I got to change um effort to medium because I'm going to end up using up all my my credits. That's why I'm at 72%. I've barely done anything and I'm already 72%. I really dislike that when you switch it over that it defaults to that. They shouldn't do that. So 70% and the next time will be April 23rd 5:00 pm. Um so what's today date? Today literally I won't get access for multiple days. Absolutely disgusting. I'm not happy with you anthropic. But that's their trick, right? So they get you to try to use the high reasoning models. It eats through your credits things and they want you to buy the tokens. Luckily I'm subscribed to like three to uh two other providers and the open source ones. But to finish this course, I'm going to need the credits to do so. has no web search filters. Is hallucinating the film. Oh, it's hallucinating. Wow. Um, but we did build a basset. So, let me check the spec to stay consistent. Uhhuh. Well, I don't understand. The original one had tools. Are you saying the original one never used tools? Because I'm almost certain that it did. Now, I'm kind of wondering, did this one never actually work properly? Oh my goodness. It never used tools. But then how did it source information? Oh my goodness. Wow. Wow. That is that is [laughter] interesting. People, if you missed that, you're gonna find out later on. You be like, "Wow, Andrew, that I mean that makes a whole lot of sense like why I wasn't really happy with the data. and it kept sourcing very specific ones, but before it seemed like it worked. I mean, we had more than findings. It must have had that at some point though. Wow. Enough credits to run this stuff, though. We'll see. That's crazy. See how easy it is to miss stuff? Go here. And now we have that. So, we got to run it again. Well, before we do, I'm just going to clear out the old stuff and we will delete this. Delete permanently and we'll run it again. But I'm out of credits. That's where we're going to end here. Okay, folks. Assuming I can even get through this run. But it's using Haiku, so it should be easy. But it also maybe it's just doing a lot of stuff and that's why it's kind of uh running into that problem. But we'll see what happens. Okay. Actually, it says my usage is here. So, I should be fine. It should be able to do it. I'm not sure why it gave me that uh crazy warning, but we will continue on here. Seems to be hanging here. I haven't seen it moved whatsoever. So, I'm going to kill it. And we're going to go ahead and say clawed. And it just uh we'll move it back to sonnet here. It just seems to hang at this step. Okay. So, I'm going to go ahead and ask it because I'm literally waiting here. It's doing nothing. All right. this thing is really really struggling. So, I'm going to go ahead here and I just think that the um coordination is just a little bit messed here. And I'm going to go say um you know I think my um prompt for my phases is too overengineered. uh since we are mixing uh two methods together can we uh simplify the process okay and we'll see what it comes back so here it's talking about duplication for these things already defined the coordinator prompt should just uh have the stop state highle sequences I'll simplify it to 15 lines so hopefully sonnet is doing a better job but I mean it does feel a little bit overengineered and there does seem like there could be conflicts between the two. Um, and so we'll go over here and just take a look. And so, um, did it change it or is it asking to change it? Yes. Okay. Because I was going to say that didn't look like it was changed. So, here we have a reduction. And so, yeah, those phases are really compiled down. And so, this will maybe give us a better uh chance of better execution. So, we'll go ahead and try this. Hopefully, it'll be faster and won't hang. We'll see what happens here. Okay. Again, it feels like it's hanging here and not moving. So, I'm going to go ahead and just go here. You know, it feels like the um agent is hanging here. Can we get better logging, right, to see what is going on? I'm going to add this to debug mode. This is driving me crazy. It just um and again maybe it just takes time but free access call Alec Mark then dispatch movie explorer with return task ID that's phase one. Another thing is that maybe we instead of having it launch all those we could just provide it a single access to research and we don't need to do them all in parallel right um here it says now I understand the issue clearly let me see the SDK sure if you think that you understand the problem clearly that'd be nice uh the coordinator receives loop prints only and all other events okay so here we have the new line process Yes. Mhm. Okay. Our running web search is so it looks frozen. Okay. So it is working. Okay. So, again, it just be nice because I'm just sitting here and I cannot tell. All right. So, we'll go ahead here and we will try again. And I'm expecting to see something. There we go. Okay. So now we can see that it's exploring. Now I'm dispatching the movie explorer agents for each pixel parallel. There we go. And now it's doing the web searches. Excellent. See, this would be things that we absolutely want to log. And then we could feed the logs back and say, hey, did it do a good search? We'll now pause and I'll just let it go and do what it wants to do. It did stop. Oh, is it done? Uh oh, we ran out of 50,000 tokens inputs per second. You can see the header. So here it's just doing too much rate limit. Okay, so let's go back here. Look, c can we just explore one axis at a time. This has been painful. I'm so sorry this is taking forever. I'll change it to explore one explore at a time. But I mean like yeah but no but only explore a single axis. Okay. Because we just are testing Providence, right? Because this is overkill. I I can't I can't keep waiting here for a thousand years. Yeah. I mean I I could have done that too, I suppose, but we'll go ahead. Yeah, I just kind of simplified it to one. So say yes. We'll try this again and we'll have less of a problem. But you know, obviously it was going like crazy here. Hopefully this does not uh hit our max token requests. And here you can see it's going. So I'm thinking we're running to less problems here. And here it is still searching. So it hasn't aired out, but it's still going. It's still going. Taking a considerable amount of time, but you know, we'll wait till it's done. All right. Synthesis is complete. scratch pads are written to. Um, let's see how much it collected. It seems like it collected a lot. And we go refresh this. Uhhuh. It didn't write in the files. Oh my goodness. Oh my goodness. It didn't write anything. What? Oh, because I hit max usage. Oh my goodness. Look, this is this is stressing me out. Okay, the agent is too exhaustive, right? And if it fails, it doesn't write to scratchpad. Okay. So, it has to not be so exhaustive in a search. And if it fails due to token rates, we need to pick up where we left off, which tech technically the manifest should allow us to do that, but I'm not really sure if it will actually do that. And none of these things are here. Right. So, I don't know. We'll give it a second. I mean, technically, it's supposed to pick up where it last left off, but like we haven't really had to do that. So, it says before writing anything hits rate limits before saving. No incremental writes to scratch pad. Resume logic existing coordinator, but doesn't wire to the resume form. I'll fix these things. Oh, yeah. Yeah. You think you say you're going to help me here, but you haven't been so far. Okay. I need to reset the manifest file please. So we do a clean run. Okay, once that's done. All right. And I'm g just make sure this manifest file is cleared out. Great. Let's run it again. Please just give me findings. Give me findings. I don't care if it even works well. I just want to see anything. Um, but yeah, mixing them together maybe not a great idea. They just the phases and this this stuff is just not a good mash. Uh, and so I was hoping that it would work, but I think I'd have to spend more time thinking about it. And I'm obviously not doing that. That's kind of part of the problem. But at least we should be able to get findings sooner. I'm still not seeing findings in here, but we'll just have to hang out and see. All right, so it says it's done. We'll give it a refresh here. We'll take a look. We now have uh a single finding. So I guess it only did one which is though I guess the finding I would have thought they would done a scratch pad for each of the things that it searched out for results but I guess not. Um so it's not exactly what I wanted. Uh does it have sources? It does and it's following kind of our original source pattern which is fine. And it's only doing synthesis from a single one. So it's not really a good example. And we refresh this. We don't even have synthesis. So, I think you know what we wanted to accomplish for this. The idea is that we're cross referencing multiple sources and ingesting them to a single location. Um, but I'm obviously not having success here and I'm tired and it's the last video, so whatever. Okay, [laughter] but hey, at least we tried. Okay, see you in the next one. Chowo chia. Hey, this is Andrew. In this video, we want to take a look at um multi- instance and multipass review architectures. So, that's the section here. But really, they're just saying is like um if you have a model or an agent and um it implements something, let's say it generates a code or a document, whatever, and then you ask it to review it, because it already has that history prior, it's going to take bias to its work and think that it's done a really really good job. And so what it's saying is that what you should do is you should have an independent agent or model or step that's going to review it so that doesn't have that context or that memory where it has um biased. I think its work is really really good. So, what we're going to do is go ahead and make a new um a new folder here. And this will be um uh create and review or this will be like independent in uh peer-reviewed be say peer-reviewed peer reviewed agent or peer-reviewed um example. Okay? Because that's really what it is. You're having a peer so somebody else that's smart another agent uh review your stuff or model if you will. So, we'll say main.py. And to just help anchor it to so it does a good reference here, we'll go ahead and grab uh this stuff here. And we will paste it in. Okay. And so now what we want to do is cd back here. And we're going to go ahead and type in claude. And so I want to uh show an example where um a model reasoning has bias to be correct when it's multi-turn and they have previous context. And so we want to show a case where uh one agent is creating and then valid uh then validating its own work. And another case where we have a completely separate uh agent or just or or just just empty context or just new context. Can we use can we use Japanese language learning? Let's say generating out practice exam uh vocab uh v uh practice vocab questions for the JPTn5 as I'm studying for that. So that's a fun use case for me and we'll see if it can make sense of what I'm trying to ask for it to do. But here it says multipass review but like think of as like peer reviewed by another agent or just again uh completely from scratch here. We'll give it a second. All right, let's take a look at what we have. Okay. And so, um, is it using the it's just it's not using the agents SDK, which is fine. I mean, like I think it'd be a little bit easier to read if it was, but here we have generation prop. So, generate five JPT vocabulary practice questions and multiple choice factor. Um, each question tests one vocabulary word. Uh, returns only a JSON array in this exact format. So, this is what we're expecting. U review prompts. So, review these JPT vocabulary questions critically check each for accuracy. And so, we have these separated out. Um, I think it'd be really hard to show bias in its reasoning. So, I'm not sure if it's really worth trying to do that, but let's see if it actually do it. So, here it says self-review base. Continue the same conversation. The model has full context of having generated these questions. It's anchored to its own reasoning, prior choices. this might not be the strongest use case for it because I feel like um it's not as as subjective or if it I guess the other thing is like if it made a wrong mistake would it actually know and might it double down on it? Um so that actually is what we're really talking about. So it might still do that but um I used to try to make these and I would just get terrible terrible results and I would have to have a second or third step to validate it with um a lot of um example information so that it could reference it. But let's take a look here. So we will go and just run this main python. Oops. Python.main. Sorry. Python.main. Let's see what we get. And I think the reason it's not working is that it stripped out. I don't know it does that, but it stripped out the code here. I don't It didn't have to switch over to this. And even if we tell it to use um agents SDK, it doesn't know what it is half the time. I'm going to go look for our um anthropic SDK test because up here we have uh this here that we can just um drop into here. Yeah, peer review. That's the one we want. So go ahead and just replace that like that. Uh we still need JSON maybe. And I'm going to go back over to this one. Grab this line. I really just like that does constants like that. And we will search for client. And I'm just looking for that client. Uhhuh. Oh, here it is. Okay. So, just replace that. So, now here we go. This should work. We'll go ahead and hit up. Um I don't know. Geez, let's uh let's fix this here. I don't feel like fiddling with it. So, we'll go back into it here and I'll just say debug. Go ahead and paste that in. We'll have it fix the code here. All right. Okay. So, that should resolve the issue. Fix the import line. So, that's all I had to do. It took a lot of time to do that. And so, here we have self versus pier. I expect um self to do totally fine, but we'll take a look and see what we get. Oh, the first one could not parse the JSON for preview. Continue with raw output. Wow, that's not good. Um, so we'll go over to here and so okay, so we'll go here and look at self-review. So the model continues the conversation which it generated. It it carries full memory for its own reasoning. Um, and so here it's saying they're all correct, peer-reviewed, a brand new request with no prior messages. The model has no knowledge. And so here it is scoring based on accuracy. What's interesting is like we have this other one and it's not using well I guess it is, but it's just not visualizing it the same way. Okay. For any AI generated content that requires quality control, always use a separate context, right? And so here it's just saying for the validation steps never ask the generator to grade its own input in the same conversation. And so that's all it is suggesting here. But the question is like um you know is the results wrong and like it would take multiple generations and checking and stuff like that to figure it out. So um we can't say for certain. Um but anyway uh just be aware that this is what the approach you should take is that one generates one reviews. Okay. And they don't have the same context. Hey folks, this is Andrew. In this video, I want to um focus on uh what we can do in terms of if we run into issues. So like imagine we are using our structured uh JSON and it comes back uh with either syntax errors or there's just something absolutely wrong and we want to have a way for it to correct. Okay. And so I did say pyantic can validate data that comes in and out. Imagine we're not using pyantic or even if we are using pyantic and it's not a structural thing but there's another problem with it. We want to feed back that um uh information back into our loop and have it try to correct and maybe it has a certain amount of retries that it can back off to do. And this is really to address uh you know retry and uh retry and um I'm going to say remediate remediate as that's really what they should be calling this. This is in this section where they're saying, well, you know, we should um implement validation retry feedback loops for extraction quality, right? Um and so I'm going to go ahead here, say main.py, and I'm going to go over to our um our uh the one with our structure JSON output, wherever that is, structure JSON output. Here it is. Oops. Here it is. And we will grab this. That's good code. And we'll put it over here. We'll paste it in. I'm going to cd into the correct directory here and we'll type in claude. So we'll say for our main.py we want to uh demonstrate um that the loop can handle um validation and retry you know. So imagine uh you know the data that comes back uh it you know does not meet uh our requirements just let me think about this for a second. Okay. Okay. And so what I was just doing was trying to just read this carefully. And so here it just says appending specific validation errors back to the prompted retry. I'm just going to copy this line as that's pretty good. So it said imagine our data came back but um it has problems but it has validation problems. from our tool schema, right? We want to append specific validation errors to the prompt and retry retry uh that there. Okay, so we'll go ahead and hit enter. And so uh you know what we wanted to do is feed back into the loop uh make corrections um so that it can work on it. So really it's just saying, hey, I got this back as the problem and we're just going to refeed back it in. Shouldn't be too challenging. All right, let's see what it's changed. So here it says u validate triage. So run four business rule checks and return specific error strings. If the ticket does not match exactly this summary must be exactly this. On failure the tool result is returned and is error true pinpointed to the error. Um it'll continue the loop with no breaks. Let's take a look and see if it's actually implementing the loop as we expect. Okay. So our loop is here. It's going to create a message. you are a support triage engine uh analyze the incoming tickets that are coming in here. And so we are appending um the response. So as it goes, it's appending it. If it ends, it ends the turn. We have tool use. And so within here, we have tool use and we have validate triage. It's going to return errors. If there are any errors, it needs to validate them all. So validation failed. Fix all the issues. So, it's giving the text as to what it needs to do and then it's appending that information so that it knows like, hey, look, these are the validations errors we have and you need to go fix these. Um, and then the loop is going to continue on. That's going to be fed back into it. It's going to know that information and then go fix them. And if it's not, it'll say that it's passed and continue on. So, that is what it's doing. Down below here, we do have max attempts. So, it can try and it will quit out if it um meets those. We'll go up to here and to just take a look here at the validate triage. So here it's validating on the uh way out. Um I kind of wonder if instructor or pideantic can take care of some or uh more of that, but that will definitely help quite a bit. Let's go ahead and go all the way at the bottom here and we will go ahead and run this. So we'll say Python Python main.py pie and we'll go ahead and see what we get as our results. So here is the raw ticket. We have a a validation uh failure and then it goes and it triages it. It corrects the information. Um let's see here. So validation failed and then it attempt attempt a second call here. And so then we have our correction and then it goes on to the next one. Let me just double check this. Make sure this makes sense. So we have attempt while calling submit triage. So submits the triage and then validation failed on attempt one. Tags must use snake case. Oh, and then it's calling a second time and now it passed and now it's outputting. Okay, great. So there we go. We implemented the loop. So is there any other questions that we need to kind of address? And no, let's take a look here. So we have provide a retry error feedback loop. We did that. Limit the amount of retries. These are infected when the required information is simply absent from the source document. Okay. Um and so you know we do obviously have down here the amount of retries that can come here. But you there could also be a thing that says like hey should we even bother retrying this? So you could go and reprompt this and say hey make a use case where if you um if you find that it just really it's never going to meet the requirements and you should quit out. That might be another thing here. Feedback loop tracking when code constructs triggers findings to enable systematic analysis of dis dismissal patterns. I don't know what they're trying to say there. Difference between semantic validation errors and schema syntax errors. Um I mean eliminated by tool use or values don't sum or wrong field. So this one validation errors is like the the quality of the data that's coming through it. Right? So like um you know cement errors is like does it meet the JSON requirements and validation errors is like is the data actually correct? I don't think again we need to really show that. I think that's pretty darn clear. The key things is here is feeding things back in the loop, setting retries, and obviously um we could add a little bit more if we want to, but I think other tools like instructor might take care of some of this. Uh we'd have to double check, but again, it's not an exam guide, so we're not really building for real use case here, so I'm going to leave that off the table. Okay, let's talk about some large context problems. And this is things that are going to occur when your context gets too large, like you have too much information you're passing through the model. So the first one is progressive summarization risks. So when an AI is asked to condense information over multiple steps, uh there's going to be information in there that's very important like dates, percentages, numbers, or even key information. Um the problem is is that as you summarize that information, it doesn't know that that's important information, and it's going to literally uh make it generic. Um and you're going to lose that information. So the solution is to extract that information out, store it somewhere, uh, and then always inject it back into the next prompt or or to the context, the exact information so it knows what is the most important information and we're not losing that out. Um, we have lost in the middle effect. So if you have uh if you give a model a lot of data, like let's say 50 pages of data, what it's going to do is it's going to look at the first few pages and the last and it's going to miss the middle information. And this is just how the model works. So it's just what it's going to do. So what you can do is break up your um data and have it process in sections or if the most important information uh you know uh is going to be read only at the start and the beginning then move that information there but really you should process in sections it will be the solution. Um if you call external tools or APIs they often return back data usually JSON but you might not need all that JSON data. maybe just need the order number or key information. And you don't need to use LLMs to uh filter that data out, but you can make an additional step uh to a smaller agent or model to do that to reduce the amount of information. But you're not going to want to pass back the entire API request. A good example might be using something like um uh Tvago where I've used the MCP and it gets you the best uh deals on flights and stuff, but it returns a lot of information. You're not going to want to ingest all that. you're going to want to only get what you need and pass that to the model. The last one, and this is just for you, like this is something that gets taken care of of you in general if you've ever used cloud code or any other tools or if you've ever used um like chatbt um and you'll notice that you can have a conversation that goes on forever. Well, what's happening uh behind the scenes is that they're summarizing the information. So, the thing is is that for an agent to know how to do stuff, it needs the whole conversation history. And each time you prompt it, you're feeding back in the last thing that you said and all the things you said. But at some point, you're going to run out of memory. And so you have to summarize parts of it or or the entire conversation. And so these are our large context problems. Uh and those are our solutions. Okay. Hey, this is Andrew. In this video, I want us to um tackle some of these large context problems. I think the ones that make the most sense are um I mean chunking chunking sections seems pretty easy so I don't think we need to do that but I think the ones that uh will be valuable will be extracting key information out and also pairing down JSON calls. So what I'm going to do is I'm going to go grab our hello world example as we continuously do and I'm going to make a new folder here called large context problems. I don't want all those uh those those letters there. That's a minor mistake there. But we'll make a new folder here saying large context problems. And we'll go ahead and say main.py. I just realized this entire time I could have been writing out the prompts. I don't know why I didn't do that. Just make a prompts file so you could uh replicate this as well. But I'm going to go cd into our large context problems. We're going to type in claude. And here I'm just going to say, you know, I want to demonstrate uh two things to solve uh large context problems. Okay. So the first the the first is um that uh key precise information. Key precision information should be extracted out, stored externally and brought back as case facts um for future future iterative prompts. Um and also uh we want to uh show tool use that returns that returns lots of JSON and we just filter out a little bit of information. So imagine imagine we have a text adventure game. Okay. So we don't need a whole Anyway, we'll go ahead and um ask to do that and we'll see if it knows what we're asking for. But the idea here is that I'm expecting it to store the information somewhere. Um it doesn't need the whole repo. So no, you don't just you don't need to read the repo for examples. Just please proceed code loves doing that. I hate when it does that. Um, so let it think. We'll be back here in just a moment. All right. For some reason, it decided to run it. Sometimes it does that. But here it says clearly states the two 45 characters filter down through the 203 uh cases. The demo works technique one. tech2 returns the etc information and shows that and that's fine but I would rather run this myself and find out I guess the reason it returns the results is because um we'd actually have to run it and see what happens so it says run it and then do this but let's just read it that's probably why it did it so tool output filtering so get state well first let's look at the code sorry I'm all over the place okay so here we have the world state that totally makes sense this is something that we'd absolutely want to keep track of and so we'll go down here and we have lots of irrelevant bulk data So that makes sense. Um I would think that we'd also want to filter some of this out, but maybe not. And so here it says return the full uh world state simulating uploaded API response. That's true. Um tool output filtering filter the massive world state down to only what's needed. So instead of injecting thousands of tokens, we'll inject 50 um 50 tokens of the fact. Here we have case fax. So load persistent uh persistent player facts from disk. So here it is doing that. Uh we have save case factax so persists information here. Okay. Extract the case fax data. So it's storing it somewhere. And if we go and find our problem here. Did it actually do that? No. But it's supposed to store it somewhere. I guess it's just storing it in memory. Build the system prompt. Okay. You are a narrator of a text adventure game. Here's the case fact. So it's providing this information each time. every time the loop current room. So this is the information that's filtered out. Respond to the player's actions. Okay. And then we have our text adventure. So large context demo. Mhm. World size state. And there we go. So we'll go down below here. We'll just play a little bit. See what happens. We might not be able to really um be able to see what's going on here. We'll try it anyway. So say north. Oh, and as per usual, it doesn't have the API key. So, that makes me think it didn't even work when they tested it. I really wish that this stupid thing would copy this here, but it never does. So, we will grab this here. Kind of getting used to pasting in here myself. What can you do, though? Um, and we'll grab this here. We'll load that and we'll go back over to here. Um, and we're looking for the key. So, it's a key. There it is. Grab that here. Like this. Go back to this one. We will find where that goes. Here it is. So now this should be able to work. Go back hit up. Okay. Um, did we forget to include that? The async. Bring that. Go back all the way here. Maybe I took it out by accident. Do this again. And I'm getting tired of this. So we'll go ahead and we'll let it fix the problem. I'll be back in just a moment. Okay. So, um let's see if it's resolved those issues. We'll say look around. Just a second here. So, you take a moment to look around. Um pick up Rusty Key. I like how it's showing us the facts as it goes through here. There we go. Look at old map. The map provides useful information, but you're still standing in the in the grand hall with Rusty Keys at your feet. So, there we go. So, it's working. Um, and I mean like it's obviously we're not exposing that information here, but let's again just go take a look here and make sure we clearly understand how it's doing this. So, here we have the world state and and basically for the room, we're going to get all the room data. So we say get world state from the tool and then we're just individually selecting that data and returning it back um to the model. Notice here we have our case factax. So this data is being stored somewhere I think in our oh it is a file now that we ran it we have it and so it's just extracting that information out of that file um and then loading into context every time. And so that solves those two problems. Obviously, we're not checking the one where we have a very large dock where we'd have to process it. If I feel like doing those videos, I might do them, but I don't think it's important. Um, but yeah, we will move on from here. Okay. Hey, this is Andrew and in this video we are going to figure out how to manage context effectively in large codebase exploration. This is the 5.4 section. And so the purpose of this section is that imagine you have a large codebase and uh you need to figure out how it works. Um but the problem is is that if you have a large codebase and it's ingesting a lot of information um the context is going to get muddled because as it increases more information as it goes, it forgets things on the tail end or when it summarizes it it loses key information. And so what we need is like an external memory. And so the idea is that as we crawl through information into the codebase um we can uh save that somewhere like let's say a findings.mmd file. Um and also the other thing is like we want to delegate out to sub agent because if we had our main agent running like just cloud code uh being the person that uh consumes all the information um as there's a lot of busy information that's going to eat up it the coordinator's context and it's not going to be able to coordinate effectively. So we need a sub agent that can handle the noise. We need a sub agent that will or at least the coordinator that will write to the findings file so that um when the context is working it can continuously reference that information. And let's say you know for whatever reason our computer shuts down or uh there's an error or something or we run out of credits and we want to pick up where we last left off. So we have crash recovery and that's what we want to do. So, I thought it would be fun if we explored a fun codebase like the Doom codebase. Anytime we can work in Doom, why not? So, I'm going to go over to here and I have not looked at the Doom codebase for some time here. I'm going to go ahead and grab it and I don't want to SSH it to be honest. I just want to let's see if we can figure this out. So, I'm going to make a new new folder here, and we're going to call this Doom Explorer. And in here, we'll say Doom Explorer. I'm going to open up Claude. I'm just going to switch it back to Sonnet. And I'm going to put the effort back to medium. Sorry. And so what I want to do here is I'm just going to ask it like I want to uh clone the uh Doom codebase in this folder. But I don't want uh it get tracked because I don't want to to have um a git a git repo and a git repo. Um, I also want you to ignore the contents. Can you can you create me a uh a a shell script that will pull the codebase into this folder without the perion uh the problems I want to avoid. Okay. So, it's going to go ahead and make that script and I'm going to run it and um yeah, it should be fun. Or at least it's fun for me. I I don't know if it's fun for you, but uh maybe you want real world use cases, you know. I I don't know, maybe this is a real world use case for you. And so we will get that little script going here. And it's already here. So that's going to pull it. And yeah, it just removes it. I mean, that's what I was going to do. So that's pretty darn simple. So we'll just chimod that up plus x doomcript. And we will do setup Doom. I'm hoping that it pulls it into a folder. It adds it to that directory. I guess that's fine. You could do it that way, too. I was thinking, oh, no, it added it right here. Perfect. And so, now we have the Doom source. Okay. So, now what we want to do is we want to create um something. So, we're going to make a file called um findings.md. We're going to create another file here which is going to be um manifest.json. And I'm going to go ahead and make a new plan uh doom codebase exploration uh orchestration. Say I want to use cloud code uh to explore the Doom codebase. um example like um how does a player take damage? I am I am concerned uh that due to the size of the codebase uh that claude code will lose context um as it summarizes information. I want to have external information, external uh fi information saved to findings, external key information, key information save to findings.mmd so that um uh it helps guide memory. I want to I want to um run uh exploration as a sub agent so that um it does not eat uh it does not muddy the context of the main parent agent uh uh or let's say cloud code runtime. so it can effectively coordinate. I want to be able to recover uh or resume uh sub aent sub aent tasks. And so I have a manifest. I want that state to be stored in manifest JSON. Um, I want a sub agent defined with uh based on claude codes um expectation uh like conventions egents know it claw agents right Okay. And so now we have that. I'm going to go over to Claude here and I'm going to reference our plan. Actually, I'm going to switch back to Opus for this. And I'm going to reference my plan. Can you create me a uh spec uh and task breakdown and save it in a file called specd? And we will let it go ahead and do that. All right. So, let's take a look at our plan. So, here it says written a spec. So, it says build a cloud code orchestrator gets copying with how does a player take damage without polluting the parents agent context processing files etc. Uh, dispatch the exploration questions. Dispatch a sub agent per question. Uh, read findings MD. Never perform raw code exploration itself. Keep context clean. Defined at the Doom Explorer. I like that. It could be even more generic, but we're going to just call it Doom Explorer. Uh, append findings to the findings.m MD. Uh, append knowledge log question status. Really have one sub agent. So, if we were multiple sub aents, we would probably have to manage that. Quarter coordinator reads manifest file. Um, and so that seems good. So, scaffold author the agent define the manifest file coordinator workflow prompt template. Yeah, that's something we're going to need. Prompt templates. So, that'll be maybe the claw.md I would think that we would load um findings.md resume flow uh smoke test failure handling acceptance criteria. So, this looks good. So, which and here we have open questions. Uh which oh we don't know. So it says which doom fork affects the file layout. I mean you have some questions. Um we are using I don't even know. I guess it's the Doom GitHub. It's probably the official one. This Doom. Um should findings MDB chunk per topic? Uh I think findings can be a folder and we can just create uh artifacts within it essentially scratchpad files. Do we want a second sub aent type synthesis? Yes, let's have a second uh sub sub aent. Please update our spec. Okay, so we'll have it update the spec. All right, so it looks like our code has done something. Um, oh, it updated our spec, right? So that's what we were doing. Let's go and review our spec file. And so here parent never calls ger read only the doom as her source does. Exploration output lives in the findings directory. sub agent crash coordinator marks task failed um smoke test. I mean like findings is pretty much our knowledge base basically for our repo. In fact, I'd be pretty tempted to rename that as knowledge base, but I'm going to leave it alone for now. Um how does a player take damage sub agent crash? And so we obviously have two steps, synthesis and um this one. So consolidated answers written by the Doom synthesizer. Makes sense. Um seems good. Okay. So we'll go ahead here. Uh please execute uh specs in specs empty. All right. Right. So we'll go ahead and have that implement and we'll be back here when it's done. All right. So we have scaffold complete T1 to T5 done. T6 I our runtime behavior is encoded into the two agents. So it built these things here. The manifest file the two things here um cleaned up states finding not executed runtime task smoke test failure. Let we kick those off. So what I'm going to do here is just take a look and see what we have. So, we have a findings folder now, which is better. Um, I'm I guess we'll see what happens to be dropped into synthesis. Let's go here and take a look at our explorer. So, explores the Doomc uh source code. I know C, but it's been a long time, so I'm not going to say I'm an expert at it, but here we can see that it has lots of access. You are a Doom codebase explorer, and you investigate the Doom source. Uh the coordinator prompt will contain um a task, a question, a resume from. Okay, so it's passing very specific things. You may only write edit paths under findings and manifest JSON because it's not there to edit. Uh you may never modify the files, never write the code. Derive a kebab case slug. Okay, I didn't know that's it's called a kebab. I mean, it kind of makes sense. Like if it's skewered, it looks like a kebab. Okay. Yep. Never knew that was called kebab case. All right. Oh, snake cases is underscore. I've been complaining like snake cases to have a hyphen and I guess they're saying that's snake case or sorry that's kebab case. So sorry folks earlier for complaining about it. If resume from is provided appendage to the file. Um update the manifest file. Use glob to glob or gp to glob. There we go. Fill the scratch pad. Um on success update the stuff. So, here's a template. Task ID question. That's not much of a of a template. Oh, this is the whole template. Okay. Question, entry points, call chain, key files, summary. Append only. Never rewrite a prior scratchpad section. Makes sense. Let's look at the synthesizer. Consolidate multiple Doom exploration scratch pads into a single synthesis document. Under findings, you're a Doom finding synthesizer. You merge pre-task scratch pads into one coherent answer. Oh, that's cool. Uh, never read anything under the Doom source. um and you update the manifest file. So that's interesting. So here we have an example of what it finds. No speculation if it doesn't cover it. Say so in gaps, no code blocks, etc., etc. That looks pretty good. I'm not sure if it Oh, these are using Haiku. That's cool. So um I think it's just pulling that from before because I was using him, but uh I actually wouldn't mind it doing that and seeing how it performs. So the question is like how do we kick this off? I would thought that there is something for the coordinator which is the the main runtime here. Let's go back to the spec and take a look here. So um 67 on startup scan the manifest file. No no smoke test. How does a player take damage? Follow up with a synthesis pass with the resulting scratch pass. Verify parent context. Um, so these require you to kick off an actual exploration run. Say the words and I'll dispatch Doom Explorer. Okay. Go and go and perform. Yeah. Go. Go. Okay. There we go. I I don't know what to say to kick it off. All right. But here is going to kick it off. While it's kicking off, let's go look at the codebase for fun. Um, look, it's C. Uh, it'd be fun to explore the codebase and see exactly how it works. All right, but uh, okay, here's the real code. I was like, where's the stuff? Look, there's this is how you do the cheats. 1993, 1996. That's crazy. Well, that's it. That's all we got in the head. And as it's executing off, just having fun looking at the code. Wow, this stuff is really simplistic. So, keep expecting to see more in here. Let's go look at the enemies. Okay, now we're getting more stuff. Okay, it's directions. All right, so that looks like more real stuff, but we will pause here. See what it comes back with. Okay, we can see that it's exploring. Well, actually, I guess while it's it's doing this, we should really uh point out the fact that um Earnest didn't register our project level agents definitions as sub agent types. Only built-in agents types are exposed. I'll work around this by invoking general purpose with Doom Explorer contract, which preserves it. Um agent type doom explorer. Well, that doesn't seem good. Maybe that'll be an issue later on. Finding persists to disc parent stays clean. Oh, it's back. So smoke test passed. So we have our findings. Let's give this a refresh here. And so so what is the sequence of events and data transformations when an end player character receives damage and doom? So, projectile projectile collision damage during trace, hit scan, weapon damage during raycast, blast radius damage propagation, uh various game system calls, target player checks, player pointer extracted from the target, uh baby difficulty reduction, armor absorption. Okay, cool. And so, it kind of walks us through all those stuff and tells us where the key files are. So player damage and doom flows from here a central function called by projectiles hit scan weapons expirations then processes armor absorption. Okay. What is the exact pain chance probability mechanism? How do we specify weapon type calculations? What happens during invulnerability uh grace periods and upgrades? Let's go down to our manifest file. So we have a manifest file and there is a task and then it can continue to collect those tasks. So this is pretty good. Um, so here it says, "We passed the smoke test. Uh, want me to dispatch the Doom synthesizer over the single scratch pad as a dry run because they run separately, right?" So, uh, yes, please. Uh, run maybe. Yeah, let's let's, uh, run three more explorations and then run the synthesizer. Okay. So, we'll do that first. All right, just checking in here. Look, it is uh uh collected those three things. Armor mechanics, weapon damage, player death, and then here we have our findings and it's going to go ahead and synthesize it. So, we'll see what pops out of here. While that's happening, let's go take a look and just look at the results. So, here, how does armor pick up and armor class effect absorption? Uh Doom's damage system uses a hit scan for oh, how weapons compute imply targets. Cool. Um player death transitions, etc., etc. So that stuff is continuing on here and we're waiting for the synthesis to complete and see what we get. Okay. And so it is now done. So all five tasks are complete. It did more than three, but that's fine. And then here uh unified life cycle site scratch pads only. Six gaps flagged. Um and so we will go into here. Um so parent context state clean zero doomed source reds in the conversation. All expirations happened inside the isolated sub aents. The synthesizer never touched the Doom Source. Want to peek at the synthesized doc? Drill into one of the flag gaps. Um, I mean, I only Is this the only file that we have? The synthesized doc synthesis. Doom's damage pipeline forms a complete life cycle. I mean, yes, I guess so. But like uh Oh, gaps. Here we go. So pain chance probability what is the uh exact pain chance probability mechanism invulnerability um okay and so here's my question is you know what does the I get it but I'm just going to ask it very clearly what does the synthesis uh doc do for us like what like uh what is why do we want it is the answer artifact the thing a human actually reads the per task scratch pads are raw files and synthes this is the report so concurly gives you one narrative instead of four the scratch pads each answer a narrow sub question the synthesis stitches them into a single end uh to end story okay so that's the idea so is this actually useful that's the question we'll go back to the top so damage life cycle synthesis damage armor weapons and death oh because now it's kind of rounding out all those together doom's damage pipeline forms a complete life cycle, weapons of environmental hazards, inflicts damage. Okay. So, do we have to like So, do we ask a question for synthesis? And if we did, what was it prompted with? Okay. Has its own question passed to it. So the question was how does the player damage armor how does the player damage armor weapons and death fit together? I made it up unifying the questions across it. It's deliberately broader than any single scratch pad because synthesis only earns its keep when it's integrating the actual prompt sent to the synthesizer agent. So here how does how does it do this findings? Do not read anything under any other places a gap we're calling out. I authored the synthesis question myself rather than coming from you in a clear design original questions etc would be that um right now the spec doesn't formalize the parent child decomposition the coordinator just invents both layers worth titing the spec MD if he wants this to always track back to a real user that asked no I don't care about that so here again we'll just read it so doom's damage pipeline from a complete life cycle weapons or environmental hazards inflict damage which flow through a central damage damage handler that applies armor absorption before reducing players health. Once health reaches zero, death is triggered. Um, and so here we have our weapons environment system, our projectile weapons, our environmental stuff. Um, and so we can see all those things there. Armor integration damage flow. So armor sits directly inside the damage mobs uh player branch. Um and so here armor extends survival by absorbing the incoming damage. Key fy duped. So here we are seeing duplicate information. Fair enough. Um contradictions. All four scratch presents consistent mechanics. Applies armor before health. Armor types and capacities are not contradicted in other documents. Weapon damage computations are consistent with the damage entry points. Uh, death logic consistently describes it here. So I would I would think that it's Oh, so none are detected. Okay. So pain chance probability invulnerability detection boss spiders immunity armor bonus edge cases mega sphere interaction corpus Q details. Fine. And then all our sources. So this is excellent. Um, yeah, it's great. Um I think the only thing is that if we go back to our original implementation, I'm not sure if we implemented failed failure handling. So I just go back here and say did we did we implement uh T9 fa failure handling. You could see how this could just be generalized out. It doesn't have to be Doom Explorer. U but it's pretty cool. So we'll give it a moment here for it to come back. Yeah, only the happy side. So, what exists both the agent uh definitions? Whoop whoop. I did not ask you to change anything. I just jumped here. So, um with a short note to reason, scratch pads are append only by convention. So, partial work will survive. What's missing? Parent side crash detection. Resume exercise. Uh, no failure injection tests. What would it take? A coordinator wrapper. Uh, a startup routine that scans for stuck running failed rows. One deliberate fail test. Uh, yeah, go for it. It's a big task, but let's just wrap it up here on on the seven because I'm the reason I'm doing this is because maybe I might reuse this and and do something better with it, but we will let it do that. Okay. And that was fastly implemented. So, we have here What was proven? NN injected a running row. Coordinator reconciles correctly. Flipped to fail. Dispatch resume from sub agent appends the update. Manifest now shows a value. Acceptance criteria. Killing and restarting the parent mid task resumes without losing findings. Oh, that sounds perfect. Um, so I mean we can go a bit far. Oh, so here's the coordinator uh coordinator helper for the Doom Explorer. So, reconcile verify stuck. Um, and so I'm guessing what it's doing is it's going to invoke this first. Verify stuck. What was bill coordinator with three commands stuck list the rows need to dispatch whatever. Um, okay. So, how is the coordinator getting invoked? Because that's the only thing that's not really spelling it out to me. Like I assume it's the main runtime that's doing that. Honestly, it isn't automatically. I ran it by hand with a bash call. No wiring. What's actually happening right now? So, um, okay. But my my issue is like, okay, but like ways to actually wire it up. Okay, here we go. So, document the coordinator or put it in the cloud procedure before any dispatch run the stuff. So I would say, you know, I would prefer a coordinator and I would like some uh claude instructions uh to claude MD to have instructions to tell it to invoke. Um unless you think it should be a skill to invoke the the coordinator. Okay. So I mean I probably should say coordinator MD file but that's what I'm kind of wondering like but then skill is but skill I think runs if you have skills they run in the main context they're not actually sub agents my take clawmd not a skill so skills must be explicitly invoked the coordinate well not necessarily because you can implicitly say that the coordinator runs needs a fire every time the parent dispatches a sub agent so a skill would only make sense for that. Um, yeah, but I still want a coordinator.mmd file. See, it wasn't asking me. It was just writing it. And so, we'll go here. We'll take a look. This directory is an exploration, orchestration, doom. Sorry. Sorry. Did you Did you put in the claude MD? What what could have been the coordinator MD and can we just have something later in the cloud MD to invoke it? Also, I thought skills can be invoked directly based on their uh descriptions. And why wouldn't we want to have a skill for direct invocation and skills run in the main agent uh the main runtime loop, right? So to me like it still seems like we should have skill. So maybe it's not reasoning well like this this seems like this should be in the coordinator empty right and then we should have a skill to invoke it that's in the project and also we could end up um extracting this out but we'll we'll wait a moment here so here it goes you're right on both accounts I was wrong to dismiss a skill so it also invokes based on the description um descriptions like this procedures live inside the skill it's not in the cloud MD um fair enough we can do that as Well, um, I dumped the whole procedure in there. It should have been a light pointer. So, we'll go ahead and take a look at what it's done. And we'll go into here. Uh, did it get rid of this file? Exploration or uh orchestrator over at the Doom source design inspect. When the coordinator exploration works in this directory, use the Doom coordinator. Never read or GP the Doom source. We don't really need this line as the skills should be able to do it. But here we have an example. you're a coordinator for the Doom codebase. Never do this. And so now what we can do is say Doom coordinator. It's really exploration. It's a terrible name that they have here. I'm just going to uh cancel out of this and try this again. Doom coordinator. I want to know how level difficulty uh affects gameplay. Oh, I've used 100% of my session. Well, I guess we'll never know if that works, but we reached our little end here, so that's perfectly fine. Technically, I have um what do you call it? Uh credits, so it's not a big deal. But I thought that was really funny that we made it right there to the end. Okay, but I think we built something really, really good there. I think I would have probably packaged this into like do go further and package this into a separate course. Um but anyway, I hope you enjoyed that. Chowo, chiao. Hey, this is Andrew. In this video, I just want to show you how batch processing works. And it's not that complicated. We're going to make a new folder, call it batch uh processing, and we're going to um copy, I guess, uh our maybe not our retry, but our force structure JSON output. And we'll go ahead and copy this. And we're going to go into our batch processing and make a new main file. I don't want to run this because uh batch processing isn't something that will happen instantly. I think it takes time for it to come back because yeah, it can take up to 24 hours to process with no guaranteed SLA. Um, so I'm not a huge fan of of of trying to run that. And I think for the exam, I just want you to know that exists and you can save money with it. Let's take a look at what we could get as our output code. So say um, you know, can you can you change this to uh utilize batch processing uh, uh, for anthropics? So we get savings. What is the key thing we need to consider? Like how does it know where the output goes? Okay. And I think what it does is it probably has like an endpoint where it outputs that generation and you have to hit it. That's probably what it's going to do. Uh when I'm thinking about OpenAI, we'll go ahead. We'll just say yes, and we'll see what it comes back with. And we'll just take a look here. And I I don't think I'm going to run it because I just want to see what it looks like, but I don't want to run something that I have to check. Maybe I'll run it, but maybe we just won't see the results. Okay. Okay. Let's take a look and see what changes. So here, um, we have a custom ID on each request when submitting. And then when you call batch results, every uh results comes back as a custom ID. Okay. And then when you batch, if I forget, you can't do interactive round trips. So instead of using tool use, uh, it's going to force a single tool call and the tool input is going to block. Okay? And then you just extract it directly. And then you were saving some money. So let's take a look. Let me just close this out. Make sure we have the latest code and see what this looks like. Let's go all the way to the top. Okay. And so here we have a couple tickets. We still have our tool and our required information. And here it's going to input that information. And so we still have tool choice, which is fine. Let's say I had to change something with that. all the way down here. Um, instead of instead of tool choice any forces a single tool call. Oh, instead tool choice any forces a single tool called. Okay. I mean like we were already I think we were already doing that. So that's fine. Um, and so we'll go here and do we have a loop? We don't really have a loop, do we? So we have batch create. Oh, so we have now batch create. Okay. and it's going to loop and then retrieve that information and then it'll tell us when it's succeeded. Okay. So, I don't know. I guess I'll run it. I'm like I'm not really sure what to expect there, but I was thinking there'd be like a link or something and like the payload would be somewhere else. Maybe I just don't understand. But we'll run and we'll find out together. So, here it's sending those out, creating that batch process. And now it's processing it. Okay. So maybe this stuff will literally hang until then. Oh wow. Okay. So really we're basically waiting here until later. So I guess my thought is like the problem with this like this is the problem with this approach right? So I'd say you know um for batch processing the user has to wait. Is there is there a way we can uh make it so we can run it and then just check on it ourselves at another time. you know, if they're if they're, you know, because that I think to me that's going to be a a better result. Um, because maybe you don't care and you just come back and you check, but like having to wait there would take forever. So, we'll just hang out here for a second and see what it does. All right, we are back and so now we have a few options. So, we have submit, check, and run. Um, let's take a look at what has changed. So, we have submit, check, and run, run, and wait. So, here it is creating a state file. All right. And then in the check here, it's loading that state file. Okay. So, let's go ahead and give this a try. So, we have um submit, check, and run. Right. So, we'll go here and we'll say submit. So, here it says submitted to the batch. Fires the batch. Saves the batch ID to the batch state file. So, we'll give this refresh here. There we go. So, we have a B that there. Original blocking behavior. Okay, that's if we want to do that there. And so now whenever we want to check it, we can just go and check it. And it's showing if it's succeeded or not. And let's go take a look at how that check works. And so it's calling that retrieve. Okay. And so it is hitting an API endpoint and we're just using ID. And so that's batch processing. I think that's pretty straightforward. Um I would expect we just get a result back and we process it. But uh yeah, if you don't need things right away, apparently uh extremely extremely good savings. Okay. Let's take a look here at MCP discovery. So, this is when you configure multiple MCP servers and all their tools are discovered and loaded at the connection time. And so, the agent will treat it like a flat list with no awareness of which server comes from where. Now, this is not what the code would look like if you're using um Anthropic or the agent SDK. This is just kind of a a pseudo code, if you will. But the idea is that in your tools or somewhere here, you're going to specify MCP servers and it's going to end up loading all of the tool uses. Okay? And you can see where this could run into an issue uh because now you have um a bunch of different tools here. And so that is uh one consideration that we have to consider. But what we'll do is just go ahead and just make sure we know how to implement this. Um but there you go. All right, folks. Um, this is for MCP discovery. I'm having a hard time showing a good example here because, um, this last one seems to be failing quite a bit, and I made it over here. Uh, but basically, I just said, "Hey, can you go ahead and show me discovery with a few examples, but here you can see within um, the cloud agent options, we have MCP servers. We're specifying those locations. We have to install them individually. This one will not work. But the idea is that all these will just be available um to the agent. Um and all I just really want to show you is just that there's this MCP server option. Okay. And then all those tools will be then accessible. Um I actually did install them here locally. So Claude should be aware of it. If we go to MCP, uh if we go over to here, it should show them here. No, it doesn't. Uh though I think uh maybe that's because Claude has a very different specific line. But the point is is that we have installed them and we can use them here. I just don't have a a complex use case and we got enough videos. So I just wanted to show you the code. Okay. Okay. So within MCP there is more than just uh tools. There's also resources and prompts. Nobody uses prompt templates as they're not useful. Um but resources are and they don't get talked about enough and you definitely need to know them for the exam. So tools we keep seeing which is basically functions that are called often they are used to uh handle a domain of an API. So there might be individual functions but maybe you have users uh API endpoints and here it is kind of uh acting as a buffer between that domain but here it's saying you know what tables exist in the database and so the tool uh will call a function right which will make a database call an SQL query and return back those results where um let's say you have a database or you have an API endpoint and an API endpoint is just going to return back data right and so it might seem seem uh very heavy to have to do tool call for very basic API calls. Um and so basically resources has this schema that maps what the data looks like from your your data source and the idea is that it'll just read it directly and so you'll get faster results. Um there'll be less back and forth and so resources are definitely something that we want to uh utilize. Okay. All right. Let's see if we can show how MCP uh resources and tools work. So, I'm going to make a new one. Say MCP uh resources versus tools. Okay. And I'm going to go into our hello world just so it has a reference of what it should do. Yeah, that one's fine. Um and we'll go over to our new file here, main.py. I don't think I copied it. So, we'll try that one more time and paste that on in there. Okay. So, now I'm going to go here. I want to show off how uh show off tools versus uh resources for MCP using the agent SDK framework. Uh it should load a custom MCP server uh with that can read a local SQLite uh 3D database in this folder called to-dos. Um, and it should have tool use to uh create, update, edit, destroy to-dos. It should have uh a re uh MCP resource to list out to-dos. Okay. So, we'll go ahead and do that and see if it will be able do that because I gave it a little bit a little bit much more than I was expecting, but we'll see if that helps. Okay. All right. All right, let's take a look and see what we have for our code. Okay, so scroll on down. Not what I was expecting. We have the to-do server here. Well, I guess we'd have to have some kind of server run. Do we need a server? Oh, yeah. Yeah, this is the MCP server. So, this is the actual MCP server. And here it can connect to the database. List tools. right out. So tool tool tool resource and so see this resource and it's just making a call here as well but it's following this schema format. Um so I mean it's still basically like a function. It's calling it but I guess the difference is that it only expects read only information. I always thought that it was a direct call and I never knew it was a function inside of this because I I don't really implement resources. I usually just implement tools. Um but I know that this is a a schema syntax. We say like uh resource schema MCP. I absolutely know that there's a schema for that. We'll go to the model context protocol website and see what we have. So somewhere here kind of describe it. Not really. Uh yeah, I don't know. But anyway, it looks like something like this. Okay. Um but we'll go back over to this one and see if we can make sense of what it's doing. So here uh we can see we have our server script. Okay. Convert MCP tool list into anthropic tool format. I'm not sure why we should have to do that, but okay. Like you'd think it would already have done that. Um here we're running the agent. We're grabbing the tools and I don't know why it's using anthropic directly. It's using asyncthropic. So it's fine but like could we can you use agent SDK? Like I don't understand why it's using like why why are you not using why are you using a thropic? Now there could be a reason for that but we'll see why. This is just sonets reasoning. If we went to opus I think we'd have less of these issues. U but again I'm trying to make this cost effective. So yes I I don't know why it wants to read the whole darn thing. Like it should know what agent SDK is. Look, stop. Stop. Stop looking around. Why did you not use agent SDK? Anthropics. Agent SDK. Let's see if it will answer us here. And while that's going here, I'll just ask, you know, can we load in a custom um MPC server into agent uh anthropics agent SDK? I'm just asking this to um Claude here in the chat. you don't see me doing this. Um, but I just want to see what it's doing here because sometimes the actual Claude uh chat seems to be a little bit more uh on point maybe because of what tools it has available to us, but we will see here in a moment. Okay, so this thing is still trying really hard. And if we go over to here, look inline MCP. So we have this query list files of prompts await. Okay. And so here what I'm going to do is grab stuff like this. Okay. Like why? Like look here. Okay. Because it's trying to get reference information and so maybe it just doesn't understand. Right. So, we'll give it a moment here to fix it. And hopefully that gives it context. All right. So, now let's see if we actually got better code output here. Uh, and so I'm just going to close this out and reopen it up. Okay. And so, let's take a look at what we have. So, here we have agent SDK. We're loading the server. We have the prompt. Just demonstrate the difference. F do the following steps. So, read the resource, use the tool, um, update it, read the resource, use the tool, etc. Going in that order. And here it is. And you can see this is way, way better. I I don't know was zoomed before, but that was crazy. So, here we have allowed tools. Um, and if we go up to here, MCP tools. So, we're allowing any stuff here. I'm just trying to find where we are setting the MCP server. uh to-do server server script args and so we're passing in here. So, oh, here it is. MCP server to-dos and then this is the argument to start it up. Okay, so that looks pretty uh pretty good. We'll go ahead stop this. Yeah, it really just comes down to like, you know, is what you're looking at correct, right? Because you can see it can generate out variations of code that might work, but that doesn't mean it's good code. Um, and so we're just watching it and see if it reads. So here it's it's listing it out. Um, and then it will go ahead and create some. And then it's going to do an update. It's going to do another read. It's using resource. Now it's deleting. Okay. But we can clearly see, you know, they're both just functions. But the idea is that these are just readonly actions, right? Or they should be. Obviously, you could put anything you want in here, but the other part is that you're just able to follow the syntax. Um, could you also emit very specific fields? I don't know. I don't do enough with resource to know. Um, but anyway, hopefully that gives you a distinction and treat one as read only, one as as like actions. Okay. All right. So, another way we can uh use cloud codes with GitHub actions. It allows us to trigger cloud code based on workflows to perform tasks in our repo. So here's an example of the cloud bot and it is um doing stuff and checking stuff off and actually performing uh work just like a developer in your team. Uh so you can create instant PR creations, you can automate code implementations, follow your coding standards, do simple setup and it's secure by default. Um I think that description kind of underells it but the way it works is that you are setting up basically a claw.l ML file in your workflow. And if you notice here, uh you can tell it where to trigger. So maybe you is when you create a new comment or if you create a new comment on a pull request or you open a new issue or assign it or submit it, obviously you can adjust this however you want. Okay. And then if you notice here, they have a cloud code action. And so basically it'll just do whatever it needs to do to get the job done. Um, and the only downside to this, I like the workflow, but it's just slow because you're not just waiting for cloud to execute, but for the GitHub action to execute, and it has to spin up that environment every time. So, I would just say that the GitHub actions are slow. And if it was faster, this would probably be my preferred method of working because if you uh move up in your career as a developer, you end up managing um developers and writing issues and and seeing it through that lens. And that's the way I would probably like to work, but again, it's too slow. And so I would um not drive it that way uh in in reality, but it is cool to see that. And if you are on the management side, then at least if it's in there, maybe use it to review things or assist you um and stuff like that. Okay. All right. So apparently um there are integrations with GitHub actions and specifically using Collad in our PRs or our issues. So that's kind of interesting. It'd be cool to make an issue and then it executed out. So, I'm not exactly sure if that's what it's talking about. Um, but we'll go down here and we'll take a look and see how we integrate it. So, the easiest way to set up this is through cloud code and just the terminal. Just open claude run install GitHub app. You must uh be a repo. Install the GitHub app and app secrets. Is that going to install the GitHub app? Because I don't want the GitHub app. Um, okay. install the GitHub or the clawed GitHub app. Oh, so I think what it's saying is like the actual GitHub like GitHub app, not like the desktop application. So what we'll do is we'll go over to GitHub and I believe that this is my developer account and we'll make our way over to the examples repo that we have here, the cloud code example, assuming the code is saved there. Yeah. And so if we go to settings and we go to apps, right? Is it installed? It already is installed. So when we set this up earlier, we already configured it or we we set it up. I was just going to see if there's any additional options. There's not. So it is ready to go. And so in in a sense, I think we should be able to make issues and do um that at sign and be able to utilize it right away. So what I'm looking for here is that information. Uhhuh. a lot of talk. Just tell me how to do it. So here we have a bunch of stuff and then we have actions. Give me a second. Okay. One thing I noticed is that it needs these particular permissions, but I'm pretty sure we just gave it a cart blank like all permissions to the that individual repo. So I don't think that'll be an issue. Okay. Okay. But it's not really talking about how to use it. Like yes, of course there are um these actions here like if you tagged it review this for PR for security issues. I was thinking that like if we do the atsign claude then it would go in like an issues and go do something here. It says with a simple at sign mentioned in uh in a PR or issue yes claw can analyze your code and create pull requests implement fixes and bugs. All right. And then I mean these are just actions. So I'm assuming that that's just if we want it to do something. So like if there was a push then it would trigger that. Okay, that makes sense. So what we'll do is we'll go over to here and we'll make a new issue and we'll just say create individual product page. I don't know if the mention has to be here in the description. So um I'm going to try over here first and we'll just say claude. So I need um implement the following page. So, uh, create a product HTML page. This is the page that describes an individual product for purchase. Um, this is a mock page. So, um, all products will link to this page. And you know what? I'm going to go ahead and make check boxes and see if it'll actually check box these off. I'm curious if it would actually do that. create for now a mock page for all um possible products. Point all products uh links to this single product HTML page. Okay, so there we go. And I haven't mentioned Claude down here. I've added it up there. Be interesting if you could assign it to Claude. See that? That would be smart. We'll go ahead and we'll create it. We'll see what happens. And so I'm curious like if we go to get up actions, is there any trigger? There's nothing happening here. So I thought something would happen. Okay, I'm going to go ahead here and say, you know, Claude, are you there? I'd be like curious if it like it would pop up and start talking. We have code with agent mode. That's probably for GitHub, right? And so Claude [laughter] did that. [snorts] Okay, so we'll go here. So Claude, can you implement this this issue? Oh my goodness. I I really hope this is what it's like just working with a with a bot and have like being like, are you doing properly? Like this is actually probably how I would want to work with this. Okay. So, it keeps looking at at um my stuff here. Claude, are you able to comment back? Uh if uh if so, indicate with an emoji like like one or zero or like or yes or no or something. or if you can write a comment, just write a comment. Like, are you okay? Blink yes or no, right? And so [snorts] I'm curious. It just keeps doing the same thing. So that's kind of not helpful whatsoever. Um, and so I thought that it would go off to the races there because that's what it's describing up here. We go up the top here and it's saying, right, I'm not crazy. It says with a simple Claude mention in your PR issue, Claude can analyze your code and create pull requests all while following your project standards. Well, I would love that, but it's not doing it. So, just give me a moment and seeing what the issue is. Okay. So, I mean, there are additional steps here, and maybe this stuff isn't happening, but I would have thought because we had created that repo um through Claude web that it would already have that, but maybe what we should do is open up this repository. And yeah, we still have this environment. So, I'm going to reopen up this in the browser. I'm going to see if we can just go ahead and run that install script. I don't think we have to do it. Okay, I think that because we did it through Claude web, unless we did it through here, and this is actually how we did it. I just don't remember, but um we'll get Claude working through um GitHub code spaces. And then we'll try to run this and maybe it's just lacking permissions or something. Okay, so just waiting a little bit more time here. And okay. And so I'm just going to go back a directory and say claude um off status. Is cloud even installed? No, it is not. So install claude code. And we'll go down to here and we're going to grab this one here. and we'll go ahead and do this. Okay, so we're just waiting for this to build. Shouldn't take too long, but it'll take a little bit of time. Okay, so um yeah, it's now installed. And so we'll go ahead and we'll do our cloth off login. I can't remember if we had issues um logging with this. So, I think what I'll do just to make my life easier, assuming that the extension is over here, I'm going to grab claude code from here, if it even lets me. Oh, they do. Okay, great. I thought they might not have it because uh you know, Microsoft might want to keep them out. But we can see Claude in here and um I thought I saw Curo, but don't really like Curo. Sorry, folks. I'm not even going to look at it to see if I like it because I already know I don't like it. Um, but anyway, so now quad code is here. And so I want to get this authenticated and I'm just going the roundabout way to do to do this. So it'll make it a lot easier. We'll go here. We'll say authorize because then if there is, we can uh paste paste the code in here. E, and we have the callback code up here. So I can just grab it out of here. We got to be creative, folks. We'll say continue. And um that should get us authenticated. It's not showing us anything, but I'm going to go down here and say status and see if we're logged in. We are not logged in. [laughter] So what I'll do instead, one second here. We'll go into cloud code examples. I guess we didn't have to use it this way. I kind of forgot that we can just type in claude like this. And yes, dark mode is fine. And we'll do that. And we will say open. We'll try this again. We'll say authorize. I think it knows to give us the code to copy paste it here. It didn't, but we'll go ahead and grab this call back here. We'll paste it in. We'll hit enter. I copied the whole darn thing. We'll hit enter to retry. So, maybe that was an older link. I don't know. Say open. Close the old one just so we don't get mixed up. Authorize. There we go. That's looking a lot more normal. Okay. And so then we'll go ahead and paste it in. We'll hit enter. And now we are logged in. So we are good. We'll hit enter again. Uh yeah, ter yes trust this folder. And so what we want to do here is get set up GitHub. So or GitHub actions installed the GitHub actions app. It should already be installed, but maybe it will give it additional permissions or whatever else we need. So it's checking GitHub CLI. Um use the current one. Yes. And so it's going over to here. Okay. Uh, I thought we would do a little bit more. So, I guess it's already installed. So, have read and write to access code. Uh, read and write access to actions and metadata. I guess we could have just checked that the entire time. We didn't really have to go through that whole install process, but we'll go down here. What I'm looking for, uh, not remote code, is we're looking for the permissions. Do we have the correct permissions? Permissions. Permissions. Permissions. Where is it? Read and write. Read and write. read and write. So we go back over to here, we confirm read and write code discussions issues. So yes, it has that access. So there should be nothing preventing it, right, from being able to respond to this stuff. All right. So let me figure out the next step. Okay. Okay. So it is suggesting the anthropic API key and also uh this part here. though because we're using a subscription I would assume that we wouldn't need an API key but maybe we do copy the workflow file for cloud YAML so maybe that's what we're missing is this oh look it responds issues pull requ um since we already have GitHub actions open or sorry this this here I'm just going to go ahead and make the folder um I believe it is uh not a cloud directory But um for ours we need to uh make the actions folder. I always forget what it is. Uh GitHub actions workflow folder name. Which is it? GitHub for gotgithub/workflows. So we'll go back over to here. We'll make make a new folder. GitHub to think because I made a whole course I'd remember this stuff and I use it all the time. Nope. Brain doesn't work that way. Okay. We'll go claude yaml. I don't think it matters if it's YML or YML. And so we'll go here. We'll take a look. Since we, you know, care about what our code is doing, we're carefully looking at it. And so you can see it's responding to those things. If we didn't want them, we could remove them out of there. Customize the trigger phase for Claude. Um, okay. So, it's already defaulted to Claude. So, we could probably change the name, change the name of the bot. So, that looks fine. We'll go ahead We'll say add claude. The only other thing that we're missing is that key, the API key. Um, so we'll go over to here and supposedly we need go back step. We need an actual key. So I'll go over to here and into my settings. I'm looking for tokens. I mean that feels like for like coding stuff like I mean like literally directly working with the API. But we'll go over here. Maybe maybe they have one for here. Oh, cool. We can see the history of authorization authorization use. Okay. So, I'm just going to I just want to make a I didn't know that was here. So, I'm just saying authorization token usage, right? Because I thought that was kind of interesting. And I'm just taking a screenshot. This is just for the course for us later here. Okay. But anyway, um so they're saying we need that API token, but wouldn't that be coming on the code side and then we'd have to pay for that and it would be part of our subscription. So maybe that's something that I didn't consider, which is fine. We have to put 10 bucks on it. I can do that. Um, if I can freaking find the page. I really dislike their uh their links here. It gets really confusing. Um, so not that page. So here it says anthropic API key. So that makes me think that you can't use it with the subscription. Okay, which is fine because that's an opportunity for us to uh grab that there. So, um I guess we could try to find that. I've done it before. Usage. I just don't remember where the tokens are. Account general. Uhhuh. Okay. So what we'll do is we go claude um let's just like workbench or something because that's the platform right so if we go over to here the developer platform this will have the API token in it right so this is separate from your subscription and actually have to put some money on here the only thing I don't like is that if you don't use it by the end of the year you lose your your money which is I don't like but uh begin buying with only five credits um that sounds good to me because this is where the API keys are right. So, we'll go ahead. We'll try this. And I'm just going to quickly load this up. Just give me a moment. Okay. I'm just buying five credits here. I didn't have to enter my credit card. It's already entered in. Um, and so I just hit that buy button and I just said five. And now I'm just verifying. So, hopefully it works. I don't know if I have a new company credit card, so I might have to update it, but we'll see in just a moment. Okay, there we go. I got a $5 balance. So, we'll go over API tokens here. And, uh, obviously you can see I I was working with Japanese grammar there. Um, that's been a while. I'm just going to disable the key for now. I'm going to create a new key. And this will just be for code or uh cloud code and it'll be in the default workspace. And you didn't see that. I'll have to actually delete that. Okay. So, I'll copy that key there. I don't know why they do that. That's ridiculous. But now you've seen it. I'm I'm not going to edit it out right now. I'll I'll delete the key very promptly uh here after this video. Um, so what we're going to do here is go to our repository secrets. I'm in the repository. And we have secrets here. Technically, it is for actions to use. Repository secrets. That's where they said to put it. I'm going to paste that in. And I'm going to go back over to here. And what we're looking for is where is it? I'm looking for it. Um, this this is what I want. So, we'll go back over to here and we'll grab this here and we'll add that key, that secret. And so, now we have that repository key there. And so now in theory we have all three things set up. And so I'm going to go back over to here and say and these are all a little bit silly. So I'm going to go ahead and delete these. Delete. Delete. Delete. So when is it going to trigger on? That's the question. Uh so we'll go back to our code and we'll take a look here. So on an issue created created open assigned submitted. So this issue would have to be created. Okay, I'm just going to go ahead here and um can we assign this to Claude now? I just want I keep on expecting to see Claude over there. Does it also trigger on comment issue comment? Yes. Yes. Yes. So, can Claude, can you implement this ticket, please? I assume it would do feature branching, but we'll find out. There we go. And so the main thing is like did this get triggered? And it has. Okay. And we'll go into here. And so it's going right. Um I'm not sure how we would go about debugging it. I guess here postr run cloud. So it's actually installing cloud code. And that's probably why you need the API token. And so I assume it can't use subscription. But I would think that there'd be a way to configure it to use subscription. But maybe because it uses that off mode that just doesn't work. I'm not sure. But anyway, it's going. So I'm just trying to figure out like what we expect to see. And there it's using cloud sonnet 4.6. I would imagine that if we needed to adjust it, we could probably go into that uh GitHub actions file and like say, hey, use this model and stuff like that. Yeah, we can right here. So, how many turns, what kind of model, additional system prompt, things that we can tweak it. So, that looks good in terms of what it can do. I would assume that as it's executing those actions, we would see them right here because that's run cloud code, right? So, I'm just going to pause it here and um because we're not seeing much and we'll be back in just a moment. Okay. All right. Let's see what the results are. So, down below we can see okay, multiple runs and um that's pretty clear. I was hoping to like clearly see the commands that are running, but I'm not sure if I can really tell from here. Um, what's going on? We'll go down. Complete job. Usage would be kind of interesting. We just have 3 point U. I thought maybe it'd be like tokens you use, but I guess not. Workflow file. That's just the file we're in. Let's go back over to issues and we'll take a look here. And well, I guess I made this so it wouldn't be able to check box these off. It would be me that would check them. E. So, implement implementation complete. So, gather contact. Oops, I didn't mean to check box that off. I hope that wouldn't trigger it more than once. Let's see. Would that actually trigger it again? That'd be really annoying. Uh, no, it did not. Okay. So, we'll go back over to here. Uh, created bath box on product.html page uses the URLs never asked to do that. Contains mock for all six pages. Okay. And so I could kind of see that as a process to like I might want to do stuff, but it didn't make a pull request. Okay. So what I would have preferred is that if it followed that uh the branching strategy, um also I don't see it here. So we'll go back for a second. Yeah. So we have a separate um separate one here. Do we have a pull request? Okay. [snorts] Where's the pull request? I'm just going to see if it attempts to go make one. The annoying part is that it probably will have to trigger every time this GitHub action and that's a little bit slow. Yeah, it's triggering right now because you don't want to wait like three minutes every time you reply to it. And but I could see how we could work around that a bit. So again, we'll just wait a few minutes and give it some time. Okay. All right. So I thought that was executing, but maybe it stopped. I just don't recognize the symbol here. I thought maybe uh that would indicate something. Maybe it did reply. Let me go back over to here and Oh, not here. Not here. Um issues. We'll go back here. Oh, I didn't tell it to. Sorry, Claude. Uh, where's the pull request? Uh, can you make one, please? And, um, so we'll go ahead and let that do there. I guess it probably also need to know where to, um, where to make a pull request into. And so what I'm going to do just quickly here, it probably will move faster than I will, but I'm going to create a um a new branch called main because there should be one. There just isn't. And then I'm going to go over to settings. I'm trying to do this as quick as I can. And yeah, of course, switch it. That's ridiculous to having it as that. We'll go to main. Okay. And that's what it really should be. Okay. And uh you know, we'll see how that works. I don't know if it if it if it doesn't have a main branch if it'll mess up. And also, I was kind of doing that in the middle of stuff. So, we'll see what happens. So, I guess these ones are like, oh, a comment was created. Oh, they created a comment here. So, let's go back over to issues. Oh, okay. So, this is how we're going to monitor it. That's interesting. Interesting. Interesting. Okay. But I'm sure there's other stuffs that we could tell it to do which we're just obviously not doing right now. Um, but we will give it a moment here to figure this stuff out. Yeah, because we run the job. The only thing is like I can't see what it's doing. You know, that's the only thing I don't particularly like, but I guess there's a lot of options in terms of the ways we can work here. Um, we we'll hang out here for a bit. Okay, there we go. So, our pull request um according to this has been created. Oh, we just got the updated information. And so the question is like would it known to send that pull request over to um I don't see it here actually. Would it send it over to the correct location? So I'm not sure if it's still running. It is finished. Create pull request. Uhhuh. Where's the pull request? Okay. So, I would have thought describe what you need Claude to do. I'm just checking here. Claw creates a complete PR with all necessary changes. So, it should be able to create a PR. So, I'm going to go back over to here. Yo, you uh Claude, you didn't please create a PR. Can you make the also notice here that it doesn't have a a branch associated with it. also this issue the branch isn't associated with it right because that's what I would like it to do and so you know if if we were spending a lot more time with this I would spend more time trying to force it through a very specific workflow just so that I could come here and and see things the way I expect to see them but we'll give it another chance here and see what happens and it is running the job so it is working so there we go so I'll analyze and back to you. It's just like we can't really have a conversation with it. So, it makes it kind of hard to uh you know, whatever, whatever. So, I don't know if this would be a really good workflow, but I mean, it is an option for us, but we'll give it a moment. Also, one thing I noticed is like the order. So, like this feels like this should have happened first and then afterwards. So, it's interesting that it's kind of matching based on the order that I said as opposed to what would be most optimal. But I guess it's not a big deal, but I would would probably like to see that done first. And so here we can see it's reasoning. So I found the branch and there's been no changes. The actual implementation is in the product. Um create a PR from the branch that has been implemented. GitHub doesn't have automatic association with existing branches. You can link them from the issue sidebar. I guess maybe they might mean to say like through the API. Like I thought maybe through an API call they'd be able to do it. Um, and do we still do we get a PR? No. So, there's obviously some trick to this. Maybe it's because I'm asking it to go to main, but before that was less of an issue. But I'm going to go ahead here. I'm just going to do it myself. And uh, I guess there's two I guess they created two separate branches for the exact same thing. But anyway, I'm going to merge each of these individually pull request. And I'll do this one here. Oh, maybe that's their initial one. Okay. And so we'll hold on here. No, no, no. That's the wrong one. So we'll go to this one here. Uhhuh. I can't tell the order because I would have thought there's code in here, right? Oh, maybe Maine. Okay, so Maine's already up to date. I see why. Because it's just the order that I created it in. That's fine. So, we'll go ahead and we'll create that. We'll say create the pull request. And I just want to see the new page working to be honest. That's all. We'll confirm and merge. And then we'll go back up to Uh this here we'll make another pull request. Oh, I don't know which one we just merged. Does it say? I don't like the issue names. This makes it really hard. 1956. So we'll go over to this. We'll create another one. We'll do this one here. So that would be something I would want to know is like, okay, can I make more human readable names? And so we have conflicts. I think that they're identical. So I don't think there's any difference to those. Let's go back over to here. Um, and I want to go Oh, my code p code space is stopped, but we'll start that back up. What I'm going to want to do here is I just want to go and uh pull and check and see what the result is. I'm sure it's fine, but I just want to see it for my own my own interest. Mhm. [snorts] Get checkout main. Get status. Okay, so that's not going to work. Um, no, it should. Get pull Get checkout main. Get pull. And we have a product page now. Um I don't have my products page. So that other one must have been it, right? Uh we'll just resolve the conflicts, I guess. So, it's like, do you want the same one or the same one? Is there even a difference between these two? That one's gift set or gift set. I don't think it matters to be honest because it's all just example stuff. I just didn't feel like resolving conflicts. That's why uh didn't do that there. I don't know which is which here. Oh, this makes it really hard to know. We'll just accept both changes because I like probably both are supposed to be there, but I just really can't tell. So, we'll go ahead and do this. So, you can already see like working with this you if you'd have to break up your code into a lot of small files. Otherwise, it's going to be really hard to tell what's going on. And yeah, so doesn't necessarily make anything easier. So we'll mark resolved. Mark resolved. We'll commit. Commit merge. We'll go ahead over here and uh merge pull request. Merge pull request and we'll do a get pull here. So that's now updated. Um HTTP server. Okay, we'll go over to here. I want to open the browser. Let's take a look at what we have. Some things might be broken because we really didn't take the time to make sure these requests were good. Looks more or less the same. You think these would be clickable, but no. And so this is that individual order page. It's fine. It's not obviously good. Maybe there's an error because of the merges we did. There is. See? So when I merged it, something messed up. I'm sure we would have had a nicer page than that. But the point is is that that's that. So that's totally fine. Um I'm going to go ahead here and close out this GitHub code spaces. And I mean that's pretty much it. So I think we learned what we could there. And obviously, you know, you have to really think about your workflow and work through a sample project and iron out the uh little kinks in that. But there you go. Okay. Hey, this is Andrew. In this video, we are going to be building a um I guess a support bot because um we want to take a look at how to handle escalation as that is something uh that the exam wants us to know. And so what I'm going to do is go into our hello world, which is a great example over where we can start. And I'm going to go over and make a new folder. And this will be our support agent. And I will make a new file here called main.py. I'm going to go ahead and paste in our code. And I'm going to do something a little bit different. We're going to make a plan ahead of time. So plan.mmd. and because I want to design this in a particular way and I'm just looking at this off screen here to decide what it is. So first like uh uh business use case. So we'll say um we are building um exam pro trading inc. And by the way we use real humans. I can't if I even wanted to make this BO would never uh accept it like you don't understand he like uninstalled his anth or sorry stopped paying for his anthropic um subscription because he likes to do everything manually. So on Exam Pro right now, at least the time of this video, uh support is 100% humans. But let's pretend that we want to be greasy and we want to uh uh have a an agent that does this. We'll say Exam Pro training inc uh needs a support agent to um handle requests. Um and so you know we have to give more context. So Example Training Inc. is a tech education, a tech educa or a tech platform that has um that's that has multiple um self-paced um tech education courses similar to Okay, so we'll say that um they need a uh customer support agent that will um resolve common issues. So we'll just define common issues. So what are the common issues that we have? Um I would say you know refunds uh changing changing uh swapping out courses swapping out courses that are similar in price. Um, we'll just say bought the wrong say refunds or swapping out courses, eg purchased wrong course. Um, one that always happens is the um not receiving um email uh confirmation email. Confir confirmation email. That one's really, really annoying. Um, what else? What else? Refund swapping out, not receiving email. Um, technical mistake or a mistake or we'll say bug with the platform. We'll say um issue or issue with a specific video um eg out or issue with spec specific content problems you know stale eg stale content uh or um no audio in video. So we say eg um you know quizlet button does not work. Uh star count or yeah say like say star count is incorrect and maybe like business development opportunity. Uh we'll say um what's the thing they call it's like where they want their data taken down because they're from Europe uh European data uh ask for data take down I don't know what you call that I forget what it's called GDPR GDPR request right um and so you know maybe those are things that we have common let's not say issues but say common requests okay and so the uh agent needs to handle the following. Uh what else do we need to solve for? So we'll go back over to this document here. So appropriate escalation. So we have um customer requests for a human. Okay. So let's talk about escalation. So escalation actually we won't worry about this right now. So we'll just say uh version one implement an agent using uh anthropics agent SDK not the a not the anthropic lowlevel SDK and create uh and create Uh I don't know what to say here because we're not like we like they can't actually invoke stuff. Oh yeah. Oh and uh we will mock out uh API requests um eg like create a ticket um create a ticket or issue a refund or things like that, right? as tool calls. Okay. Uh as an MPC server, we we probably would have an MPC server that goes to Exampro endpoints, but then there are I guess it's mostly and so tool calls would live there. Okay. So, we'll do that. And I Yeah, I know it's not the best writtens, but we'll go ahead and and execute this. So, we'll say uh support agent. We'll say claude. And I'm going to say plan. We'll say build me version one. And we'll go ahead and let that do that. All right. So, it's produced some kind of code here. Let's go take a look and see what we have. Um, and so here, your customer support agent for exam pro tech uh tech training platform. literally just grab the prompt. I think for me like I would think I would have a knowledge base and tell it how to handle all of these kind of requests. We're not going to build out a a giant support agent. There is actually interest in that. I would make that a separate course. We needed this just to work just good enough for our use case. So always be polite and empathetic. Oh, good. So we're providing uh a state here. It is using agent SDK which is good. It's not using our end dot. So you you you need to load in m dot you keep removing that. So please for thev file please refer to I don't know like does hello world have that I feel like it does right. I don't know why it does that. It drives me crazy. Oh it never did have it. Oh well there you go. There you go. I've been complaining this entire time. It's just not in the example that we're pulling from. And so I'm the problem. I'm the problem, folks. So I'm going to go ahead and I guess I'll just manually grab it here. Actually, I'm just going to tell it to do it. There we go. And so it should just be able to update that there. And we can continue on reading here. So um always be polite. So here are our tools. issue a refund, uh, swap a course, resend confirmation email, uh, create a bug ticket, uh, create a content issue ticket, uh, route a business development, um, process GDPR request. And so here we have our, um, tool calls for those particular things. And so we can run our support agent and have a conversation. Hi, I accidentally purchased a course with the ad solution architect. Um, oh, cool. And so we have that information. We don't have ordered numbers like that, but let's go ahead and um see if it works now. And it should have added in that env. So we'll go ahead and type in python main.py. And here we have unexpected tool handler. I'm not sure why we'd be having that problem. Uh I guess it just made something up. So, we'll go ahead here and go back to Claude and we're using Sauna, right? We're trying to keep our costs down here. If we used Opus, it probably would work, but u you know, let's you know, be able to get through this course, right, with actually stuff. Okay, so let it adjust that fix that problem. Okay, so it did a lot more than what I asked it to do, but says fix the cloud uh cloud agent SDK. And now we have a tool loop. Good. Let's go ahead and try run this and see what happens. Oh my goodness. This thing is just not implementing anything correct here today. There we go. And so here we're having a bit of back and forth here. So hi, I accidentally purchased this course. I'm happy to help you swap your course. Let uh you get the course ID. And so here I need your information. However, I need specific course IDs for both uh to complete. could you provide them? Uh, these are typically the found courses, etc., etc. So, what I'm going to do here is I want to change this so that it's actually a loop. So, I'm going to go back over here um make the agent a real uh loop I can talk to in um when I run it when I run it. Okay, because that right now it's like hardcoded, right? These values and we don't want that. So we actually want to interact with this and so we will ask it to do that and then we will look at our next versions. Okay, let's take a look here. The agent is now in interactive loop. Uh we have messages, run, turn, etc. And so now what we can do is kind of drive our interest and see what it can do. Oops. Oops. Oops. Oops. Oops. We actually want to run it. Okay. So we'll go ahead and run this. And so say uh I want a refund for the CLF CO2 I purchased. Okay. And so see what it does here. So, it goes, okay, I'm happy to help with a refund. I need a few pieces. So, this would be andrewample.com. Uh, order order one two three4. Um, I don't need I uh didn't use the course. Okay. So, we'll go ahead and do this. I'm not sure why it's double repeating here. That's kind of annoying here. So, perfect. Uh, your refund will be processed successfully. Here are the details, etc. So there's an example of it understanding. Um and so if we go over to here, let's take a look here. Um and so we have customer requests for a human policy exception gaps and ability to make meaningful progress. Meaning like um there isn't an option to talk to a person. So imagine you're trying to talk to a person. Let's say can I can I talk to a human? Unfortunately, I don't have a direct transfer function available in my current system. And so um the thing is like with these systems you generally want them to follow some kind of structure before there's an escalation. So maybe what we should be making is some kind of uh graph or diagram in terms of what it is that should escalate it. So, I'm going to go back over here and we'll say, you know, I want to show I want to have uh a system where uh through progressive escalation escalation um they can uh be turned over to a human. um how can we map out uh that step or flow and feed it into the agent? And I would think like like is there a state machine a simple state machine? So, you know, like what we could do is tell the the prompt like what the state machine is and then have it update it. That' probably be the easiest way to do it. Um that's what I would do, but let's just see what it comes up with here. Um because once we've defined defined like a flow or steps that it should follow to get to those desired states then uh we can see here. So here yeah it's putting it right in it into the thing. Bot handling escalation trigger human Q human active resolved right. So customer explicitly asks for human AI can't resolve it after turns. AI decides it's out of scope. Uh certain issues um auto escalate. So GDPR requests legal how it feeds into the agent. So add escalation to tools. Um so now it has a tool for that track the state and count in the session context. And so we will take a look and see what that looks like. There's obviously like many ways that we could implement this. So I'm not saying like this is how I would actually do it. But like if it works in this one case to for our understanding that that will be good enough. So we'll go over here to support agent. Let's take a look at what we have here. So, we have this, but like I would probably map out state machines for all of these things. This is probably what I would do. Um, so what I'm looking for here, so here we have GDPR request wrote business development. Sure, sure. Sure, sure, sure. Um, did it add human intervention or is there human? I don't think it did. So, I'm going to close this again. Reopen it. Human. Oh, want me to implement it? It didn't even implement it. Yes, I thought it was already there. So, we'll we'll hang on and see what we get. Okay. All right. So, now we should have a loop. Let's take a look here um and see if we can find exactly where this information is. So we'll go all the way to the top here and okay so basically this is our um escalation state. So we have some state here and then we have a session context. So how many turns the reason the messaging which is fine and it's current state. So bot handling escalation triggered human Q human act active resolved. Um so that's fine like we can try this but how do we trigger it? So you must call the escalation to human tool with any of the followings are true. The customer explicitly asked to speak to a human. Uh this involves a legal threat, fraud claim or dispute. The customer expresses extreme frustration. You cannot resolve the issue after two three attempts. You the request fails. So we'll go ahead here. When they say request a human, but we technically don't want that to happen. So, so we could go in here and say um the thing is like we wouldn't always so do not attempt to handle the situation clearly that requires human judgment. Right? So, um, if the customer, so I'll just take that one line out because I really want it to, you know, attempt its best effort. So, try, you know, if it doesn't, Ah, we won't even put that in there. But, like, you know what I'm trying to say? Like, you know, if if you can try to not bother the humans, right? Unless really absolutely needing to, right? Um so we'll go ahead and we will run this here. We'll say uh I I am having problems uh with my CLF CO CO2 count source. Okay. Uh I want a refund. I say Andrew.com. No, I need that information now. So now I'm being rude. Look, I told you now. And so here it it transferred to human. So there you go. So you can kind of see how that works and customers extremely frustrated demanding immediate refund for the CLF CO2 course customers having providing email for that information. I guess I didn't really write in the plan like what these uh iterations were. Um but the idea was to I guess I should have done a better job with that. But if you're following along it's it's not that big of a deal. Let's go back over to our um uh exam guy here and just take a look and see if we are satisfied. So we have appropriate escalation triggers. Customer requests a human, right? The distinction between escalating immediately when a customer explicitly demands it versus offering to resolve when the issue is straightforward. So you'll notice that like it was staying on track. I mean really wouldn't be hard for us to do that. But I think again to make this really good, we would have to expand um all of these uh all of these options and really make a state machine for all of them because that's usually how the systems works is that if you know if you can keep them in that system, it's going to save humans time. I'm not saying it's good. I don't obviously don't like that, but I'm just saying like if we're engineering based on what they are saying here. Um why sentiment based escalation and self-reported confidence scores are unreliable proxies for actual complexity use case. So sentiment sentiment based escalation means like are they mad? Why wouldn't that work? It obviously worked right there. So adding explicit escalation criteria with few shot examples. So here it wants us to add examples to give an idea. Honoring explicit customer requests for human agents immediately without first attempting investigation. I mean it would have done that if we had that line there to begin with. Acknowledging frustration while offering a solution when the issue is with the agents capability escalating when the policy is ambiguous or silent or the customer uh requests instructions the agents to ask for uh additional identifiers with the tools. So it's already kind of doing some of these things and basically they've given us the list. I like I don't I'm not usually pulling from the exam guide like this, but I think in this case we would just go here and say like um uh like implement implementation list to-dos. Okay. And so we'll go over to here. Really it's that it's that simple. We'll say plan uh please implement the to-dos. Okay. and we'll come back here and just look at what it's changed in the code. But again, like you know, if we're doing this for real, and again, I just don't want to make a three-hour course here. You folks are going to yell at me because you want to pass your exam here. But I would make state machines for each of these things and test them and do a bunch of other stuff. But for this case, we're just trying to cement this information here. But this seems pretty evident. The only thing I'm not I'm not clear about is like why sentiment based escalation and self-report confidence are unreliable proxies for actual use case complexity. I guess if something was very very complex then it doesn't work and then you'd have to offload to a human. Um so maybe that's what they're trying to say there. It's not exactly clear but I think we got questions we would be able to handle them. We'll wait a moment here. Okay. Okay. So um it's now updated that code. Let's take a look and see. I uh it's probably just mostly going to be in the prompt here. Wow, that's large. So here um that's a saying be polite multiple matches ask for clarification. So if a tool returns multiple matching records uh let's add the word wrap here so we can actually read it. If a if a tool returns multiple matching records do not guess or pick. That's actually smart. Ask the customer for additional information. Uh multiple orders found for janeample.com. I found two orders on your account. Another thing that's like, you know, where's the source coming from? So, if somebody's asking you like, how do you know you're not just grabbing information for a just like someone's just trying to trick the bot, right? But if you're logged into the account, I feel like if it's within your platform, you already have that data. Handling customer frustrations. When a customer expresses frustration or dissatisfaction but does not explicitly ask for human, acknowledge the frustration and offer to resolve the issue. Only escalate if necessary. Oh, so they have some examples. Okay, good. um explicit human requests, no frustration context. So if a customer uh very first messages uh and they want to speak to human, call it right away, right? Obviously there are some systems that are evil that want to push this off. Right? A policy ambiguity. Escalate rather than improvise. If a customer request is not covered by your defined capabilities or fails in a gray area, uh escalate to a human rather than guessing or improvising. Okay, good. competitor price match. I saw this course. Can you uh match that price? I have two exampro accounts. I want to merge them. The course is listed at 49 on the site, but was charged 79. Actually, that's a good example. Sometimes that happens. I don't know. Like that's not the prices, but that's an example of where maybe the coupon did not apply. So, escalate immediately. Offer resolution first. Um resolve at autonomously. and we will go ahead and try this out. So, that's pretty good. Um, but again, I would do more with the state machine if it was me. So, say, um, I want a refund. Uh, we'll say andrewpro.com. Uh I it's for the CLF CO2 I don't have the other information. Um so here I don't know let me connect with human support. Okay, great. And so there it did and it it transferred it to a human. So that it's pretty pretty good I would say um for what we have there. The only thing that that doesn't really help is that sent sentiment uh information. Um but I think generally you know the the key thing is like make sure the customer is not frustrated. But we will um continue on we'll continue on with other stuff but I think our support agent solves uh the things we're trying to uh go for. Okay.

Generated algorithmically for Search Engine Indexing.

Summarize Another Video