WEBVTT

00:00.160 --> 00:03.520
And a very warm welcome to week four, day three.

00:03.560 --> 00:04.200
Here we are.

00:04.240 --> 00:09.280
This is going to be the time that Landgraf is going to start to pay dividends.

00:09.280 --> 00:13.560
The investment that we've made in understanding the new terminology is going to come together, and

00:13.560 --> 00:15.240
we're going to see some real value.

00:15.480 --> 00:18.960
But first, as always, I have to give you a quick recap.

00:19.000 --> 00:22.720
Again, I'm going to get bored of it, but it's better that you get bored of it and you understand it.

00:22.840 --> 00:29.880
So before you can call Graph Invoke, which is how you kick off your graph, you have to define it.

00:29.920 --> 00:33.240
And defining it is these five steps to find your state class.

00:33.240 --> 00:34.240
The graph Builder.

00:34.240 --> 00:37.240
Create a node edges and compile the graph.

00:37.440 --> 00:38.840
Just a quick refresher.

00:38.840 --> 00:41.080
I'm sure you've got this all committed to memory now.

00:41.400 --> 00:43.440
Okay, so what are we actually going to cover today?

00:43.560 --> 00:48.160
Well, there's going to be a few ways we're going to go deeper into the world of graph.

00:48.200 --> 00:52.920
First of all, we're going to look at Lang Smith and have a moment of understanding how information

00:52.920 --> 00:54.360
gets logged there.

00:54.600 --> 00:59.240
We're then going to look at tools tool calling something that we've done many times now using the out

00:59.280 --> 01:02.000
of the box tools that come with Lang graph.

01:02.160 --> 01:05.680
And then we're going to build a custom tool again as we've done many times.

01:05.680 --> 01:07.000
So we'll see that working.

01:07.200 --> 01:12.610
And we'll finally end with checkpointing which is a very important part of it.

01:12.650 --> 01:13.290
Indeed.

01:13.770 --> 01:18.170
And to to tee that up to motivate checkpointing.

01:18.170 --> 01:21.290
I want to talk for a moment about something called the super step.

01:21.410 --> 01:23.050
So what's a super step?

01:23.290 --> 01:24.650
Well, a super step.

01:24.690 --> 01:25.770
Start with a docs.

01:25.810 --> 01:26.370
A super step.

01:26.370 --> 01:30.290
They define as a single iteration over the graph nodes.

01:30.290 --> 01:33.290
Nodes that run in parallel a part of the same super step.

01:33.410 --> 01:36.690
Nodes that run sequentially belong to a separate super step.

01:37.090 --> 01:38.770
So what does that mean exactly?

01:38.810 --> 01:40.690
Now this is super, super important.

01:40.730 --> 01:42.370
Super steps are super important.

01:42.370 --> 01:44.410
And it's something which you have to get your head around.

01:44.410 --> 01:48.770
And it's it's a it's a definitely may not be what you're expecting.

01:49.570 --> 01:59.610
So a graph defines one set of interactions between like agents and their use of tools and perhaps delegating

01:59.650 --> 02:00.930
to other agents.

02:00.930 --> 02:05.810
If you think back to the handoff of, uh, OpenAI agents SDK.

02:06.330 --> 02:10.450
So one invocation of the graph is just one kind of step.

02:10.450 --> 02:17.370
It's like when the user says one message, putting that message to our LLM, that is one invocation

02:17.370 --> 02:23.250
of the entire graph all the way through from top to bottom, and if then it comes back to the user with

02:23.250 --> 02:25.770
a response and the user types in another message.

02:25.770 --> 02:28.210
That's another invocation of the whole graph.

02:28.210 --> 02:32.090
And each of these invocations is a superstep.

02:32.130 --> 02:35.210
Every time you invoke the graph, that is a superstep.

02:35.450 --> 02:39.970
And so yeah, it's important to get your head around it, because you might initially think that maybe

02:39.970 --> 02:45.170
you could imagine that a node is like a human and a node is a chatbot, and that a graph is human and

02:45.170 --> 02:46.890
chatbot going backwards and forwards.

02:46.890 --> 02:51.330
But no, every time that there is that kind of human interaction, you should think of that as a whole

02:51.330 --> 02:52.650
invocation of the graph.

02:52.650 --> 02:57.850
Or in some situations, you might be resuming the graph from one point if it was paused for for a human

02:57.850 --> 02:58.570
to respond.

02:58.650 --> 03:04.690
So there's various ways of doing it, but each of these interactions is considered an entire superstep

03:04.890 --> 03:06.290
within a superstep.

03:06.330 --> 03:13.250
One one invocation of the graph belongs to to activities which happen in parallel as part of that step.

03:14.130 --> 03:20.730
So this is a bit repetitive, but yeah, the graph describes one full superstep an interaction between

03:20.730 --> 03:25.490
agents and tools and potentially multiple agents to achieve an outcome.

03:26.250 --> 03:28.170
Every user interaction.

03:28.380 --> 03:30.700
It's a fresh invoke call.

03:30.700 --> 03:33.460
It's a fresh time that you're calling Graph Invoke.

03:33.500 --> 03:35.220
There's also a graph resume.

03:35.220 --> 03:36.380
But but the point remains.

03:36.380 --> 03:37.780
It's a fresh call.

03:38.420 --> 03:44.460
And the reducer that I talked about, the thing that is able to combine the state that comes out of

03:44.460 --> 03:50.460
a call with the original state that applies during carrying out a single super step.

03:50.460 --> 03:53.180
That is how state is managed across the graph.

03:53.220 --> 03:57.740
That's how if multiple nodes update the same state state, it gets combined at the end.

03:58.020 --> 04:00.020
That's what the reducer is handling.

04:00.020 --> 04:06.780
But the reducer doesn't handle, uh, the separate super steps a separate super step is an entirely

04:06.780 --> 04:09.740
fresh invocation of the graph.

04:10.740 --> 04:13.740
So that's going to be a bit confusing.

04:13.740 --> 04:16.620
So what does that mean to show that visually.

04:16.660 --> 04:18.540
Next I want to draw you a diagram.

04:18.540 --> 04:24.620
So with this diagram it's now all going to become crystal clear I'm confident it all begins with defining

04:24.620 --> 04:25.180
the graph.

04:25.180 --> 04:30.460
As I keep saying this is the five things you got to do, including defining the nodes, the edges,

04:30.460 --> 04:31.780
and compiling the graph.

04:31.780 --> 04:32.900
And then you're set.

04:33.460 --> 04:39.100
The next thing you do is perhaps the user has a question, and that question is what you then use to

04:39.140 --> 04:40.780
invoke the graph.

04:40.940 --> 04:41.500
There you go.

04:41.500 --> 04:43.220
And that is called a super step.

04:43.260 --> 04:48.900
And out pops some kind of an answer after the agents and tools have done their thing, and then the

04:48.900 --> 04:51.540
user says something, a follow up question, they have something else.

04:51.540 --> 04:53.500
And that would be another super step.

04:54.060 --> 04:58.460
And then that might happen again with another follow up or with another external activity.

04:58.620 --> 05:03.220
Each of these are super steps, complete invocations of the graph.

05:03.420 --> 05:07.940
So just to make that really obvious, I'm putting a little picture of a graph by each one.

05:07.940 --> 05:11.420
The whole graph is is invoked each time.

05:11.900 --> 05:14.300
And that is what it means to have a super step.

05:14.500 --> 05:16.020
And why am I going on about this?

05:16.020 --> 05:22.140
Because when it comes to memory, when it comes to preserving context between these different calls,

05:22.660 --> 05:28.220
we need to involve something called checkpointing, which is something that landgraaf makes available

05:28.220 --> 05:35.900
to us to be able to keep track, to sort of freeze a record of the state after each super step.

05:35.900 --> 05:42.020
So we've got that tracked, and then next time we call a super step, it can recall the state exactly

05:42.020 --> 05:43.260
as it was Checkpointed.

05:43.580 --> 05:47.500
And that is one of the things that we're going to be doing in the lab right now.
