WEBVTT

00:00.800 --> 00:06.160
And let's go and run this so we can see the print from the beginning.

00:06.400 --> 00:11.840
And we can see also the print inside the search function, the search tool.

00:12.000 --> 00:17.520
And we can see that the query that was actually sent is called weather in Tokyo.

00:18.480 --> 00:20.800
And now we get the response.

00:20.800 --> 00:23.920
We have tons of things in here in the response.

00:23.920 --> 00:26.600
So by the end of this course we'll know most of them.

00:26.640 --> 00:27.720
What do they mean.

00:28.040 --> 00:34.760
And let me go and let me run this in debug mode so we can see this more nicely.

00:34.760 --> 00:39.560
And we can figure out what's the actual output of the agent here.

00:39.880 --> 00:47.960
So all right so let me put a breakpoint here and if I'll check out the results variable.

00:48.320 --> 00:51.560
So it's a dictionary containing the key of messages.

00:51.560 --> 00:54.400
Here the first message is going to be the input.

00:54.400 --> 00:59.840
So you can see it's a human message with the content of what is the weather in Tokyo.

01:00.280 --> 01:06.260
And the answer is in the last message, and we can see it's labeled as an AI message, where it says

01:06.260 --> 01:09.380
that the weather in Tokyo is currently sunny.

01:09.540 --> 01:11.180
Now, what's in between?

01:11.180 --> 01:14.620
We have here an AI message and a message.

01:14.780 --> 01:20.300
And those are actually what is the agent is doing in order to get this answer.

01:20.300 --> 01:23.500
So right now it is sort of like magic.

01:23.660 --> 01:28.500
But in this video you'll have a better understanding how this is working.

01:28.660 --> 01:34.940
And by the end of this section and the next section, you'll know exactly how this is working and there

01:34.940 --> 01:36.220
will be no magic.

01:36.260 --> 01:37.940
Okay, so trust me on this.

01:37.980 --> 01:38.420
Cool.

01:38.420 --> 01:44.260
So let me now open links and let's see the trace of this agent execution.

01:44.260 --> 01:47.380
And let's dive a bit deeper of what's happening here.

01:47.620 --> 01:51.940
Now you can see now that the title here of this execution is called Land Graph.

01:51.940 --> 01:58.700
And this is because underneath the hood in the internals, it's going to be executing via the graph

01:58.700 --> 01:59.220
framework.

01:59.500 --> 02:06.360
Do not worry about this I promise we will be covering this in the course we open now the first call.

02:06.400 --> 02:08.680
So it's called here chat open AI.

02:09.000 --> 02:15.040
And by the way something interesting that the default model for link chain currently and this is was

02:15.040 --> 02:17.640
filmed on November 7th, 2025.

02:17.880 --> 02:23.480
So the current A model is GPT 3.5 and not GPT five.

02:23.760 --> 02:26.320
So this is just something interesting right.

02:26.320 --> 02:28.600
So let's analyze this LLM code.

02:28.680 --> 02:31.320
So here we can see the input to the LLM call.

02:31.320 --> 02:34.760
And we sent a message of what is the weather in Tokyo.

02:34.960 --> 02:37.000
Now when long chain made the LLM call.

02:37.000 --> 02:43.280
It also sent to the LLM information about which tools does it has access to.

02:43.320 --> 02:44.600
And it can call.

02:44.600 --> 02:49.360
And if you open this model you'll see all the information about the tool that we defined earlier.

02:49.760 --> 02:58.280
Now if you've noticed my terminology, I said that we send to the LLM the list of tools and I said LLM.

02:58.280 --> 03:06.020
And I did not say agent because right now we are in the granularity of the LM with the LM call here.

03:06.020 --> 03:11.300
So we equip it now our LM with a tool that it can choose.

03:11.660 --> 03:20.020
And with the query of what is the weather in Tokyo, it decided that it needs to invoke the search tool

03:20.180 --> 03:22.940
with the query weather in Tokyo.

03:23.100 --> 03:26.300
And we have here some kind of tool calling ID here.

03:26.620 --> 03:30.060
So notice here the LM response is not.

03:30.060 --> 03:36.020
The invocation of this tool is simply which tool to call and with which arguments here.

03:36.180 --> 03:39.100
And it's going to do so with function calling.

03:39.260 --> 03:41.500
And how does this work under the hood?

03:41.540 --> 03:43.620
We are soon in this section.

03:43.620 --> 03:46.460
And in the section later we're going to figure out.

03:46.500 --> 03:55.260
Alright, so after the LM decided that it needs to call the search tool link chain then went and invoked

03:55.260 --> 03:58.900
the search tool with the query Weather in Tokyo.

03:58.900 --> 04:00.660
And this we can see right over here.

04:00.860 --> 04:07.800
And we can see that the response of these tools execution is Tokyo, weather is sunny and this is the

04:07.800 --> 04:11.360
static string that we defined in our Python function earlier.

04:11.640 --> 04:17.480
So we went and it ran this function with the argument of weather in Tokyo.

04:17.520 --> 04:20.480
So let's recap what happened up until now.

04:20.880 --> 04:26.520
So the LM decided which tool to call with which arguments.

04:27.200 --> 04:33.040
Then link chain went in ran this function with those arguments.

04:33.280 --> 04:36.000
So something very interesting is happening right now.

04:36.000 --> 04:38.680
And let me give you a quick preview of what's to come.

04:38.960 --> 04:45.840
So we have here a reasoning engine that decides which tool to call and with which arguments.

04:46.080 --> 04:53.560
And we have here now an agent execution runtime which actually goes in execute and run those tools and

04:53.560 --> 04:54.720
gets the output.

04:55.400 --> 05:02.840
Now link chain is going to be making another LM call, but this time it's going to contain the input.

05:02.880 --> 05:09.340
It's going to contain the LM decision to call the search tool, and it's going to contain the answer

05:09.340 --> 05:11.180
after executing the search tool.

05:11.340 --> 05:18.340
So the LLM should have a very easy time now generating the answer, because it has all the information

05:18.340 --> 05:19.060
it needs.

05:19.060 --> 05:25.020
And we can see here that the answer is that the weather in Tokyo is currently sunny right now.

05:25.060 --> 05:30.740
Remember that I told you that now all of those messages are going to be making more sense.

05:30.980 --> 05:33.100
The first message was the input.

05:33.420 --> 05:40.300
The second message was the AI's decision to call the search tool, and with which arguments link chain

05:40.300 --> 05:42.260
went and executed that tool.

05:42.260 --> 05:48.500
And then the result of this tool is structured here in this tool message object.

05:48.500 --> 05:53.860
And the tool message is simply a data structure to represent a result of a tool execution.

05:53.860 --> 05:56.820
And in this case the result of executing the search tool.

05:56.980 --> 06:05.140
And finally link chain went and made another LLM call with the input with the decision of the LLM to

06:05.140 --> 06:09.320
execute the search tool with the search tool a result.

06:09.320 --> 06:10.960
So the tool execution results.

06:10.960 --> 06:14.960
And then the final answer is that the weather in Tokyo is sunny.

06:15.080 --> 06:22.960
And also notice that the final LM call did not choose to execute a tool, but it chose to return an

06:22.960 --> 06:25.880
answer because it had all the information it needed.

06:26.320 --> 06:35.080
All right, let me go back to the code now and let me change the model to be GPT five and let me run

06:35.080 --> 06:35.720
it again.

06:36.280 --> 06:44.040
Now notice this time it's going to run a bit slower, because GPT five is a slower model than GPT 3.5

06:44.080 --> 06:44.560
turbo.

06:48.640 --> 06:50.080
And we got a result.

06:50.080 --> 06:54.400
Let me go now and show you the trace now of the latest run.

06:54.800 --> 06:56.440
And it's very similar.

06:56.440 --> 07:00.920
Just notice here there is a difference because the model name now is going to be GPT five.

07:01.240 --> 07:03.480
And let's go now back to the code.

07:03.480 --> 07:06.920
And let's go and add more meat here.

07:06.960 --> 07:08.760
Now to this search agent.
