fix(tools): honor recursive list_dir depth#29
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c371048df0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if err := walk(filepath.Join(dir, e.Name()), relPath, depth-1); err != nil { | ||
| return err |
There was a problem hiding this comment.
Skip unreadable subdirectories during recursive list_dir
When depth > 1, a single os.ReadDir failure in any child directory aborts the entire list_dir call and returns only an error, even if the parent directory was readable and already had useful entries. This is a regression from the non-recursive behavior and will surface in repos that contain permission-restricted folders (or transiently inaccessible mounts), where callers now lose all listing data instead of getting a partial tree. Consider treating child traversal failures as per-entry errors (or skipping that subtree) rather than failing the whole tool result.
Useful? React with 👍 / 👎.
Non-technical summary
intentnow honors recursivelist_dirrequests, so the model can inspect one or two nested directory levels without guessing filenames.depth, but the implementation silently ignored it, weakening read-only context gathering.Technical summary
list_dirtraversal ininternal/tools/tools.go, withdepthdefaulting to1, a globalmax_entriescap, and no symlink traversal.pathfield alongsidename/type/sizeso nested entries stay grounded to the requested directory.internal/tools/tools_test.go.internal/model/prompt.goto advertiselist_dir(path[, depth])and bumpedPromptTemplateVersionso cached prompts refresh against the new capability.docs/SPEC.mdso the documented return shape matches the recursive tool output.Additional notes
pathfield, which is additive and keeps top-levelnamebehavior intact.read_filebefore edit proposals remains out of scope for this bounded increment.