Skip to content

List-directory should support server-side pagination #26108

@mafredri

Description

@mafredri

Problem

The workspace agent list-directory API returns every entry in a directory in one response. That is manageable for small directories, but it becomes expensive when a caller asks for a large path such as a dependency directory or generated output directory.

This is newly easier to hit from chat tooling because read_file can now fall back to list-directory when the path is a directory. The chat tool paginates and caps what it returns to the model, but the agent still sends the full directory listing over the wire before that local cap is applied.

How to verify

Trace codersdk/workspacesdk.AgentConn.LS to the agent list-directory handler. The response shape contains one contents array and no request field for offset, limit, page token, or server-side byte budget.

A practical reproduction is to call list-directory against a path with thousands of entries and compare the response size to the subset a UI or chat caller actually renders.

Desired outcome

Large directory reads should have a server-side bound. Callers should be able to request only the first page, a later page, or a bounded number of entries without downloading the full directory first.

Scope

This is not required to keep #26105 correct. That PR keeps the existing LS API contract and caps the chat-tool response after LS returns. This issue tracks the lower-level API gap so large directories are not fetched in full by every caller.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions