Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn definition(&self) -> ToolDefinition;
    fn call_json<'life0, 'async_trait>(
        &'life0 self,
        args: Value,
    ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn read_only_hint(&self) -> bool { ... }
}
Expand description

Tool callable from the agent loop.

read_only_hint() defaults to false. Tools that don’t mutate the host system (Read, Glob, Grep, Web*) should override it to true so the loop runs them in parallel and so PermissionMode::Plan allows them.

Required Methods§

Source

fn name(&self) -> &str

Source

fn definition(&self) -> ToolDefinition

Source

fn call_json<'life0, 'async_trait>( &'life0 self, args: Value, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Provided Methods§

Source

fn read_only_hint(&self) -> bool

Hint to the loop that this tool is safe to execute concurrently with other read-only tools and is allowed under PermissionMode::Plan.

Implementors§