#1300·eino

grep files_with_matches: empty result is "No files found" even when path is an existing file

Author: NoksaCreated Sep 18, 2026Updated Sep 18, 2026

Summary

Stock grep (default output_mode=files_with_matches) returns the literal string No files found whenever GrepRaw yields zero matches. That is also the empty string for glob / ls. Agents treat it as "the path does not exist."

When path is a file that exists (including reduction offloads at /tmp/trunc/<call-id> / /tmp/clear/<call-id>), a miss should mean "pattern not in this file," not "file missing."

formatContentMatches already returns No matches found for output_mode=content. Models almost never set that mode, so they never see it.

Related

  • #821 (feat(adk): improve filesystem tools empty result handling) codified this: files_with_matches empty → "No files found". That is correct for glob-style listing. It is wrong for grepping one existing file.
  • Truncation/reduction is unrelated and works: the offload file is there; GrepRaw finds other keys in the same file.

Repro

  1. Reduction offloads a large helm template result to /tmp/trunc/call-….
  2. Agent greps that path for a key that is not in the render (auth-url), without output_mode=content.
  3. Tool result is exactly No files found (14 bytes).
  4. Same path, grep checksum returns Found 1 file\n/tmp/trunc/call-….

Expected

Distinguish:

Situation Suggested text
Path is a readable file, pattern misses No matches found in <path> (file exists)
Path missing file not found: <path> or keep No files found
Directory, no file contained the pattern No files found is OK for files_with_matches

Optional: when path is a single existing file, default output_mode to content so the agent sees lines (or an honest miss).

Why it matters

Agents then skip verification of offloaded helm/logs and rubber-stamp. We wrap grep in our framework for now (GrepToolConfig.CustomTool). Happy to drop the wrapper if this lands.