.NET: Improve skill name validation: reject consecutive hyphens and enforce directory name match#4526
Merged
SergeyMenshykh merged 2 commits intomicrosoft:mainfrom Mar 6, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the .NET skill loader’s validation to better align with the AgentSkills spec by tightening allowed skill-name formats and ensuring the frontmatter name matches the on-disk skill directory name.
Changes:
- Disallow consecutive hyphens in
namevia an updated validation regex and error message. - Enforce
nameinSKILL.mdfrontmatter matches the parent directory name; mismatches are logged and excluded. - Extend unit tests to cover consecutive-hyphen rejection and directory/name mismatch exclusion.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI/Skills/FileAgentSkillLoader.cs | Tightens name regex and adds directory-name match validation + logging. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/FileAgentSkillLoaderTests.cs | Adds/adjusts tests for consecutive hyphens, duplicate discovery, and directory/name mismatch. |
dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/FileAgentSkillLoaderTests.cs
Show resolved
Hide resolved
westey-m
approved these changes
Mar 6, 2026
peibekwe
approved these changes
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves skill validation in
FileAgentSkillLoaderwith two changes:excludes the skill.
Closes: #4421