grep_search returns No matches for patterns that match the printed path; session snapshot copies are searched
Before opening, please confirm:
- [x] I have searched for duplicate or closed issues
Operating System
Windows 11
Kiro Version
1.4.178 (IDE, user install)
Bug Description
grep_search returns "No matches found" for valid includePattern values, and the path it prints for a hit does not match the pattern that would select that same file. The empty result looks like "the text does not exist", so the agent draws wrong conclusions. In addition, old copies of workspace files under .kiro/sessions/.../snapshots/ are indexed and returned as hits, so a hit can come from an outdated copy instead of the real file.
This is related to #10566 (closed) and #11720, but is a different case: **/ patterns and absolute paths still return nothing on 1.4.178, and the printed path and the matched path differ.
Steps to Reproduce
Setup: the workspace has C:\Users\<user>\.kiro as one of its workspace folders, and C:\Users\<user>\.kiro\steering\notes.md contains the line UNIQUE_MARKER_123.
- Ask the agent to call
grep_searchwithquery="UNIQUE_MARKER_123"andincludePattern="C:/Users/<user>/.kiro/steering/*.md". Result: "No matches found" (no error). - Same query with
includePattern="**/.kiro/steering/*.md". Result: "No matches found". - Same query with
includePattern="steering/*.md". Result: 1 match, printed as.kiro/steering/notes.md. - Note the printed path
.kiro/steering/notes.md. A pattern that matches that printed path (step 2) returns nothing, so the tool prints one path and matches against another (it seems to be relative to the workspace folder, without the folder name). - Same query with
includePattern="**/snapshots/**/steering/*.md". Result: 21 matches, all in.kiro/sessions/<hash>/<session>/snapshots/<id>/steering/notes.md. These are older versions of the file, with different line numbers.
Not tested: a workspace folder whose name is not a dot-folder. The behavior in steps 1 and 2 may differ there.
Expected Behavior
- A pattern that matches the path the tool prints should return that file, and an absolute path or a pattern the tool cannot handle should return an error instead of "No matches found".
- Session snapshot copies should not be searched by default, or should be marked clearly as snapshots, so a hit is not mistaken for the current file.
Conversation ID
No response
Additional Context
Impact: an empty result from a tool is read as proof that the text is absent. In my case the agent stated that content was missing when it was present, and I had to add rules to always re-read the file directly and to avoid absolute paths and **/<root-folder>/ patterns.
Related: #10566 (closed, patterns without **/ returned nothing on Windows), #11720 (includePattern treated as a filter, not a search root).
🤖 Potential Duplicate Detected
This issue appears to be similar to:
What happens next?
- ⏰ This issue will be automatically closed in 3 days
- 🏷️ If this is not a duplicate, you can prevent automatic closure by adding a comment or reacting with 👎 to this message.
- 💬 Comment on the original issue if you have additional information
Why is this marked as duplicate? Both issues report problems with grep_search's includePattern behavior - the new issue describes includePattern not working as a search root and causing incorrect results, while #11720 describes includePattern being treated as a workspace-tree filter rather than a search root, causing full-tree crawls. Both share the same underlying tool behavior problem with includePattern in grep_search/file_search.
This is not a duplicate of #11720.
#11720 is about performance: on an NFS-mounted home, includePattern is treated as a filter, so the walk crawls the whole tree and stalls. This issue is about correctness on Windows: patterns that match the printed path (absolute path, **/.kiro/...) return "No matches found" silently, and session snapshot copies are returned as hits.
Please remove the duplicate label and send this back for review.
Thank you for your feedback! 🙏
The duplicate label has been removed and this issue has been sent back for maintainer review.
A maintainer will review this issue shortly.
Thanks for raising this, and for the step-by-step comparison. grep_search returns "No matches found" for include patterns that should select the file, the printed path does not match the pattern that would select it, and old copies of workspace files from session snapshots are searched and returned as hits. Together these lead the agent to wrong conclusions. Marking this as a bug to investigate further.