-: So we talked about the Planning Tool
or To-Do List tool,
and let's talk about another characteristic;
and this is the Sub Agents capability.
So Deep Agents employ the idea of Sub Agents,
which are going to enable us have something
which is called hierarchical delegation.
And this means the Deep Agent itself
can spawn and create new instances of itself,
but those instances are going to be specialized Sub Agents
for focused tasks.
So each Sub Agent is going to be holding
its different system prompt, its own description,
its different set of tools it can use.
And this is actually quite genius I have to say,
because this is exactly like we have in real-life.
Whenever we don't feel like doing something
and we want to delegate a task to another,
then we need to make sure that the other person,
he has the correct skills and the correct tools
to achieve that tasks.
But not only that,
we need to know how to explain to that person what to do.
And let me give you an example from the real-world.
So I personally am not a handyman,
I have no craftsmanship,
and I don't know how to drill a hole in the wall,
and I'm really, really bad at this stuff.
And I've had a really annoying issue in my house
where I have this kind of hatch in the ceiling
of my top floor,
and every time it rains,
then what happens is that the rain hits this hatch,
and it's covered with fiberglass or some kind of material,
and it makes a lot of noise.
And when it's pouring raining,
it's really, really noisy
and it echoes through the entire house,
so I really needed to handle this.
And in order to fix it, I bought some synthetic grass
to simply put over the fiberglass,
so that when the rain drops,
it's not going to hit the fiberglass,
it's going to drop on the synthetic grass,
and then it's going to be much less noise.
And the ceiling is pretty high,
and in order to get up to the roof,
you need to have this kind of special ladder
where it needs to open diagonally,
and you can then climb to the roof
and then assemble this piece of synthetic grass.
Anyways, I don't have the skills even to do it.
So what I did is call my father-in-law
who is really good at this stuff.
And he went in with his own tools, he has a box cutter,
which he used to cut the synthetic grass
into the right size,
and he used his own ladder to climb to the ceiling
and to do all of this.
And I think the analogy of a Sub Agent
is really appropriate here
because I had a message that I wrote to him
that I needed help with doing this task.
I described the task, and then he came with his own tools,
and his own "system prompt," which is his skills,
and he knows how to do these things.
He went and did it,
I wasn't even there when he did it,
because he had a key to the house.
And finally the result was I went and everything was fixed.
And when it rains now,
it doesn't echo through my entire home.
And this is really similar to how Sub Agents work.
Now, I want to add on top of that,
that while he was working, I had no idea what's happening.
So as far as context, he was working in context isolation.
I didn't know what was happening,
and I just got the final result.
So let's go back to the discussion on Sub Agents.
The Sub Agents, they're going to do isolated work,
so this means they're going to run
in their own context window
without polluting the main agent's context window,
and they're going to be specialized.
So they can have their own system prompt, their own tools,
which can differ from one Sub Agent to another.
And this gives us the capability to scale our work
and to actually get more quality work
with specialized agents here.
So those Sub Agents are going to execute
on their own tool calling loops,
their own react loops internally,
and they're going to return back only the final response
without those intermediate results.
So this delegation pattern
helps us achieve this context isolation.
And preventing this specialized work
from polluting the main agent's attention,
it's going to enable parallel execution of tasks,
and this is going to dramatically improve the quality
and efficiency and the depth of the results
we can get from our agent.
And let's go back to an example, more techy with cloud code.
And here you can see that cloud code
has found an exploration agent,
which is going to find us authentication patterns,
and it's going to do some searching,
and it's going to run while the main agent is running
as well here.
So the point here is that cloud code
is implementing this kind of architecture as well,
and he has this capability support for Sub Agents,
which is super powerful and super useful.
Now, a quick disclaimer over here.
I know that by now I've been very theoretical,
I've been waving my hands,
and I've only been talking about concepts,
not about implementation.
So, don't worry,
I promise you the implementation part will come,
and we'll see exactly how we can go and implement
all these kinds of beautiful magic here.
But I just want to continue and review the concepts
and the interface
and how those capabilities of Deep Agents are looking
in our day-to-day lives with the common tools
that we use here.
So the implementation part will come soon.
And in the next video,
I want to dive deeper into the context flow
when using Sub Agents,
and I want to show you how using Sub Agents
is going to prevent us from bloating our context
and achieve context isolation,
and eventually better results.