Skip to content

.NET: skill as class#5027

Open
SergeyMenshykh wants to merge 6 commits intomicrosoft:mainfrom
SergeyMenshykh:skill-as-class
Open

.NET: skill as class#5027
SergeyMenshykh wants to merge 6 commits intomicrosoft:mainfrom
SergeyMenshykh:skill-as-class

Conversation

@SergeyMenshykh
Copy link
Copy Markdown
Member

@SergeyMenshykh SergeyMenshykh commented Apr 1, 2026

Summary

Add class-based skills so skills can be distributed and reused as first-class C# types (for example from shared libraries/NuGet packages).

Changes

  • Introduce a class-based skill type for programmatic skill definitions.
  • Allow registering and using these skills through the existing skills source/provider pipeline.
  • Keep support for existing skill sources (file-based and inline) while enabling reusable class-based packaging.

Closes: #4350

@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation .NET labels Apr 1, 2026
@github-actions github-actions bot changed the title skill as class .NET: skill as class Apr 1, 2026
@SergeyMenshykh SergeyMenshykh marked this pull request as ready for review April 1, 2026 14:16
Copilot AI review requested due to automatic review settings April 1, 2026 14:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for class-based Agent Skills in the .NET implementation so skills can be packaged and reused as first-class C# types (e.g., from shared libraries/NuGet), while preserving existing file-based and inline skill flows.

Changes:

  • Introduces AgentClassSkill and a shared XML content builder to synthesize skill content (name/description/instructions/resources/scripts).
  • Broadens skill registration to accept AgentSkill instances (enabling inline + class-based skills through existing provider/source pipelines).
  • Adds unit tests and expands the .NET AgentSkills samples to include class-based skills, DI-enabled variants, and mixed-source usage.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/AgentSkillsProviderTests.cs Adds provider tests covering class-based skills registration + deduplication.
dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/AgentClassSkillTests.cs New unit tests validating AgentClassSkill behavior and synthesized content.
dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentInlineSkillScript.cs Exposes parameters schema via override to support generic script schema handling.
dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentInlineSkillContentBuilder.cs New internal helper to build XML content for programmatic/class-based skills.
dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentInlineSkill.cs Refactors inline skill content generation to use shared builder.
dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentClassSkill.cs New abstract base type for class-packaged skills (instructions/resources/scripts).
dotnet/src/Microsoft.Agents.AI/Skills/AgentSkillsProviderBuilder.cs Documentation updates clarifying advanced mixed-source builder usage.
dotnet/src/Microsoft.Agents.AI/Skills/AgentSkillsProvider.cs Updates constructors to accept AgentSkill (not only inline skills).
dotnet/src/Microsoft.Agents.AI/Skills/AgentSkillScript.cs Adds virtual ParametersSchema to unify schema exposure across script types.
dotnet/samples/02-agents/AgentSkills/README.md Updates overview to include class-based skills and mixed/DI samples.
dotnet/samples/02-agents/AgentSkills/Agent_Step06_ClassBasedSkillsWithDI/README.md New sample documentation for DI with class-based skills.
dotnet/samples/02-agents/AgentSkills/Agent_Step06_ClassBasedSkillsWithDI/Program.cs New DI-enabled class-based skills sample implementation.
dotnet/samples/02-agents/AgentSkills/Agent_Step06_ClassBasedSkillsWithDI/Agent_Step06_ClassBasedSkillsWithDI.csproj New sample project file for Step06.
dotnet/samples/02-agents/AgentSkills/Agent_Step05_CodeDefinedSkillsWithDI/README.md New sample documentation for DI with inline (code-defined) skills.
dotnet/samples/02-agents/AgentSkills/Agent_Step05_CodeDefinedSkillsWithDI/Program.cs New DI-enabled inline skills sample implementation.
dotnet/samples/02-agents/AgentSkills/Agent_Step05_CodeDefinedSkillsWithDI/Agent_Step05_CodeDefinedSkillsWithDI.csproj New sample project file for Step05.
dotnet/samples/02-agents/AgentSkills/Agent_Step04_MixedSkills/skills/unit-converter/SKILL.md New file-based skill content for mixed-skills sample.
dotnet/samples/02-agents/AgentSkills/Agent_Step04_MixedSkills/skills/unit-converter/scripts/convert-units.py New script used by file-based skill in mixed sample.
dotnet/samples/02-agents/AgentSkills/Agent_Step04_MixedSkills/skills/unit-converter/references/unit-conversion-table.md New reference document for file-based unit conversion skill.
dotnet/samples/02-agents/AgentSkills/Agent_Step04_MixedSkills/README.md New documentation for advanced mixed skills sample.
dotnet/samples/02-agents/AgentSkills/Agent_Step04_MixedSkills/Program.cs New mixed skills sample combining file + inline + class-based skills.
dotnet/samples/02-agents/AgentSkills/Agent_Step04_MixedSkills/Agent_Step04_MixedSkills.csproj New sample project file for Step04 (copies skills to output).
dotnet/samples/02-agents/AgentSkills/Agent_Step03_ClassBasedSkills/README.md New documentation for basic class-based skills sample.
dotnet/samples/02-agents/AgentSkills/Agent_Step03_ClassBasedSkills/Program.cs New class-based skills sample implementation.
dotnet/samples/02-agents/AgentSkills/Agent_Step03_ClassBasedSkills/Agent_Step03_ClassBasedSkills.csproj New sample project file for Step03.
dotnet/samples/02-agents/AgentSkills/Agent_Step01_FileBasedSkills/README.md Minor terminology correction (“script runner” wording).
dotnet/filtered-unit.slnx Adds a filtered solution file (currently appears to be a generated artifact).
dotnet/AGENTS.md Updates .NET guidance to require Async suffix on async test methods.
dotnet/agent-framework-dotnet.slnx Adds new AgentSkills sample projects to the main solution.

SergeyMenshykh and others added 2 commits April 1, 2026 14:58
The filtered solution file is generated dynamically by
eng/scripts/New-FilteredSolution.ps1 during CI. Checking it in
risks it becoming stale and out-of-sync with the real solution.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The filtered solution file is generated dynamically by
eng/scripts/New-FilteredSolution.ps1 during CI. Checking it in
risks it becoming stale and out-of-sync with the real solution.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@@ -0,0 +1,116 @@
// Copyright (c) Microsoft. All rights reserved.

// This sample demonstrates how to use Dependency Injection (DI) with Agent Skills.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Could some of these samples be merged with others (e.g. DI and non-DI related samples merged into one project) to reduce the number of sample projects we have?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation .NET

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

.NET: Support multiple sources for agent skills

4 participants