github / github/copilot-cli

`glob` tool false-negatives on any multi-segment pattern unless prefixed with `**/`

未關閉
#4,271 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
area:tools
主要語言
Shell
星號
11.2k
分支
1.9k
平均合併
14 小時 16 分鐘
30 天內合併 PR
6

描述

## Describe the bug

The built-in `glob` tool returns "No files matched the pattern." for **any
pattern containing a path separator**, unless the pattern is prefixed with
`**/`. Literal relative paths (`2026/07/26.md`) and wildcarded multi-segment
patterns (`2026/07/*.md`) both fail even though the files exist directly under
the given `paths` root. Single-segment patterns (`inbox.md`, `*.md`) and
`**/`-prefixed patterns work.

This is worse than an inconvenience: the agent trusts the empty result. In one
session the agent checked for a file with its exact relative path, got no
match, and confidently declared the file missing — then acted on that false
premise.

## Affected version

1.0.70-0 (running as the VS Code Agent Sessions CLI backend; macOS arm64)

## Steps to reproduce the behavior

Against a repo containing `2026/07/26.md` and `inbox.md` at the root:

1. `glob` with `pattern: "2026/07/26.md"`, `paths: [""]` →
`No files matched the pattern.` (file exists)
2. `glob` with `pattern: "2026/07/*.md"`, same paths →
`No files matched the pattern.` (31 files exist there)
3. `glob` with `pattern: "**/07/26.md"`, same paths →
`/2026/07/26.md` ✔
4. `glob` with `pattern: "inbox.md"`, same paths →
`/inbox.md` ✔

So the failure is specifically: multi-segment pattern **not** prefixed with
`**/`. It looks like the matcher compares patterns against basenames (or a
single path segment) unless a globstar forces full-path matching.

## Expected behavior

A relative pattern is resolved against the given `paths` roots, per standard
glob semantics: `2026/07/26.md` matches `/2026/07/26.md`. At minimum,
the tool description should say patterns must be `**/`-prefixed to traverse
directories — but fixing the matching is much better than documenting the
trap, since empty results are treated as evidence of absence.

## Additional context

- OS: macOS 26.5.2, arm64
- Observed both from VS Code Agent Sessions and reproduced deterministically
(4 calls above, same session, seconds apart)

貢獻指南

開啟貢獻指南

研究方向

首先定位內建的 glob 工具及其路徑比對實作,然後針對一個包含所列檔案的 repository 重現 issue 中的四個模式。追蹤相對模式與路徑根目錄的比較方式。當多段相對模式能夠比對到現有檔案,同時現有的單段和 **/ 情況繼續正常運作時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
shell
領域
cli, tooling
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
冷清
描述清晰度
基本清楚
新手友好度
55/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。