Thanks to visit codestin.com
Credit goes to github.com

Skip to content

.NET: [Breaking] Refactor AgentFileSkillsSource for depth-based discovery and predicate filters#6109

Merged
semenshi merged 2 commits into
microsoft:mainfrom
semenshi:refactor/agent-file-skill-filter-context
May 28, 2026
Merged

.NET: [Breaking] Refactor AgentFileSkillsSource for depth-based discovery and predicate filters#6109
semenshi merged 2 commits into
microsoft:mainfrom
semenshi:refactor/agent-file-skill-filter-context

Conversation

@semenshi

Copy link
Copy Markdown
Contributor

Refactors AgentFileSkillsSource to make script and resource discovery more flexible.

Changes

  • Drops ScriptDirectories / ResourceDirectories options (preconfigured directory whitelists).
  • Adds SearchDepth option (>= 1, default 2): controls how deep the recursive scan goes within each skill directory.
  • Adds ScriptFilter / ResourceFilter predicate options that receive an AgentFileSkillFilterContext (SkillName + RelativeFilePath), allowing whitelist/blacklist filtering by file path.

Notes

  • The options surface is marked [Experimental] -- the option removals are intentional.
  • Security checks (path containment, symlink detection, reparse-point skipping) are preserved and continue to use the skill root directory as the trusted boundary.
  • All 2888 unit tests pass.

…FileSkillFilterContext

- Replace hardcoded script/resource directory lists with configurable ScriptFilter and ResourceFilter predicates
- Add AgentFileSkillFilterContext class to provide contextual file information to filter predicates
- Replace MaxSearchDepth constant with configurable SearchDepth option
- Update AgentFileSkillsSourceOptions with new filter and search depth properties
- Update tests to reflect the new filtering approach

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings May 27, 2026 12:08

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.

Copilot wasn't able to review any files in this pull request.

@moonbox3 moonbox3 added the .NET Usage: [Issues, PRs], Target: .Net label May 27, 2026
@moonbox3

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
TOTAL36634433388% 
report-only-changed-files is enabled. No files were changed during this commit :)

Python Unit Test Overview

Tests Skipped Failures Errors Time
7287 34 💤 0 ❌ 0 🔥 1m 57s ⏱️

@semenshi semenshi enabled auto-merge May 27, 2026 16:18
Comment thread dotnet/src/Microsoft.Agents.AI/Skills/File/AgentFileSkillsSource.cs Outdated
@semenshi semenshi added this pull request to the merge queue May 28, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 28, 2026
@semenshi semenshi added this pull request to the merge queue May 28, 2026
@semenshi semenshi removed this pull request from the merge queue due to a manual request May 28, 2026
@semenshi semenshi added this pull request to the merge queue May 28, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 28, 2026
@semenshi semenshi added this pull request to the merge queue May 28, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 28, 2026
@semenshi semenshi added this pull request to the merge queue May 28, 2026
Merged via the queue into microsoft:main with commit 3ee1bb4 May 28, 2026
26 checks passed
pull Bot pushed a commit to nagyist/ms-agent-framework that referenced this pull request Jun 24, 2026
…y and predicate filters (microsoft#6488)

* Python: [Breaking] Refactor FileSkillsSource for depth-based discovery and predicate filters

Refactors FileSkillsSource to make script and resource discovery more flexible.

## Changes

- **Drops** resource_directories / script_directories options (preconfigured
  directory whitelists).
- **Adds** search_depth option (>= 1, default 2): controls how deep the
  recursive scan goes within each skill directory.
- **Adds** script_filter / resource_filter predicate options that receive a
  FileSkillFilterContext (skill_name + relative_file_path), allowing
  whitelist/blacklist filtering by file path.
- **Adds** FileSkillFilterContext class exported from agent_framework.

## Notes

- The Skills API is marked @experimental -- the option removals are intentional
  breaking changes within the experimental surface.
- Security checks (path containment, symlink detection) are preserved and
  continue to use the skill root directory as the trusted boundary.
- Ports the same refactoring from .NET PR microsoft#6109 while following Python
  conventions (instance methods, Callable type hints, __slots__).

Co-authored-by: Copilot <[email protected]>

* Address PR feedback: clarify depth constants and skip nested skill directories

- Add clarifying comments distinguishing MAX_SEARCH_DEPTH (SKILL.md
  discovery) from DEFAULT_SEARCH_DEPTH (per-skill resource/script scanning).
- Stop recursing into subdirectories that contain their own SKILL.md,
  preventing child skill files from being attached to the parent skill.
- Add test verifying nested skill boundary is respected.

Co-authored-by: Copilot <[email protected]>

* Remove __slots__ from FileSkillFilterContext and add type-ignore comments

- Remove __slots__ from FileSkillFilterContext per reviewer feedback —
  the optimization is negligible and inconsistent with sibling classes.
- Add type: ignore[attr-defined] / ty: ignore[unresolved-attribute]
  comments to test lines accessing private _resources/_scripts attributes,
  matching the convention established on main.

Co-authored-by: Copilot <[email protected]>

* Simplify filter predicates: remove FileSkillFilterContext, use Callable[[str, str], bool]

Address reviewer feedback:
- Remove FileSkillFilterContext class — a dedicated class for two strings
  is overkill in Python. Filters now receive (skill_name, relative_file_path)
  directly as positional args.
- Update docstrings to describe behavior instead of referencing private
  instance attributes.
- Remove FileSkillFilterContext from exports and __all__.
- Update all test lambdas and remove TestFileSkillFilterContext class.

Co-authored-by: Copilot <[email protected]>

* Use DEFAULT_SEARCH_DEPTH as default argument directly

Instead of accepting int | None and resolving None to the default
internally, use DEFAULT_SEARCH_DEPTH as the parameter default value
on both FileSkillsSource.__init__() and SkillsProvider.from_paths().

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
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