pub struct StreamingToolExecutor { /* private fields */ }Expand description
Executes tools as they stream in with concurrency control. Rust port of TypeScript’s StreamingToolExecutor class.
- Concurrency-safe tools can execute in parallel
- Non-concurrent tools must execute exclusively
Uses Arc<Mutex
Implementations§
Source§impl StreamingToolExecutor
impl StreamingToolExecutor
pub fn new(parent_abort: Arc<AtomicBool>) -> Self
Sourcepub fn discard(&self)
pub fn discard(&self)
Discard all pending and in-progress tools. Called when streaming fallback occurs.
Sourcepub fn add_tool(&self, tool_use_block: Value, is_concurrency_safe: bool)
pub fn add_tool(&self, tool_use_block: Value, is_concurrency_safe: bool)
Add a tool to the execution queue.
Sourcepub fn has_unfinished_tools(&self) -> bool
pub fn has_unfinished_tools(&self) -> bool
Check if there are any unfinished tools
Sourcepub fn get_completed_results(&self) -> Vec<(String, Value)>
pub fn get_completed_results(&self) -> Vec<(String, Value)>
Get completed results that haven’t been yielded. Stops on non-concurrency-safe executing tool (yielding order).
Sourcepub fn mark_tool_errored(&self, tool_id: &str, _description: &str)
pub fn mark_tool_errored(&self, tool_id: &str, _description: &str)
Mark a tool as having errored (cascading error for sibling tools).
Sourcepub async fn execute_all(
&self,
executor_fn: SharedExecutorFn,
) -> Vec<(String, Result<ToolResult, AgentError>)>
pub async fn execute_all( &self, executor_fn: SharedExecutorFn, ) -> Vec<(String, Result<ToolResult, AgentError>)>
Execute queued tools with concurrency control. Spawns each tool as a task and waits for results respecting concurrency limits. Returns list of (tool_id, result) pairs in execution order.