Skip to content

feat(filesystem): say when list_directory finds an empty directory - #3912

Merged
trungutt merged 1 commit into
docker:mainfrom
trungutt:list-directory-empty-message
Aug 5, 2026
Merged

feat(filesystem): say when list_directory finds an empty directory#3912
trungutt merged 1 commit into
docker:mainfrom
trungutt:list-directory-empty-message

Conversation

@trungutt

@trungutt trungutt commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Why

list_directory returns an empty Output for an empty directory, and the runtime substitutes a generic (no output) placeholder (pkg/runtime/toolexec/dispatcher.go). The model cannot tell "the listing succeeded and the directory is empty" from "the tool broke".

In a real session the working directory was an empty scratch dir: the model called list_directory, got (no output), distrusted it, and re-listed the same directory through the shell — a wasted turn, and it still concluded "your directory is empty or I don't have access to it".

What

When the listing produces no entries, say so explicitly instead of returning nothing:

  • Directory is empty: <resolved path> — nothing there at all
  • Directory has no visible entries (N hidden by ignore patterns): <resolved path> — entries exist but are all VCS/agents-ignore filtered, so the model doesn't go looking for files that are deliberately hidden

Including the resolved path doubles as a resolution hint, same as #3908 did for not-found errors.

@trungutt
trungutt marked this pull request as ready for review August 5, 2026 07:27
@trungutt
trungutt requested a review from a team as a code owner August 5, 2026 07:27

@docker-agent docker-agent 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.

Assessment: 🟢 APPROVE

@docker-agent docker-agent 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.

Assessment: 🟢 APPROVE

The change is correct and clean. When list_directory produces zero visible entries, the new if count == 0 block now emits an explicit human-readable message instead of returning an empty string that the runtime replaces with a generic (no output) placeholder. The two-branch logic correctly distinguishes a truly empty directory (zero entries) from one that had entries but all were filtered by ignore patterns (non-zero entries, zero count), and both messages include the resolved path as a resolution hint — consistent with the pattern established in #3908. No correctness issues found.

@aheritier aheritier added area/testing Test infrastructure, CI/CD, test runners, evaluation area/tools For features/issues/fixes related to the usage of built-in and MCP tools kind/feat PR adds a new feature (maps to feat:). Use on PRs only. labels Aug 5, 2026
@trungutt
trungutt merged commit f3a36b5 into docker:main Aug 5, 2026
12 of 13 checks passed
dwin-gharibi pushed a commit to dwin-gharibi/docker-agent that referenced this pull request Aug 6, 2026
Reflects changes from docker#3912.
Source PR: docker#3912

Added documentation for the new empty directory detection behavior:
- list_directory now explicitly reports when a directory is empty
- Distinguishes between truly empty directories and directories with
  all entries hidden by ignore patterns
- Helps models avoid unnecessary shell command retries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/testing Test infrastructure, CI/CD, test runners, evaluation area/tools For features/issues/fixes related to the usage of built-in and MCP tools kind/feat PR adds a new feature (maps to feat:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants