@@ -891,7 +891,8 @@ async fn run_single_shot(
891891 output_format : OutputFormat ,
892892) -> anyhow:: Result < ( ) > {
893893 let event_rx = take_event_rx ( session) ;
894- let printer = tokio:: spawn ( print_events ( event_rx, output_format) ) ;
894+ let registry = session. executor . registry_arc ( ) ;
895+ let printer = tokio:: spawn ( print_events ( event_rx, output_format, registry) ) ;
895896
896897 let result = session. handle_user_input ( prompt) . await ;
897898 // Replace the event_tx with a dummy so the printer's rx sees all senders dropped.
@@ -943,7 +944,8 @@ async fn run_repl(
943944 let effective_input = resolve_slash_command ( input, skill_registry) ;
944945
945946 let event_rx = take_event_rx ( session) ;
946- let printer = tokio:: spawn ( print_events ( event_rx, OutputFormat :: Text ) ) ;
947+ let registry = session. executor . registry_arc ( ) ;
948+ let printer = tokio:: spawn ( print_events ( event_rx, OutputFormat :: Text , registry) ) ;
947949
948950 match session. handle_user_input ( & effective_input) . await {
949951 Ok ( ( ) ) => { }
@@ -975,7 +977,11 @@ fn take_event_rx(session: &mut AgentSession) -> mpsc::Receiver<Event> {
975977///
976978/// `OutputFormat::Json` and `StreamJson` emit NDJSON to stdout.
977979/// `OutputFormat::Text` uses colored human-readable output.
978- async fn print_events ( mut rx : mpsc:: Receiver < Event > , output_format : OutputFormat ) {
980+ async fn print_events (
981+ mut rx : mpsc:: Receiver < Event > ,
982+ output_format : OutputFormat ,
983+ registry : Arc < crab_tools:: registry:: ToolRegistry > ,
984+ ) {
979985 let mut stdout = std:: io:: stdout ( ) ;
980986 let mut spinner: Option < Spinner > = None ;
981987
@@ -993,18 +999,25 @@ async fn print_events(mut rx: mpsc::Receiver<Event>, output_format: OutputFormat
993999 }
9941000
9951001 match event {
996- Event :: ContentDelta { delta, .. } => {
997- if let Some ( mut s) = spinner. take ( ) {
998- s. stop ( ) ;
1002+ Event :: ContentDelta { index, delta } => {
1003+ // Only print text content (index 0), not tool arguments (index 1000+)
1004+ if index == 0 {
1005+ if let Some ( mut s) = spinner. take ( ) {
1006+ s. stop ( ) ;
1007+ }
1008+ print ! ( "{delta}" ) ;
1009+ let _ = stdout. flush ( ) ;
9991010 }
1000- print ! ( "{delta}" ) ;
1001- let _ = stdout. flush ( ) ;
10021011 }
1003- Event :: ToolUseStart { name, .. } => {
1012+ Event :: ToolUseStart { name, input , .. } => {
10041013 if let Some ( mut s) = spinner. take ( ) {
10051014 s. stop ( ) ;
10061015 }
1007- eprintln ! ( "{} {}" , "tool:" . cyan( ) . bold( ) , name. cyan( ) ) ;
1016+ let summary = registry
1017+ . get ( & name)
1018+ . and_then ( |tool| tool. format_use_summary ( & input) )
1019+ . unwrap_or_else ( || name. clone ( ) ) ;
1020+ eprintln ! ( "{} {}" , "tool:" . cyan( ) . bold( ) , summary. cyan( ) ) ;
10081021 spinner = Some ( Spinner :: start ( & format ! ( "running {name}..." ) ) ) ;
10091022 }
10101023 Event :: ToolOutputDelta { id : _, delta } => {
@@ -1161,10 +1174,11 @@ fn event_to_json(event: &Event) -> Option<Value> {
11611174 "cache_creation_tokens" : usage. cache_creation_tokens,
11621175 } ,
11631176 } ) ) ,
1164- Event :: ToolUseStart { name, id } => Some ( json ! ( {
1177+ Event :: ToolUseStart { name, id, input } => Some ( json ! ( {
11651178 "type" : "tool_use_start" ,
11661179 "tool" : name,
11671180 "id" : id,
1181+ "input" : input,
11681182 } ) ) ,
11691183 Event :: ToolUseInput { id, input } => Some ( json ! ( {
11701184 "type" : "tool_use_input" ,
@@ -1622,6 +1636,7 @@ mod tests {
16221636 Event :: ToolUseStart {
16231637 id: "t" . into( ) ,
16241638 name: "n" . into( ) ,
1639+ input: Value :: Null ,
16251640 } ,
16261641 Event :: ToolUseInput {
16271642 id: "t" . into( ) ,
0 commit comments