fix(search): search_files ignores the user's ripgrep config (--color=always no longer reads as 0 matches) #138111
<!-- hermes-ci-review-bot -->
૮ >ﻌ< ა ci review
<sub>ran on 780cba2 — Merge remote-tracking branch 'origin/main' into codex-port/r</sub>
ℹ️ Info
CI caches · View report · View job
25 / 25 cache hits (0 misses)
4080.40 MiB restored
0 B not restored.
<details>
<summary>per-job cache results</summary>
<h3>hits</h3>
<table><thead><tr><th>Job</th><th>Step</th><th>Logs</th><th>Restored</th><th>Δ vs main</th></tr></thead><tbody>
<tr><td>OS-specific tests / Windows-only tests (arm64, 1/2)</td><td>Set up native ARM64 build dependencies / Cache ARM64 OpenSSL development files</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030630#step:3:1">view step</a></td><td>26.23 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / Windows-only tests (arm64, 1/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030630#step:4:1">view step</a></td><td>165.07 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / Windows-only tests (arm64, 1/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030630#step:4:1">view step</a></td><td>840.68 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / Windows-only tests (arm64, 2/2)</td><td>Set up native ARM64 build dependencies / Cache ARM64 OpenSSL development files</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030846#step:3:1">view step</a></td><td>26.23 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / Windows-only tests (arm64, 2/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030846#step:4:1">view step</a></td><td>165.07 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / Windows-only tests (arm64, 2/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030846#step:4:1">view step</a></td><td>840.68 MiB</td><td>+0 B</td></tr>
<tr><td>Icon assets freshness / Regenerate icons + diff against committed</td><td>Run ./.github/actions/setup-pm / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501029492#step:4:1">view step</a></td><td>131.05 MiB</td><td>+0 B</td></tr>
<tr><td>Icon assets freshness / Regenerate icons + diff against committed</td><td>Run ./.github/actions/setup-pm / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501029492#step:4:1">view step</a></td><td>66.76 MiB</td><td>+0 B</td></tr>
<tr><td>Icon assets freshness / Regenerate icons + diff against committed</td><td>Run ./.github/actions/setup-pm / Restore npm dependency downloads</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501029492#step:4:1">view step</a></td><td>265.04 MiB</td><td>+0 B</td></tr>
<tr><td>Python lints / ruff enforcement (blocking)</td><td>Run ./.github/actions/setup-pm / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030186#step:4:1">view step</a></td><td>79.77 MiB</td><td>+0 B</td></tr>
<tr><td>Python lints / ruff + ty diff</td><td>Run ./.github/actions/setup-pm / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030270#step:4:1">view step</a></td><td>79.77 MiB</td><td>unknown</td></tr>
<tr><td>Python lints / Windows footguns (blocking)</td><td>Run ./.github/actions/setup-pm / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030296#step:4:1">view step</a></td><td>79.77 MiB</td><td>+0 B</td></tr>
<tr><td>Python lints / code health ratchet (blocking)</td><td>Run ./.github/actions/setup-pm / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030256#step:4:1">view step</a></td><td>79.77 MiB</td><td>unknown</td></tr>
<tr><td>Python tests / Run tests (1/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030572#step:5:1">view step</a></td><td>79.77 MiB</td><td>+0 B</td></tr>
<tr><td>Python tests / Run tests (1/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030572#step:5:1">view step</a></td><td>66.76 MiB</td><td>+0 B</td></tr>
<tr><td>Python tests / Run tests (1/2)</td><td>Run tests</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030572#step:8:1">view step</a></td><td>0.08 MiB</td><td>-69 B</td></tr>
<tr><td>Python tests / Run tests (2/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030582#step:5:1">view step</a></td><td>79.77 MiB</td><td>+0 B</td></tr>
<tr><td>Python tests / Run tests (2/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030582#step:5:1">view step</a></td><td>66.76 MiB</td><td>+0 B</td></tr>
<tr><td>Python tests / Run tests (2/2)</td><td>Restore per-file duration cache</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030582#step:7:1">view step</a></td><td>0.08 MiB</td><td>unknown</td></tr>
<tr><td>OS-specific tests / macOS-only tests (2/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030500#step:5:1">view step</a></td><td>42.25 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / macOS-only tests (2/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030500#step:5:1">view step</a></td><td>152.27 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / macOS-only tests (1/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030892#step:5:1">view step</a></td><td>42.25 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / macOS-only tests (1/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030892#step:5:1">view step</a></td><td>152.27 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / Windows-only tests</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030508#step:5:1">view step</a></td><td>171.65 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / Windows-only tests</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/39978964162/job/120501030508#step:5:1">view step</a></td><td>380.58 MiB</td><td>+0 B</td></tr>
</tbody></table>
<h3>misses</h3>
none
<p>Compressed archive bytes. Not-restored bytes use the main-size reference; missing sizes remain unknown.</p>
</details>
---
debug info
<details>
<summary>CI timings</summary>
CI timings · View report · View job
Wall time 7m49s vs 7m56s (-1.5%). 7 job(s) slower, 8 faster, 3 unchanged.
</details>
<!-- greptile_summary -->
<h2><a href="https://app.greptile.com/api/retrigger?id=80321680"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a>Confidence Score: 4/5</h2>
[Medium impact] Search tool now ignores user ripgrep configuration\.
The PR appears safe to merge; the only finding is a non-blocking gap in the case-sensitivity test.
<h2>Findings</h2>
1. <img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"> Case check misses smart\-case <a href="https://github.com/NousResearch/hermes-agent/pull/138111#discussion_r4265455438">▶</a>
<details><summary>Fix with agent prompt</summary>
`### Issue 1
tests/tools/test_search_native_rg.py:144
The uppercase pattern `NEEDLE` returns zero with both default matching and `--smart-case`, so this assertion cannot detect that setting leaking through. The lowercase searches also use only lowercase fixture text.
Add an uppercase-only fixture match and search with a lowercase pattern. That would catch the user’s config making a case-sensitive search ignore case.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
</details>
<details><summary><h3>Summary</h3></summary>
Adds --no-config` to ripgrep searches, zero-match probes, folder context listings, and CLI file completion.
Review used source inspection; tests were not run.
</details>
<!-- greptile_confidence_score:4 -->
<sub>Reviews (1) · Last reviewed commit: "fix: search\_files ignores the user's rip..." · Reviewed by Greptile</sub>
<a href="#"><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> Case check misses smart-case
The uppercase pattern NEEDLE returns zero with both default matching and --smart-case, so this assertion cannot detect that setting leaking through. The lowercase searches also use only lowercase fixture text.
Add an uppercase-only fixture match and search with a lowercase pattern. That would catch the user’s config making a case-sensitive search ignore case.
<details><summary>Prompt To Fix With AI</summary>
``This is a comment left during a code review.
Path: tests/tools/test_search_native_rg.py
Line: 144
Comment:
**Case check misses smart-case**
The uppercase pattern `NEEDLE` returns zero with both default matching and `--smart-case`, so this assertion cannot detect that setting leaking through. The lowercase searches also use only lowercase fixture text.
Add an uppercase-only fixture match and search with a lowercase pattern. That would catch the user’s config making a case-sensitive search ignore case.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
</details>
Valid, fixed in 0b5ce3629bc: added a Needle five fixture line and dropped the NEEDLE check, so the lowercase search must return exactly 4. With only --smart-case in the ripgreprc, origin/main returns 5 (red, both transports) and this branch 4.
Refreshed onto current main (merge commit 780cba2199c, no rewrite): the only conflict was additive in tests/tools/test_search_native_rg.py (main added test_local_search_runs_the_pinned_ripgrep_not_the_first_on_path beside this PR's test; both kept). All five rg call sites still carry --no-config; no new rg invocation landed on main since.
Independent corroboration: earendil-works/pi shipped the same fix this week (pi 8c4e87389, "grep tool ignores ripgrep config via --no-config", closes pi#11203), motivated by a --fixed-strings ripgreprc silently turning regex searches literal.
Re-verified on the merged head:
| ripgreprc | origin/main search_files | this head |
|---|---|---|
| --fixed-strings | regex def foo_ba.\( → 0 matches | 2 matches |
| --column | content reads 1:def foo_bar(): (column glued into the text) | def foo_bar(): |
| --max-count=1 | 1 of 2 matches, silently | 2 |
| --ignore-case | foo also matches FOO_QUX | 2 (case-sensitive as asked) |
(real search_tool path, local backend, scratch HOME/HERMES_HOME.) Search/file-ops/context-reference suites on the merged head: 13 files, 246 passed, 10 skipped.
teknium1
search_files(and @-folder context, CLI @-file completion) now returns the same results whatever the user'sRIPGREP_CONFIG_PATHsays.Port of openai/codex#51527 ("Ignore ripgrep configuration when expanding sandbox deny globs"). There a user
--quietemptied the file list for deny masks; here the same class hits every rg call the tools make.Symptom
Hermes spawns rg with the user's environment, so a personal ripgreprc is applied to the tool's own searches. With rg's own GUIDE-style options:
| ripgreprc line | effect on
search_files(origin/main) ||---|---|
|
--color=always| every output line is ANSI-wrapped, thepath:line:contentparser finds nothing: an existing match returnstotal_count: 0plus a warning that "the pattern's casing may be wrong", paths in file-name results carry\x1b[35m…||
--glob=!*.py| content search silently skips those files: 0 matches ||
--smart-case| a case-sensitive search quietly becomes case-insensitive |Change
--no-configon every rg invocation: content search (_search_with_rg), file-name search (_search_files_rg), the zero-match steering probes,agent/context_references.pyfolder listing, andhermes_cli/commands_completion.py@-file completion.tests/tools/test_search_native_rg.py, parametrized over both transports (native argv lane and backend shell lane), under a hostile ripgreprc.Adaptation note: Codex fixed the one rg call that feeds its sandbox; Hermes has no rg-built sandbox mask, but five call sites whose output the model reads, so all five get the flag.
--no-configexists since ripgrep 0.8 (2018), so remote/Docker backends with older rg are fine.Validation
Live repro: real
hermes chat -q(gpt-5-mini viaopenai-api, isolatedHERMES_HOME,RIPGREP_CONFIG_PATH=--color=always+--smart-case), model told to callsearch_filesforNEEDLE_LONGin a one-file project. Tool rows read back from that run'sstate.db:e06df9c2eae:{"total_count": 0, "warning": "0 exact matches, but 1 case-insensitive match(es) in 1 file(s): \^[[0m\^[[35m…/app.py\^[[0m — the pattern's casing may be wrong."}→ model answered0{"total_count": 1, "matches": [{"path": "…/app.py", "line": 3, …}]}→ model answered1| Check | Result |
|---|---|
| new test on origin/main source (
git show origin/main:tools/file_operations_search.pyswapped in) | 2 failed (native + shell) || new test on this branch | 6/6 passed |
| search / file-ops / context-reference / completion test files (28 files) | 403 passed, 19 skipped |
|
ruff, windows-footguns, no-tmp,scripts/check --only health| clean |Existing test touched:
test_search_files_engine_selection.py::test_remote_msys_shaped_executable_is_not_rewritten_as_controller_path(Windows-only, caught by the first CI round) pinned the literal'/c/remote-tools/rg' --files; it now expects'/c/remote-tools/rg' --no-config --files. Its invariant (the MSYS-shaped remote executable is quoted verbatim, never rewritten toC:/...) is unchanged and still asserted.Infographic
!search ignores the user's ripgrep config