Skip to content

fix(core): bound default search results - #37154

Merged
kitlangton merged 1 commit into
v2from
bounded-search-results
Jul 15, 2026
Merged

fix(core): bound default search results#37154
kitlangton merged 1 commit into
v2from
bounded-search-results

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

Give V2 filesystem glob and grep searches the same 100-result default bound as V1 when callers omit limit.

The audit found both model-facing search tools had the same unbounded fallback. Other built-in tools already have concrete capture limits: read bounds lines and bytes, shell bounds captured output, and webfetch / websearch bound response sizes.

Before / After

Before: A model could call glob or grep without limit. The tool translated that omission to Number.MAX_SAFE_INTEGER, and the ripgrep adapter collected matching rows in memory. A broad search over a large worktree could therefore retain millions of paths or matches, exhaust process memory, and leave the tool call running indefinitely.

After: Omitted limits resolve to 100 before either ripgrep or fff executes. Ripgrep's existing take(limit + 1) boundary stops collection and terminates the scoped subprocess once the bounded result is known.

How

  • packages/core/src/filesystem.ts defines the shared DEFAULT_SEARCH_LIMIT.
  • packages/core/src/tool/glob.ts and packages/core/src/tool/grep.ts apply and advertise that default for model calls.
  • packages/core/src/filesystem/search.ts applies the same default in both ripgrep and fff service implementations so non-tool consumers cannot recover the unbounded omission behavior.
  • packages/core/test/tool-search.test.ts executes both real registered tools against 101 matches and verifies omitted limits settle with 100 structured results.

Scope

This does not change explicit caller-supplied limits or the Location file indexer, whose catch-all scan deliberately uses separate indexing behavior. It does not modify V1, which already hard-codes a 100-result bound for both tools.

Testing

  • cd packages/core && bun run test test/tool-search.test.ts (3 passed)
  • cd packages/core && bun run test (1,292 passed, 6 skipped)
  • cd packages/core && bun run typecheck
  • Pre-push hook: bun turbo typecheck --concurrency=3 (32 packages passed)
  • bun run prettier --check packages/core/src/filesystem.ts packages/core/src/filesystem/search.ts packages/core/src/tool/glob.ts packages/core/src/tool/grep.ts packages/core/test/tool-search.test.ts
  • bun run lint (passes with existing repository warnings)
  • bun run lint:effect-patterns remains blocked by seven pre-existing findings outside this diff

@kitlangton
kitlangton merged commit b6ccb66 into v2 Jul 15, 2026
10 checks passed
@kitlangton
kitlangton deleted the bounded-search-results branch July 15, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant