Skip to content

.NET: increase default search depth for script and resource discovery (fixes #5968)#6201

Open
hanhan761 wants to merge 1 commit into
microsoft:mainfrom
hanhan761:fix-5968-script-subdirectory-search
Open

.NET: increase default search depth for script and resource discovery (fixes #5968)#6201
hanhan761 wants to merge 1 commit into
microsoft:mainfrom
hanhan761:fix-5968-script-subdirectory-search

Conversation

@hanhan761
Copy link
Copy Markdown

Summary

Increase the default SearchDepth for script and resource file discovery from 2 to 10, allowing the discovery of nested scripts/resources in deeper subdirectory structures.

Background

AgentFileSkillsSource already supports recursive directory traversal via ScanDirectoryForScripts and ScanDirectoryForResources, but the default _searchDepth of 2 limits discovery to the root directory plus one level of subdirectories. Files nested deeper (e.g., scripts/subdir/tool/my_script.py) are silently skipped.

Fix

Changed DefaultSearchDepth from 2 to 10. This allows discovery up to 10 levels of nesting while maintaining the existing security checks (symlink detection, path traversal prevention) and the SearchDepth configuration option for users who need different limits.

Issue

Fixes #5968

Verification

  • Existing tests in AgentFileSkillsSourceScriptTests.cs cover the default depth behavior
  • The SearchDepth option remains configurable via AgentFileSkillsSourceOptions.SearchDepth
  • Security checks (symlink, path traversal) are unaffected

Copilot AI review requested due to automatic review settings May 30, 2026 07:23
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

Note

Copilot was unable to run its full agentic suite in this review.

Updates the default directory search depth used by AgentFileSkillsSource when looking for skill files.

Changes:

  • Increased DefaultSearchDepth from 2 to 10.

Comment on lines +33 to 34
private const int DefaultSearchDepth = 10;
private const int MaxSkillDirectorySearchDepth = 2;
@moonbox3 moonbox3 added the .NET label May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: Why do script and resource not support searching for files in subdirectories?

3 participants