(&self, tool_call: &ToolCall)
| 348 | } |
| 349 | |
| 350 | async fn execute_tool(&self, tool_call: &ToolCall) -> Result<String, ToolError> { |
| 351 | if self.disabled_tools.contains(&tool_call.name) { |
| 352 | return Err(ToolError::PermissionDenied(format!( |
| 353 | "Tool '{}' is disabled for this subagent session", |
| 354 | tool_call.name |
| 355 | ))); |
| 356 | } |
| 357 | self.ensure_tool_allowed(&tool_call.name)?; |
| 358 | |
| 359 | let directory = std::env::current_dir() |
| 360 | .unwrap_or_default() |
| 361 | .to_string_lossy() |
| 362 | .to_string(); |
| 363 | |
| 364 | let current_model = self.current_model_string(); |
| 365 | let base_ctx = ToolContext::new("default".to_string(), "default".to_string(), directory) |
| 366 | .with_agent(self.agent.name.clone()) |
| 367 | .with_get_last_model({ |
| 368 | let current_model = current_model.clone(); |
| 369 | move |_session_id| { |
| 370 | let current_model = current_model.clone(); |
| 371 | async move { Ok(current_model) } |
| 372 | } |
| 373 | }); |
| 374 | let ctx = self.with_subsession_callbacks(base_ctx); |
| 375 | |
| 376 | self.tools |
| 377 | .execute(&tool_call.name, tool_call.arguments.clone(), ctx) |
| 378 | .await |
| 379 | .map(|r| r.output) |
| 380 | } |
| 381 | |
| 382 | async fn execute_tool_without_subsessions( |
| 383 | &self, |
no test coverage detected