Skip to content

GitHub Copilot grep_search includePattern silently fails with workspace root folder name prefix in multi-root workspaces (severe) #293428

Closed
microsoft/vscode-copilot-chat
#4287

Description

Summary

In a multi-root workspace, GitHub Copilot's grep_search's includePattern does not recognize the workspace root folder name as a path prefix. The pattern rootname/path/to/file.ext silently returns zero results with a misleading error message, even though file_search finds the same file with the identical pattern.

This is the single largest source of LLM search failures in multi-root workspaces. Two additional lower-severity bugs discovered during this investigation are filed separately (see §Related Issues).

Environment

  • OS: Windows 11 (likely affects all platforms — see §Recommended Test Suite)
  • VS Code: 1.109
  • Workspace: Multi-root (3 roots)

Reproduction

Setup

Create a multi-root workspace with two roots:

C:\projects\alpha\       ← workspace root "alpha"
    src/
        hello.txt        ← contains "hello world"
C:\projects\beta\        ← workspace root "beta"
    src/
        hello.txt        ← contains "goodbye world"

Steps

  1. Open both folders as a multi-root workspace.
  2. Use grep_search with includePattern: "alpha/src/hello.txt" and query: "hello".
  3. Use file_search with query: "alpha/src/hello.txt".
  4. Use grep_search with includePattern: "src/hello.txt" and query: "hello" (workaround).

Expected

Steps 2 and 3 both find C:\projects\alpha\src\hello.txt.

Actual

  • Step 2 (grep_search, root-prefixed): ❌ Returns no results. Error message: "Your search pattern might be excluded completely by either the search.exclude settings or .*ignore files."
  • Step 3 (file_search, root-prefixed): ✅ Finds the file.
  • Step 4 (grep_search, root-relative): ✅ Finds the file — but matches both roots, defeating the purpose of scoping.

The Discrepancy

includePattern / query file_search grep_search
alpha/src/hello.txt (root-prefixed) ✅ ❌
alpha/**/hello.txt (root-prefixed glob) ✅ ❌
src/hello.txt (root-relative) ✅ ✅
**/hello.txt (recursive glob) ✅ ✅

The tools agree on root-relative and recursive patterns, but diverge on root-prefixed patterns. Slash direction (/ vs. \ vs. mixed) has no effect on this behavior — the results are identical in all slash variants.

Why This Is Critical for LLMs

  1. Natural behavior leads to failure. LLMs use file_search to locate files, get back results, and learn that rootname/path is valid. They then pass the same root-prefixed path to grep_search as includePattern — which silently returns nothing.

  2. The error message misdirects. The LLM is told the file "might be excluded by .gitignore or search.exclude." This is false. The LLM then retries with includeIgnoredFiles: true (doesn't help), and may eventually fall back to terminal commands, bypassing VS Code's search infrastructure entirely.

  3. No way to scope grep_search to a specific root. The only workaround is root-relative paths (e.g., src/hello.txt), which match files in every root. In a multi-root workspace with similar directory structures, this produces unwanted cross-root results.

Confounding Factor: False Positives with **

The root-prefixed ** pattern (alpha/**/hello.txt) can appear to succeed if the root folder name coincidentally matches a directory segment inside the file tree (e.g., src/com/alpha/util/Hello.java contains a directory named alpha). The ** traverses to the coincidental match, not the root prefix. This creates false confidence in projects where the name coincidence exists, and silent failure in projects where it does not — making the bug appear intermittent when it is actually deterministic.

Root Cause Hypothesis

grep_search appears to delegate to a VS Code API that resolves includePattern globs strictly against paths relative to each workspace root's content directory. file_search appears to use a different API that additionally accepts the root folder name as a scope prefix. The two APIs have different multi-root path resolution semantics, but this distinction is not surfaced in the tool documentation.

Recommendation

  1. grep_search includePattern should accept root folder names as path prefixes, consistent with file_search.
  2. The error message when includePattern matches no files should not suggest .gitignore or search.exclude unless those are actually responsible.

Related Issues

Two additional bugs discovered during this investigation:

Recommended Test Suite

To prevent these discrepancies and catch regressions:

  1. Tool parity: grep_search and file_search produce equivalent results for identical path patterns (root-relative, root-prefixed, recursive glob, explicit path).
  2. Multi-root scoping: Root-prefixed paths correctly scope to the named root. Test with a root name that does not appear as any internal directory segment to avoid false positives.
  3. Error message accuracy: When includePattern produces no results due to an unrecognized path format, the message should not claim .gitignore/search.exclude exclusion.
  4. Platform coverage: Run on Windows (cmd and Git Bash), macOS, and Linux.

Activity

  1. added
    chat-ext-issue
    on Feb 6, 2026
  2. removed
    chat-ext-issue
    on Feb 6, 2026
  3. changed the title [-]GitHub Copilot `grep_search` `includePattern` silently fails with workspace root folder name prefix in multi-root workspaces[/-] [+]GitHub Copilot `grep_search` `includePattern` silently fails with workspace root folder name prefix in multi-root workspaces (severe)[/+] on Feb 6, 2026
  4. garretwilson commented on Feb 6, 2026

    @garretwilson
    Author

    The following test matrix should help you understand all the tests that were performed with which tools, and where the failures were.

    (I hope that the GitHub Copilot team can put in place a comprehensive test suite so that all of these can be contested in a consistent an automated manner in the future, so it won't be left to users to run into them here and there—and sometimes not even understand that there is a bug, thinking that the LLM is just acting up.)


    VS Code Search Tool Path Resolution — Comprehensive Test Matrix

    Legend

    • ✅ = works correctly
    • ❌ = silent failure (no results or nonexistent file error)
    • 🔶 = triggers spurious "external file/directory" security prompt, then fails
    • ⚠️ = partial results (fewer matches than expected)
    • — = not applicable (tool doesn't accept this format)

    Bug Key

    Path Formats Tested

    # Format Example
    1 Root-relative, / src/main/App.java
    2 Root-relative, \ src\main\App.java
    3 Root-relative, mixed src\main/App.java
    4 Recursive glob, / **/App.java
    5 Recursive glob, \ **\App.java
    6 Root-prefixed, explicit, / alpha/src/main/App.java
    7 Root-prefixed, explicit, \ alpha\src\main\App.java
    8 Root-prefixed, /**/ glob alpha/**/App.java
    9 Root-prefixed, \**\ glob alpha\**\App.java
    10 Windows absolute, \ C:\projects\alpha\src\App.java
    11 Windows absolute, / C:/projects/alpha/src/App.java
    12 Git Bash absolute /c/projects/alpha/src/App.java
    13 Leading \, no colon \c\projects\alpha\src\App.java

    Results

    # Path Format file_search grep_search read_file list_dir
    1 root-relative / ✅ ✅ — —
    2 root-relative \ ✅ ✅ — —
    3 root-relative mixed ✅ ✅ — —
    4 **/file / ✅ ✅ — —
    5 **\file \ ✅ ✅ — —
    6 root-prefixed / ✅ ❌ A — —
    7 root-prefixed \ ✅ ❌ A — —
    8 root /**/ glob ✅ ❌ A — —
    9 root \**\ glob ⚠️ B ❌ A — —
    10 C:\ absolute — ❌ ✅ ✅
    11 C:/ absolute — ❌ ✅ ✅
    12 /c/ Git Bash — ❌ 🔶 C 🔶 C
    13 \c\ no colon — ❌ 🔶 C 🔶 C

    Reading the Table

    • Bug A (rows 6–9, grep_search column): root-name prefix silently rejected.
    • Bug B (row 9, file_search column): \**\ glob produces partial/no results.
    • Bug C (rows 12–13, read_file/list_dir columns): malformed absolute paths prompt then fail.
    • Rows 1–5: all tools agree — these are the safe patterns.
    • Rows 10–11: correct absolute paths work for read_file/list_dir; file_search and grep_search don't accept absolute paths (by design, not a bug).
  5. marcofraccaro commented on Feb 9, 2026

    @marcofraccaro

    Garret Wilson (@garretwilson) great catch, I'm facing the exact same issue.

    It makes Github Copilot nearly unusable in multi-root workspaces, even more with new models that rely heavily on grep search and get confused by the failing searches and the inconsistencies you reported. I hope the copilot team can prioritize this ticket soon.

    Have you found any workaround?

  6. garretwilson commented on Mar 8, 2026

    @garretwilson
    Author

    This bug constantly hits me, even with instructions to the LLM about how to work around this VS Code GitHub Pilot bug. Just last night the LLM did a simple update of a project to bring it in line with a dependency update. It completely missed certain dependency references because of these bugs.

    Matt Bierner (@mjbvz) , these are blatant bugs in the critical search tools. These bug reports are explicit, thorough, well researched, and presented in understandable, accessible form. Why are they being ignored?

  7. added
    bug
    and removed on Mar 9, 2026
  8. added this to the 1.112.0 milestone on Mar 9, 2026
  9. locked and limited conversation to collaborators on Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugchatchat-agentverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions