diff --git a/hive-agent/src/stream_enrich.rs b/hive-agent/src/stream_enrich.rs index 3789e553..942b98a5 100644 --- a/hive-agent/src/stream_enrich.rs +++ b/hive-agent/src/stream_enrich.rs @@ -273,6 +273,12 @@ fn is_rich_tool(name: &str) -> bool { /// /// Returns `None` for tools whose body is inherently client-side (markdown /// rendering, DOM forms) or that have no body at all. +/// +/// **`Write` is intentionally absent**: its `content` field can be megabytes +/// and is one-sided (no `old_string` to diff against), making it too large to +/// inline in every SSE event. The flat `"Write /path"` summary row is +/// sufficient — the operator can open the file directly if they need to inspect +/// the written content. fn rich_tool_body(name: &str, input: &Value) -> Option<(String, &'static str)> { match name { // Edit diff: old lines prefixed `- `, new lines prefixed `+ `. @@ -396,19 +402,22 @@ fn fmt_builtin_tool(name: &str, short: &str, input: &Value) -> String { "Read" | "Write" => format!("{short} {}", sv(input, "file_path")), "Edit" => { let path = sv(input, "file_path"); - let old_n = input + let old = input .get("old_string") .and_then(Value::as_str) - .unwrap_or("") - .lines() - .count(); + .unwrap_or(""); let new_n = input .get("new_string") .and_then(Value::as_str) .unwrap_or("") .lines() .count(); - format!("{short} {path} · -{old_n} +{new_n}") + if old.is_empty() { + format!("{short} {path} · +{new_n}") + } else { + let old_n = old.lines().count(); + format!("{short} {path} · -{old_n} +{new_n}") + } } "Glob" | "Grep" => format!("{short} {}", sv(input, "pattern")), "Bash" => {