Skip to main content

ToolExecutor

Trait ToolExecutor 

Source
pub trait ToolExecutor:
    Send
    + Sync
    + 'static {
    // Required methods
    fn defs(&self) -> Vec<ToolDef>;
    fn is_read_only(&self, name: &str, args: &str) -> bool;
    fn run<'a>(
        &'a self,
        name: &'a str,
        args: &'a str,
    ) -> Pin<Box<dyn Future<Output = (String, String)> + Send + 'a>>;
    fn supports_images(&self) -> bool;
    fn space_files_dir(&self) -> Option<PathBuf>;
}
Expand description

The tool-calling seam: everything an agent loop needs from the tool layer — definitions for the request, read-only classification for parallelizing independent calls, and execution. ToolBox is the local implementation; a Phase 4 remote implementation (nexus host) speaks the same methods over the wire, and the loops don’t know the difference. supports_images/space_files_dir are required because the tool loop injects image references from tool results as vision content (the host that runs the tools is the only one who knows the model’s vision support and where the space’s files live).

Required Methods§

Source

fn defs(&self) -> Vec<ToolDef>

Tool definitions to attach to the request (see ToolBox::defs).

Source

fn is_read_only(&self, name: &str, args: &str) -> bool

Whether a call is read-only (see is_read_only_tool) — parallel calls run concurrently only when every one of them is.

Source

fn run<'a>( &'a self, name: &'a str, args: &'a str, ) -> Pin<Box<dyn Future<Output = (String, String)> + Send + 'a>>

Run one tool call, returning (result, status-label). Boxed future so the trait stays dyn-compatible (the loops hold Arc<dyn ToolExecutor>).

Source

fn supports_images(&self) -> bool

Whether the current model accepts image inputs.

Source

fn space_files_dir(&self) -> Option<PathBuf>

The active space’s files dir, for resolving image references in tool results.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§