Skip to main content

ToolProvider

Trait ToolProvider 

Source
pub trait ToolProvider: Send + Sync {
    // Required methods
    fn provider_id(&self) -> &'static str;
    fn tools_for_session(
        &self,
        ctx: &SessionToolContext,
    ) -> Result<Vec<ToolSpec>, ToolError>;
    fn get_permission_name(tool_name: &str) -> Result<&'static str, ToolError>
       where Self: Sized;
    fn get_permission_resource(
        &self,
        tool_name: &str,
        arguments: &Value,
    ) -> Result<(&'static str, Option<String>), ToolError>;
    fn get_display_argument(
        &self,
        name: &str,
        arguments: &Value,
    ) -> Result<String, ToolError>;
    fn prepare<'life0, 'async_trait>(
        &'life0 self,
        ctx: ToolPreparationContext,
        call: ToolCall,
    ) -> Pin<Box<dyn Future<Output = Result<PreparedTool, ToolError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn prompt_sections(
        &self,
        _ctx: &SessionToolContext,
    ) -> Result<Vec<PromptSection>, ToolError> { ... }
    fn permission_for_unlisted_tool(
        &self,
        _tool_name: &str,
    ) -> Result<Option<&'static str>, ToolError> { ... }
    fn presentation(&self, call: &ToolCall) -> ToolCallPresentation { ... }
    fn prepare_parallel<'life0, 'async_trait>(
        &'life0 self,
        ctx: ToolPreparationContext,
        calls: Vec<ToolCall>,
    ) -> Pin<Box<dyn Future<Output = Vec<Result<PreparedTool, ToolError>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}

Required Methods§

Source

fn provider_id(&self) -> &'static str

Stable engine-facing identity used for system-prompt provenance labels.

Source

fn tools_for_session( &self, ctx: &SessionToolContext, ) -> Result<Vec<ToolSpec>, ToolError>

Source

fn get_permission_name(tool_name: &str) -> Result<&'static str, ToolError>
where Self: Sized,

Source

fn get_permission_resource( &self, tool_name: &str, arguments: &Value, ) -> Result<(&'static str, Option<String>), ToolError>

Source

fn get_display_argument( &self, name: &str, arguments: &Value, ) -> Result<String, ToolError>

Source

fn prepare<'life0, 'async_trait>( &'life0 self, ctx: ToolPreparationContext, call: ToolCall, ) -> Pin<Box<dyn Future<Output = Result<PreparedTool, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Provided Methods§

Source

fn prompt_sections( &self, _ctx: &SessionToolContext, ) -> Result<Vec<PromptSection>, ToolError>

Sections resolved once at run admission and frozen into the agent snapshot.

Source

fn permission_for_unlisted_tool( &self, _tool_name: &str, ) -> Result<Option<&'static str>, ToolError>

Claims a currently undiscovered dynamic tool, allowing preparation to make it available.

Source

fn presentation(&self, call: &ToolCall) -> ToolCallPresentation

Source

fn prepare_parallel<'life0, 'async_trait>( &'life0 self, ctx: ToolPreparationContext, calls: Vec<ToolCall>, ) -> Pin<Box<dyn Future<Output = Vec<Result<PreparedTool, ToolError>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Prepare one turn’s parallel call batch. Providers whose calls may target the same mutable resource can chain preparation against successive states.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§