transcribe

Claude Code Agents: Delegate Research Automatically

Joe Rhew · 14m · transcribed May 2026
More from Joe Rhew Business
𝕏 Share ▶ YouTube 📥 PDF 🤖 .md

Transcript

0:00 All right. Today we're going to talk about agents. And when we talk about agents, it's really just sub agents. So what is a sub agent in cloud code? It's um it's a markdown file just like skills. And we covered skills in our previous video. Um but it and it similar to skills. It gives sort of a guideline instruction on what they're supposed to do. But the um the main difference is that the agent the sub agent does not take up the main agents context window.

0:35 So first of all let's clarify what is a main agent? What is the agent slash the the sub agent? The agent is the the default cloud code agent that you talk to when you first fire up a cloud code session. Right? that agent can delegate its work to a sub agent which means that the cloud code agent the main agent calls a sub agent and is able to say hey do this work right uh the benefit that you get from doing that is that the main agent has its own context window and I've pulled up this context window by typing in slashcontext I'll show it to you again and you can see visually the context window right here there's 200,000 tokens that are available uh and then 45,000 is taken already and if I was to continue doing this work uh inside of the agent this context window would start getting taken up with the messages history right and this is what eventually leads to a full uh filled up uh context window and then you have to compact or restart the um the sub agent has its own context window so that's both a pro and a con so um the benefit of having a separate context window is that it doesn't uh it uses own its own context window and doesn't clutter up or pollute the uh the main agent context window. The downside of that is it might not have all of the context that it needs to do all this work. There's a clear separation and that's by design and so not every task that you currently do with the with the main agent makes sense to delegate to the sub agent. And I'll show you an example of what might make sense, right?

2:16 And so in the previous video, we created a skill where we do an account research. So I say, "Okay, conduct a comprehensive account research." Uh, and I'll give you the URL, right? And once I give you the URL, uh, and the company name. There we go. Company name and the URL. Um, you provide, you do all of this work. You do a bunch of research. You look up their uh, leadership. You look up their product positioning, recent news, blah blah blah. And then you return the research, right? What I've done here is create the exact same um account research skill but replicated that in a pro in an agent uh format. And the way I did that is very simple. You just go slash agent agents and then you can actually just um create create new agent right here. Um, and if you click on it, you can say, do you want it saved at a project level, so only just in this repo, or uh at a personal level, which means I can use this agent across all of my projects.

3:18 Uh, and I'll say just this specific project, and I can actually generate with Claude, which is recommended. So Claude kind of uh reads your prompt and then generates a full-fledged um agent file based on that, right? And that basically what I told it was you know uh read the account research skill and replicate that skill in an agent form. That's basically what I did and this is the result of it. It's as easy as that. But what I'm going to do is actually show you um why it might make sense to create agents in certain cases but in most cases it doesn't right. Um, so what I can do here is I'm going to actually say, there we go. Use the account research skill on the following URLs. And I will, so this one to clarify is using the skill because I want to show you how it eats up the context window already.

4:14 This was the context window. It started at 54%. I don't know if you noticed it, but now it's at 46. Now it's at 44%. and it's going down as uh the main agent is reading all of this, right? So, I'll fire up a claude session here and I'm going to say use the account research not skill agent on the following URLs. And you will see that the CTX the context will start at 50ome percent. Uh 56% and it'll go through and sort of show you what it looks like. Um this is going to take forever. So uh I'll walk you through a few other things while we're waiting on this. Right. the uh the first thing is there's like a pattern that you um that I use uh for agents and I think this is sort of a best practice because I definitely did not come up with it. I learned it from someone else. um where when you're using sub aents always tell them to give the final output in a file like save the final output in a file because if you don't specify sort of the handoff between the main agent and the sub agent right so the main agent says sub aent go do x y and z tasks and the sub agent goes and does that and then if they don't know what they're supposed to do with the final output of their work they will dump everything back to the main agent and the main agent's context window will get cluttered with all of the work that the sub agent did, right?

5:45 And so if you look here, I say critical output requirement read first before you do anything else. You must save to a file, not return a response to conserve context window um space. Write your full research report to file and then to the main agent return only a three to five sentence summary and that's it. Right? This way this context window is preserved uh and I can do a bunch of other stuff. Often times if you want to look at is this company uh that I'm looking at targeting like enterprise or is it targeting more of a like free trial selferve PLG motion right? Are they doing that? Well, one way to tell is like read the CTA button, right?

6:33 Every landing page will have some sort of CTA button that says like start now, uh, do a free trial or like book a demo, uh, talk to our team or something like that, right? Well, if it's like talk to our team or, you know, book a demo, you know that it's more of an enterprise motion. Whereas, if it says start uh start a free trial, no cards required or whatever, you know that it's PLG. And that might be relevant for you. But in order to get that information, you actually have to go send an agent to fetch the entire content of the landing page, right? Um, and then from there, the agent can find, oh, this is the main CTA button. Oh, this is what it says, right? So, you can create a sub agent to basically go and and scrape the entire content of a website of maybe your target account. Uh, and to determine whether they're a good fit for you or not by seeing if they're enterprise or PLG, you can say throw everything away and only return the text of the um of the CTA button. Right? So that would be like an example of where there's a lot of this context that has to first be consumed by the sub agent and the sub aent finds a relevant uh bit of information which is usually quite small and then only returns that to the agent and it's kind of similar I mean to a larger extent this is what we're doing right account research if you if you read this um what they're actually doing they're doing company overview they're doing business model uh organizational structure technology landscape. So they're doing all of this stuff which means that they're actually um accumulating a ton of context in terms of raw research and then um they're aggregating all of that and synthesizing it and summarizing it into uh a more compact research report. Right? And even then I'm giving it specific instructions to not return that whole report to the main agent but instead to save it as a file and then only give a three to five bullet summary. And so this is really useful if um if you're doing um like a hundred of these or whatever, right? The other thing that I'll also mention is that um you're with uh agents, you can run them in parallel. So I didn't Oh, I did say no, I didn't say that, right? I didn't actually say use the account research on the following. I just said on the following URLs, but uh Claude knew to run it in parallel, right? So it's like predisposed to run things in parallel to save you time.

9:05 Um and so it runs it in parallel. Uh and it'll return everything when um when the research is done. What's also nice is you can see here it says controlB to run in background. So I could actually press controlB here and then um now everything is just running in background tasks which is kind of cool. Um, so see here I've spun up three account research agents and they're still running in the background, but I can talk to the main agent now. Whereas here I can't really talk to uh the agent because the agent the main agent is the is the entity that's doing the work, right? They're busy doing something else. So I can't be like, you know, go do something else, right?

9:51 Um, but what I have noticed in my testing is that just because they're running in parallel doesn't actually mean that it's faster. In fact, if you see uh here with using a skill instead of an a sub agent, this is already done, right? And look, uh, context is at 18%. Right? So, we started at 56% and it used up around 40% of its context just researching these things right here.

10:26 And with the agent, you can see that the context is still 54% and it's it has three background tasks that are running. Once it completes, you'll see that the context um is going to stay around 54%. Now, the agent tasks just completed and you can see that the context remains at 54%. I think I said at the um when we first started it was it started at 56% so it only took 2% of the context. So if you if I show you the context um visualization again, you can see that uh messages only 6,000 tokens despite the fact that um if I show you the um the the reports, right? Like it's literally um major announcements. It's like 7 800 p uh lines of research and all of these things that it went and visited and read, right? All of these sources. Um and yet it only took up 3%. If I show you here, wait, you can see context. Yeah, you can see all these purple discs. Uh and you can see messages uh that took up 38.4 4%.

11:43 Right? So, um, now you might have an instance where you still want to do this like context rich, context heavy, uh, research inside the main agent because maybe you're developing a skill and you want to iterate and give it feedback in which case you know this is the right direction. Uh, but otherwise, you know, offloading it to an to a sub agent might make a lot of sense. That said, I almost uh like never use agents really because I find that skills are often good enough. But if there is this like very targeted use case of uh tons of tokens uh being generated and I only need uh a very summarized version of that or whatever, um then I'll probably use uh I'll probably use an agent. Um, now I think we've seen a lot of changes with both agents and with the launch of Skills.

12:42 Um, I do think they're going to continue to serve like two different purposes and they'll probably diverge even further. So, you know, this is February 2026. Uh we'll see how things change and you know I might update this video at some point if uh I find other really good use cases for agents but for the time being um that is you know context heavy uh tasks where uh it's not dependent on the main context window and it can be scoped explicitly um is a really good use case for agents otherwise I would lean towards just using skills Cool. Um that is all for uh agents. If you want to learn more, there is a whole uh page on how to create custom agents. And first is isolate high volume operations, which is what we've been talking about a lot. Uh run parallel research, yes, but at the same time, uh I found that it's a lot slower. So, if you're trying to save on time, that's not necessarily the right um that's not a benefit. Um chain sub agents I think is something that is interesting that I haven't explored enough uh to be honest with you. So, that can be something pretty cool. But, and then they have a pretty good framework in terms of like agents, sub agents versus main conversation. Uh and a main conversation, you can obviously bring skills into it. Uh so, yeah. And then like the this is like the 101 stuff, but like the 2011 stuff, you could actually create um a skill that can be forked to an agent, right? Uh so you can you can create a skill that um an agent can use or you can create an agent and then give it specific skills that it can use for example. So you can like combine those two. Uh and now you know we're talking about sort of more advanced cloth code.

14:39 uh uh usage patterns. Uh and maybe we'll save that for another time. Okay. All right. Well, thanks for watching.

Summary

The video discusses the concept of sub agents in cloud code, highlighting their role in delegating tasks from a main agent without consuming its context window. Sub agents are markdown files that provide guidelines for specific tasks, allowing for efficient management of context and output.

- Sub agents are distinct from main agents and do not occupy the main agent's context window.
- Main agents can delegate tasks to sub agents, which have their own context windows, preventing clutter.
- A best practice is to instruct sub agents to save their output to a file rather than returning it directly to the main agent, preserving context.
- Sub agents can run tasks in parallel, but this does not always lead to faster completion times.
- The video emphasizes that while sub agents can be useful for context-heavy tasks, skills often suffice for many applications.
- Future developments may further differentiate the roles of agents and skills in cloud code.
- Users can create skills that can be utilized by agents, allowing for more complex interactions.
© transcribe · For agents Built with care and craft by Gokul Rajaram