diff --git a/crates/agent/src/tests/mod.rs b/crates/agent/src/tests/mod.rs index 513ffce0fa..c2efda7673 100644 --- a/crates/agent/src/tests/mod.rs +++ b/crates/agent/src/tests/mod.rs @@ -4063,14 +4063,8 @@ async fn test_streaming_tool_completes_when_llm_stream_ends_without_final_input( tool_use_id: tool_use.id.clone(), tool_name: tool_use.name, is_error: true, - content: vec![ - "Failed to receive tool input: tool input was not fully received" - .into(), - ], - output: Some( - "Failed to receive tool input: tool input was not fully received" - .into() - ), + content: vec!["tool input was not fully received".into(),], + output: Some("tool input was not fully received".into()), } )], cache: true, diff --git a/crates/agent/src/tests/test_tools.rs b/crates/agent/src/tests/test_tools.rs index 750ea48dc8..56a5733761 100644 --- a/crates/agent/src/tests/test_tools.rs +++ b/crates/agent/src/tests/test_tools.rs @@ -61,10 +61,7 @@ impl AgentTool for StreamingEchoTool { ) -> Task> { let wait_until_complete_rx = self.wait_until_complete_rx.lock().unwrap().take(); cx.spawn(async move |_cx| { - let input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let input = input.recv().await.map_err(|e| e.to_string())?; if let Some(rx) = wait_until_complete_rx { rx.await.ok(); } @@ -127,7 +124,7 @@ impl AgentTool for StreamingJsonErrorContextTool { )); } Err(error) => { - return Err(format!("Failed to receive tool input: {error}")); + return Err(error.to_string()); } } } @@ -220,10 +217,7 @@ impl AgentTool for EchoTool { cx: &mut App, ) -> Task> { cx.spawn(async move |_cx| { - let input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let input = input.recv().await.map_err(|e| e.to_string())?; Ok(input.text) }) } @@ -271,10 +265,7 @@ impl AgentTool for DelayTool { { let executor = cx.background_executor().clone(); cx.foreground_executor().spawn(async move { - let input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let input = input.recv().await.map_err(|e| e.to_string())?; executor.timer(Duration::from_millis(input.ms)).await; Ok("Ding".to_string()) }) @@ -311,10 +302,7 @@ impl AgentTool for ToolRequiringPermission { cx: &mut App, ) -> Task> { cx.spawn(async move |cx| { - let _input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let _input = input.recv().await.map_err(|e| e.to_string())?; let authorize = cx.update(|cx| { let context = crate::ToolPermissionContext::new(Self::NAME, vec![String::new()]); @@ -359,10 +347,7 @@ impl AgentTool for ToolRequiringPermission2 { cx: &mut App, ) -> Task> { cx.spawn(async move |cx| { - let _input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let _input = input.recv().await.map_err(|e| e.to_string())?; let authorize = cx.update(|cx| { let context = crate::ToolPermissionContext::new(Self::NAME, vec![String::new()]); @@ -404,10 +389,7 @@ impl AgentTool for InfiniteTool { cx: &mut App, ) -> Task> { cx.foreground_executor().spawn(async move { - let _input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let _input = input.recv().await.map_err(|e| e.to_string())?; future::pending::<()>().await; unreachable!() }) @@ -460,10 +442,7 @@ impl AgentTool for CancellationAwareTool { cx: &mut App, ) -> Task> { cx.foreground_executor().spawn(async move { - let _input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let _input = input.recv().await.map_err(|e| e.to_string())?; // Wait for cancellation - this tool does nothing but wait to be cancelled event_stream.cancelled_by_user().await; self.was_cancelled.store(true, Ordering::SeqCst); @@ -519,10 +498,7 @@ impl AgentTool for WordListTool { cx: &mut App, ) -> Task> { cx.spawn(async move |_cx| { - let _input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let _input = input.recv().await.map_err(|e| e.to_string())?; Ok("ok".to_string()) }) } diff --git a/crates/agent/src/tools/context_server_registry.rs b/crates/agent/src/tools/context_server_registry.rs index 9948b587f4..01601679c9 100644 --- a/crates/agent/src/tools/context_server_registry.rs +++ b/crates/agent/src/tools/context_server_registry.rs @@ -350,7 +350,7 @@ impl AnyAgentTool for ContextServerTool { let input = input .recv() .await - .map_err(|e| anyhow::anyhow!(format!("Failed to receive tool input: {e}")))?; + .map_err(|e| anyhow::anyhow!(e.to_string()))?; authorize .await diff --git a/crates/agent/src/tools/copy_path_tool.rs b/crates/agent/src/tools/copy_path_tool.rs index b40f26bee7..c263179790 100644 --- a/crates/agent/src/tools/copy_path_tool.rs +++ b/crates/agent/src/tools/copy_path_tool.rs @@ -88,10 +88,7 @@ impl AgentTool for CopyPathTool { ) -> Task> { let project = self.project.clone(); cx.spawn(async move |cx| { - let input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let input = input.recv().await.map_err(|e| e.to_string())?; let paths = vec![input.source_path.clone(), input.destination_path.clone()]; let decision = cx.update(|cx| { decide_permission_for_paths(Self::NAME, &paths, &AgentSettings::get_global(cx)) diff --git a/crates/agent/src/tools/create_directory_tool.rs b/crates/agent/src/tools/create_directory_tool.rs index 602b880932..da2b33fa5f 100644 --- a/crates/agent/src/tools/create_directory_tool.rs +++ b/crates/agent/src/tools/create_directory_tool.rs @@ -77,10 +77,7 @@ impl AgentTool for CreateDirectoryTool { ) -> Task> { let project = self.project.clone(); cx.spawn(async move |cx| { - let input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let input = input.recv().await.map_err(|e| e.to_string())?; let decision = cx.update(|cx| { decide_permission_for_path(Self::NAME, &input.path, AgentSettings::get_global(cx)) }); diff --git a/crates/agent/src/tools/delete_path_tool.rs b/crates/agent/src/tools/delete_path_tool.rs index 9e48d42641..4e4747eb02 100644 --- a/crates/agent/src/tools/delete_path_tool.rs +++ b/crates/agent/src/tools/delete_path_tool.rs @@ -81,10 +81,7 @@ impl AgentTool for DeletePathTool { let project = self.project.clone(); let action_log = self.action_log.clone(); cx.spawn(async move |cx| { - let input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let input = input.recv().await.map_err(|e| e.to_string())?; let path = input.path; let decision = cx.update(|cx| { diff --git a/crates/agent/src/tools/diagnostics_tool.rs b/crates/agent/src/tools/diagnostics_tool.rs index a59f61ae97..1d6528007d 100644 --- a/crates/agent/src/tools/diagnostics_tool.rs +++ b/crates/agent/src/tools/diagnostics_tool.rs @@ -93,10 +93,7 @@ impl AgentTool for DiagnosticsTool { ) -> Task> { let project = self.project.clone(); cx.spawn(async move |cx| { - let input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let input = input.recv().await.map_err(|e| e.to_string())?; match input.path { Some(path) if !path.is_empty() => { diff --git a/crates/agent/src/tools/edit_file_tool.rs b/crates/agent/src/tools/edit_file_tool.rs index 9d5f7953ff..e22436c7a8 100644 --- a/crates/agent/src/tools/edit_file_tool.rs +++ b/crates/agent/src/tools/edit_file_tool.rs @@ -439,7 +439,7 @@ impl EditFileTool { }, Err(error) => { return EditSessionResult::Failed { - error: format!("Failed to receive tool input: {error}"), + error: error.to_string(), session, }; } diff --git a/crates/agent/src/tools/fetch_tool.rs b/crates/agent/src/tools/fetch_tool.rs index ca8e9a3697..716b4b364e 100644 --- a/crates/agent/src/tools/fetch_tool.rs +++ b/crates/agent/src/tools/fetch_tool.rs @@ -143,10 +143,7 @@ impl AgentTool for FetchTool { ) -> Task> { let http_client = self.http_client.clone(); cx.spawn(async move |cx| { - let input: FetchToolInput = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let input: FetchToolInput = input.recv().await.map_err(|e| e.to_string())?; let authorize = cx.update(|cx| { let context = diff --git a/crates/agent/src/tools/find_path_tool.rs b/crates/agent/src/tools/find_path_tool.rs index 66d127e756..952996b9c8 100644 --- a/crates/agent/src/tools/find_path_tool.rs +++ b/crates/agent/src/tools/find_path_tool.rs @@ -128,7 +128,7 @@ impl AgentTool for FindPathTool { let project = self.project.clone(); cx.spawn(async move |cx| { let input = input.recv().await.map_err(|e| FindPathToolOutput::Error { - error: format!("Failed to receive tool input: {e}"), + error: e.to_string(), })?; let search_paths_task = cx.update(|cx| search_paths(&input.glob, project, cx)); diff --git a/crates/agent/src/tools/grep_tool.rs b/crates/agent/src/tools/grep_tool.rs index 485084a406..32d872f657 100644 --- a/crates/agent/src/tools/grep_tool.rs +++ b/crates/agent/src/tools/grep_tool.rs @@ -126,7 +126,7 @@ impl AgentTool for GrepTool { let input = input .recv() .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + .map_err(|e| e.to_string())?; let results = cx.update(|cx| { let path_style = project.read(cx).path_style(cx); diff --git a/crates/agent/src/tools/list_directory_tool.rs b/crates/agent/src/tools/list_directory_tool.rs index 8431648b64..94e2a0b2ea 100644 --- a/crates/agent/src/tools/list_directory_tool.rs +++ b/crates/agent/src/tools/list_directory_tool.rs @@ -155,7 +155,7 @@ impl AgentTool for ListDirectoryTool { let input = input .recv() .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + .map_err(|e| e.to_string())?; // Sometimes models will return these even though we tell it to give a path and not a glob. // When this happens, just list the root worktree directories. diff --git a/crates/agent/src/tools/move_path_tool.rs b/crates/agent/src/tools/move_path_tool.rs index abf45a7ec1..629b40dbf7 100644 --- a/crates/agent/src/tools/move_path_tool.rs +++ b/crates/agent/src/tools/move_path_tool.rs @@ -104,7 +104,7 @@ impl AgentTool for MovePathTool { let input = input .recv() .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + .map_err(|e| e.to_string())?; let paths = vec![input.source_path.clone(), input.destination_path.clone()]; let decision = cx.update(|cx| { decide_permission_for_paths(Self::NAME, &paths, AgentSettings::get_global(cx)) diff --git a/crates/agent/src/tools/now_tool.rs b/crates/agent/src/tools/now_tool.rs index 9721c923b6..f8f4e0d91b 100644 --- a/crates/agent/src/tools/now_tool.rs +++ b/crates/agent/src/tools/now_tool.rs @@ -55,10 +55,7 @@ impl AgentTool for NowTool { cx: &mut App, ) -> Task> { cx.spawn(async move |_cx| { - let input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let input = input.recv().await.map_err(|e| e.to_string())?; let now = match input.timezone { Timezone::Utc => Utc::now().to_rfc3339(), Timezone::Local => Local::now().to_rfc3339(), diff --git a/crates/agent/src/tools/open_tool.rs b/crates/agent/src/tools/open_tool.rs index dc72c758e3..7329965e62 100644 --- a/crates/agent/src/tools/open_tool.rs +++ b/crates/agent/src/tools/open_tool.rs @@ -67,10 +67,7 @@ impl AgentTool for OpenTool { ) -> Task> { let project = self.project.clone(); cx.spawn(async move |cx| { - let input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let input = input.recv().await.map_err(|e| e.to_string())?; // If path_or_url turns out to be a path in the project, make it absolute. let (abs_path, initial_title) = cx.update(|cx| { diff --git a/crates/agent/src/tools/restore_file_from_disk_tool.rs b/crates/agent/src/tools/restore_file_from_disk_tool.rs index aaab281046..3b2c95596c 100644 --- a/crates/agent/src/tools/restore_file_from_disk_tool.rs +++ b/crates/agent/src/tools/restore_file_from_disk_tool.rs @@ -75,10 +75,7 @@ impl AgentTool for RestoreFileFromDiskTool { let project = self.project.clone(); cx.spawn(async move |cx| { - let input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let input = input.recv().await.map_err(|e| e.to_string())?; // Check for any immediate deny before doing async work. for path in &input.paths { diff --git a/crates/agent/src/tools/save_file_tool.rs b/crates/agent/src/tools/save_file_tool.rs index 8fe27fc350..f704209841 100644 --- a/crates/agent/src/tools/save_file_tool.rs +++ b/crates/agent/src/tools/save_file_tool.rs @@ -72,10 +72,7 @@ impl AgentTool for SaveFileTool { let project = self.project.clone(); cx.spawn(async move |cx| { - let input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let input = input.recv().await.map_err(|e| e.to_string())?; // Check for any immediate deny before doing async work. for path in &input.paths { diff --git a/crates/agent/src/tools/spawn_agent_tool.rs b/crates/agent/src/tools/spawn_agent_tool.rs index cdb36126f5..5cb2f8c98c 100644 --- a/crates/agent/src/tools/spawn_agent_tool.rs +++ b/crates/agent/src/tools/spawn_agent_tool.rs @@ -137,7 +137,7 @@ impl AgentTool for SpawnAgentTool { .await .map_err(|e| SpawnAgentToolOutput::Error { session_id: None, - error: format!("Failed to receive tool input: {e}"), + error: e.to_string(), session_info: None, })?; diff --git a/crates/agent/src/tools/terminal_tool.rs b/crates/agent/src/tools/terminal_tool.rs index ffbd4393bc..34d19c581a 100644 --- a/crates/agent/src/tools/terminal_tool.rs +++ b/crates/agent/src/tools/terminal_tool.rs @@ -89,10 +89,7 @@ impl AgentTool for TerminalTool { cx: &mut App, ) -> Task> { cx.spawn(async move |cx| { - let input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let input = input.recv().await.map_err(|e| e.to_string())?; let (working_dir, authorize) = cx.update(|cx| { let working_dir = diff --git a/crates/agent/src/tools/update_plan_tool.rs b/crates/agent/src/tools/update_plan_tool.rs index 39e88590b1..ebc84ad031 100644 --- a/crates/agent/src/tools/update_plan_tool.rs +++ b/crates/agent/src/tools/update_plan_tool.rs @@ -90,10 +90,7 @@ impl AgentTool for UpdatePlanTool { cx: &mut App, ) -> Task> { cx.spawn(async move |_cx| { - let input = input - .recv() - .await - .map_err(|e| format!("Failed to receive tool input: {e}"))?; + let input = input.recv().await.map_err(|e| e.to_string())?; event_stream.update_plan(Self::to_plan(input)); diff --git a/crates/agent/src/tools/web_search_tool.rs b/crates/agent/src/tools/web_search_tool.rs index 271829c626..2938cee3e1 100644 --- a/crates/agent/src/tools/web_search_tool.rs +++ b/crates/agent/src/tools/web_search_tool.rs @@ -78,7 +78,7 @@ impl AgentTool for WebSearchTool { .recv() .await .map_err(|e| WebSearchToolOutput::Error { - error: format!("Failed to receive tool input: {e}"), + error: e.to_string(), })?; let authorize = cx.update(|cx| {