Skip to content

list_directory emits byte sizes on every entry by default #767

Closed

Description

@will-lamerton

Problem

source/tools/list-directory.tsx:161-164 appends a byte size to every file entry:

const sizeStr = entry.size
    ? ` (${entry.size.toLocaleString()} bytes)`
    : '';

So a listing looks like:

useAppState.tsx (15,504 bytes)
tool-manager.ts (12,134 bytes)
App.tsx (29,252 bytes)

That is roughly 8-10 tokens per entry for information that is rarely load-bearing when the model is just orienting itself in a directory. On a 50-entry listing it is 400-500 tokens, and on a recursive listing it multiplies.

The information is already available on demand through read_file with metadata_only: true.

There is also an lstat call per file (source/tools/list-directory.tsx:96-102) purely to get the size, so dropping it by default is a small wall-clock win on large directories too.

Fix

Make sizes opt-in behind a showSizes boolean on the tool schema, defaulting to false. Skip the lstat when it is false.

The tool description at source/tools/list-directory.tsx:188 says "List directory contents with file sizes", so that needs updating to match.

Notes for a first-time contributor

Contained to one file. Add the flag to the ListDirectoryArgs interface and the inputSchema, gate the lstat and the size string on it, update the description. Tests in source/tools/list-directory.spec.tsx.

Activity

  1. added
    enhancement
    good first issue
    on Aug 3, 2026
  2. will-lamerton commented on Aug 3, 2026

    @will-lamerton
    MemberAuthor

    Part of #772.

  3. added a commit that references this issue on Aug 9, 2026
    f994ebd
  4. added
    area:providers
    on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:providersenhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions