← Back to Pull requests

fix(search): search_files ignores the user's ripgrep config (--color=always no longer reads as 0 matches) #138111

Open
teknium1 opened this pull request with 43 lines diff across 5 files
View on GitHub
teknium1 teknium1 commented on Oct 14, 2026 00:14 UTC
Author

search_files (and @-folder context, CLI @-file completion) now returns the same results whatever the user's RIPGREP_CONFIG_PATH says.

Port of openai/codex#51527 ("Ignore ripgrep configuration when expanding sandbox deny globs"). There a user --quiet emptied 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, the path:line:content parser finds nothing: an existing match returns total_count: 0 plus 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-config on every rg invocation: content search (_search_with_rg), file-name search (_search_files_rg), the zero-match steering probes, agent/context_references.py folder listing, and hermes_cli/commands_completion.py @-file completion.

  • One invariant test in 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-config exists since ripgrep 0.8 (2018), so remote/Docker backends with older rg are fine.

    Validation

    Live repro: real hermes chat -q (gpt-5-mini via openai-api, isolated HERMES_HOME, RIPGREP_CONFIG_PATH = --color=always + --smart-case), model told to call search_files for NEEDLE_LONG in a one-file project. Tool rows read back from that run's state.db:

  • origin/main 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 answered 0

  • this branch: {"total_count": 1, "matches": [{"path": "…/app.py", "line": 3, …}]} → model answered 1
  • | Check | Result |
    |---|---|
    | new test on origin/main source (git show origin/main:tools/file_operations_search.py swapped 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 to C:/...) is unchanged and still asserted.

    Infographic

    !search ignores the user's ripgrep config

    Diff: 43 lines (+33 / -10) across 5 files Reviewer: teknium1 Review duration: 73300m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.81) × (1 − Review Confidence (0.80)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.81 · 43 lines diff across 5 files
    0.81
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.95 · 5 substantive comment(s)
    0.95
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    79%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.226
    Self Review self_review
    0.140
    Sensitive Paths sensitive_paths
    0.081
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    6 items
    github-actions[bot] github-actions[bot] commented on Oct 14, 2026 00:15 UTC
    Bot

    <!-- 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.

  • OS-specific tests / macOS-only tests (2/2): +64.0s

  • Python lints / Windows footguns (blocking): +28.0s

  • OS-specific tests / Windows-only tests (arm64, 1/2): -27.0s

  • OS-specific tests / Windows-only tests: -16.0s

  • Python tests / Run tests (1/2): -9.0s
  • </details>

    greptile-apps[bot] greptile-apps[bot] commented on Oct 14, 2026 00:18 UTC
    Bot

    <!-- 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">&nbsp;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.

  • File searches return the matches requested, regardless of ripgrep settings.

  • Folder and @-file suggestions ignore personal ripgrep settings.
  • 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&#39;s rip..." · Reviewed by Greptile</sub>

    greptile-apps[bot] greptile-apps[bot] commented on code on Oct 14, 2026 00:18 UTC
    Code Review
    tests/tools/test_search_native_rg.py:1
    @@ -126,3 +126,21 @@ def test_limit_hit_keeps_drained_matches_when_group_kill_is_refused(tree, ops_fa
         monkeypatch.setattr(os, "killpg", lambda pgid, sig: (_ for _ in ()).throw(PermissionError(1, "Operation not permitted")))
         result = ops.search(pattern="needle", path=str(tree), limit=2)
         assert not result.error and len(result.matches) == 2, result.to_dict()
    +
    +
    +@pytest.mark.parametrize("native", ["1", "0"])
    +def test_user_ripgrep_config_cannot_change_search_results(tree, ops_factory, monkeypatch, native):
    +    """A user's RIPGREP_CONFIG_PATH must not reach the tool's rg: --color=always made every
    +    content hit unparseable (0 matches, ANSI in paths) and --glob=!*.py hid files outright."""
    +    rc = tree.parent / f"ripgreprc-{native}"
    +    rc.write_text("--color=always\n--glob=!*.py\n--smart-case\n", encoding="utf-8")
    +    monkeypatch.setenv("RIPGREP_CONFIG_PATH", str(rc))
    +    monkeypatch.setenv("HERMES_NATIVE_FILE_READ", native)
    +    ops = ops_factory(tree, [])
    +    content = ops.search(pattern="needle", path=str(tree)).to_dict()
    +    assert content["total_count"] == 4, content
    +    assert {m["path"] for m in content["matches"]} == {
    +        str(tree / "a.py"), str(tree / "b.txt"), str(tree / "sub" / "c.py")}
    +    assert ops.search(pattern="NEEDLE", path=str(tree)).to_dict()["total_count"] == 0  # case-sensitive

    <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>

    teknium1 teknium1 commented on code on Oct 14, 2026 00:38 UTC
    Code Review
    tests/tools/test_search_native_rg.py:1
    @@ -126,3 +126,21 @@ def test_limit_hit_keeps_drained_matches_when_group_kill_is_refused(tree, ops_fa
         monkeypatch.setattr(os, "killpg", lambda pgid, sig: (_ for _ in ()).throw(PermissionError(1, "Operation not permitted")))
         result = ops.search(pattern="needle", path=str(tree), limit=2)
         assert not result.error and len(result.matches) == 2, result.to_dict()
    +
    +
    +@pytest.mark.parametrize("native", ["1", "0"])
    +def test_user_ripgrep_config_cannot_change_search_results(tree, ops_factory, monkeypatch, native):
    +    """A user's RIPGREP_CONFIG_PATH must not reach the tool's rg: --color=always made every
    +    content hit unparseable (0 matches, ANSI in paths) and --glob=!*.py hid files outright."""
    +    rc = tree.parent / f"ripgreprc-{native}"
    +    rc.write_text("--color=always\n--glob=!*.py\n--smart-case\n", encoding="utf-8")
    +    monkeypatch.setenv("RIPGREP_CONFIG_PATH", str(rc))
    +    monkeypatch.setenv("HERMES_NATIVE_FILE_READ", native)
    +    ops = ops_factory(tree, [])
    +    content = ops.search(pattern="needle", path=str(tree)).to_dict()
    +    assert content["total_count"] == 4, content
    +    assert {m["path"] for m in content["matches"]} == {
    +        str(tree / "a.py"), str(tree / "b.txt"), str(tree / "sub" / "c.py")}
    +    assert ops.search(pattern="NEEDLE", path=str(tree)).to_dict()["total_count"] == 0  # case-sensitive

    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.

    teknium1 teknium1 commented on Oct 23, 2026 15:31 UTC
    Author

    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.

    Reviewers
    Assignees
    teknium1 teknium1
    Labels
    risk: low confidence: 79.7% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 80.7% (HIGH) · Higher = larger blast radius
    80.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 79.7% · Lower = rushed or shallow review
    79.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.4% · Safe to merge
    16.4%