AI Agents Run While I Sleep /loop (Claude Code Scheduled Tasks)
채널: Artem Zhutov 링크: https://www.youtube.com/watch?v=fOpFgjH8IfQ
트랜스크립트
[0:00]
[0:00] Anthropic just shipped a schedule task [0:02] for cloud code and Twitter is calling it [0:05] chron jobs for AI and some people are [0:07] saying cloud code just killed open [0:09] cloud. So what's going on? I have set up [0:12] a three agents in my obsidian vault and [0:15] I have those sub agents and I have [0:18] interval when they're going to fire and [0:21] let's take example here. That's my [0:23] accountability check. It's asking me [0:25] about okay so every 30 minutes I'm on [0:28] track on my goals. That's one example. [0:30] Another one is executive coach. And the [0:32] final one is a source monitor. I have [0:35] them here in my terminal in this [0:37] workspace. Auto all. And here's my [0:40] executive coach checking on me, asking [0:42] me questions. When did you fel today [0:45] every 3 hours? And then here's our [0:47] source monitor which is getting the [0:50] information from Reddit threads and my [0:52] YouTube home feed every 8 hours. And [0:56] another agent is accountability agent [0:59] which asks me about okay so what are you [1:02] doing and actually I've been [1:03] procrastinating on that. [laughter] [1:06] So it's still looking that I am editing [1:09] my slides for this video and saying okay [1:12] just just hit that just record it and [1:14] here we are. Let's try to understand how [1:16] you can set this up those automations [1:18] yourself and that's what you're going to [1:20] get by the end of this video. We're [1:22] going to understand so what's the [1:23] difference now with both schedule tasks [1:26] we're going to set up the Reddit [1:28] automation we're going to stop [1:30] accountability check and executive coach [1:32] and also the limitations of this [1:35] approach all right so let's start so how [1:37] how can we set this up to set this up uh [1:40] we're going to use this loop command in [1:42] clo code let me open my clo code right [1:45] now I'm on my terminal I go to the clo [1:49] code and by the way this is also [1:52] available on desktop version. Okay. Um [1:55] here is a loop. Let's say here's a loop [1:58] command and here's a description. Run a [2:00] prompt or a slash command on recurring [2:02] interval. And here is a helper for us. [2:05] What is the interval you want to run? [2:07] And then there is a prompt and let's say [2:10] uh okay so you want to get there and [2:12] let's say um loop. So every 30 minutes I [2:16] want to read my day plan for today my [2:19] daily note and check with me if I am on [2:22] track and if I don't have anything in my [2:25] daily plan for today ask me what is the [2:28] goal right now clot I'm going to use [2:31] this skill called loop this is available [2:35] by default I didn't create a skill it [2:38] comes with a clo code and now it's [2:41] parsing that okay every 30 minutes so [2:44] interval is 30 [2:45] And then it's scheduled a chrome job for [2:49] us. Basically a script which going to [2:52] run inside of this session with all of [2:54] the context which we have here and then [2:58] it's going to fire every 30 minutes and [3:00] it's going to read my day plan and day [3:02] node and check if I'm on track. Let's [3:05] actually test it. I want to just fire [3:07] this now to see how it's going to [3:09] behave. So let's let's try to fire this. [3:12] Okay. So now it's going to fire it [3:13] manually. So we're just going to go and [3:15] explore what are my daily notes for [3:18] today. So the daily note is not on this [3:22] path. So it figures this out. Oh, are [3:25] you on track for the demo day? So I had [3:27] like u two plans for today. Um and it's [3:31] asking me about okay so what's happening [3:34] right? So I want to show how it works. [3:36] So let's actually create a new daily [3:38] note u in a daily folder and open it in [3:41] my obsidian in a new tab. And then let's [3:44] say my goal for today is to publish this [3:47] video and just you know relax a bit um [3:50] at the end of the day it's um Saturday. [3:53] Okay. So here is my daily note template [3:56] which has been created and it's quite [3:59] extensive um and let's say here is my [4:02] today goal which wrote so I want to try [4:06] to see how how you going to behave. So [4:08] try to sketch like run this and u I want [4:12] to see how how it's going to look like [4:14] and here's a simulation how it's going [4:16] to look like in 30 minutes. Um let's say [4:20] okay publish um schedule task video then [4:23] relax that's a goal and then it asking [4:26] about okay am I on track um where are [4:29] you in the process and so on and it's [4:31] going to run it within this session now [4:34] and this is what makes this all powerful [4:36] that we have this agent which has access [4:39] to all of our skills to all of our MCP [4:42] tools and connections to all of our [4:44] context within Obsidian. it can reason, [4:47] it can understand, it can debug and [4:50] adapt at at the next run. And here is [4:53] the point that right it's um running [4:57] with all of the context. Let's say I [4:59] have those automations set up right
[5:00]
[5:02] here. I can see what's going on here and [5:07] the agent remembers what was the [5:09] previous interactions before and it has [5:12] all the context. And another thing which [5:15] excites me that I can actually go here [5:19] and if I something if I don't like [5:21] something I can just tell okay so let's [5:23] change this skill and make it in a bit [5:26] different way and that's how I went [5:27] about this source monitor um that's a [5:32] Reddit and YouTube check let me show you [5:35] what it's doing for me so I have this [5:38] daily not um and we agreed with cloud so [5:42] we're going to run this automation. So [5:45] how this automations right here it's [5:47] called um source monitor. I can go there [5:51] and it tells clot okay so check my [5:55] sources for the relevant content about [5:57] clot code. Yeah agents obsidian or scan [6:00] those um those Reddits using the Reddit [6:04] red skill and then also check my YouTube [6:08] home feed. Okay. So and do that for each [6:11] source extract uh the most interesting [6:14] items and then try to notify me once we [6:19] are done and the way we did it on the [6:21] first iteration this is what cloud [6:24] produced so it produced this u sources [6:27] with a ready threads you can click there [6:30] so it opens um Reddit thread but I [6:35] didn't like that it uh actually didn't [6:37] read the comments and understand what [6:39] what's happening [6:40] And here is just u YouTube videos with [6:43] no links with no summary. So this one I [6:46] didn't like. And then we went about [6:48] doing another iteration within the same [6:51] session. And here is a iteration two. [6:55] Here's actually okay. Actually clude [6:58] read all of the comments at extracted [7:01] you know what is the community thinks [7:03] about that. And here also for the [7:05] obsidian uh separated all of those uh [7:09] different posts with activity. Now I can [7:13] go there and click and engage with the [7:16] material which matters to me. So I don't [7:19] have to scroll Reddit or YouTube on my [7:21] own. My agents can just okay go ahead [7:25] and extract what only matters to me and [7:28] what will be interesting for me. I don't [7:30] have to go to those YouTube home feed to [7:33] Reddit now just um huge and log as you [7:36] can see now I'm also interested in the [7:38] immigration I can check okay so what's [7:40] going on with uh immigration to Canada [7:43] um there's some problems [7:46] and also for the YouTube uh this is like [7:49] amazing just imagine that okay cloth [7:54] went um and search for the recent videos [7:57] about you know cloth code and That's [7:59] interview with Boris Churnney. Uh here [8:02] is actual video. So it went about [8:05] getting the transcript and giving me a [8:08] summary. So what matters and here are [8:11] some big takeaways from the actual [8:15] source. You know the Boris runs five [8:17] terminal tabs um and so on. And here is [8:21] some analysis. Yeah. And you can just [8:24] make it your own. You can make your own [8:27] daily digest without going to those you [8:29] know different websites just huge log [8:33] and that was a prompt which we did with [8:36] clo that's it I told okay use my radius [8:39] skill and use my YouTube skill to [8:42] accomplish this and that's how it looks [8:44] like in terminal let me just like okay [8:46] let me just go about um going full [8:49] screen right here so I like it more so [8:52] that's a source monitor so we but we [8:55] kind of did is um okay um we set up this [9:00] automation and then claude went about [9:02] exploring what's going on it appended to [9:06] my daily note the first results and then [9:08] I told that I want to have exact links I [9:11] want to have uh you know uh add this uh [9:15] subreddit into my monitoring and then [9:18] you run it again so this way you can [9:20] like u if you are not satisfied with the [9:23] results you can just Okay, tell let's [9:25] change that and let it rerun and I can [9:28] trigger this job um whenever I want. I [9:32] can tell. Okay, so let's do this right [9:35] now. So let's take this now. Okay, it [9:38] reads this source monitor. So it [9:41] actually uh updated the skill right now [9:44] because I asked it to to update before [9:46] but it didn't and now it actually [9:48] updates it and it reruns it uh right [9:50] now. So in this way you can see that if [9:53] you don't like something you can change [9:54] it right away and and run it right away. [9:58] So here is just just start this
[10:00]
[10:00] background agent. Yeah. So that's been [10:03] um this part uh for the source monitor [10:07] skill. Yeah. And by the way if you're [10:09] interested in those skills so you can [10:11] grab them here. So link in the [10:13] description. So it has the source [10:15] monitor for scanning Reddit and YouTube [10:18] and save it into your wall. It also has [10:20] this accountability check which I'm [10:21] going to show next and executive coach [10:24] and it's a scale pattern which you can [10:26] apply for different other areas which [10:29] are interested to you. The next one is [10:31] accountability check. So in this one is [10:34] um the one that helps me to stay on [10:37] track. Every 30 minutes it fires this [10:40] automation to see if I'm on track if I'm [10:43] on track with um what I plan to do uh [10:47] throughout my day. Typically what [10:49] happens I start working on something and [10:50] then okay one like two hours later I'm I [10:53] don't know what's happening and how I [10:55] ended up here in the current situation. [10:57] This is very very helpful um for people [11:01] who might have you know like [11:03] multitasking and they're quickly [11:04] deviating away from from the goal. [11:07] That's how it looks like. Um that's the [11:10] accountability check one. It's um [11:13] actually uh quite cool. Uh so it reminds [11:18] me that okay you have a limited time in [11:21] your life and every 30 minutes matters [11:23] so and check in with me so what am I [11:25] doing right now so read my today plan [11:28] for my daily not yeah it asks a hard [11:31] question you know um isn't the thing [11:34] that the matters the most right now or [11:36] how many like 30 minutes blocks do you [11:38] have left today and then in the end it [11:41] notifies me uh so you can see that life [11:45] I think here There is a terminal um [11:48] right here. That's accountability check. [11:50] So you can see that it was um actually [11:53] firing firing those jobs uh at at 12 uh [11:57] 12 p.m. today. So I was not answering [12:00] because I was busy. And now we can try [12:02] to see um let's say okay go check on me. [12:08] So we can uh try try to see how how it's [12:10] going to look like. So right now it [12:12] checks what's the current date right [12:14] now. So then it fires this notification. [12:17] It should appear here, I believe. Um, [12:21] okay. So, no notifications. Yeah, [12:24] notification didn't fire. But now, uh, [12:28] [laughter] [12:29] you're telling me you're reading on the [12:31] build automation file instead of [12:33] recording. Um, [12:38] yes. So, it's prompting me to to record. [12:41] Um, I am recording. go chill. Yeah. So [12:46] you can see how it can be very very [12:48] useful so to stay on track. So this is [12:51] especially useful if you're sit and [12:54] think for 15 minutes at the start of [12:56] your day. So what you want to accomplish [12:58] and then you fire this agent and tell [13:00] okay so let's go. Let's stay on track. [13:04] So that was accountability check. And I [13:07] also have this um executive coach and I [13:12] use this Dancoy framework for uh six [13:15] interrupts throughout my day. So that's [13:17] the resource. Um so let let me show you [13:22] um how it looks like. So for this [13:24] executive coach is basically runs every [13:26] 3 hours. It tries to ask me like these [13:30] questions to interrupt the patterns [13:32] which um I live throughout my life. Um [13:36] and those are questions really really [13:37] hard. So am I moving towards the life I [13:40] ahead or the life I want and those [13:42] questions are really refreshing if [13:44] you're throughout your day and you're [13:46] you know just um into the task and you [13:49] try to think oh is it really matters [13:52] like the most important thing to do [13:53] right now. So I would say there's [13:55] overlap between this 30 minutes uh [13:57] checkin and this executive coach but I [13:59] think the scope is a bit different. I [14:01] think this executive co is something [14:03] like which enables this like broad broad [14:06] uh perspective on what's going on. So [14:09] and I highly recommend this article from [14:11] Dan Koy. So I think it's was right here. [14:15] Um yeah so how to fix your life in in [14:18] one day. So it's it's a good read. So [14:20] and it basically extracted like those [14:22] questions uh from this framework. Yeah. [14:26] So here are the questions. Um so [14:29] regarding the throughout the day um this [14:32] interrupting autopilot and those [14:34] questions are supposed to interrupt the [14:37] patterns and they should be you know [14:38] like just random and here like those [14:41] questions which I just like imported [14:43] into my obsidian and set up this agent [14:46] for me and then at the end of the day [14:48] you perform this uh inside synthesis [14:52] um and you kind of reflect okay so [14:54] what's happening right so and then [14:56] regarding the notification So I think [14:58] it's very like useful to add some
[15:00]
[15:00] observability. So when do I need to [15:03] check up on my agent and essentially [15:06] this is done by those u notifications [15:09] which you can set up and then I tell uh [15:12] when I have this automation called [15:15] executive coach I tell it to run this [15:17] this command to display to notify me [15:20] basically that uh this session requires [15:23] some action with executive coach. So I [15:26] think let's see if it's going to work [15:28] right now. Yeah, I think it doesn't work [15:30] because I'm do not distraction mode. But [15:33] that's the way you set up those uh [15:35] notifications. So also one thing which [15:38] was huge unlock for me is to um set up [15:42] this terminal. So I have this like [15:45] terminal with with a bunch of um you [15:49] know tabs and it's has those workspaces. [15:53] if I try to work on something else. So I [15:55] create a new workspace and then I can [15:58] start cloud code session here and it's [16:01] uh it's been very helpful to keep those [16:02] workspaces organized and that's um the [16:06] way I manage my automations. So I have [16:08] this all uh workspace where I have [16:12] terminals running there. So they're all [16:15] together so I can clearly see what's [16:18] happening. The terminal which I'm using [16:20] it's called CMAX. It can actually [16:24] [gasps] [16:25] do a lot of stuff. So if you connect [16:27] cloud code to this uh cmax, if you can [16:30] tell how to like use this terminal, it [16:33] can actually do uh some quite good stuff [16:36] for you. Uh let me u let's say I have [16:40] this orchestrator workspace and I want [16:43] to show how you can set up your [16:45] automation just in in one command. I [16:50] want to set up my automations using Cmax [16:53] skill. I want to create a new workspace. [16:55] Um, so this is for demo purposes. I [16:58] already have a workspace for my [16:59] automations. Just call it in a different [17:02] way. So then I want to spawn all of the [17:05] three automations in a new workspace and [17:10] then rename this workspace as well as [17:12] all the terminals. Now what's going to [17:15] happen right now is that I have this um [17:18] spawn workspace command which can create [17:22] those clock code sessions with those [17:24] automations running. Now it checks on [17:27] which are the workspaces which are [17:28] available right now. It checks all my [17:31] automations and right now it's going to [17:33] set them up in a new workspace. So it [17:37] reads this automation skill right now. [17:41] Okay. And here is a plan. Spawn three [17:43] different workspaces. So we actually [17:45] want a one workspace and spawn uh [17:49] terminals inside of this workspace with [17:51] those um um automations. Okay. So it [17:55] figures out right now it created a new [17:57] workspace. So that's workspace 11 right [18:00] now. So and then it creates those uh [18:03] terminals for me. Right now they're [18:06] ready. So and then it's going to run [18:09] clot code inside of them. So here is the [18:12] cloud code which is running one by one. [18:15] So you can see it's it's working it's [18:17] sending those commands to set up of [18:19] works uh those workspaces and then here [18:22] it's also start um this executive coach [18:25] and then here it's I think it's just [18:27] starting. So this one was accountability [18:31] check and here is a source uh monitor [18:34] for ready and then it renamed all of the [18:37] terminals. Uh that's accountability [18:40] source monitor executive check. So in [18:42] this way I can just spawn my [18:43] automations. Um and there you go. So [18:47] it's kind of did all of this work for me [18:48] so I don't have to do it manually. It [18:50] renamed the workspaces so I can have a [18:52] clear dashboard to see all of my [18:56] different automations and I just like [18:58] stop stop them because I don't want to [19:01] do those. They already running for me in [19:04] this tab. Yeah. So that's been uh like [19:07] how you can manage those agents through [19:09] a terminal and then also we can control [19:13] those automations through the from our [19:16] phone or from a desktop app. So here is [19:20] a um cloud desktop app and I can [19:24] actually [19:25] see here all of my sessions appearing [19:29] right here and that's the one which we [19:32] just run and here we just scheduled this [19:34] job and I can access to those sessions [19:37] from the desktop app as well as the web [19:41] app and my my mobile phone and that's a [19:45] remote control and the key here is to [19:48] turn on in the settings you can go to [19:51] cloud code and uh say remote control and [19:55] then you enable remote control for for [19:56] all of the sessions each session which [19:59] is spawn inside the terminal it becomes
[20:00]
[20:01] um available for remote control and you [20:03] can connect to it through your phone or [20:06] through the desktop app it's the same [20:08] thing now and also not the point that [20:11] okay so what's the difference between [20:12] open claw right so open can actually do [20:17] these tasks [20:18] Um but so what we have here is you have [20:22] like full vault context on every run and [20:25] you can execute skills on the different [20:27] intervals and I feel it was much easier [20:30] for me to manage what's happening [20:32] because I was trying to set up those [20:34] chrome jobs inside of open and it was [20:36] just not great experience. Um everything [20:40] was just uh falling apart. So right now [20:43] I kind of have easier way to debug my [20:45] automations and my agents and also yeah [20:49] you can use this command because [20:52] caffinate uh you can set up it in a such [20:55] way that um your MacBook is going to be [20:58] alive when the lead is closed. So this [21:00] way you can run it um even if it's [21:03] closed. Yeah. And I think that um here [21:08] is the main difference. Here is the main [21:10] difference um how I think about that and [21:13] this is a concept of this self-healing [21:16] agent that [21:18] um so let's say we have some automations [21:21] like on this example of us daily digest [21:24] right where we just pared the resources [21:26] from YouTube from Reddit we then we run [21:29] it and then we didn't like something or [21:33] there was some error so and then what we [21:37] did is we provide a feedback back, [21:39] right? Or agent read the logs of what [21:43] went wrong and then you can based on [21:46] this feedback and based on those logs [21:49] agent goes and edits the code or our [21:52] skill files and then the next run is [21:56] going to produce a better result. This [21:59] way you kind of have this continuous [22:01] loop where you don't actually try to [22:03] design that perfect automation, perfect [22:05] agent from like one go. It's [22:08] continuously evolving and you tune it in [22:10] a way how you want the agent to behave [22:14] and you have this complete flexibility [22:16] in terms of what the agent are capable [22:18] and that makes this very very flexible [22:21] and just exciting you know and here are [22:24] some limitations which I found here are [22:26] some constraints that so those [22:29] automations should be uh those [22:32] automations only work within a session [22:34] and by session what I mean is let's Hey, [22:38] this terminal has the clo code running [22:40] and that's a session that's a one [22:42] session of the cloud code and within [22:44] this cloud code if the session is alive [22:47] is going to work. Now there's another [22:49] limitation that those sessions have a [22:52] 3-day expiry date. So they they auto [22:55] expire and um to avoid this I also set [22:59] up this um in automations base a task [23:02] renewer like every two days to renew [23:04] automation. So they uh get automatically [23:08] rescheduled um and avoiding this uh [23:11] 3-day limit. So it's going to delete the [23:14] old chrome job and then create a new [23:16] chron job. Also the machine must be [23:19] awake. So if your machine is not running [23:20] then okay so it's not going to run right [23:23] and then there might be some issues with [23:25] the token cost. We need to manage u how [23:28] much is actually spent on that. So if [23:31] you're going to have a lot of tasks, you [23:33] can see that. Okay. So it might be not [23:35] that manageable to to have all of them [23:37] running. So here we need here we need to [23:39] be mindful. And here uh here are some [23:42] workarounds about that. So if you if you [23:45] want to make um cloud code session [23:50] persistence persistent uh you can run it [23:53] inside of the uh T-Max and the T-Max is [23:57] a terminal multiplexer [23:59] um or you can just uh set up those [24:02] sessions you know on a MacBook sorry on [24:06] a Mac Mini uh which is always on and [24:09] then it runs those automations for you [24:12] and this solves this like those two [24:14] issues for the session only and for the [24:16] machine being awake and I guess for this [24:18] one for the 3 days expiry we have this [24:20] like workar around that automation which [24:23] uh deletes old jobs and creates a new [24:25] ones and then in terms of token cost so [24:27] we're going to see um so how how it [24:30] actually is it like manageable or not um [24:33] yes and that's been quite quite exciting [24:36] for me to record this video I I'm very [24:38] very keen on exploring this further [24:40] because it seems to be very very [24:42] powerful [24:43] And I really love this concept that you [24:48] have a automation with full context with [24:52] all the skills with all of the claw.md [24:55] rules with all of your tools which makes [24:58] it very very different from what I've [24:59] seen before. Now actually so if you're
[25:00]
[25:02] using cloud desktop you can also set up [25:04] those tasks right there and they're in [25:08] the code cloud code section and they're [25:11] in the schedule section. So and here you [25:14] can create a new task. Um and here is [25:17] the name of the task description and [25:19] then you can select folder you can just [25:21] put your abscian vault um and then [25:24] there's a frequency like manual hourly [25:27] weekly and it's kind of similar [25:29] interface I just found that it's it was [25:32] much easier to do it from the term [25:34] terminal because I don't have to fill [25:36] out any forms. I can just tell okay [25:38] every 30 minutes let's do accountability [25:39] and then it creates this for me. So, [25:42] it's much easier in terminal to manage [25:45] all of these automations. Yeah. And if [25:47] you want to grab the skills, the link in [25:48] the description, it contains source [25:50] monitor, uh, automation, accountability [25:53] check, and executive coach. So, you can [25:55] just set this up in just one go. So, [25:58] link in the description. And thank you [25:59] for stopping by. It's been amazing to [26:01] see you. And I guess until the next