Skip to content

feat: make list_directory file sizes opt-in via showSizes - #778

Merged
will-lamerton merged 2 commits into
Nano-Collective:mainfrom
MsfPablo:feat/list-directory-opt-in-sizes
Aug 9, 2026
Merged

will-lamerton merged 2 commits into
Nano-Collective:mainfrom
MsfPablo:feat/list-directory-opt-in-sizes

Conversation

@MsfPablo

@MsfPablo MsfPablo commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #767. list_directory appended a byte size to every file entry unconditionally — roughly 8-10 tokens per entry for information that's rarely load-bearing when the model is just orienting itself in a directory (400-500 tokens on a 50-entry listing, more on recursive listings). It also cost an lstat syscall per file purely to get that size.

Added a showSizes boolean to ListDirectoryArgs and the tool schema, defaulting to false:

  • Gated the lstat call on showSizes (skipped entirely when not requested)
  • The existing entry.size ? ... : '' size-string logic already handles size being undefined correctly, so no change needed there
  • Updated the tool description, which claimed "List directory contents with file sizes" — now mentions showSizes=true as opt-in, and points to read_file's metadata_only for a single file's size

Test plan

  • pnpm run test:format, test:lint, test:types — all clean
  • pnpm run test:ava source/tools/list-directory.spec.tsx — 30 tests pass
  • Updated list_directory shows file sizes → list_directory hides file sizes by default (asserts no bytes in output) and added list_directory shows file sizes when showSizes=true to cover the opt-in path explicitly

list_directory appended a byte size to every file entry unconditionally,
~8-10 tokens per entry for information that's rarely load-bearing when
the model is just orienting itself in a directory (400-500 tokens on a
50-entry listing, more on recursive listings). It also cost an lstat
syscall per file purely to get that size.

Added a showSizes boolean (default false) to gate both the lstat call
and the size string. Sizes are still available on demand: per-file via
read_file's metadata_only, or for a listing via showSizes=true. Updated
the tool description, which claimed sizes were always included.

Fixes Nano-Collective#767

@akramcodez akramcodez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM great work @MsfPablo :)

@will-lamerton

Copy link
Copy Markdown
Member

Nice work @MsfPablo :)

@will-lamerton
will-lamerton merged commit bf5bcf7 into Nano-Collective:main Aug 9, 2026
1 check passed
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.

list_directory emits byte sizes on every entry by default

3 participants