pub trait AsyncTool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn spec(&self) -> Result<ToolSpec>;
fn execute<'life0, 'async_trait>(
&'life0 self,
ctx: ToolContext,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn concurrency(&self) -> ToolConcurrency { ... }
}Expand description
Async, context-aware tool interface for advanced Rust tools.
This trait extends Appam’s original synchronous Tool interface with
runtime metadata and managed-state access while remaining additive and
opt-in. Legacy tools continue to implement Tool unchanged; new stateful
or asynchronous tools should implement AsyncTool.
§Concurrency
Tools are treated as ToolConcurrency::SerialOnly unless they explicitly
opt into ToolConcurrency::ParallelSafe. This avoids surprising races for
tools that mutate shared state or depend on side-effect ordering.
Required Methods§
Sourcefn execute<'life0, 'async_trait>(
&'life0 self,
ctx: ToolContext,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
ctx: ToolContext,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the tool with runtime metadata and JSON arguments.
The provided ToolContext contains stable identifiers for the current
session and tool call plus managed state lookup helpers.
§Errors
Returns an error if arguments are invalid, required managed state is missing, execution fails, or the result cannot be serialized.
Provided Methods§
Sourcefn concurrency(&self) -> ToolConcurrency
fn concurrency(&self) -> ToolConcurrency
Return the concurrency policy for this tool.
Implementations should keep the default unless concurrent execution is demonstrably safe with respect to shared state and external side effects.