Skip to content

feat(runtime): report Glob truncation instead of stopping silently #5597

Description

@wutongyuonce

Problem

Glob returns at most 200 matches and reports nothing about whether the pattern matched more. A caller receiving exactly 200 cannot tell a complete result from a capped one:

await globFiles({ cwd, pattern: '*.txt', limit: 200 })
// { files: [ ...200 paths... ] }

A directory holding 201 matching files produces the same shape and the same count as one holding exactly 200. The model therefore reads a partial listing as the whole answer: it can conclude a package has no tests, that a rename left nothing behind, or that a directory listing is complete when it is not.

The tool description ("Returns at most 200 matches") does not help, because a count of exactly 200 is ambiguous by construction.

Grep already answers this question for search results — it returns matchedLines, returnedLines, omittedLines, and truncated from one completed search. Glob has no equivalent, so the two search tools disagree about whether they report completeness.

Desired outcome

Glob reports whether the result was cut short. Reading one match past the cap distinguishes "the pattern had exactly limit matches" from "there were more":

  • exactly at the cap → truncated: false
  • more than the cap → truncated: true, with limit files returned

The flag reaches the model in the Glob tool result, and the tool description states it.

One constraint matters as much as the flag itself. Filling the cap ends the result set; traversal past it only answers whether one more match existed. It must therefore not newly fail a capped result. Today a 200-match query over a large tree succeeds when some directory further down is unreadable, because the walk stops at the cap. A naive probe walks one step further and turns that success into an EACCES failure, which would regress exactly the large repositories the cap exists to serve.

Alternatives or workarounds

The model can narrow the pattern or add directory prefixes and compare counts across several calls. That costs turns, is unreliable, and cannot recover the fact that the walk discarded — nothing downstream of the tool can reconstruct whether the list was complete.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions