Skip to content

.NET: Discover skill resources from directory instead of markdown links - #4401

Merged
SergeyMenshykh merged 6 commits into
microsoft:mainfrom
SergeyMenshykh:discover-resources-from-paths
Mar 4, 2026
Merged

SergeyMenshykh merged 6 commits into
microsoft:mainfrom
SergeyMenshykh:discover-resources-from-paths

Conversation

@SergeyMenshykh

Copy link
Copy Markdown
Contributor

Summary

Switches FileAgentSkillLoader from parsing markdown links ([text](path)) to discover resources to scanning the skill directory for files with matching extensions. This is more robust and aligns with the convention that all files in a skill folder are part of that skill.

Changes

  • Resource discovery: Replace regex-based markdown link extraction with recursive directory scanning using configurable allowed extensions (.md, .json, .yaml, .yml, .csv, .xml, .txt by default)
  • Graceful degradation: Invalid resources (path traversal, symlink escape, disallowed extensions) are now skipped with warnings instead of rejecting the entire skill
  • Configurable extensions: FileAgentSkillLoader accepts an optional allowedResourceExtensions parameter; FileAgentSkillsProviderOptions exposes a corresponding property
  • Log safety: Added SanitizePathForLog to prevent log injection via crafted filenames containing control characters
  • Tests: Updated and expanded unit tests to reflect the new discovery-based approach

Copilot AI review requested due to automatic review settings March 2, 2026 20:17
@markwallace-microsoft Mark Wallace (markwallace-microsoft) added the .NET Usage: [Issues, PRs], Target: .Net label Mar 2, 2026

Copilot AI left a comment

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.

Pull request overview

This PR updates the .NET skill-loading pipeline to discover skill resources by scanning the skill directory (by allowed extensions) instead of parsing markdown links from SKILL.md, and adapts configuration and tests accordingly.

Changes:

  • Replace markdown-link-based resource extraction with recursive directory scanning filtered by an allowed extension list.
  • Add an options surface (AllowedResourceExtensions) and wire it through FileAgentSkillsProvider into FileAgentSkillLoader.
  • Update and expand unit tests to validate discovery, extension filtering, and symlink behavior under the new approach.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

File Description
dotnet/src/Microsoft.Agents.AI/Skills/FileAgentSkillLoader.cs Implements directory-scan-based resource discovery, extension validation, and log sanitization.
dotnet/src/Microsoft.Agents.AI/Skills/FileAgentSkillsProvider.cs Passes configured allowed resource extensions into the loader.
dotnet/src/Microsoft.Agents.AI/Skills/FileAgentSkillsProviderOptions.cs Exposes AllowedResourceExtensions to configure discovery behavior.
dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/FileAgentSkillLoaderTests.cs Updates tests to validate file-based discovery and new edge cases.

Comment thread dotnet/src/Microsoft.Agents.AI/Skills/FileAgentSkillLoader.cs
Comment thread dotnet/src/Microsoft.Agents.AI/Skills/FileAgentSkillLoader.cs
Comment thread dotnet/src/Microsoft.Agents.AI/Skills/FileAgentSkillLoader.cs Outdated
Comment thread dotnet/src/Microsoft.Agents.AI/Skills/FileAgentSkillLoader.cs Outdated
Comment thread dotnet/src/Microsoft.Agents.AI/Skills/FileAgentSkillLoader.cs Outdated
Comment thread dotnet/src/Microsoft.Agents.AI/Skills/FileAgentSkillLoader.cs Outdated
Comment thread dotnet/src/Microsoft.Agents.AI/Skills/FileAgentSkillLoader.cs
Comment thread dotnet/src/Microsoft.Agents.AI/Skills/FileAgentSkillLoader.cs Outdated
@SergeyMenshykh
SergeyMenshykh added this pull request to the merge queue Mar 4, 2026

This branch was previously deployed

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

Labels

.NET Usage: [Issues, PRs], Target: .Net

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants