pub struct BasicToolExecutor { /* private fields */ }Expand description
The default ToolExecutor that walks one or more ToolSources,
checks permissions via Tool::proposed_requests, and invokes the tool.
Compose static native tools (a frozen ToolRegistry) alongside
dynamic sources (a CatalogReader minted by dynamic_catalog and
owned by an MCP manager, skill watcher, plugin loader, etc.) without
merging into a single mutable registry.
§Example
use std::sync::Arc;
use agentkit_tools_core::{BasicToolExecutor, ToolRegistry, ToolSource};
let static_registry: Arc<dyn ToolSource> = Arc::new(ToolRegistry::new());
let executor = BasicToolExecutor::new([static_registry]);
// Pass `executor` to the agent loop.Implementations§
Source§impl BasicToolExecutor
impl BasicToolExecutor
Sourcepub fn new(sources: impl IntoIterator<Item = Arc<dyn ToolSource>>) -> Self
pub fn new(sources: impl IntoIterator<Item = Arc<dyn ToolSource>>) -> Self
Creates an executor that walks sources in order on every lookup.
Sourcepub fn from_registry(registry: ToolRegistry) -> Self
pub fn from_registry(registry: ToolRegistry) -> Self
Back-compat shorthand: wrap a single ToolRegistry as the only source.
Sourcepub fn with_collision_policy(self, policy: CollisionPolicy) -> Self
pub fn with_collision_policy(self, policy: CollisionPolicy) -> Self
Sets the collision policy applied when the same tool name appears in multiple sources.
Trait Implementations§
Source§impl ToolExecutor for BasicToolExecutor
impl ToolExecutor for BasicToolExecutor
Source§fn drain_catalog_events(&self) -> Vec<ToolCatalogEvent>
fn drain_catalog_events(&self) -> Vec<ToolCatalogEvent>
Drains any pending dynamic catalog events. Read more
Source§fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: ToolRequest,
ctx: &'life1 mut ToolContext<'life2>,
) -> Pin<Box<dyn Future<Output = ToolExecutionOutcome> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: ToolRequest,
ctx: &'life1 mut ToolContext<'life2>,
) -> Pin<Box<dyn Future<Output = ToolExecutionOutcome> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Looks up the tool, evaluates permissions, and invokes it.
Source§fn execute_approved<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
request: ToolRequest,
approved_request: &'life1 ApprovalRequest,
ctx: &'life2 mut ToolContext<'life3>,
) -> Pin<Box<dyn Future<Output = ToolExecutionOutcome> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn execute_approved<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
request: ToolRequest,
approved_request: &'life1 ApprovalRequest,
ctx: &'life2 mut ToolContext<'life3>,
) -> Pin<Box<dyn Future<Output = ToolExecutionOutcome> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Re-executes a tool call that was previously interrupted for approval. Read more
Source§fn execute_owned<'life0, 'async_trait>(
&'life0 self,
request: ToolRequest,
ctx: OwnedToolContext,
) -> Pin<Box<dyn Future<Output = ToolExecutionOutcome> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute_owned<'life0, 'async_trait>(
&'life0 self,
request: ToolRequest,
ctx: OwnedToolContext,
) -> Pin<Box<dyn Future<Output = ToolExecutionOutcome> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Looks up the tool, evaluates permissions, and invokes it using an
owned execution context.
Source§fn execute_approved_owned<'life0, 'life1, 'async_trait>(
&'life0 self,
request: ToolRequest,
approved_request: &'life1 ApprovalRequest,
ctx: OwnedToolContext,
) -> Pin<Box<dyn Future<Output = ToolExecutionOutcome> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute_approved_owned<'life0, 'life1, 'async_trait>(
&'life0 self,
request: ToolRequest,
approved_request: &'life1 ApprovalRequest,
ctx: OwnedToolContext,
) -> Pin<Box<dyn Future<Output = ToolExecutionOutcome> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Re-executes a tool call that was previously interrupted for approval
using an owned execution context.
Auto Trait Implementations§
impl Freeze for BasicToolExecutor
impl !RefUnwindSafe for BasicToolExecutor
impl Send for BasicToolExecutor
impl Sync for BasicToolExecutor
impl Unpin for BasicToolExecutor
impl UnsafeUnpin for BasicToolExecutor
impl !UnwindSafe for BasicToolExecutor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more