feat(filesystem): say when list_directory finds an empty directory - #3912
Merged
Conversation
trungutt
marked this pull request as ready for review
August 5, 2026 07:27
docker-agent
reviewed
Aug 5, 2026
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
docker-agent
reviewed
Aug 5, 2026
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
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.
melmennaoui
approved these changes
Aug 5, 2026
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
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.
Why
list_directoryreturns an emptyOutputfor 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 allDirectory 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 hiddenIncluding the resolved path doubles as a resolution hint, same as #3908 did for not-found errors.