Skip to content

System grep strategy is case-sensitive while git grep and JS fallback are not #24955

@Anjaligarhwal

Description

@Anjaligarhwal

What happened?

The GrepTool has three search strategies that cascade on failure: git grep, system grep, and a JavaScript fallback. Two of these perform case-insensitive matching, but the system grep strategy does not:

Strategy Flag Case-insensitive
git grep --ignore-case (line 418) Yes
system grep (none) No
JS fallback RegExp(pattern, 'i') (line 553) Yes

This means search results depend on which strategy runs at runtime. On a non-git repo where system grep is available, a search for "TODO" won't match "todo" or "Todo" — but the same search in a git repo (git grep) or on Windows (JS fallback) will match all casings.

The system grep args at packages/core/src/tools/grep.ts line 467:

const grepArgs = ['-r', '-n', '-H', '-E', '-I'];  // missing -i

The exclude_pattern regex on line 404 already uses the 'i' flag, which further confirms case-insensitive was the intended behavior.

What did you expect to happen?

All three strategies should produce consistent case-insensitive results. The system grep strategy should include -i in its argument list, matching the behavior of git grep (--ignore-case) and the JS fallback (RegExp(pattern, 'i')).

Client information

Identified via code review on main branch. Not a runtime reproduction, the inconsistency is visible in the source at packages/core/src/tools/grep.ts line 467 vs line 418 and line 553.

Login information

N/A — code-level bug, not auth-related.

Anything else we need to know?

The ripGrep.ts alternative implementation already uses --ignore-case at line 432, so this inconsistency is specific to the grep.ts system grep path. Submitting a PR shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualitystatus/need-triageIssues that need to be triaged by the triage automation.status/possible-duplicate

    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