Skip to main content

ToolHandler

Trait ToolHandler 

Source
pub trait ToolHandler: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn invoke<'life0, 'async_trait>(
        &'life0 self,
        arguments: Value,
        ctx: ToolContext,
    ) -> Pin<Box<dyn Future<Output = Result<Value, ARCPError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Application-supplied tool handler.

Implementations should poll cancel at safe checkpoints to honour cooperative cancellation (RFC §10.4).

Required Methods§

Source

fn name(&self) -> &str

Tool identifier (matches tool.invoke.payload.tool).

Source

fn invoke<'life0, 'async_trait>( &'life0 self, arguments: Value, ctx: ToolContext, ) -> Pin<Box<dyn Future<Output = Result<Value, ARCPError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Run the tool. Return either an inline JSON result or an error.

arguments is the raw arguments block from the envelope. ctx is the per-job ToolContext — the handler polls ctx.cancel for cooperative cancellation.

§Errors

Implementations return ARCPError for any failure path. The runtime maps the error to a job.failed (or job.cancelled) envelope on the wire.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§