Skip to main content

StatefulTool

Trait StatefulTool 

Source
pub trait StatefulTool<S: State>: Tool {
    // Required method
    fn invoke_with_state(
        &self,
        input: Value,
        runtime: &ToolRuntime<S>,
    ) -> BoxFuture<'_, Result<String, ToolError>>;

    // Provided method
    fn invoke_with_store<'a>(
        &'a self,
        input: Value,
        store: &'a dyn Store,
    ) -> BoxFuture<'a, Result<String, ToolError>>
       where Self: 'a { ... }
}
Expand description

Stateful tool trait for tools that need graph state access

Tools can access the current graph state during execution.

Note: This trait does not implement Debug as it’s an async trait intended for dynamic dispatch via trait objects.

Required Methods§

Source

fn invoke_with_state( &self, input: Value, runtime: &ToolRuntime<S>, ) -> BoxFuture<'_, Result<String, ToolError>>

Execute with state access

§Arguments
  • input - Tool input
  • runtime - Runtime context with state access
§Returns

Tool output as string

Provided Methods§

Source

fn invoke_with_store<'a>( &'a self, input: Value, store: &'a dyn Store, ) -> BoxFuture<'a, Result<String, ToolError>>
where Self: 'a,

Override invoke_with_store to use state access when available

This default implementation calls the base Tool trait’s invoke_with_store. Tools that need both state and store access can override this method.

§Arguments
  • input - Tool input
  • store - Store for cross-thread data access
§Returns

Tool output as string

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§