WEBVTT

1
00:00:00.000 --> 00:00:06.000
Hi, and welcome to this AI and C-Sharp video on the Microsoft Agent Framework.

2
00:00:06.000 --> 00:00:10.000
Today we're going to dive into a topic that has changed a lot

3
00:00:10.000 --> 00:00:15.000
during the RC1 and RC2 releases of Microsoft Agent Framework,

4
00:00:15.000 --> 00:00:21.000
and that is the AI Contact Provider, or AI Contact Providers in plural now,

5
00:00:21.000 --> 00:00:25.000
because we have the option to have multiple of them.

6
00:00:25.000 --> 00:00:29.500
But it has completely changed since the preview,

7
00:00:29.500 --> 00:00:33.500
so in this video, we're going to do a really, really deep dive

8
00:00:33.500 --> 00:00:38.500
on what it can do, what is all the methods you can override,

9
00:00:38.500 --> 00:00:41.500
why are they there, and so on,

10
00:00:41.500 --> 00:00:46.500
in order for you to better understand everything here.

11
00:00:46.500 --> 00:00:52.500
So in the samples, I have an AI Contact Providers deep dive.

12
00:00:52.500 --> 00:00:57.000
I've made a folder for this, and I've taken my two previous videos,

13
00:00:57.000 --> 00:01:03.500
one on how to do memory, and one on how to do on-the-fly tool calling,

14
00:01:03.500 --> 00:01:09.500
and put them up in here because they're all three using the AI Contact Provider.

15
00:01:09.500 --> 00:01:14.500
So I'm going to primarily work here, and then I will show you

16
00:01:14.500 --> 00:01:20.500
how these have changed a bit as we go along.

17
00:01:20.500 --> 00:01:25.500
But what I have is a completely normal agent here,

18
00:01:25.500 --> 00:01:30.000
and right now, I have no Contact Providers.

19
00:01:30.000 --> 00:01:39.000
Before we got the RC1, this was called AI Contact Provider Factory,

20
00:01:39.000 --> 00:01:45.500
and we can only give one option, and we needed to inject a bunch of odd things.

21
00:01:45.500 --> 00:01:50.000
But now, it's just that we can view our classes.

22
00:01:50.000 --> 00:01:58.000
But let's quickly run without, just for you to see what it is I'm running here.

23
00:02:00.500 --> 00:02:07.000
So I have a completely normal chat loop, and if I say hi,

24
00:02:07.000 --> 00:02:16.000
I'm printing out the raw HTML, or the LLM call directly,

25
00:02:16.000 --> 00:02:18.500
so we can also see what is going on.

26
00:02:18.500 --> 00:02:24.500
So when I say hi, the LLM call happens, the system message is being added

27
00:02:24.500 --> 00:02:30.500
because I put a system message here, saying we need to wave in the prefix,

28
00:02:30.500 --> 00:02:36.000
the user message sent, and the final response is here.

29
00:02:36.000 --> 00:02:40.000
So this is pretty normal, other than I put in that we can actually see

30
00:02:40.000 --> 00:02:42.500
what the LLM request is.

31
00:02:43.500 --> 00:02:51.500
So now let's put in our AI Contact Provider.

32
00:02:51.500 --> 00:02:59.500
And an AI Contact Provider is just a class that inherits from AI Contact Provider.

33
00:02:59.500 --> 00:03:06.000
And it has four methods you can overwrite.

34
00:03:06.000 --> 00:03:14.000
Invoking call, provideAIContext, invoke call, and storeAIContext.

35
00:03:15.000 --> 00:03:19.000
And the order they are called in is that the invoking call

36
00:03:19.000 --> 00:03:24.000
actually is in charge of calling the provideAIContext,

37
00:03:24.000 --> 00:03:30.000
then the LLM call happens, and then the invoked happen, and store.

38
00:03:31.000 --> 00:03:39.000
So in real life, there are four of these, theoretically,

39
00:03:39.000 --> 00:03:42.000
but when you are going to use these,

40
00:03:42.000 --> 00:03:47.000
you will essentially never use the invoking and the invoked.

41
00:03:49.000 --> 00:03:54.000
Behind the scenes, these two have some very, very advanced things

42
00:03:54.000 --> 00:04:00.000
of merging messages, because there can be multiple of these.

43
00:04:00.500 --> 00:04:03.500
But in reality, you will stay here.

44
00:04:03.500 --> 00:04:08.000
This is the user version, while this is a more technical version.

45
00:04:08.000 --> 00:04:12.500
And I will argue that if you know when to use this,

46
00:04:12.500 --> 00:04:15.000
you probably don't need this video.

47
00:04:15.000 --> 00:04:19.500
And in the same manner, if you were to use this,

48
00:04:19.500 --> 00:04:24.500
where you can go and overwrite how error handling works

49
00:04:24.500 --> 00:04:27.500
when something goes wrong in the LLM,

50
00:04:27.500 --> 00:04:30.000
you're probably not going to need this video.

51
00:04:30.000 --> 00:04:36.500
So we're going to focus on these two ones here.

52
00:04:37.000 --> 00:04:41.000
ProvideAIContext, which happens before the LLM call,

53
00:04:41.000 --> 00:04:45.000
and storeAIContext, which happens after the LLM call.

54
00:04:45.500 --> 00:04:48.500
But you can see I put in messages here,

55
00:04:48.500 --> 00:04:52.500
so we can see they are all being called, and we'll see that in one second.

56
00:04:54.500 --> 00:04:57.500
But what are we using this for?

57
00:04:57.500 --> 00:05:01.000
Well, whenever an LLM call is about to happen,

58
00:05:01.000 --> 00:05:05.500
we can interject things using this method.

59
00:05:06.000 --> 00:05:10.500
And what we have here, let me set a breakpoint so we can try it out.

60
00:05:19.000 --> 00:05:21.000
So if I say hi,

61
00:05:22.000 --> 00:05:26.000
you will actually see that the invoking callAsync,

62
00:05:26.000 --> 00:05:29.500
meaning this method up here, have already been called.

63
00:05:29.500 --> 00:05:34.000
But right now, I don't have any code in here other than the message.

64
00:05:34.000 --> 00:05:36.500
And again, we're not going to use this.

65
00:05:38.000 --> 00:05:41.000
But in here, we get a context.

66
00:05:41.000 --> 00:05:43.000
What is this context?

67
00:05:43.000 --> 00:05:47.000
The context contains our agent.

68
00:05:47.000 --> 00:05:51.000
So if we need to get the name of the agent, or the instructions of the agent,

69
00:05:51.000 --> 00:05:56.000
or something here, we can get it from the context.

70
00:05:57.000 --> 00:05:59.000
We can also get the session.

71
00:05:59.000 --> 00:06:04.500
In my case, I put in session on this call.

72
00:06:04.500 --> 00:06:07.000
If we didn't have a session, it would just be null.

73
00:06:09.000 --> 00:06:13.000
But we have, in this case, our session we could go in and work with.

74
00:06:14.000 --> 00:06:16.500
And then we have AIContext.

75
00:06:16.500 --> 00:06:22.500
And this is right now what we have in the instructions in the system,

76
00:06:23.000 --> 00:06:26.000
and what messages that has been sent,

77
00:06:26.000 --> 00:06:30.000
meaning our simple message of hi.

78
00:06:31.000 --> 00:06:35.000
And then it shows which tools are available right now.

79
00:06:35.000 --> 00:06:37.000
And we can see there's no tools.

80
00:06:37.000 --> 00:06:39.500
I'm not using tools in this sample.

81
00:06:41.000 --> 00:06:46.000
So what we can do is we can go in and inspect this data, of course.

82
00:06:47.000 --> 00:06:49.000
So that's nothing special here.

83
00:06:49.000 --> 00:06:54.000
So we're just gonna do that.

84
00:07:03.000 --> 00:07:07.500
What we can do here is we can go in.

85
00:07:07.500 --> 00:07:12.000
Let me restart the code so we can see it again here.

86
00:07:17.000 --> 00:07:19.000
Let's say hi again.

87
00:07:20.000 --> 00:07:22.000
So we gotta get in here,

88
00:07:22.000 --> 00:07:26.000
because what we can get out is the message itself.

89
00:07:27.000 --> 00:07:31.500
And now you can argue, what do we need this for?

90
00:07:32.000 --> 00:07:37.000
Well, we can go in and inject additional instructions.

91
00:07:37.500 --> 00:07:39.500
We can inject additional tools.

92
00:07:39.500 --> 00:07:43.500
And we can technically inject additional messages.

93
00:07:43.500 --> 00:07:47.500
But if we do that, they will become part of the chat history.

94
00:07:48.000 --> 00:07:50.500
Because if we see here,

95
00:07:50.500 --> 00:07:57.000
this only happens for the LM call this one time and nothing more.

96
00:07:57.000 --> 00:08:01.000
It's not like it's being appended directly to the instructions

97
00:08:01.000 --> 00:08:03.000
again and again and again.

98
00:08:03.000 --> 00:08:07.500
So in my case, I'm injecting some new instructions.

99
00:08:07.500 --> 00:08:10.000
That is, speak like a pirate.

100
00:08:11.000 --> 00:08:15.000
And that's what I'm sending back from provide AI context.

101
00:08:15.000 --> 00:08:19.500
So the AI context I'm providing is speak like a pirate.

102
00:08:21.500 --> 00:08:24.000
And if I run this,

103
00:08:24.500 --> 00:08:31.000
we can then see now that I was called with invoking and then provide.

104
00:08:31.000 --> 00:08:34.500
And we saw we just read out the message.

105
00:08:35.000 --> 00:08:38.500
Then we can see that the messages, the system,

106
00:08:38.500 --> 00:08:43.000
now have the prefix or messages with our waves,

107
00:08:43.000 --> 00:08:47.500
but also speak like a pirate. So on the fly,

108
00:08:48.000 --> 00:08:52.000
Agent Framework added this to the context.

109
00:08:52.500 --> 00:08:56.500
But it's not like if we say hi again,

110
00:09:00.500 --> 00:09:04.500
it only adds it one time.

111
00:09:04.500 --> 00:09:07.000
It's not like it's saying speak like a pirate, speak like a pirate,

112
00:09:07.000 --> 00:09:08.000
speak like a pirate.

113
00:09:08.000 --> 00:09:13.500
So it is taking the original instructions

114
00:09:13.500 --> 00:09:18.000
and appending what we put in for that one call.

115
00:09:20.000 --> 00:09:26.000
And then if we set some more breakpoints down in invoke,

116
00:09:26.500 --> 00:09:33.000
which again we don't really want to use for anything, and our store,

117
00:09:33.500 --> 00:09:36.500
here we could go in and begin to store it.

118
00:09:38.000 --> 00:09:42.000
So we could extract information from the response

119
00:09:42.500 --> 00:09:47.000
or deal with exceptions in a different way than the default,

120
00:09:47.000 --> 00:09:49.000
which is just drawing the exception.

121
00:09:50.500 --> 00:09:54.000
So if we say hi again,

122
00:09:56.000 --> 00:09:58.500
we can now see that invoked happened.

123
00:09:59.500 --> 00:10:04.000
And if we just go down and see that invoke will call store,

124
00:10:04.000 --> 00:10:07.000
we will be able to see that in context here.

125
00:10:08.000 --> 00:10:11.000
We can get the agent and the session as before.

126
00:10:11.000 --> 00:10:13.500
We can check if there's any exceptions.

127
00:10:14.000 --> 00:10:17.000
But else we can get the request messages,

128
00:10:17.000 --> 00:10:19.000
meaning what we have set,

129
00:10:19.000 --> 00:10:21.000
but only for that one call,

130
00:10:21.000 --> 00:10:24.500
not the entire message or chat history.

131
00:10:24.500 --> 00:10:27.000
If we want that, we need to take that from the session.

132
00:10:28.500 --> 00:10:31.500
And we can also see the response message,

133
00:10:31.500 --> 00:10:35.000
which is what is about to go back to the user,

134
00:10:35.000 --> 00:10:39.000
but haven't been shown yet to the user,

135
00:10:39.000 --> 00:10:43.000
meaning we are still in the middle of the run async right now.

136
00:10:45.000 --> 00:10:47.000
So if we look at that,

137
00:10:47.500 --> 00:10:50.500
we can see we got invoked call async,

138
00:10:51.000 --> 00:10:53.000
the store AI context.

139
00:10:53.500 --> 00:10:55.000
There was no exception.

140
00:10:55.000 --> 00:10:57.000
There was a request message of hi,

141
00:10:57.000 --> 00:11:00.000
and a response message of advanced here,

142
00:11:00.000 --> 00:11:02.000
which is the final response down here.

143
00:11:03.500 --> 00:11:07.500
So that is how one AI context works.

144
00:11:08.000 --> 00:11:12.500
And let's see a few of the examples I have used it for,

145
00:11:12.500 --> 00:11:15.500
for context on why we want to do this.

146
00:11:16.500 --> 00:11:20.000
So over here in my memory system,

147
00:11:20.500 --> 00:11:25.500
we are putting in a contact provider of a custom context provider here,

148
00:11:26.000 --> 00:11:29.000
where we're sending in an agent and a user ID.

149
00:11:30.000 --> 00:11:33.500
And over here, we're just storing those

150
00:11:33.500 --> 00:11:37.500
and saving some user ID,

151
00:11:37.500 --> 00:11:40.000
which is our memory store.

152
00:11:40.000 --> 00:11:43.500
That could have been a database, but right now it's just a text file.

153
00:11:44.000 --> 00:11:47.000
And then we're reading all existing memory.

154
00:11:47.500 --> 00:11:49.000
Again, this is a previous video,

155
00:11:49.000 --> 00:11:51.500
so you can go and check that in more details.

156
00:11:51.500 --> 00:11:56.500
But the main thing is that whenever we provide AI context,

157
00:11:57.500 --> 00:12:02.500
we are taking that user fax and putting it into the memory,

158
00:12:02.500 --> 00:12:05.500
just like we put in Speak Like a Pi before.

159
00:12:06.000 --> 00:12:09.000
Now we're putting in, for example, if it knows my name,

160
00:12:09.000 --> 00:12:11.500
my favorite color, and stuff like that.

161
00:12:13.500 --> 00:12:16.000
And in the store AI context,

162
00:12:16.500 --> 00:12:20.000
in that case, we are actually taking the request message,

163
00:12:21.000 --> 00:12:24.000
and we are using an AI to figure out

164
00:12:24.000 --> 00:12:29.000
what I have told the AI, my favorite color is blue, and so on,

165
00:12:29.000 --> 00:12:36.500
and extract any memories I want to add or update or delete,

166
00:12:37.000 --> 00:12:40.000
and save them into the file.

167
00:12:40.500 --> 00:12:44.500
So we are essentially just doing a pre and a post,

168
00:12:44.500 --> 00:12:47.000
pre being put in the user fax,

169
00:12:47.500 --> 00:12:52.500
post being extract new user fax after the fact.

170
00:12:53.500 --> 00:12:56.000
So that is how we use it for memory.

171
00:12:56.500 --> 00:12:59.500
If we want to see how we use it for tools,

172
00:12:59.500 --> 00:13:02.000
it's in a similar manner.

173
00:13:04.500 --> 00:13:08.500
So down here we add on-the-fly tool injection.

174
00:13:08.500 --> 00:13:11.500
Again, we are putting in an agent

175
00:13:11.500 --> 00:13:15.000
because we want to use AI to do something about this.

176
00:13:15.500 --> 00:13:18.500
And then when we are providing AI context,

177
00:13:18.500 --> 00:13:20.000
we are actually looking at the message

178
00:13:20.000 --> 00:13:23.000
before it goes to the real run async,

179
00:13:23.500 --> 00:13:25.500
and extracting, in this case,

180
00:13:26.000 --> 00:13:29.000
do we need to use some time tools, some weather tools,

181
00:13:29.000 --> 00:13:31.000
or some file system tools,

182
00:13:31.000 --> 00:13:33.500
and we end up with a response.

183
00:13:34.000 --> 00:13:36.000
And based on that response,

184
00:13:36.500 --> 00:13:42.500
we make a new context back on which tools we want to inject.

185
00:13:43.500 --> 00:13:47.000
So if we need time tools, we inject some time tools,

186
00:13:47.000 --> 00:13:50.500
some file system tools, or some weather tools,

187
00:13:51.000 --> 00:13:57.000
and the injected instruction is just something for the file tools

188
00:13:57.000 --> 00:13:59.000
and how it needs to work.

189
00:14:00.000 --> 00:14:03.500
So here we are on-the-fly putting in tools.

190
00:14:03.500 --> 00:14:08.500
Again, there's a separate video on this with much more details,

191
00:14:08.500 --> 00:14:12.500
but essentially, again, it's just that before the LM call,

192
00:14:12.500 --> 00:14:15.000
we add more instruction and tools.

193
00:14:15.000 --> 00:14:19.000
In this case, we're not caring about after the fact.

194
00:14:19.000 --> 00:14:23.000
Here, it's just pre-we're-going-to-do-something.

195
00:14:24.500 --> 00:14:28.500
So it's a very, very open-ended system of doing this.

196
00:14:28.500 --> 00:14:31.000
In my case, over here in the basic,

197
00:14:31.000 --> 00:14:34.500
we're just injecting Speak Like a Pirate.

198
00:14:36.500 --> 00:14:39.000
But what if we have multiple of these?

199
00:14:39.500 --> 00:14:44.500
So I have my context provider 2 here as well.

200
00:14:45.500 --> 00:14:48.500
And it's almost the same thing, but it only says,

201
00:14:48.500 --> 00:14:51.000
instead of Speak Like a Pirate, it says,

202
00:14:51.000 --> 00:14:54.000
suffix response with three robots.

203
00:14:55.500 --> 00:14:57.500
But else, it's exactly the same.

204
00:14:57.500 --> 00:15:01.000
Again, we're not storing any context, we're just reading it out.

205
00:15:01.000 --> 00:15:05.500
But again, we could have taken whatever the AI came back with

206
00:15:05.500 --> 00:15:08.000
and done something with it.

207
00:15:09.000 --> 00:15:13.000
Made a summary of what we have talked about so far, for example.

208
00:15:14.000 --> 00:15:17.000
So if we run it with two...

209
00:15:20.500 --> 00:15:22.500
and say hi again,

210
00:15:23.500 --> 00:15:27.500
we can see, let's take this away,

211
00:15:27.500 --> 00:15:34.500
that we call the first AI context provider,

212
00:15:34.500 --> 00:15:38.500
then we call our second context provider.

213
00:15:38.500 --> 00:15:41.500
They're getting exactly the same information.

214
00:15:42.500 --> 00:15:47.000
And they provide each one some data,

215
00:15:47.000 --> 00:15:55.000
Speak Like a Pirate, and put in suffix with the robots.

216
00:15:55.000 --> 00:15:58.000
And that is all being put into the system message.

217
00:15:58.000 --> 00:16:01.000
We have the original, we have the Speak Like a Pirate,

218
00:16:01.000 --> 00:16:03.000
and we have the suffix.

219
00:16:04.000 --> 00:16:07.000
Beyond that, nothing else has changed in DLLM.

220
00:16:07.000 --> 00:16:09.000
And we get our messages back,

221
00:16:09.000 --> 00:16:12.000
and now we have that we have instructed it

222
00:16:12.000 --> 00:16:16.000
to get the robots at the end.

223
00:16:18.500 --> 00:16:22.500
So we can put in as many of these as we wish to

224
00:16:22.500 --> 00:16:27.000
in order to do memory, tool injection,

225
00:16:27.000 --> 00:16:30.000
whatever we want to do.

226
00:16:30.000 --> 00:16:32.500
And we can reuse these across multiple agents,

227
00:16:32.500 --> 00:16:38.000
so if we wanted for some reason to have the wave thing every time,

228
00:16:38.000 --> 00:16:45.000
we would just have a wave before you answer IA context provider.

229
00:16:47.000 --> 00:16:52.000
There's also a third type of context provider,

230
00:16:52.000 --> 00:16:55.500
and it's called a message context provider.

231
00:16:57.500 --> 00:17:00.500
So instead of AI context provider here,

232
00:17:00.500 --> 00:17:03.500
we have a message context provider.

233
00:17:04.500 --> 00:17:09.000
This one is a bit strange compared to the other one

234
00:17:09.000 --> 00:17:15.500
in that it has both a provide AI context and a provide messages.

235
00:17:16.500 --> 00:17:19.500
This one can actually provide messages, but they are permanently messages.

236
00:17:19.500 --> 00:17:24.500
This one is on the fly extra messages you want to put into the system.

237
00:17:26.500 --> 00:17:30.000
So in my case, I'm using the provide messages,

238
00:17:30.000 --> 00:17:34.000
which is yet another way of calling this.

239
00:17:35.000 --> 00:17:40.000
So we can go in and say, for example, make all text uppercase.

240
00:17:43.000 --> 00:17:48.000
So if we do that and say hi,

241
00:17:49.000 --> 00:17:54.000
we will now see that we call our first provider,

242
00:17:54.000 --> 00:17:57.000
which is speak like a pirate, second provider,

243
00:17:57.000 --> 00:18:02.000
put the robots at the end, our third provider, uppercase everything,

244
00:18:03.000 --> 00:18:10.000
and in our case, it is putting in the ones that does things with instructions,

245
00:18:10.000 --> 00:18:15.000
and then it's adding one more message here, make all text uppercase.

246
00:18:16.000 --> 00:18:21.500
I'm a bit surprised that it puts it after the original message,

247
00:18:21.500 --> 00:18:25.500
but they must have evaluated that that is best.

248
00:18:26.500 --> 00:18:30.000
If I had made this implementation, just probably put it before,

249
00:18:30.000 --> 00:18:36.500
and then so the real user message would be the highlighted one,

250
00:18:36.500 --> 00:18:40.500
but they have chosen to put it after, and AI can understand it.

251
00:18:42.500 --> 00:18:46.500
The messages comes back to all three providers,

252
00:18:46.500 --> 00:18:52.000
and we now get all our instructions put together,

253
00:18:52.000 --> 00:18:57.500
plus the extra message that gives even further instructions being uppercase.

254
00:19:01.000 --> 00:19:03.500
So now we have three of these,

255
00:19:03.500 --> 00:19:08.000
but there's one more way of using the message providers.

256
00:19:08.500 --> 00:19:12.000
You can't use these for that for some reason.

257
00:19:12.000 --> 00:19:18.000
Perhaps that will change, but you can also make this as middleware.

258
00:19:18.000 --> 00:19:21.500
So middleware is where we do the tool calling middleware,

259
00:19:21.500 --> 00:19:23.500
the OpenTelemetry middleware,

260
00:19:23.500 --> 00:19:27.500
but we also have an AI context provider's middleware now.

261
00:19:29.000 --> 00:19:33.000
So this one can only take message context providers.

262
00:19:33.000 --> 00:19:36.000
It cannot take my AI context provider.

263
00:19:36.000 --> 00:19:40.000
It will say it's a wrong type. Okay.

264
00:19:42.500 --> 00:19:48.000
So if we do this, things change a bit.

265
00:19:48.000 --> 00:19:54.000
Let's get rid of... let's keep these two, but keep this one down here.

266
00:19:58.000 --> 00:20:02.500
Because when they are run like this, and we say hi,

267
00:20:03.500 --> 00:20:09.000
we essentially end up with the same scenario,

268
00:20:09.000 --> 00:20:13.000
but we are now calling for the provider.

269
00:20:13.000 --> 00:20:16.500
We can see that happens before everything else.

270
00:20:16.500 --> 00:20:20.500
So it's like this one is going before the ones we get up here.

271
00:20:21.500 --> 00:20:30.500
And it's also calling another invoking version instead of the context,

272
00:20:30.500 --> 00:20:36.500
because we cannot provide context for the myMessage right now.

273
00:20:36.500 --> 00:20:39.500
I don't know if it's a bug or if it's a feature,

274
00:20:39.500 --> 00:20:41.500
but they have chosen to do that.

275
00:20:42.500 --> 00:20:46.500
Them being Microsoft Agent Framework team, of course.

276
00:20:47.500 --> 00:20:52.500
The thing is essentially the same. We get the exact same setup.

277
00:20:54.500 --> 00:20:58.500
But why would we ever want to do it down here?

278
00:20:58.500 --> 00:21:05.500
Well, this down here is kind of okay that we can do this,

279
00:21:05.500 --> 00:21:10.500
because, for example, if we get an agent that we don't define,

280
00:21:12.500 --> 00:21:15.500
we don't have the chance to put in AI context providers.

281
00:21:15.500 --> 00:21:20.500
So, for example, if we use the Google's A2A protocol,

282
00:21:20.500 --> 00:21:24.500
the agent-to-agent protocol, we're just being given an agent,

283
00:21:24.500 --> 00:21:28.500
but we're not being able to give it any kind of options,

284
00:21:28.500 --> 00:21:32.500
meaning we're not able to put in our providers.

285
00:21:34.500 --> 00:21:37.500
But down here, we can certainly put in providers,

286
00:21:37.500 --> 00:21:41.500
but only providers to put in extra messages.

287
00:21:41.500 --> 00:21:45.000
And that's probably one of the reasons why we don't get the context,

288
00:21:45.000 --> 00:21:49.500
because they can't on the fly inject system messages,

289
00:21:49.500 --> 00:21:54.500
but they can at least send extra messages like this down here.

290
00:21:56.500 --> 00:22:01.500
So, it sort of makes sense that we can't inject instructions down here,

291
00:22:01.500 --> 00:22:03.500
but only messages.

292
00:22:04.500 --> 00:22:07.000
But that's the main reason. If you own the agent,

293
00:22:07.000 --> 00:22:10.000
you probably don't want to use the middleware parts.

294
00:22:10.000 --> 00:22:13.500
You will just put them in as your own providers.

295
00:22:14.000 --> 00:22:21.500
But in those cases, it's a nice thing that we can actually inject them

296
00:22:21.500 --> 00:22:26.000
by just putting in messages, because that is under our control,

297
00:22:26.000 --> 00:22:29.500
no matter how the agent has been created.

298
00:22:31.000 --> 00:22:37.500
So, that is actually everything there is to say about context providers.

299
00:22:37.500 --> 00:22:41.500
They are kind of intimidating, but end of day,

300
00:22:41.500 --> 00:22:46.500
you should just see them as a place to put something in before,

301
00:22:46.500 --> 00:22:50.000
adjust on the fly instructions and tools,

302
00:22:50.000 --> 00:22:52.500
and after the fact, do something.

303
00:22:53.000 --> 00:22:57.500
So, again, my best two examples is the memory part,

304
00:22:58.500 --> 00:23:02.000
where we can on the fly put in memory,

305
00:23:02.000 --> 00:23:05.000
and on the fly extract it again,

306
00:23:05.000 --> 00:23:08.500
and the tool calling injection, where we can on the fly

307
00:23:08.500 --> 00:23:11.000
determine what tools to put in,

308
00:23:11.000 --> 00:23:14.500
so we can save tokens not giving every single tool.

309
00:23:15.000 --> 00:23:19.000
There's probably many other ways of doing this.

310
00:23:19.000 --> 00:23:23.000
My agent framework themselves have used it to make agent skills.

311
00:23:23.000 --> 00:23:26.000
I have a different video on that,

312
00:23:26.000 --> 00:23:31.000
and I will compare my agent skills to their agent skills,

313
00:23:31.000 --> 00:23:35.500
but they're actually using the AI context providers

314
00:23:35.500 --> 00:23:38.500
in order to inject those tools on the fly.

315
00:23:38.500 --> 00:23:44.000
Kind of a cool idea, but I find it a little too limiting what they do,

316
00:23:44.000 --> 00:23:46.000
but that's for another video.

317
00:23:47.000 --> 00:23:51.500
So, for now, I know this is a bit advanced,

318
00:23:51.500 --> 00:23:56.500
but we needed to go deep dive in order to understand this,

319
00:23:56.500 --> 00:24:01.000
and now that it's logged in and not changing a lot,

320
00:24:01.000 --> 00:24:03.500
it made sense to do this now.

321
00:24:03.500 --> 00:24:08.000
So, thank you for listening. See you in the next one.

