Generate a one-line summary for a tool call node. The summary is human-readable and concise, suitable for display in the provenance graph and compaction context.
(
tool_name: &str,
kind: NodeKind,
tool_input: Option<&serde_json::Value>,
tool_output: Option<&str>,
status: Option<&str>,
)
| 150 | /// The summary is human-readable and concise, suitable for display in |
| 151 | /// the provenance graph and compaction context. |
| 152 | pub fn summarize_tool_call( |
| 153 | tool_name: &str, |
| 154 | kind: NodeKind, |
| 155 | tool_input: Option<&serde_json::Value>, |
| 156 | tool_output: Option<&str>, |
| 157 | status: Option<&str>, |
| 158 | ) -> String { |
| 159 | // For errors, prefix with the tool name and "failed" |
| 160 | if status == Some("error") { |
| 161 | let reason = tool_output |
| 162 | .map(|o| truncate_for_summary(o, 80)) |
| 163 | .unwrap_or_default(); |
| 164 | if reason.is_empty() { |
| 165 | return format!("{} failed", tool_name); |
| 166 | } |
| 167 | return format!("{} failed: {}", tool_name, reason); |
| 168 | } |
| 169 | |
| 170 | match kind { |
| 171 | NodeKind::Exploration => summarize_exploration(tool_name, tool_input), |
| 172 | NodeKind::Commitment => summarize_commitment(tool_name, tool_input), |
| 173 | NodeKind::Verification => summarize_verification(tool_input, tool_output), |
| 174 | NodeKind::Execution => summarize_execution(tool_name, tool_input), |
| 175 | _ => tool_name.to_string(), |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | // ============================================================================= |
| 180 | // Shell Command Sub-Classification |