Skip to content

GitHub Copilot file_search glob with \**\ (backslash double-star) produces partial or no results where /**/ succeeds #293430

Open

Description

Summary

In GitHub Copilot's file_search tool, using backslashes around the ** glob segment (root\**\file.ext) produces fewer results or no results compared to the forward-slash equivalent (root/**/file.ext). Non-glob path segments handle both slash directions interchangeably, so the inconsistency is specific to the ** glob operator.

This is the second of three related bugs in Copilot's search tools affecting multi-root workspaces on Windows. The principal issue is tracked in #293428.

Environment

  • OS: Windows 11
  • VS Code: 1.109
  • Workspace: Multi-root (3 roots)

Reproduction

Setup

Create a multi-root workspace with one root:

C:\projects\alpha\       ← workspace root "alpha"
    readme.md
    src/
        util/
            Helper.java

Steps

  1. Use file_search with query: "alpha/**/Helper.java".
  2. Use file_search with query: "alpha\**\Helper.java".
  3. Use file_search with query: "alpha/**/readme.md".
  4. Use file_search with query: "alpha\**\readme.md".

Expected

Steps 1–4 all find the respective files.

Actual

  • Step 1 (/**/): ✅ Finds Helper.java.
  • Step 2 (\**\): ❌ No results, or partial results depending on root.
  • Step 3 (/**/): ✅ Finds readme.md.
  • Step 4 (\**\): ⚠️ May return fewer results. In testing, \**\ appears to require at least one path segment between the prefix and the filename, missing files where ** should match zero segments.

The Discrepancy

Pattern / separators \ separators
alpha/**/file.ext (root-prefixed glob) ✅ All results ❌ or ⚠️ Partial/no results
alpha/src/file.ext (root-prefixed explicit) ✅ ✅
**/file.ext (recursive glob) ✅ ✅
alpha/src/*.ext (single-star glob) ✅ ✅

The issue is isolated to ** when surrounded by backslashes. Single-star globs (*), explicit paths, and non-glob backslash segments all work correctly with either separator. The ** glob with forward slashes also works correctly. Only the combination of ** with \ is affected.

Observed Variation Across Roots

In a multi-root workspace with three roots, the \**\ pattern was tested with each root name as prefix:

Pattern /**/ \**\
Root A (name appears as internal directory in its own tree) ✅ ✅ (partial — fewer results)
Root B (name does not appear as internal directory) ✅ ❌ No results
Root C (name does not appear as internal directory) ✅ ❌ No results

Root A's partial success with \**\ may be due to the same coincidental-directory-name matching described in #293428. The /**/ form works consistently for all roots.

Impact on LLMs

On Windows, LLMs sometimes produce backslash-separated paths. When combined with ** glob patterns, this causes file_search to silently return fewer or no results. Since non-glob backslash paths work fine, the failure appears intermittent from the LLM's perspective — backslash paths work in some calls but not others, depending solely on whether ** is present.

Root Cause Hypothesis

The glob engine used by file_search likely normalizes / and \ for literal path segments but does not normalize the separators adjacent to **. The ** operator may be recognized only when delimited by / (i.e., /**/), causing \**\ to be interpreted as a literal segment match or a malformed glob rather than a recursive wildcard.

Recommendation

The file_search glob engine should normalize \**\ to /**/ before evaluation, or treat ** as a recursive wildcard regardless of surrounding separator characters.

Related Issues

Activity

  1. added
    chat-ext-issue
    on Feb 6, 2026
  2. removed
    chat-ext-issue
    on Feb 6, 2026
  3. garretwilson commented on Feb 6, 2026

    @garretwilson
    Author

    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).
  4. roblourens commented on Mar 9, 2026

    @roblourens
    Member

    The basic setup doesn't make sense to me, doesn't it contradict #293428? We don't resolve the alpha in that glob, so if the LLM does what you say, none of those cases work for me. It doesn't really matter though, once the general fix microsoft/vscode-copilot-chat#4287 is in, we should just see whether that fixes whatever you were seeing. You wrote 1000 lines here where just seeing one log showing the actual tool args from the LLM in context would have been much more clear, but I know you don't like to share logs.

  5. garretwilson commented on Mar 9, 2026

    @garretwilson
    Author

    … none of those cases work for me.

    I appreciate that someone is looking into this, and if you can't reproduce it I will certainly try to help you. Just be clear though: you are saying you performed the setup in the description on a Windows system? (I don't know if the OS is related; I just want to be clear on what you did in attempting to reproduce this.)

    Note however that of these three bugs, #293428 is the most critical, As it mentions:

    This is the single largest source of LLM search failures in multi-root workspaces.

  6. roblourens commented on Mar 9, 2026

    @roblourens
    Member

    Yeah, I tried on Windows. I agree that issue is the primary problem, my PR fixes that. If you haven't seen, we are starting to do stable vscode releases more often. I will merge the PR this week, and it will be in stable starting next week. I need to do more testing of my PR on Windows first.

  7. garretwilson commented on Mar 9, 2026

    @garretwilson
    Author

    I agree that issue is the primary problem, my PR fixes that.

    roblourens that is amazing news! Thank you!

    If you haven't seen, we are starting to do stable vscode releases more often.

    I hadn't seen. Thanks for the heads-up!

  8. garretwilson commented on Jul 29, 2026

    @garretwilson
    Author

    roblourens, Peng Lyu (@rebornix), Matt Bierner (@mjbvz), this is still very much a problem. It turns out the reproduction steps weren't quite correct.

    Reproducing this is easy really:

    1. Create a multi-root workspace that meets the criteria (see below for more explanation).
    2. Take a model such as GPT-5.6 Sol on Max thinking effort.
    3. Point the model at this ticket and tell it to run comprehensive, read-only tests on a Windows installation.

    Really it's that easy. You can even ask the model to confirm that the repository fits the criteria.

    Below are the results of GPT-5.6 Sol running the tests on an arbitrary workspace I happened to be working on (as with #328102 when testing the state of #293428). It explains where the reproduction attempt missed the mark, clarifies the necessary repository layout and points to where the problem might lie.

    Retest: issue remains reproducible in VS Code 1.131.0

    I retested this directly through file_search, then inspected the linked multi-root fix and the current glob implementation. The reported discrepancy remains present. No improvement to the \**\ behavior was observable.

    Environment

    • OS: Windows 11
    • VS Code: 1.131.0
    • Architecture: x64
    • Workspace: Multi-root (2 roots)
    • Method: Read-only searches against existing files at zero, one, two, and three-or-more directory depths. maxResults was set above every reported total, eliminating result truncation as a confounding factor.

    Results

    Pattern form Zero directories One directory Two or more directories
    prefix/**/file ✅ ✅ ✅
    prefix\**\file ❌ ✅ ❌
    Mixed prefix/**\file ❌ ✅ ❌
    Mixed prefix\**/file ❌ ✅ ❌

    Control tests:

    Pattern form Result
    Root-prefixed explicit path using / ✅
    Root-prefixed explicit path using \ ✅
    Root-prefixed * using / ✅
    Root-prefixed * using \ ✅
    Leading **/file with no literal prefix ✅ at every depth
    Leading **\file with no literal prefix ✅ at every depth
    Root-relative prefix/**/file ✅ recursively
    Root-relative prefix\**\file ⚠️ exactly one directory only

    The same behavior occurred independently in both workspace roots. Multi-match searches confirmed that the backslash form returned exactly the subset located one directory below the prefix, omitting both root-level and deeper matches.

    The behavior can therefore be stated more precisely than “partial or no results”:

    A backslash-delimited ** following a literal prefix behaves as though it were an ordinary wildcard matching exactly one path segment, rather than a globstar matching zero or more path segments.

    Minimal Corrected Reproduction

    The current description says “multi-root workspace with one root.” Workspace-folder-name resolution requires more than one folder, so that setup can mask this issue. Use at least two roots:

    C:\projects\alpha\
        marker.txt
        one\
            marker.txt
            two\
                marker.txt
    
    C:\projects\beta\
        sentinel.txt
    

    Invoke the tool with these literal arguments:

    {"query":"alpha/**/marker.txt","maxResults":100}
    {"query":"alpha\\**\\marker.txt","maxResults":100}

    Expected: both return all three marker.txt files.

    Actual: the forward-slash form returns all three; the backslash form returns only alpha\one\marker.txt.

    Why the Earlier Test Did Not Reproduce It

    The maintainer tested before #293428’s multi-root fix, when the alpha workspace-folder prefix was not resolved. Consequently, both slash forms failed before evaluation reached the separator difference. #293428 masked this issue.

    PR microsoft/vscode-copilot-chat#4287 subsequently added root-prefix and absolute-path resolution, but did not test this case:

    • Every recursive suffix in the PR uses /.
    • Windows tests construct roots such as c:\test\workspace1 but append /**/*.ts, not \**\*.ts.
    • Unit tests record the pattern sent to a search-service double; they do not search a real tree.
    • Extension-host tests inspect inputGlobToPattern() output but do not create files at multiple depths and compare matching results.
    • No later comment records a post-[jade] comment line color wrongly colored after new lines #4287 retest of \**\.

    Thus the maintainer’s result did not contradict this bug; the prerequisite root-prefix defect prevented the distinguishing condition from being reached.

    Cause

    The official GlobPattern contract states that a backslash is invalid within a glob pattern and instructs callers to convert backslashes to slashes.

    The current Copilot adapter does not perform that conversion. Its path interpretation is slash-specific, including checks equivalent to:

    raw.startsWith("**/");
    raw.indexOf("/");

    The core glob parser likewise splits pattern segments only on / and recognizes globstar only when an entire resulting segment equals **. In prefix\**\file, ** is therefore not a globstar; each star becomes an ordinary within-segment wildcard. Ordinary stars cannot cross a path separator, explaining the observed exactly-one-directory behavior.

    The core glob parser is behaving according to its documented contract. The missing normalization is at the Copilot tool boundary.

    Recommended Fix

    Canonicalize tool-supplied glob and path strings before any interpretation:

    function normalizeGlobPattern(pattern: string): string {
        return pattern.replaceAll("\\", "/");
    }

    Apply the same normalization:

    1. At the start of file_search and grep_search resolveInput(), before testing leading glob syntax, absolute paths, or trailing separators.
    2. At the start of shared inputGlobToPattern(), covering direct invocation and prepareInvocation() paths.
    3. To any relative glob remainder derived from an absolute path.

    This should be implemented in the Copilot adapter, not by changing the core glob parser. It should also fix the remaining grep_search failure for a backslash at the workspace-folder-name boundary.

    If backslash compatibility is intentionally rejected instead, the tools should fail explicitly with an actionable diagnostic. Silently returning a plausible but incomplete result set is the dangerous behavior.

    Recommended Regression Tests

    Add end-to-end tests, not only pattern-forwarding tests, covering:

    • zero, one, and multiple directory depths;
    • /, \, and both mixed forms around **;
    • root-relative and workspace-folder-name-prefixed patterns;
    • explicit paths, *, and leading ** controls;
    • absolute Windows drive paths and UNC paths;
    • both file_search and grep_search;
    • at least two workspace roots whose names do not occur inside their own directory trees;
    • exact equality of complete result sets between separator variants.
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