.NET: [BREAKING] Harness: Switch FileAccess to opt-in#7093
Merged
moonbox3 merged 4 commits intoJul 14, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes the .NET HarnessAgent’s file access capability least-privilege by switching FileAccessProvider from default-on (opt-out) to opt-in (enabled only when a FileAccessStore is explicitly provided), and updates the API surface, tests, and samples accordingly.
Changes:
HarnessAgentOptions: removesDisableFileAccess, clarifies opt-in behavior viaFileAccessStore, and addsFileAccessProviderOptionsfor provider configuration.HarnessAgent: wires upFileAccessProvideronly whenFileAccessStoreis set, passing throughFileAccessProviderOptions.- Tests and samples: remove
DisableFileAccessusage, update expectations (provider absent by default), and explicitly setFileAccessStorein samples that need file access.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.Harness.UnitTests/HarnessAgentTests.cs | Updates FileAccess provider expectations (absent by default; present when store provided) and adds an options-focused test. |
| dotnet/tests/Microsoft.Agents.AI.Harness.UnitTests/HarnessAgentOptionsTests.cs | Aligns option default/value tests with removal of DisableFileAccess and addition of FileAccessProviderOptions. |
| dotnet/src/Microsoft.Agents.AI.Harness/HarnessAgentOptions.cs | Removes disable flag, documents opt-in behavior, and introduces FileAccessProviderOptions. |
| dotnet/src/Microsoft.Agents.AI.Harness/HarnessAgent.cs | Makes FileAccessProvider opt-in by FileAccessStore presence and passes provider options through. |
| dotnet/samples/02-agents/Harness/Harness_Step05_Loop/Program.cs | Removes redundant DisableFileAccess configuration. |
| dotnet/samples/02-agents/Harness/Harness_Step04_CodeExecution/Program.cs | Explicitly enables file access via FileAccessStore and updates explanatory comments. |
| dotnet/samples/02-agents/Harness/Harness_Step03_DataProcessing/README.md | Updates documentation to reflect opt-in file access and the need to set FileAccessStore. |
| dotnet/samples/02-agents/Harness/Harness_Step03_DataProcessing/Program.cs | Updates comments and explicitly sets FileAccessStore for the sample’s working folder. |
| dotnet/samples/02-agents/Harness/Harness_Step02_Research_WithBackgroundAgents/Program.cs | Removes redundant DisableFileAccess lines since file access is no longer default-on. |
| dotnet/samples/02-agents/Harness/Harness_Step01_Research/Program.cs | Removes redundant DisableFileAccess configuration. |
5 tasks
rogerbarreto
approved these changes
Jul 13, 2026
peibekwe
approved these changes
Jul 13, 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 & Context
The
HarnessAgentpreviously enabled itsFileAccessProviderby default (opt-out viaHarnessAgentOptions.DisableFileAccess), implicitly rooting aFileSystemAgentFileStoreat{cwd}/workingunless the caller disabled it. File access grants the agent read/write/delete tools over a working directory, so enabling it implicitly is surprising and violates least-privilege.As part of preparing the harness for release, file access is now opt-in: it is only wired up when the caller deliberately supplies a
FileAccessStore. This mirrors the existing opt-in pattern used forBackgroundAgents(presence of the value enables the provider; noDisable*flag).Description & Review Guide
What are the major changes?
HarnessAgentOptions: removedDisableFileAccess; rewordedFileAccessStoredocs to describe opt-in behavior; addedFileAccessProviderOptions? FileAccessProviderOptionsso callers can configure the provider (instructions, disable write tools, approval).HarnessAgent:FileAccessProvideris added only whenFileAccessStoreis set — no implicit{cwd}/workingdefault store is ever created. The suppliedFileAccessProviderOptionsare passed through. Class<remarks>updated to list FileAccess under the optional/enabled-via-options providers.DisableFileAccessusage; the "all defaults" test now assertsFileAccessProvideris absent by default; the include/exclude/custom-store tests are now store-driven, plus a new test coveringFileAccessProviderOptions.DisableFileAccess = truelines; the "all features" code-execution sample now explicitly enables file access via aFileAccessStore; corrected comments/README describing the old default behavior.What is the impact of these changes?
FileAccessStoreis supplied, andDisableFileAccessis removed. Samples that need file access setFileAccessStoreexplicitly.What do you want reviewers to focus on?
HarnessAgent.BuildContextProvidersand the sample updates that keep file access working where it is intended.Related Issue
Related to #7092 (the issue covers both .NET and Python, so this PR does not close it).
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.