MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / execute_tool

Method execute_tool

crates/opencode-agent/src/executor.rs:350–380  ·  view source on GitHub ↗
(&self, tool_call: &ToolCall)

Source from the content-addressed store, hash-verified

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,

Callers 1

executeMethod · 0.80

Calls 9

newFunction · 0.85
containsMethod · 0.80
ensure_tool_allowedMethod · 0.80
current_model_stringMethod · 0.80
with_get_last_modelMethod · 0.80
with_agentMethod · 0.80
cloneMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected