Skip to content

.NET: Improve skill name validation: reject consecutive hyphens and enforce directory name match#4526

Merged
SergeyMenshykh merged 2 commits intomicrosoft:mainfrom
SergeyMenshykh:improve-skills-validation
Mar 6, 2026
Merged

.NET: Improve skill name validation: reject consecutive hyphens and enforce directory name match#4526
SergeyMenshykh merged 2 commits intomicrosoft:mainfrom
SergeyMenshykh:improve-skills-validation

Conversation

@SergeyMenshykh
Copy link
Member

This PR improves skill validation in FileAgentSkillLoader with two changes:

  1. Reject consecutive hyphens in skill names — The name regex now disallows names like "my--skill". The error message is updated accordingly.
  2. Enforce skill name matches parent directory name — A new validation ensures the name field in SKILL.md frontmatter matches the parent directory name (e.g., a skill at skills/my-skill/SKILL.md must have name: my-skill). A mismatch logs an error and
    excludes the skill.

Closes: #4421

Copy link
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

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 name via an updated validation regex and error message.
  • Enforce name in SKILL.md frontmatter 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.

@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Mar 6, 2026
Merged via the queue into microsoft:main with commit 394e9c1 Mar 6, 2026
21 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Agent Framework Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

.NET: [Bug]: AgentSkills do not validate/follow the spec

5 participants