.NET: [BREAKING] Align FileAccess tools with Python; add directory discovery and recursive search#6474
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns the .NET “File Access” tool surface with the Python implementation by adding directory discovery and making content search recursive across the store, while updating tool naming to snake_case (file_access_*). These changes improve an agent’s ability to explore a file tree and find content without prior knowledge of subdirectory structure.
Changes:
- Added directory discovery via a new
file_access_list_subdirectoriestool and correspondingAgentFileStore.ListDirectoriesAsyncAPI. - Updated store search APIs to support optional recursive enumeration and glob matching against store-root-relative (or search-root-relative) paths.
- Renamed .NET FileAccess tool names to
file_access_*and updated tests + sample instructions accordingly.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/FileStore/InMemoryAgentFileStoreTests.cs | Adds unit tests for recursive search and directory listing in the in-memory store. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/FileStore/FileSystemAgentFileStoreTests.cs | Adds unit tests for recursive search, directory listing, and symlink-skipping behavior in the filesystem store. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/FileAccess/FileAccessProviderTests.cs | Updates tests for snake_case tool names and adds coverage for new list-subdirectories + recursive search behavior. |
| dotnet/src/Microsoft.Agents.AI/Harness/FileStore/InMemoryAgentFileStore.cs | Implements ListDirectoriesAsync and adds optional recursive search semantics in-memory. |
| dotnet/src/Microsoft.Agents.AI/Harness/FileStore/FileSystemAgentFileStore.cs | Implements recursive search enumeration + ListDirectoriesAsync, with reparse-point skipping. |
| dotnet/src/Microsoft.Agents.AI/Harness/FileStore/AgentFileStore.cs | Extends the abstract store contract with ListDirectoriesAsync and a recursive search option + updated glob semantics. |
| dotnet/src/Microsoft.Agents.AI/Harness/FileMemory/FileMemoryProvider.cs | Pins FileMemoryProvider to non-recursive search to preserve existing behavior. |
| dotnet/src/Microsoft.Agents.AI/Harness/FileAccess/FileAccessProvider.cs | Renames tools to file_access_*, adds list-subdirectories tool, and documents recursive search + ** glob semantics. |
| dotnet/samples/02-agents/Harness/Harness_Step03_DataProcessing/Program.cs | Updates sample instructions to reference file_access_* tools. |
| dotnet/samples/02-agents/Harness/Harness_Shared_Console/Observers/PlanningResponse.cs | Clarifies PlanningQuestion.Choices constraints to ensure choices are valid free-form-compatible inputs. |
rogerbarreto
approved these changes
Jun 11, 2026
peibekwe
approved these changes
Jun 11, 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.
Motivation and Context
The Python and .NET implementations of the file-access function tools had diverged, and there were two functional gaps on the .NET side:
file_access_list_filesonly surfaces direct-child files; child directory names were never exposed, so an agent could not discover that subdirectories existed.file_access_search_filesonly scanned the direct children of a single directory, with no way to search an entire subtree.This PR closes both gaps and aligns the .NET tool surface with Python (same
file_access_*snake_case tool names).#6398
Description
Tool layer (
FileAccessProvider)file_access_list_subdirectoriestool that lists the direct child subdirectories of a directory (root when omitted), enabling the agent to discover and walk the directory tree one level at a time.file_access_search_filesrecursive across all descendants from the store root. Removed thedirectoryparameter from the search tool; subtree scoping is now expressed purely through the globfilePattern, which is matched against the store-root-relative path of each file. Results return root-relative paths infileName, directly usable by read/delete tools.**for cross-directory matching).Store layer (
AgentFileStore,InMemoryAgentFileStore,FileSystemAgentFileStore)ListDirectoriesAsync(direct child subdirectories; FileSystem store skips symlinked/reparse-point directories).bool recursive = falseparameter toSearchFilesAsync. The default preserves the existing behavior thatFileMemoryProviderdepends on (direct children, basename results);FileAccessProvideropts into recursion. Glob and resultFileNameare defined relative to the search directory. FileSystem recursive enumeration skips symlinked files and directories.Glob semantics are intentionally kept native per language (Python
fnmatch, .NETMicrosoft.Extensions.FileSystemGlobbing.Matcher); the expected format is documented to the model via the tool descriptions rather than unified in code.Misc
PlanningQuestion.Choicesdescription in the Harness sample to clarify that the model must provide valid free-form-compatible choices.Contribution Checklist
ListDirectories, and symlink-skip tests)