Skip to content

fix(tools): honor recursive list_dir depth#29

Merged
CoreyRDean merged 1 commit into
mainfrom
fix/list-dir-depth
May 12, 2026
Merged

fix(tools): honor recursive list_dir depth#29
CoreyRDean merged 1 commit into
mainfrom
fix/list-dir-depth

Conversation

@CoreyRDean
Copy link
Copy Markdown
Owner

Non-technical summary

  • intent now honors recursive list_dir requests, so the model can inspect one or two nested directory levels without guessing filenames.
  • This matters now because the tool catalog already documented depth, but the implementation silently ignored it, weakening read-only context gathering.
  • The system is better afterward because nested discovery is now real, bounded, and visible in both the tool result shape and prompt guidance.

Technical summary

  • Implemented recursive list_dir traversal in internal/tools/tools.go, with depth defaulting to 1, a global max_entries cap, and no symlink traversal.
  • Added a relative path field alongside name/type/size so nested entries stay grounded to the requested directory.
  • Added focused tests covering depth semantics and truncation behavior in internal/tools/tools_test.go.
  • Updated internal/model/prompt.go to advertise list_dir(path[, depth]) and bumped PromptTemplateVersion so cached prompts refresh against the new capability.
  • Updated docs/SPEC.md so the documented return shape matches the recursive tool output.
  • Breaking changes: none.

Additional notes

  • Trade-off: the tool result now includes an extra path field, which is additive and keeps top-level name behavior intact.
  • Follow-up intentionally deferred: broader file-grounding policy work such as enforcing read_file before edit proposals remains out of scope for this bounded increment.
  • Remaining gap: this improves nested discovery, but higher-level prompt/engine policies can still evolve separately for richer multi-step editing behavior.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread internal/tools/tools.go
Comment on lines +150 to +151
if err := walk(filepath.Join(dir, e.Name()), relPath, depth-1); err != nil {
return err
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@CoreyRDean CoreyRDean merged commit 1aaf072 into main May 12, 2026
8 checks passed
@CoreyRDean CoreyRDean deleted the fix/list-dir-depth branch May 12, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant