grep files_with_matches: empty result is "No files found" even when path is an existing file
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_matchesempty →"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;
GrepRawfinds other keys in the same file.
Repro
- Reduction offloads a large
helm templateresult to/tmp/trunc/call-…. - Agent greps that path for a key that is not in the render (
auth-url), withoutoutput_mode=content. - Tool result is exactly
No files found(14 bytes). - Same path,
grep checksumreturnsFound 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.
Source: cloudwego/eino