From 97a0a9be320da4c1cca1d4b8e4bb83df5d9fc522 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 8 Mar 2026 10:15:25 -0400 Subject: [PATCH] Fix clippy warnings in arc-agent - Collapse nested if statements in heredoc stripping (v4a_patch.rs) - Pass ToolCall directly to execute_one_tool to reduce argument count (tool_execution.rs) Co-Authored-By: Claude Opus 4.6 --- crates/arc-agent/src/tool_execution.rs | 24 ++++++++++-------------- crates/arc-agent/src/v4a_patch.rs | 8 ++++---- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/crates/arc-agent/src/tool_execution.rs b/crates/arc-agent/src/tool_execution.rs index feb7bf7ab..97f96e8da 100644 --- a/crates/arc-agent/src/tool_execution.rs +++ b/crates/arc-agent/src/tool_execution.rs @@ -184,9 +184,7 @@ async fn execute_and_emit_one_tool_with_lookup( ); let result = execute_one_tool( - &tc.id, - &tc.name, - &tc.arguments, + tc, registered_tool, env, tool_approval, @@ -217,9 +215,7 @@ async fn execute_and_emit_one_tool_with_lookup( /// Execute a single tool call: argument validation and execution. async fn execute_one_tool( - tool_call_id: &str, - tool_name: &str, - arguments: &serde_json::Value, + tc: &arc_llm::types::ToolCall, registered_tool: Option<&crate::tool_registry::RegisteredTool>, env: Arc, tool_approval: Option<&ToolApprovalFn>, @@ -227,17 +223,17 @@ async fn execute_one_tool( tool_env: Option<&HashMap>, ) -> ToolResult { if let Some(approval_fn) = tool_approval { - if let Err(denial_message) = approval_fn(tool_name, arguments) { - return ToolResult::error(tool_call_id, denial_message); + if let Err(denial_message) = approval_fn(&tc.name, &tc.arguments) { + return ToolResult::error(&tc.id, denial_message); } } match registered_tool { Some(tool) => { if let Err(validation_error) = - validate_tool_args(&tool.definition.parameters, arguments) + validate_tool_args(&tool.definition.parameters, &tc.arguments) { - return ToolResult::error(tool_call_id, validation_error); + return ToolResult::error(&tc.id, validation_error); } let ctx = crate::tool_registry::ToolContext { @@ -245,12 +241,12 @@ async fn execute_one_tool( cancel: cancel_token, tool_env: tool_env.cloned(), }; - match (tool.executor)(arguments.clone(), ctx).await { - Ok(output) => ToolResult::success(tool_call_id, serde_json::json!(output)), - Err(err) => ToolResult::error(tool_call_id, err), + match (tool.executor)(tc.arguments.clone(), ctx).await { + Ok(output) => ToolResult::success(&tc.id, serde_json::json!(output)), + Err(err) => ToolResult::error(&tc.id, err), } } - None => ToolResult::error(tool_call_id, format!("Unknown tool: {tool_name}")), + None => ToolResult::error(&tc.id, format!("Unknown tool: {}", tc.name)), } } diff --git a/crates/arc-agent/src/v4a_patch.rs b/crates/arc-agent/src/v4a_patch.rs index 4aabd0bda..e3bb9d39e 100644 --- a/crates/arc-agent/src/v4a_patch.rs +++ b/crates/arc-agent/src/v4a_patch.rs @@ -59,10 +59,10 @@ pub fn parse_v4a_patch(text: &str) -> Result, String> { // Strip heredoc wrapper if let Some(first) = lines.first() { let trimmed = first.trim(); - if trimmed == "<