Skip to content

Python: return actionable file-access write path errors - #8710

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
lakers-abing:fix/file-access-collision-guidance
Sep 28, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
lakers-abing:fix/file-access-collision-guidance

Conversation

@lakers-abing

Copy link
Copy Markdown

Motivation & Context

When a write hits a file/directory path collision, the file-access tool should tell the agent how to recover. The current generic OS error does not distinguish whether the parent path is a file or the target is a directory. The existing FileExistsError response is specific to exclusive create and should continue recommending overwrite=true only for that case.

Description & Review Guide

  • What are the major changes? Return separate actionable messages for NotADirectoryError and IsADirectoryError, and add tool-level regression tests for both cases plus the existing exclusive-create response.
  • What is the impact of these changes? Agents can choose a valid path after a collision while overwrite=false retains its existing behavior.
  • What do you want reviewers to focus on? Confirm the guidance distinguishes path collisions from an existing file that can be overwritten.

Related Issue

Fixes #8567. This is complementary to open PR #8687: that PR adds the in-memory store path checks; this change handles the tool response and does not repeat those checks.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change

Copilot AI balanced review requested due to automatic review settings September 24, 2026 08:05
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Sep 24, 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.

Copilot review overview

🟡 Changes recommended

Filesystem-backed collisions can still be misclassified as overwriteable existing files.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds actionable file-write collision errors, complementing PR #8687’s in-memory path validation.

Changes:

  • Distinguishes parent-file and target-directory collisions.
  • Adds regression tests while preserving exclusive-create guidance.
File Description
python/​packages/​core/​agent_framework/​_harness/​_file_access.py Adds collision-specific write responses.
python/​packages/​core/​tests/​core/​test_harness_file_access.py Tests collision and overwrite guidance.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/packages/core/agent_framework/_harness/_file_access.py
@lakers-abing

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Merged via the queue into microsoft:main with commit cc89fe6 Sep 28, 2026
44 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — 5c94901d Deployed Sep 24, 2026 by lakers-abing via add_label #23726
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: InMemoryAgentFileStore permits a path to be both a file and a directory

3 participants