diff --git a/crates/zeph-core/src/agent/streaming.rs b/crates/zeph-core/src/agent/streaming.rs index 395cd03d..9aae9c78 100644 --- a/crates/zeph-core/src/agent/streaming.rs +++ b/crates/zeph-core/src/agent/streaming.rs @@ -620,9 +620,43 @@ impl Agent { .await; let (output, is_error) = match tool_result { Ok(Some(out)) => { + if let Some(ref fs) = out.filter_stats { + let saved = fs.estimated_tokens_saved() as u64; + let raw = (fs.raw_chars / 4) as u64; + let confidence = fs.confidence; + let was_filtered = fs.filtered_chars < fs.raw_chars; + self.update_metrics(|m| { + m.filter_raw_tokens += raw; + m.filter_saved_tokens += saved; + m.filter_applications += 1; + m.filter_total_commands += 1; + if was_filtered { + m.filter_filtered_commands += 1; + } + if let Some(c) = confidence { + match c { + zeph_tools::FilterConfidence::Full => { + m.filter_confidence_full += 1; + } + zeph_tools::FilterConfidence::Partial => { + m.filter_confidence_partial += 1; + } + zeph_tools::FilterConfidence::Fallback => { + m.filter_confidence_fallback += 1; + } + } + } + }); + } if let Some(diff) = out.diff { let _ = self.channel.send_diff(diff).await; } + if let Some(ref fs) = out.filter_stats + && fs.filtered_lines < fs.raw_lines + { + let stats_line = fs.format_inline(&tc.name); + self.channel.send(&stats_line).await?; + } (out.summary, false) } Ok(None) => ("(no output)".to_owned(), false), diff --git a/crates/zeph-tools/src/shell.rs b/crates/zeph-tools/src/shell.rs index 5951553a..077cdde1 100644 --- a/crates/zeph-tools/src/shell.rs +++ b/crates/zeph-tools/src/shell.rs @@ -207,17 +207,6 @@ impl ShellExecutor { }; self.log_audit(block, result, duration_ms).await; - if let Some(ref tx) = self.tool_event_tx { - let _ = tx.send(ToolEvent::Completed { - tool_name: "bash".to_owned(), - command: (*block).to_owned(), - output: out.clone(), - success: !out.contains("[error]"), - filter_stats: None, - diff: None, - }); - } - let sanitized = sanitize_output(&out); let mut per_block_stats: Option = None; let filtered = if let Some(ref registry) = self.output_filter_registry {