WEBVTT

00:00.400 --> 00:02.480
Okay, now to recap.

00:02.480 --> 00:03.400
What have we done?

00:03.560 --> 00:09.120
We first just used agents to write Python code so that agents could run.

00:09.160 --> 00:13.640
We sort of sneakily used the async gather so that we could run multiple in parallel.

00:13.800 --> 00:18.520
And then we used another agent afterwards to pick the best email.

00:18.640 --> 00:19.600
That was simple.

00:19.800 --> 00:26.280
We then use tools to wrap a function so that we could have an agent that calls a function, and we also

00:26.320 --> 00:32.040
used the as tool construct so that we could wrap other agents to be a tool.

00:32.040 --> 00:36.920
And we provided all of those tools to our sales manager agent.

00:36.920 --> 00:44.560
And we let it call three different email producers and then finally send the email at the end.

00:44.880 --> 00:49.640
So that's that's hopefully connecting for you, making a lot of sense.

00:49.640 --> 00:53.560
There is one more construct that is in some ways really similar.

00:53.560 --> 00:57.960
So it's a bit confusing, but there is a distinction and it's called a handoff.

00:58.520 --> 01:01.230
A hand-off is something that you can give an agent.

01:01.270 --> 01:04.150
An agent has a number of tools, and a number of handoffs.

01:04.270 --> 01:08.110
And handoffs are other agents that it can delegate to.

01:08.390 --> 01:12.950
So in many ways, that sounds really similar to taking an agent and wrapping it as a tool.

01:13.190 --> 01:16.270
An agent as a tool is very similar to a handoff.

01:16.430 --> 01:20.950
There's a kind of conceptual difference and and a very practical difference.

01:21.030 --> 01:27.750
The conceptual difference is that you can you can sort of think of it like there's an agent which either

01:27.750 --> 01:33.630
has just the ability to use tools as part of doing its job, or handoff is when it's delegating.

01:33.630 --> 01:39.670
It's sort of giving giving responsibility and ownership of a specialist task to another agent.

01:39.750 --> 01:42.470
So sort of philosophically, it's a bit of a different mindset.

01:42.510 --> 01:46.710
It's not just just using this as a little feature, a little tool to help with it's job.

01:46.710 --> 01:50.190
It's it's passing an entire job to another agent.

01:50.990 --> 01:54.990
But there's a more sort of fundamental, simple technical difference between them, which is that when

01:54.990 --> 01:58.570
you're using tools, you can think of that more as a request response.

01:58.570 --> 02:04.250
You're calling the tool and control passes back to you, and you continue as the main agent executing

02:04.250 --> 02:05.650
in the case of handoffs.

02:05.690 --> 02:11.010
You've done your piece, and you are now passing control to the other agent, and the flow does not

02:11.010 --> 02:12.610
come back to you again.

02:12.690 --> 02:15.090
It's just a passing of control.

02:15.130 --> 02:18.010
Delegation of control to a different agent.

02:18.250 --> 02:23.090
So that's the difference between agents as tools and handoffs.

02:23.330 --> 02:29.010
And it's, uh, you can you can use either in different situations, but but they are slightly different

02:29.010 --> 02:30.090
constructs.

02:30.290 --> 02:32.130
So I explain that a little bit here.

02:32.490 --> 02:37.850
And now we're going to make a new agent that eventually is going to be a handoff.

02:38.170 --> 02:39.650
So here's the deal.

02:40.250 --> 02:48.330
We are going to start by saying that, uh, you are I want a subject writer agent, something that is

02:48.330 --> 02:53.170
able to write, construct a subject for a given email body.

02:53.330 --> 02:56.480
Because if you noticed, but we didn't have subjects on those emails.

02:56.760 --> 02:59.720
So we're saying you can write subject for a cold email.

02:59.720 --> 03:00.840
When you're given a message.

03:01.000 --> 03:05.760
You need to write a subject for an email that's likely to get a response.

03:06.080 --> 03:07.960
So that's one instructions.

03:08.000 --> 03:16.520
Another instructions is going to be that you can convert a text email to an HTML email, a formatted

03:16.520 --> 03:21.760
email, which is how most emails get sent these days, particularly the fancy sales emails.

03:22.240 --> 03:24.360
So you will be given a text email.

03:24.360 --> 03:30.760
Body might have some markdown because llms often put markdown in these things, and you need to convert

03:30.760 --> 03:37.640
it to an HTML email with simple, clear, compelling layout and design.

03:38.040 --> 03:44.160
So we're then going to make an agent for the subject writer with those instructions.

03:44.520 --> 03:47.880
And we're going to use the as tool approach.

03:47.880 --> 03:50.560
This time we're going to make this a tool because it sounds like a tool right.

03:50.600 --> 03:52.400
It's just a tool to write a subject.

03:52.400 --> 03:53.640
So we're going to have a tool.

03:53.750 --> 03:56.670
and that tool is going to be wrapped around this agent.

03:57.150 --> 04:02.950
Similarly for the HTML converter, we're going to say, okay, so you're something which is able to

04:02.990 --> 04:04.550
write HTML emails.

04:04.550 --> 04:06.150
We're going to make you a tool.

04:06.150 --> 04:10.190
We're going to turn you into a tool, an HTML tool that's able to do that.

04:10.510 --> 04:10.950
All right.

04:10.990 --> 04:12.630
Let's oops what have I done.

04:13.150 --> 04:14.830
I'm in cursor land.

04:15.030 --> 04:15.630
Undo that.

04:15.630 --> 04:16.270
All right.

04:16.550 --> 04:17.350
Run that.

04:17.390 --> 04:18.030
Great.

04:18.470 --> 04:18.870
Okay.

04:18.910 --> 04:24.230
And then we're going to have one more tool which is rather similar to to the prior send email.

04:24.310 --> 04:27.270
But I've made this a send HTML email.

04:27.470 --> 04:30.070
And it takes a subject and a body.

04:30.270 --> 04:35.390
And it sends out an email with the given subject and body to all sales prospects.

04:35.550 --> 04:40.550
Again, remember to change this to your verified email sender.

04:40.710 --> 04:47.430
Make this some other email than mine please, and then send using SendGrid.

04:47.430 --> 04:53.370
And you can see there's just a tiny change here that it sends it as an HTML email, not a text email.

04:53.730 --> 04:54.050
Okay.

04:54.090 --> 05:00.650
So then we now have three tools subject HTML tool, and a subject tool that creates a subject, an HTML

05:00.690 --> 05:05.810
tool that converts a text email to HTML and the send tool.

05:05.970 --> 05:07.250
So two of these are agents.

05:07.250 --> 05:09.010
And one of them let's print them.

05:09.050 --> 05:10.050
Let's have a look.

05:10.330 --> 05:11.090
Tools.

05:12.410 --> 05:13.330
Two of them.

05:13.370 --> 05:14.810
They're all function tools.

05:14.930 --> 05:18.050
Two of them are actual agents wrapped.

05:18.050 --> 05:20.010
And one of them is just a function.

05:20.450 --> 05:21.650
Okay, we're almost there.

05:21.690 --> 05:22.490
Almost there.

05:22.930 --> 05:27.250
So now now we're going to create a separate agent.

05:27.250 --> 05:30.290
And this is going to be the agent that we're going to want to hand off to.

05:30.330 --> 05:32.850
If you're wondering what I'm where this is all heading.

05:33.210 --> 05:38.650
So this agent says you are an email formatter and sender.

05:38.850 --> 05:41.050
You receive the body of an email.

05:41.170 --> 05:45.890
You first use the subject writer tool, then the HTML converter tool.

05:45.890 --> 05:49.330
And finally you send the email.

05:49.600 --> 05:52.560
So we call this emailer agent.

05:52.560 --> 05:54.920
It has a name, it has instructions.

05:54.920 --> 05:56.120
It has tools.

05:56.120 --> 05:58.400
It has something new in here.

05:58.640 --> 06:00.440
Hand off description.

06:00.760 --> 06:03.400
Convert an email to HTML and send it.

06:03.400 --> 06:04.480
Now this.

06:04.640 --> 06:12.800
This is how this agent will sort of announce itself to the world in case another agent wants to use

06:12.800 --> 06:13.200
it.

06:13.240 --> 06:19.640
If there's another agent that might want to to do something, this is how it knows whether or not the

06:19.640 --> 06:22.680
emailer agent is an agent that might be useful.

06:22.960 --> 06:24.600
So that's a sort of framing.

06:24.600 --> 06:27.360
It's very similar to the to the tool description.

06:27.360 --> 06:30.040
It's a description of what this agent does.

06:31.160 --> 06:31.800
Okay.

06:32.080 --> 06:37.960
So if you've been following me you will now be clear that we have three tools.

06:37.960 --> 06:40.760
These are the three sales agents.

06:41.160 --> 06:43.400
And we have a hand off.

06:43.720 --> 06:48.000
We have this thing this this agent which we can hand over control to.

06:48.540 --> 06:56.860
and somewhat confusingly, this handoff itself has three tools subject writer, HTML converter, and

06:56.860 --> 06:58.300
a send HTML email.

06:58.700 --> 06:59.540
You following this?

06:59.580 --> 07:02.180
If not, come back, go through it or of course print.

07:02.180 --> 07:03.660
It's always good to print.

07:03.780 --> 07:11.060
We should print tools and we should print handoffs and take a look at what we've got.

07:11.060 --> 07:15.780
So this is the tools are just the sales email sales agent one, two and three.

07:16.260 --> 07:20.700
And the handoffs is a single agent called the email manager.

07:20.940 --> 07:25.140
And this agent we should see itself will have a bunch of tools.

07:25.860 --> 07:27.620
It has a handoff description.

07:27.860 --> 07:30.140
It doesn't have any handoffs itself.

07:30.620 --> 07:34.100
But somewhere in here we should find that it has a few tools.

07:34.100 --> 07:39.020
Here they are tools function tool named subject writer and so on.

07:39.420 --> 07:39.820
All right.

07:39.820 --> 07:45.900
If any of that's not clear, come back, look through this, print it, get a sense of it and then we

07:45.900 --> 07:47.140
will actually run this.
