WEBVTT

1
00:00:00.000 --> 00:00:06.400
Hi and welcome to this AI and C-Sharp video on the Microsoft agent framework

2
00:00:06.400 --> 00:00:13.439
and today we are going to look into yet another new format from Anthropic which

3
00:00:13.439 --> 00:00:22.040
is called agent skills. Agent skills is a way to try and save tokens, have things

4
00:00:22.040 --> 00:00:32.200
run more offline and in general just work better and they have made a site

5
00:00:32.200 --> 00:00:38.799
called agentskills.io and they have open-sourced everything but they use

6
00:00:38.799 --> 00:00:50.000
internally and it's adopted by many and it's mostly aimed at the various coding

7
00:00:50.000 --> 00:00:56.080
tools but you can also use it in normal AI. So when I saw this the first time

8
00:00:56.080 --> 00:01:04.639
and saw that you need to have some skills and stuff I thought I wanted to

9
00:01:04.639 --> 00:01:12.080
make an integration into it, into my agent framework toolkit as well. But

10
00:01:12.440 --> 00:01:20.120
let's first see what it's more is in general. So what is agent skills? According

11
00:01:20.120 --> 00:01:24.720
from the agentskills.io it's a simple open format for giving agents new

12
00:01:24.720 --> 00:01:30.160
capabilities and expertise. Agent skills are folders of instructions, scripts and

13
00:01:30.160 --> 00:01:35.120
resources that agents can discover and use to do things more accurately and

14
00:01:35.199 --> 00:01:45.199
efficiently. Fancy words. In reality it is a folder on your hard drive and inside

15
00:01:45.199 --> 00:01:49.720
that you will have some subfolders and each of these subfolders will be skills

16
00:01:49.720 --> 00:01:59.480
and the way a skill is defined is that it has a skill.md file. Such a skill.md

17
00:01:59.480 --> 00:02:04.879
file you can see over here where it has header where you give it a name and this

18
00:02:05.120 --> 00:02:12.000
name should match the folder in order to follow the spec and you need to have a

19
00:02:12.000 --> 00:02:19.039
description where you put in what the field is. A little like a tool description

20
00:02:19.039 --> 00:02:26.839
or a tool name. And then you have full control you can just write somebody and

21
00:02:26.839 --> 00:02:31.839
in this case I'm using Markdown but you can use whatever there's no rules on

22
00:02:32.039 --> 00:02:40.839
what after the header how it should look. So this one is a skill with just the

23
00:02:40.839 --> 00:02:48.119
skill file that tells a little about in this case a pirate called C-Dog John who

24
00:02:48.119 --> 00:02:56.119
is aimed at kids and telling a little about how he should react. We can also go

25
00:02:56.240 --> 00:03:03.199
into things that you can run scripts with this. So for example here is a

26
00:03:03.199 --> 00:03:07.800
skill called secret formulas and one of the secret formulas is inside this

27
00:03:07.800 --> 00:03:16.399
pi script that we can execute on the fly. And up here a more corporate version of

28
00:03:16.399 --> 00:03:20.559
an employee handbook where we have a skill that is the employee handbook and

29
00:03:21.080 --> 00:03:26.039
then further references underneath. Because you can have soft folders like

30
00:03:26.039 --> 00:03:30.919
this like script folders, reference folders, assets folders and you can

31
00:03:30.919 --> 00:03:34.880
essentially put everything you want in here but these are the main things that

32
00:03:34.880 --> 00:03:40.919
happens. There's a bit more information over here like metadata license and so

33
00:03:40.919 --> 00:03:50.800
on that are optional. But this is what it is. Let's see it in action. So in my

34
00:03:50.800 --> 00:03:56.600
samples as always I have something called agent skills. And before we go

35
00:03:56.600 --> 00:04:02.119
into the code let me quickly show you the three skills in more details. So we

36
00:04:02.119 --> 00:04:11.039
already saw this skill which is just a persona of a pirate. We have the secret

37
00:04:11.039 --> 00:04:17.600
formula skills which just tells that we have a formula and it should use an

38
00:04:17.600 --> 00:04:25.559
execute pi tool in order to run it. And the final one is just a handbook where

39
00:04:25.559 --> 00:04:30.440
it references the other reference documents. Something about benefits,

40
00:04:30.440 --> 00:04:36.119
something about cultures and values for a made-up company, something about hours

41
00:04:36.119 --> 00:04:43.519
and attendance and something about the pay. So that is what it essentially is.

42
00:04:43.519 --> 00:04:51.920
It's just a folder structure. So if we look at in normal file explorer we just

43
00:04:51.920 --> 00:05:01.000
see the three folders with the references, the scripts and so on. So

44
00:05:01.000 --> 00:05:07.160
nothing fancy, nothing major, nothing special here. But of course we want to

45
00:05:07.160 --> 00:05:13.940
use them in AI and this I could give to for example Codex that can do skills,

46
00:05:13.940 --> 00:05:19.119
Cloud Code that can do skills and so on. But if we want to run them ourselves we

47
00:05:19.119 --> 00:05:26.880
need to parse these files and turn them into tools and instructions. And in order

48
00:05:26.880 --> 00:05:35.200
to do that I have made a new NuGet package called agentskills.net.

49
00:05:35.200 --> 00:05:41.239
I have referenced it here which is technically not needed because it's also

50
00:05:41.440 --> 00:05:50.640
part of my Agent Framework Toolkit as a dependency on that. So you

51
00:05:50.640 --> 00:05:54.359
either can use it directly with the Agent Framework Toolkit no matter what

52
00:05:54.359 --> 00:05:59.519
provider you choose, or you can reference it directly if you don't want to use the

53
00:05:59.519 --> 00:06:08.160
Agent Framework Toolkit. It's NuGet, it's MIT like normal, so nothing special there.

54
00:06:08.160 --> 00:06:19.200
But let's see how we do this then. Let's close all these and look at the program.

55
00:06:19.200 --> 00:06:25.679
So what we do is we just clear the console and get our normal Agent Factory

56
00:06:25.679 --> 00:06:31.200
from Toolkit, but you can of course also use the normal Microsoft Agent

57
00:06:31.200 --> 00:06:38.320
Framework tools raw if you want, because this is just defining skills. And then we

58
00:06:38.320 --> 00:06:44.200
have a new class called AgentSkillsFactory which you can just

59
00:06:44.200 --> 00:06:50.359
new up, or there is a dependency version of it if you wish to do that. And on that

60
00:06:50.359 --> 00:06:57.480
factory you have one method and that's called getAgentSkills. And you simply

61
00:06:57.480 --> 00:07:03.600
just need to, as a minimum, give a folder path. I will go into the more advanced

62
00:07:03.600 --> 00:07:07.920
options after we've seen the first pass through here. But we just need to give it

63
00:07:07.920 --> 00:07:19.279
here is my subfolders, pass them for me. So let's have this run and see this in action.

64
00:07:20.200 --> 00:07:30.519
So when we get our skills, we will see that we will get three skills, and there's

65
00:07:30.519 --> 00:07:36.920
an exclude skills lock if there's any of the skills that are invalid in terms of

66
00:07:36.920 --> 00:07:42.279
structure and stuff, if it doesn't have the right format in the skills MD and so

67
00:07:42.279 --> 00:07:50.880
on. But each skill have various things, allow tools, the body, the folder it's in,

68
00:07:50.880 --> 00:07:57.399
what reference files it have, and so on and so forth. So these are the raw skills

69
00:07:57.399 --> 00:08:01.440
that we can access,

70
00:08:03.079 --> 00:08:12.000
and the locks. We can then take these skills and get instructions that if it's

71
00:08:12.000 --> 00:08:20.079
the desired format into instructions. So we could see here that we can make some

72
00:08:20.079 --> 00:08:28.720
XML-like structure here that tells the default about each skill, the name, the

73
00:08:28.720 --> 00:08:33.679
description, and the location for all three. And we can use this in the agents

74
00:08:33.679 --> 00:08:41.840
instructions as normal. We can then make them into tools, and in this case I'm

75
00:08:41.840 --> 00:08:48.400
making it into three different tools. I'm making into a get available skills, a get

76
00:08:48.400 --> 00:08:55.159
skill by name, and a read skill file content. So the first one can list all

77
00:08:55.159 --> 00:09:01.640
the skills, the second one can show the exact skill, and the third one can read

78
00:09:01.640 --> 00:09:08.840
any of the reference files or script files. I also make a Python runner script

79
00:09:08.840 --> 00:09:14.239
here, and that's not included in the package because I don't want to control

80
00:09:14.239 --> 00:09:20.280
how you secure Python, or if you even want to have Python be able to run, or

81
00:09:20.280 --> 00:09:26.080
even have Python installed. So this is just for the sample, where it just takes

82
00:09:26.159 --> 00:09:32.599
a Python file and run it, nothing special, and give the output. I made chatGBT

83
00:09:32.599 --> 00:09:42.359
make this for me. So we get the tools, and then we have the normal agent as always.

84
00:09:42.359 --> 00:09:48.960
We make a chatGBT 4.1 mini here. It's a tool, and we give it what skills it's

85
00:09:48.960 --> 00:09:56.080
available, and we tell it, hey, don't call the read tool before you have

86
00:09:56.080 --> 00:10:02.239
actually asked for the skills, so you know what the files are called. We add

87
00:10:02.239 --> 00:10:08.440
the tools, and we put in a little thing about, so we can see what tools are being

88
00:10:08.440 --> 00:10:16.599
called. Then we make the normal chat loop, and nothing special there. So if we go in

89
00:10:16.599 --> 00:10:27.919
and say, what skills are available, it will call a tool to get available skills,

90
00:10:27.919 --> 00:10:33.640
and it will get back that it has the three skills. And then we can, of course,

91
00:10:33.640 --> 00:10:39.880
use these skills. So let's start by trying to use the pirate. So I can just

92
00:10:39.880 --> 00:10:47.960
say, enter pirate mode. It will understand that. And then it will call

93
00:10:47.960 --> 00:10:57.960
that specific skill and get, essentially, on the fly, this information. So on the

94
00:10:57.960 --> 00:11:05.719
fly, we have now loaded that in via a tool, like normal, and we are now in

95
00:11:05.719 --> 00:11:10.760
pirate mode, where we had the direct instructions. And yes, we could have put

96
00:11:10.760 --> 00:11:15.599
those instructions up here, but then we could not have multiple ways of doing

97
00:11:15.599 --> 00:11:24.760
things. It would be filling up even when we say hello, and stuff like that.

98
00:11:24.760 --> 00:11:39.919
And we can now talk to John the pirate here. Do you drink rum?

99
00:11:39.919 --> 00:11:43.239
And in the instructions, it was told not to talk about such things,

100
00:11:43.239 --> 00:11:54.440
because it's kid-friendly, and so on. So it is now being controlled as a pirate.

101
00:11:54.440 --> 00:12:06.719
If we restart again, just so we have a clean slate, and we should get our

102
00:12:06.719 --> 00:12:12.479
things over here. We can also use the employee handbook. So, for example,

103
00:12:12.479 --> 00:12:24.200
we could just go in and say, is maternity leave paid?

104
00:12:24.200 --> 00:12:29.159
So what's happening now, it's getting the tool by name.

105
00:12:29.159 --> 00:12:33.119
And the reason why it could do that directly was because it was put in the

106
00:12:33.119 --> 00:12:38.679
instruction what each of the tool are called. And it then looked both in the

107
00:12:38.679 --> 00:12:43.440
benefits part of the system, and the pay parts of the system.

108
00:12:43.440 --> 00:12:50.039
So it, on the fly, read what was in this file, and what was in this file.

109
00:12:50.039 --> 00:13:00.080
Of course, it got all that was here, so it knew that it had those available.

110
00:13:00.080 --> 00:13:08.479
And it came back and talked about maternity leave is typically benefits.

111
00:13:08.479 --> 00:13:14.039
It's briefly mentioned over here in the system.

112
00:13:18.520 --> 00:13:23.000
If we try the final one, which is a bit more advanced,

113
00:13:23.000 --> 00:13:28.840
in that we are going to run this Python script, which just gives back 42.

114
00:13:30.559 --> 00:13:36.760
So it's not a very secret formula, but if we go in and see,

115
00:13:36.799 --> 00:13:48.799
we can now go in and say, what is the result of the extra secret formula?

116
00:13:52.320 --> 00:13:57.679
So what happens here is it's going in, getting the skill by name,

117
00:13:57.679 --> 00:14:05.320
the secret formula. So it reads this file on the fly,

118
00:14:05.320 --> 00:14:11.320
and it knows that there is a secret formula called the extra secret formula.py.

119
00:14:14.320 --> 00:14:17.320
Go back to this one, and get rid of that one.

120
00:14:19.239 --> 00:14:23.559
And on the fly, it actually executed the Python,

121
00:14:23.559 --> 00:14:25.679
and just gave the file directly.

122
00:14:25.679 --> 00:14:32.200
So it's not like we used a lot of tokens on doing that, sending it out on the fly.

123
00:14:32.200 --> 00:14:37.599
And right now, the Python file was very small, but it had been very, very big.

124
00:14:37.599 --> 00:14:42.039
We would not have spent tokens on using those,

125
00:14:42.039 --> 00:14:45.599
because we only referenced it by the file name.

126
00:14:45.599 --> 00:14:53.280
And had it been 10 lines, or 100 lines, a thousand lines of Python,

127
00:14:53.280 --> 00:14:58.679
we would still have only used the tokens for the tools.

128
00:14:58.679 --> 00:15:02.679
And it come back, and says that the secret formula is 42.

129
00:15:04.119 --> 00:15:11.119
So this is the out-of-the-box experience for the AgentSkillFactory,

130
00:15:11.119 --> 00:15:13.200
but it can do much, much more.

131
00:15:13.200 --> 00:15:17.159
So let's go a little more details-oriented,

132
00:15:17.159 --> 00:15:22.000
in that in here, for getting the skills by itself,

133
00:15:22.000 --> 00:15:24.679
we have some options as well.

134
00:15:25.679 --> 00:15:28.400
So we have two options.

135
00:15:28.400 --> 00:15:34.280
We have the validation rules, and by default, this is set to be strict.

136
00:15:34.280 --> 00:15:37.880
So if a tool doesn't follow the correct format,

137
00:15:37.880 --> 00:15:42.280
and there's various formats for this.

138
00:15:42.280 --> 00:15:45.280
So for example, let's say that this one doesn't.

139
00:15:45.280 --> 00:15:50.679
One of the things that are not allowed is double quotes like this, for some reason.

140
00:15:50.679 --> 00:15:54.200
And we could say there's no description.

141
00:15:55.679 --> 00:15:59.679
So if we do it like this, and get our skills...

142
00:16:02.679 --> 00:16:06.679
we will see that we only get two skills now.

143
00:16:06.679 --> 00:16:11.679
And the speak-like-a-pirate one was excluded,

144
00:16:11.679 --> 00:16:14.280
because it didn't match the parent directory,

145
00:16:14.280 --> 00:16:20.280
and must not have consecutive hyphens.

146
00:16:21.280 --> 00:16:24.280
So those are just rules that they have chosen,

147
00:16:24.280 --> 00:16:29.280
and by default, this will try to be strict.

148
00:16:29.280 --> 00:16:32.280
But if you want to let things like that through,

149
00:16:32.280 --> 00:16:35.280
you can go down to lose,

150
00:16:35.280 --> 00:16:38.280
where it's only looking for, does it have a name?

151
00:16:38.280 --> 00:16:42.280
If it have a name, it's okay, else we will ignore it.

152
00:16:42.280 --> 00:16:45.280
Or you can completely turn this on, and then off,

153
00:16:45.280 --> 00:16:47.280
and then even the name is not needed,

154
00:16:47.280 --> 00:16:49.280
and then even the name is not needed,

155
00:16:49.280 --> 00:16:52.280
then it will take the folder name,

156
00:16:52.280 --> 00:16:55.280
and choose as a name for the system.

157
00:16:56.280 --> 00:16:59.280
So you can get things out.

158
00:17:01.280 --> 00:17:06.280
If someone cannot follow the rules, you can loosen the rules up here.

159
00:17:07.280 --> 00:17:10.280
The other thing you can do is do filtering.

160
00:17:10.280 --> 00:17:16.280
So for example, you just get a bunk here,

161
00:17:16.280 --> 00:17:22.280
and in here, you can return true, if that specific tool,

162
00:17:22.280 --> 00:17:26.280
because this will be called for each single tool,

163
00:17:26.280 --> 00:17:32.280
if it should be included, or if it should not be included.

164
00:17:32.280 --> 00:17:34.280
So for example, we could go and say,

165
00:17:34.280 --> 00:17:41.280
skills.scriptfiles.count equals zero.

166
00:17:41.280 --> 00:17:49.280
So now it will only return skills that doesn't have any script files.

167
00:17:50.280 --> 00:17:53.280
So if we run it again,

168
00:17:54.280 --> 00:18:03.280
we will now see that our skills, we only have two again, which is there.

169
00:18:03.280 --> 00:18:07.280
Employ, and speak like a pirate,

170
00:18:07.280 --> 00:18:12.280
and it says here the SQL formula was excluded, as it did not hit filter.

171
00:18:13.280 --> 00:18:16.280
We could have turned it the other way around,

172
00:18:19.280 --> 00:18:23.280
and we could have gotten that we only got one,

173
00:18:23.280 --> 00:18:26.280
and two of them was thrown away, because they didn't have script files.

174
00:18:26.280 --> 00:18:30.280
So you have full control over everything that is about this,

175
00:18:30.280 --> 00:18:34.280
so it could say if the description mentions a certain word,

176
00:18:34.280 --> 00:18:40.280
or the license is not MIT, or whatever you want to do.

177
00:18:42.280 --> 00:18:46.280
So those are the options for getting the skills themselves.

178
00:18:47.280 --> 00:18:52.280
Then there's the instructions. There's no special things about that.

179
00:18:52.280 --> 00:18:59.280
And then there's the tools, because the tools can get extra setups.

180
00:18:59.280 --> 00:19:05.280
First of all, you can get a strategy for how you want to have these tools.

181
00:19:05.280 --> 00:19:10.280
And by default, it's using the available skills and lookup tools that we just saw,

182
00:19:10.280 --> 00:19:13.280
but you can also say that each skill is a tool.

183
00:19:13.280 --> 00:19:15.280
So if we do that,

184
00:19:16.280 --> 00:19:18.280
let's set a breakpoint here,

185
00:19:23.280 --> 00:19:26.280
we will now see that we get four tools.

186
00:19:26.280 --> 00:19:31.280
We get the Employee Handbook as a tool by itself, the Secret Formulas as a tool,

187
00:19:31.280 --> 00:19:36.280
the Speak Like a Pirate, and our Read Skill File Content,

188
00:19:36.280 --> 00:19:40.280
which is out-of-the-box default every time.

189
00:19:41.280 --> 00:19:47.280
So then we turn each skill folder into its own skill.

190
00:19:47.280 --> 00:19:50.780
This might not be the best if you have a lot of skills,

191
00:19:50.780 --> 00:19:54.280
because then you are ending up spending a lot of tokens.

192
00:19:54.780 --> 00:19:59.780
The default is that you only get the two available lookup tools

193
00:19:59.780 --> 00:20:02.780
and the Read File tool by default,

194
00:20:02.780 --> 00:20:06.280
because then, no matter how many skills you put in,

195
00:20:06.280 --> 00:20:08.280
you will only end up with three tools.

196
00:20:11.280 --> 00:20:17.780
What you can do as well is control some extra options here.

197
00:20:18.780 --> 00:20:22.280
So here we can control, for example,

198
00:20:22.280 --> 00:20:27.280
if we want to include the tool for Read Content.

199
00:20:27.280 --> 00:20:31.280
If we don't trust the system to read any files,

200
00:20:31.280 --> 00:20:33.280
by default, this tool is actually set up

201
00:20:33.280 --> 00:20:36.280
that it can only read the files that are in the skills.

202
00:20:36.280 --> 00:20:40.780
So behind the scenes, when it runs the tool,

203
00:20:40.780 --> 00:20:45.280
it will actually check, is it any of the files that are in any of the skills,

204
00:20:45.780 --> 00:20:48.780
and if not, it will say it's not a valid file.

205
00:20:48.780 --> 00:20:52.780
So it's not dangerous to do, other than what skills you have,

206
00:20:52.780 --> 00:20:54.280
and it can only read.

207
00:20:54.280 --> 00:20:59.780
But if you don't want it, you can simply go and say False here,

208
00:20:59.780 --> 00:21:03.780
and then we only get the two tools,

209
00:21:03.780 --> 00:21:06.780
to Get Available and to Get Skill By Name.

210
00:21:08.780 --> 00:21:12.280
Similar, you see these tools, but you can go in

211
00:21:12.280 --> 00:21:15.280
and choose that they should be called something else.

212
00:21:15.280 --> 00:21:19.280
So Get Available Tools could be called Boo.

213
00:21:21.780 --> 00:21:24.780
So they are controllable,

214
00:21:26.280 --> 00:21:28.780
if you don't like the names I have chosen.

215
00:21:28.780 --> 00:21:34.280
The same, you can change the description, and so on and so forth.

216
00:21:34.280 --> 00:21:38.280
So that's for all these tools and description here.

217
00:21:38.280 --> 00:21:40.280
And the final thing you can do is,

218
00:21:40.280 --> 00:21:44.780
you can choose how each tool are being generated,

219
00:21:45.780 --> 00:21:49.280
in that you can choose, should it include the description,

220
00:21:49.280 --> 00:21:51.780
should it include the metadata,

221
00:21:51.780 --> 00:21:57.780
should it include the files lists, and all these kinds of things.

222
00:21:58.780 --> 00:22:01.780
And behind the scenes, each of the tool,

223
00:22:01.780 --> 00:22:06.780
we look in here, we can say AgentSkills.

224
00:22:07.280 --> 00:22:09.780
Just take one of the skills.

225
00:22:09.780 --> 00:22:13.780
We can go in and say Get Definition,

226
00:22:13.780 --> 00:22:18.780
and we can also validate the result, if we want to validate it.

227
00:22:18.780 --> 00:22:22.780
But we can get the definition, and then you will also be able to see

228
00:22:22.780 --> 00:22:26.780
how each tool are being presented to the LLM.

229
00:22:26.780 --> 00:22:29.780
So if we set a breakpoint here,

230
00:22:32.280 --> 00:22:33.780
and run it,

231
00:22:34.780 --> 00:22:38.780
you will see that each skill will be shown as a skill,

232
00:22:38.780 --> 00:22:42.280
with the name and description, instructions,

233
00:22:42.280 --> 00:22:46.280
and then the files, in this case the reference files,

234
00:22:46.280 --> 00:22:49.280
but if there was other files, and so on.

235
00:22:49.280 --> 00:22:54.280
So each of them are being presented in this manner,

236
00:22:54.280 --> 00:22:57.780
to the LLM, on the fly.

237
00:22:58.780 --> 00:23:01.280
And if you don't like that, you can, of course,

238
00:23:01.280 --> 00:23:05.280
just go in and use the raw skills, build your own definitions,

239
00:23:05.280 --> 00:23:08.280
build your own tools, if you want to.

240
00:23:08.280 --> 00:23:14.280
But out-of-the-box, I've made it as opinionated as possible,

241
00:23:14.280 --> 00:23:16.780
and as I would use it default.

242
00:23:16.780 --> 00:23:20.280
So if we just go back to this,

243
00:23:20.280 --> 00:23:23.780
we get the three out-of-the-box tools.

244
00:23:23.780 --> 00:23:26.780
We get the good names, in my opinion.

245
00:23:26.780 --> 00:23:30.280
Again, if you don't like them, you can overwrite them.

246
00:23:30.280 --> 00:23:33.280
And from that, we just need to build our skills,

247
00:23:33.280 --> 00:23:36.280
and use them in the system,

248
00:23:36.280 --> 00:23:39.280
and everything is up and running.

249
00:23:39.280 --> 00:23:41.780
So that's everything.

250
00:23:41.780 --> 00:23:43.780
See you in the next one.

