Repository navigation
Description
Title
Possible false negatives when using rtk rg
Description
Hi, first of all, thanks for building RTK. I have been trying it with Claude Code and the token reduction idea is very useful.
I noticed a possible issue with rg/ripgrep when executed through RTK. I am not yet sure if this is a bug, a limitation, or something specific to my setup, but I wanted to report it because it can affect code-search reliability.
In one Claude Code Fable 5 session, the assistant reported that an RTK-wrapped rg search returned no matches for strings that were later confirmed to exist in the repository.
The relevant Claude Code messages were:
The rtk wrapper interfered with some searches. Let me load the dedicated Grep/Glob tools for reliable results.
Grep/Glob aren't available as tools. Let me use raw ripgrep via rtk proxy to avoid wrapper interference.
Then later:
The rtk-wrapped rg gave FALSE NEGATIVES — output_subagent and generative_ui_dashboard clearly exist (deepagent.py:287, :251) but rg returned empty. This is exactly the false-negative trap. I must not trust that tool for absence claims. Let me use plain grep and verify it actually finds known-present strings.
And after switching to plain grep:
grep works reliably; rtk-rg is broken. I'll use grep going forward. Now let me map the full dead-stack surface and the demo YAML.
The strings involved were:
output_subagent
generative_ui_dashboard
Claude reported they existed in:
deepagent.py:287
deepagent.py:251
but the RTK-wrapped search apparently returned empty output.
Why I think this is worth checking
For most commands, summarization or aggressive compression is fine. But for search commands like rg, grep, or git grep, false negatives can be risky because coding agents often use search results to decide whether something exists, whether a legacy path was fully removed, or whether a symbol is unused.
So even if RTK compresses the output, it would be safer if search commands never silently drop matches.
Expected behavior
If the underlying rg command finds matches, rtk rg should preserve at least enough information to show that matches exist.
If the output is too large, a truncated result with an explicit marker would be safer than returning empty output, for example:
[RTK truncated output — underlying command produced more matches]
Possible commands to compare
I can try to reproduce with something like:
rg "output_subagent" .
rtk rg "output_subagent" .
rg "generative_ui_dashboard" .
rtk rg "generative_ui_dashboard" .and also:
rg -n "output_subagent" .
rtk rg -n "output_subagent" .
rg --json "output_subagent" .
rtk rg --json "output_subagent" .Environment
I can provide exact versions if useful:
rtk --version
rtk gain
which rtk
rg --version
grep --version
uname -aThe setup is:
Claude Code
RTK wrapper
WSL/Linux development environment
ripgrep / rg
Request
Could you please check whether RTK’s handling of rg can produce false negatives or suppress matches in some cases?
I may also be missing a recommended way to run search commands through RTK, so guidance would be welcome.
Activity
pszymkowiak commentedon Jul 3, 2026
🔍 Automated Triage
bughighSummary
Reporter relays a Claude Code session claiming rtk-wrapped
rgreturned empty results for strings confirmed present via plain grep, suggesting possible silent false negatives in search output; no first-hand reproduction or exact command/output provided yet.Triaged automatically by wshm · This is an automated analysis, not a human review.
nbruzzi commentedon Sep 6, 2026
Confirming this on rtk 0.38.0 with Claude Code, and adding a precise root cause + a working config workaround.
Reproduced: a bare
rgrecursive search issued through Claude Code's Bash tool returned zero matches for a string that was present in the repo the whole time. An explicit single-filerg pattern path/to/fileworked fine; only recursive/directory searches failed.Root cause (mechanism): rtk's PreToolUse hook rewrites
rg→rtk grep.rtk grepfalls through to the systemgrep, and when handed ripgrep-style args (a directory argument without-r,--files, etc.) the underlyinggreperrors — e.g.grep: <dir>: Is a directory→ exit 2, empty stdout. Because agents commonly append2>/dev/null, that error is swallowed and the result is indistinguishable from a clean "no matches" — a silent false negative onabsenceclaims. Verified via rtk's own dry-run:The trap is that
rg(ripgrep) is not flag-compatible withgrep: they collide on value-taking flags (-r,-E,-m, etc.), so aliasing one to the other silently corrupts search semantics. This overlaps with #2253 and #2817 (rtk grep shells to system grep, not ripgrep).Workaround (not mentioned elsewhere in the thread) — exclude
rgfrom the hook via rtk config so it runs as genuine ripgrep, while keeping thegrep/ls/findproxies intact:Verified after the change:
rg(andcommand rg) then pass through untouched in every position (leading, post-pipe, post-;, post-&&), and recursive searches find matches again.Suggested fix: rtk shouldn't alias
rg→rtk grepat all — ripgrep and grep are not drop-in equivalents, and a search tool that silently returns wrong/empty results is worse than no proxy. At minimum,rgcould be excluded by default, andrtk grepshould not silently change recursion semantics relative to the underlyinggrep(a directory without-rshould not silently start recursing, nor silently return empty).in-moonshadow commentedon Oct 1, 2026
0.50.0 fixed the
rgpath but regressed thegreppath on directory argumentsFollowing up on the false-negative class reported here. I have both 0.42.0 and 0.50.0 binaries available and measured the same inputs against both, so I can show exactly what changed.
Short version: in 0.50.0
rgandgrepwere split onto separate paths. The newrtk rgpath behaves correctly. The oldrtk greppath lost directory-recursion — it now fails on any directory argument, where 0.42.0 recursed. This is still #3611, not a new rewrite bug, so I am not reopening that part; the useful new datum is the regression plus the fact that the two paths no longer agree.The rewrite table changed between the two versions
rtk rgis new in 0.50.0 (--help: "Compact ripgrep - runs rg natively, same output filter as grep"). strace confirms it execs the real binary:The regression:
rtk grepon a directory now failsExit 2, zero matches reported. Full form matrix, same file tree, both versions:
rtk grep -n PAT .Is a directory, exit=2rtk grep -n PAT ./Is a directory, exit=2rtk grep -rn PAT .rtk grep -n PAT a.txtrtk grep -n PAT *.txtSo
rtk grepnow requires an explicit-rfor directories. That is not wrong on its own — GNU grep 3.7 also does not recurse on a bare directory — but it is a regression from 0.42.0, and it interacts badly with the rewrite:grep -rnsurvives (the user's own-ris preserved asrtk grep -rn), whilegrep -n PAT <dir>is rewritten to a form that cannot work.Both paths were inconsistent in 0.42.0; only one got fixed
The inconsistency behind the
grep -cfalse negative reported on this thread is the same in both versions on thegrepside —-c/-l/-L/-o/-Ztake a raw path that does not add-r, while-ntook a filtered path that implied recursion:rtk grep -c PAT .0+Is a directory0+Is a directory, exit=2rtk grep -rc PAT .rtk grep -n PAT .rtk rg -c PAT .rtk rg -l PAT .Ground truth for the tree:
/usr/bin/rg -c PAT .returns 2 matching files with 1 hit each.Why the
0is the dangerous partrtk grep -creturns a clean0.0is a plausible answer to "how many matches?", and it is what the caller receives whether the true count is zero or the search never ran. GNU grep's "Is a directory" text goes to stderr and is lost when stdout is captured or piped. There is no formatting tell and no distinct exit code in the-ccase (it is 0), so for the "is there residue / did this file change" class of check this reads as a clean bill of health.Worth noting
rtk proxydoes not help here — it is not an output-filtering problem:The natural instinct is to bypass the wrapper, so this seems worth stating explicitly.
Ripgrep semantics restored on the
rgpathFor completeness on #2606's point about losing ripgrep's skip behaviour — that no longer applies to
rgin 0.50.0:RTK_DISABLED=1does not disable the rewriteStill rewritten. Only an absolute path (
/usr/bin/rg ..., which the rewrite table does not match) orrtk proxybypass it. Mentioning it because the env var reads like it should be the escape hatch.Not reported here (still present, adjacent)
rtk rg -ris ripgrep's--replace, andrtk rg -hprints help — both differ from the grep flags of the same name, andrtk rg -rreturns empty with a success-looking exit rather than erroring. Separate from the above, but the same "silently different semantics" family, so noting it for completeness.Environment
/usr/bin/rgPreToolUse→ matcherBash→rtk hook claudeHappy to test a nightly or a specific build if that is more useful than the released 0.50.0.
Reported by @in-moonshadow — measurements reproducible with rtk 0.42.0 and 0.50.0 on Linux x86_64.
KuSh commentedon Oct 3, 2026
Fixed by #2641, shipped in v0.43.0: rg commands are now rewritten to
rtk rg, which runs the real ripgrep instead of falling back to grep, so recursive and directory searches return their matches again. If you still see missing matches withrtk rgon the latest release, please comment with the exact command and we will reopen.