pub struct StreamingToolExecutor { /* private fields */ }Expand description
Executes tools as they stream in with concurrency control.
Implementations§
Source§impl StreamingToolExecutor
impl StreamingToolExecutor
Sourcepub fn new(
executor: Arc<dyn Fn(String, Value, String) -> Pin<Box<dyn Future<Output = Result<ToolResult, AgentError>> + Send + Sync>> + Send + Sync>,
tools_def: Vec<ToolDefinition>,
) -> (Self, UnboundedReceiver<ToolMessageUpdate>)
pub fn new( executor: Arc<dyn Fn(String, Value, String) -> Pin<Box<dyn Future<Output = Result<ToolResult, AgentError>> + Send + Sync>> + Send + Sync>, tools_def: Vec<ToolDefinition>, ) -> (Self, UnboundedReceiver<ToolMessageUpdate>)
Create a new streaming tool executor.
Sourcepub fn add_tool(&self, name: String, id: String, args: Value)
pub fn add_tool(&self, name: String, id: String, args: Value)
Add a tool to the execution queue. Will start executing immediately if conditions allow.
Sourcepub async fn mark_complete(&self, tool_use_id: &str)
pub async fn mark_complete(&self, tool_use_id: &str)
Mark a tool use as complete.
Sourcepub async fn get_is_concurrency_safe(&self, tool_use_id: &str) -> bool
pub async fn get_is_concurrency_safe(&self, tool_use_id: &str) -> bool
Get a tool’s concurrency safety flag.
Sourcepub async fn has_unfinished_tools(&self) -> bool
pub async fn has_unfinished_tools(&self) -> bool
Check if there are unfinished tools.
Sourcepub async fn has_executing_tools(&self) -> bool
pub async fn has_executing_tools(&self) -> bool
Check if any tools are currently executing.
Sourcepub async fn trigger_sibling_abort(&self)
pub async fn trigger_sibling_abort(&self)
Trigger sibling abort (called when Bash tool errors).
Sourcepub async fn set_tool_result(
&self,
tool_call_id: String,
result: Result<ToolResult, AgentError>,
)
pub async fn set_tool_result( &self, tool_call_id: String, result: Result<ToolResult, AgentError>, )
Set tool result from external execution.
Sourcepub async fn get_completed_results(&self) -> Vec<ToolMessageUpdate>
pub async fn get_completed_results(&self) -> Vec<ToolMessageUpdate>
Get completed results that haven’t been yielded yet. Yields progress messages immediately, then results in order. Stops yielding when encountering a non-concurrency-safe executing tool.
Sourcepub async fn get_remaining_results(
&self,
result_rx: &mut UnboundedReceiver<ToolMessageUpdate>,
) -> Vec<ToolMessageUpdate>
pub async fn get_remaining_results( &self, result_rx: &mut UnboundedReceiver<ToolMessageUpdate>, ) -> Vec<ToolMessageUpdate>
Wait for remaining tools and collect their results.
Sourcepub async fn discard_sync(&self)
pub async fn discard_sync(&self)
Discard all pending and in-progress tools.
Auto Trait Implementations§
impl Freeze for StreamingToolExecutor
impl !RefUnwindSafe for StreamingToolExecutor
impl Send for StreamingToolExecutor
impl Sync for StreamingToolExecutor
impl Unpin for StreamingToolExecutor
impl UnsafeUnpin for StreamingToolExecutor
impl !UnwindSafe for StreamingToolExecutor
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