fix(mcp): stop surfacing regex-fallback warning alongside matches

When a grep pattern like 'foo(' triggers regex compilation and fails,
the core engine already falls back to literal matching and returns the
correct results. Prepending '! regex failed: ...' on top of those
results only confuses LLM callers (issue #425) — they see the error
before the matches and conclude the call failed.

Drop the warning from the formatter output entirely; the core still
populates the field for debugging and other bindings.
This commit is contained in:
Dmitriy Kovalenko
2026-05-03 15:18:43 -07:00
committed by Dmitriy Kovalenko
parent 3a52fc7c76
commit f401061fa6
2 changed files with 0 additions and 10 deletions
-6
View File
@@ -154,7 +154,6 @@ pub struct GrepFormatter<'a> {
pub files: &'a [&'a FileItem],
pub total_matched: usize,
pub next_file_offset: usize,
pub regex_fallback_error: Option<&'a str>,
pub output_mode: OutputMode,
pub max_results: usize,
pub show_context: bool,
@@ -169,7 +168,6 @@ impl GrepFormatter<'_> {
files,
total_matched,
next_file_offset,
regex_fallback_error,
output_mode,
max_results,
show_context,
@@ -216,10 +214,6 @@ impl GrepFormatter<'_> {
2500
};
if let Some(err) = regex_fallback_error {
lines.push(format!("! regex failed: {}, using literal match", err));
}
// File overview: collect first match per file
let file_preview = collect_file_preview(items, files, picker);
let mut content_def_file = String::new();
-4
View File
@@ -273,7 +273,6 @@ impl FffServer {
files: &retry_result.files,
total_matched: retry_result.matches.len(),
next_file_offset: retry_result.next_file_offset,
regex_fallback_error: retry_result.regex_fallback_error.as_deref(),
output_mode,
max_results,
show_context: ctx_lines > 0,
@@ -363,7 +362,6 @@ impl FffServer {
files: &result.files,
total_matched: result.matches.len(),
next_file_offset: result.next_file_offset,
regex_fallback_error: result.regex_fallback_error.as_deref(),
output_mode,
max_results,
show_context: ctx_lines > 0,
@@ -604,7 +602,6 @@ impl FffServer {
files: &fb_file_refs,
total_matched: fb_result.matches.len(),
next_file_offset: fb_result.next_file_offset,
regex_fallback_error: None,
output_mode,
max_results,
show_context: false,
@@ -636,7 +633,6 @@ impl FffServer {
files: &file_refs,
total_matched: result.matches.len(),
next_file_offset: result.next_file_offset,
regex_fallback_error: None,
output_mode,
max_results,
show_context: ctx_lines > 0,