mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
e5f7b9c260
* support reflection for discovery of resources and scripts in class-based skills * fix format issues * refactor samples to use reflection * Validate resource member signatures during discovery Add discovery-time validation in AgentClassSkill.DiscoverResources() to fail fast when [AgentSkillResource] is applied to members with incompatible signatures: - Reject indexer properties (getter has parameters) - Reject methods with parameters other than IServiceProvider or CancellationToken Throws InvalidOperationException with actionable error messages instead of allowing silent runtime failures when ReadAsync invokes the AIFunction with no named arguments. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * prevent duplicates --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
e5f7b9c260
·
2026-04-10 11:56:28 +01:00
History
AgentSkills Samples
Samples demonstrating Agent Skills capabilities. Each sample shows a different way to define and use skills.
| Sample | Description |
|---|---|
| Agent_Step01_FileBasedSkills | Define skills as SKILL.md files on disk with reference documents. Uses a unit-converter skill. |
| Agent_Step02_CodeDefinedSkills | Define skills entirely in C# code using AgentInlineSkill, with static/dynamic resources and scripts. |
| Agent_Step03_ClassBasedSkills | Define skills as C# classes using AgentClassSkill. |
| Agent_Step04_MixedSkills | (Advanced) Combine file-based, code-defined, and class-based skills using AgentSkillsProviderBuilder. |
| Agent_Step05_SkillsWithDI | Use Dependency Injection with both code-defined (AgentInlineSkill) and class-based (AgentClassSkill) skills. |
Key Concepts
Skill Types
| Aspect | File-Based | Code-Defined | Class-Based |
|---|---|---|---|
| Definition | SKILL.md files on disk |
AgentInlineSkill instances in C# |
Classes extending AgentClassSkill |
| Resources | All files in skill directory (filtered by extension) | AddResource (static value or delegate-backed) |
CreateResource factory methods |
| Scripts | Supported via script runner delegate | AddScript delegates |
CreateScript factory methods |
| Discovery | Automatic from directory path | Explicit via constructor | Explicit via constructor |
| Dynamic content | No (static files only) | Yes (factory delegates) | Yes (factory delegates) |
| Sharing pattern | Copy skill directory | Inline or shared instances | Package in shared assemblies/NuGet |
| DI support | No | Yes (via IServiceProvider parameter) |
Yes (via IServiceProvider parameter) |
AgentSkillsProvider vs AgentSkillsProviderBuilder
For single-source scenarios, use the AgentSkillsProvider constructors directly — they accept a skill directory path, a set of skills, or a custom source.
Use AgentSkillsProviderBuilder for advanced scenarios where simple constructors are insufficient:
- Mixed skill types — combine file-based, code-defined, and class-based skills in one provider
- Multiple file script runners — use different script runners for different file skill directories
- Skill filtering — include or exclude skills using a predicate
See Agent_Step04_MixedSkills for a working example.