Skip to content

fix: skip file tree entries removed during scan - #2092

Open
laoyyu wants to merge 1 commit into
agent0ai:mainfrom
laoyyu:fix/2089-file-tree-vanished-entries
Open

laoyyu wants to merge 1 commit into
agent0ai:mainfrom
laoyyu:fix/2089-file-tree-vanished-entries

Conversation

@laoyyu

@laoyyu laoyyu commented Nov 24, 2026

Copy link
Copy Markdown

What changed

Directory-tree collection now tolerates a file or folder disappearing between os.scandir() and DirEntry.stat(). Vanished entries are skipped from both the normal tree and the deferred summary path instead of aborting prompt preparation.

Why

Agent workdirs can contain transient state files. When one was removed during the scan window, FileNotFoundError escaped through file_tree() and aborted the chat turn.

Verification

  • pytest tests/test_file_tree_helper.py -q -> 1 passed
  • python -m py_compile helpers/file_tree.py tests/test_file_tree_helper.py
  • git diff --check

The existing tests/test_file_tree_indent.py could not be collected in the minimal local environment because optional runtime dependency aiohttp is not installed.

Closes #2089

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FileNotFoundError from entry.stat() in helpers/file_tree.py kills chats when files are deleted during the directory scan (TOCTOU race)

1 participant