pub struct BackgroundCapable<T: BackgroundExecutable> { /* private fields */ }Expand description
Wraps a tool that implements BackgroundExecutable to provide full task
lifecycle management:
- New tasks: generates
task_id, persists, executes foreground or spawns background. - Resume: if
task_idis in args and the task isStopped, re-executes. - Status query: if
task_idis in args and the task is running/terminal, returns status. - Orphan detection: if a persisted
Runningtask has no live handle, marks itStopped.
Implementations§
Source§impl<T: BackgroundExecutable> BackgroundCapable<T>
impl<T: BackgroundExecutable> BackgroundCapable<T>
pub fn new(inner: T, manager: Arc<BackgroundTaskManager>) -> Self
pub fn from_arc(inner: Arc<T>, manager: Arc<BackgroundTaskManager>) -> Self
pub fn with_task_store(self, task_store: Option<Arc<TaskStore>>) -> Self
Trait Implementations§
Source§impl<T: BackgroundExecutable + 'static> Tool for BackgroundCapable<T>
impl<T: BackgroundExecutable + 'static> Tool for BackgroundCapable<T>
Source§fn descriptor(&self) -> ToolDescriptor
fn descriptor(&self) -> ToolDescriptor
Get the tool descriptor.
Source§fn validate_args(&self, args: &Value) -> Result<(), ToolError>
fn validate_args(&self, args: &Value) -> Result<(), ToolError>
Validate tool arguments against the descriptor’s JSON Schema before execution. Read more
Source§fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: Value,
ctx: &'life1 ToolCallContext<'life2>,
) -> Pin<Box<dyn Future<Output = Result<ToolResult, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: Value,
ctx: &'life1 ToolCallContext<'life2>,
) -> Pin<Box<dyn Future<Output = Result<ToolResult, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute the tool. Read more
Source§fn execute_effect<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: Value,
_ctx: &'life1 ToolCallContext<'life2>,
) -> Pin<Box<dyn Future<Output = Result<ToolExecutionEffect, ToolError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn execute_effect<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: Value,
_ctx: &'life1 ToolCallContext<'life2>,
) -> Pin<Box<dyn Future<Output = Result<ToolExecutionEffect, ToolError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Execute tool and return structured effects. Read more
Auto Trait Implementations§
impl<T> Freeze for BackgroundCapable<T>
impl<T> !RefUnwindSafe for BackgroundCapable<T>
impl<T> Send for BackgroundCapable<T>
impl<T> Sync for BackgroundCapable<T>
impl<T> Unpin for BackgroundCapable<T>
impl<T> !UnwindSafe for BackgroundCapable<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more