Skip to content

fix(file-ops): allow file search in hidden roots - #16672

Closed
fmercurio wants to merge 1 commit into
NousResearch:mainfrom
fmercurio:fix/search-files-hidden-root
Closed

fix(file-ops): allow file search in hidden roots#16672
fmercurio wants to merge 1 commit into
NousResearch:mainfrom
fmercurio:fix/search-files-hidden-root

Conversation

@fmercurio

Copy link
Copy Markdown

Summary

  • allow search_files(target="files") to return results when the explicit search root is inside a hidden directory, e.g. ~/.hermes/logs
  • keep the find fallback excluding hidden descendant files/directories for normal roots
  • add regression tests for hidden-root searches and normal hidden-descendant filtering

Root cause

When rg is unavailable, the file search fallback uses find ... -not -path '*/.*' to mimic ripgrep's hidden-directory behavior. If the caller explicitly searches a hidden root like /Users/me/.hermes/logs, every result path contains /.hermes/, so the filter removes all files and returns total_count=0.

Test plan

  • scripts/run_tests.sh tests/tools/test_file_operations.py -q -k 'SearchFilesFallbackHiddenPaths or SearchPathValidation'
  • scripts/run_tests.sh tests/tools/test_file_operations.py -q

@fmercurio

Copy link
Copy Markdown
Author

I can confirm this still reproduces on current origin/main after updating.

In a live Hermes gateway session, search_files(target="files", path="/Users/.../.hermes/...") returned total_count=0 even though matching files existed. The agent then interpreted it as “no content”.

The root cause appears unchanged on current origin/main in tools/file_operations.py:

hidden_exclude = "-not -path '*/.*'"

Because the explicit search root itself contains a hidden path component (.hermes), every result path matches */.* and gets filtered out.

I reapplied this PR's fix locally and verified the repro succeeds: it returns the expected file under the explicit hidden root while still excluding hidden descendants like .hub/.

Local verification:

58 passed, 2 skipped

So this is still affecting current users after update; it would be great to get this merged or consolidated with the newer related PRs (#18487 / #18645).

@teknium1

teknium1 commented May 4, 2026

Copy link
Copy Markdown
Contributor

Salvaged via #19878 onto current main - your commit authorship was preserved. Thanks!

@teknium1 teknium1 closed this May 4, 2026
luxles added a commit to luxles/hermes-agent that referenced this pull request Jun 19, 2026
… search roots

Two bugs in _search_with_grep() when ripgrep is unavailable:

1. BRE mode: grep -rnH uses Basic Regular Expression mode, where | is a
   literal character. ripgrep ships with Rust regex (| = alternation), so
   patterns with alternation silently fail on the grep fallback.
   Fix: add -E to enable ERE (Extended Regular Expression) mode.

2. --exclude-dir='.*': GNU grep applies this to all directory components
   INCLUDING command-line arguments, so a search under ~/.hermes/workspace
   skips the entire tree because .hermes matches .*. Ripgrep only applies
   globs to subdirectories, not the root.
   Fix: only add --exclude-dir when no path component is hidden, mirroring
   the logic already used by _search_files (merged in NousResearch#16672).

Both bugs produce silent false-negatives: search_files returns
total_count=0 without any error. Cross-reference NousResearch#18473, NousResearch#18645, NousResearch#34017.

Fixes NousResearch#18473
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists tool/file File tools (read, write, patch, search) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants