Repository navigation
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
- Use
file_searchwithquery: "alpha/**/Helper.java". - Use
file_searchwithquery: "alpha\**\Helper.java". - Use
file_searchwithquery: "alpha/**/readme.md". - Use
file_searchwithquery: "alpha\**\readme.md".
Expected
Steps 1–4 all find the respective files.
Actual
- Step 1 (
/**/): ✅ FindsHelper.java. - Step 2 (
\**\): ❌ No results, or partial results depending on root. - Step 3 (
/**/): ✅ Findsreadme.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 |
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
- GitHub Copilot
grep_searchincludePatternsilently fails with workspace root folder name prefix in multi-root workspaces (severe) #293428 —grep_searchincludePatternsilently fails with workspace root folder name prefix in multi-root workspaces (principal issue). - Malformed absolute paths in
read_fileandlist_dirtrigger "Allow reading external files?" prompt, then fail on GitHub Copilot #293204 — Malformed absolute paths trigger "Allow reading external files?" prompt, then fail. Affectsread_fileandlist_dir.
Activity
garretwilson commentedon Feb 6, 2026
VS Code Search Tool Path Resolution — Comprehensive Test Matrix
Legend
Bug Key
grep_searchincludePatternsilently fails with workspace root folder name prefix in multi-root workspaces (severe) #293428 —grep_searchrejects root-name prefixfile_searchglob with\**\(backslash double-star) produces partial or no results where/**/succeeds #293430 —file_search\**\glob failureread_fileandlist_dirtrigger "Allow reading external files?" prompt, then fail on GitHub Copilot #293204 — malformed absolute paths trigger external-file promptPath Formats Tested
/src/main/App.java\src\main\App.javasrc\main/App.java/**/App.java\**\App.java/alpha/src/main/App.java\alpha\src\main\App.java/**/globalpha/**/App.java\**\globalpha\**\App.java\C:\projects\alpha\src\App.java/C:/projects/alpha/src/App.java/c/projects/alpha/src/App.java\, no colon\c\projects\alpha\src\App.javaResults
file_searchgrep_searchread_filelist_dir/\**/file/**\file\/\/**/glob\**\globC:\absoluteC:/absolute/c/Git Bash\c\no colonReading the Table
grep_searchcolumn): root-name prefix silently rejected.file_searchcolumn):\**\glob produces partial/no results.read_file/list_dircolumns): malformed absolute paths prompt then fail.read_file/list_dir;file_searchandgrep_searchdon't accept absolute paths (by design, not a bug).roblourens commentedon Mar 9, 2026
The basic setup doesn't make sense to me, doesn't it contradict #293428? We don't resolve the
alphain 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.garretwilson commentedon Mar 9, 2026
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:
roblourens commentedon Mar 9, 2026
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.
garretwilson commentedon Mar 9, 2026
roblourens that is amazing news! Thank you!
I hadn't seen. Thanks for the heads-up!
garretwilson commentedon Jul 29, 2026
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:
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
maxResultswas set above every reported total, eliminating result truncation as a confounding factor.Results
prefix/**/fileprefix\**\fileprefix/**\fileprefix\**/fileControl tests:
/\*using/*using\**/filewith no literal prefix**\filewith no literal prefixprefix/**/fileprefix\**\fileThe 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”:
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:
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.txtfiles.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
alphaworkspace-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:
/.c:\test\workspace1but append/**/*.ts, not\**\*.ts.inputGlobToPattern()output but do not create files at multiple depths and compare matching results.\**\.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
GlobPatterncontract 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:
The core glob parser likewise splits pattern segments only on
/and recognizes globstar only when an entire resulting segment equals**. Inprefix\**\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:
Apply the same normalization:
file_searchandgrep_searchresolveInput(), before testing leading glob syntax, absolute paths, or trailing separators.inputGlobToPattern(), covering direct invocation andprepareInvocation()paths.This should be implemented in the Copilot adapter, not by changing the core glob parser. It should also fix the remaining
grep_searchfailure 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:
/,\, and both mixed forms around**;*, and leading**controls;file_searchandgrep_search;