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.
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_filecan 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.LSto the agentlist-directoryhandler. The response shape contains onecontentsarray 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
LSAPI contract and caps the chat-tool response afterLSreturns. This issue tracks the lower-level API gap so large directories are not fetched in full by every caller.