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 <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-03-08 10:15:25 -04:00
parent f4481e5287
commit 97a0a9be32
2 changed files with 14 additions and 18 deletions

View file

@ -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<dyn Sandbox>,
tool_approval: Option<&ToolApprovalFn>,
@ -227,17 +223,17 @@ async fn execute_one_tool(
tool_env: Option<&HashMap<String, String>>,
) -> 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)),
}
}

View file

@ -59,10 +59,10 @@ pub fn parse_v4a_patch(text: &str) -> Result<Vec<PatchOperation>, String> {
// Strip heredoc wrapper
if let Some(first) = lines.first() {
let trimmed = first.trim();
if trimmed == "<<EOF" || trimmed == "<<'EOF'" || trimmed == "<<\"EOF\"" {
if lines.last().map(|l| l.trim()) == Some("EOF") {
lines = lines[1..lines.len() - 1].to_vec();
}
if (trimmed == "<<EOF" || trimmed == "<<'EOF'" || trimmed == "<<\"EOF\"")
&& lines.last().map(|l| l.trim()) == Some("EOF")
{
lines = lines[1..lines.len() - 1].to_vec();
}
}