pub struct TaskExecutor { /* private fields */ }Expand description
Task executor for delegated child runs.
Implementations§
Source§impl TaskExecutor
impl TaskExecutor
Sourcepub fn new(
registry: Arc<AgentRegistry>,
llm_client: Arc<dyn LlmClient>,
workspace: String,
) -> Self
pub fn new( registry: Arc<AgentRegistry>, llm_client: Arc<dyn LlmClient>, workspace: String, ) -> Self
Create a new task executor
Sourcepub fn with_mcp(
registry: Arc<AgentRegistry>,
llm_client: Arc<dyn LlmClient>,
workspace: String,
mcp_manager: Arc<McpManager>,
) -> Self
pub fn with_mcp( registry: Arc<AgentRegistry>, llm_client: Arc<dyn LlmClient>, workspace: String, mcp_manager: Arc<McpManager>, ) -> Self
Create a new task executor with MCP manager for tool inheritance
Sourcepub fn with_parent_context(self, ctx: ChildRunContext) -> Self
pub fn with_parent_context(self, ctx: ChildRunContext) -> Self
Set parent session capabilities to inherit into child runs.
pub fn with_max_parallel_tasks(self, max_parallel_tasks: usize) -> Self
Sourcepub fn with_subagent_tracker(
self,
tracker: Arc<InMemorySubagentTaskTracker>,
) -> Self
pub fn with_subagent_tracker( self, tracker: Arc<InMemorySubagentTaskTracker>, ) -> Self
Share a tracker with this executor. When set, each task registers
a CancellationToken against the tracker so the parent session
can cancel by task_id.
Sourcepub async fn execute(
&self,
params: TaskParams,
event_tx: Option<Sender<AgentEvent>>,
parent_session_id: Option<&str>,
) -> Result<TaskResult>
pub async fn execute( &self, params: TaskParams, event_tx: Option<Sender<AgentEvent>>, parent_session_id: Option<&str>, ) -> Result<TaskResult>
Execute a task by spawning an isolated child AgentLoop.
parent_session_id flows into the emitted SubagentStart/SubagentEnd
events so dashboards can associate child runs with the parent session.
Sourcepub async fn execute_with_task_id(
&self,
task_id: String,
params: TaskParams,
event_tx: Option<Sender<AgentEvent>>,
parent_session_id: Option<&str>,
emit_start: bool,
) -> Result<TaskResult>
pub async fn execute_with_task_id( &self, task_id: String, params: TaskParams, event_tx: Option<Sender<AgentEvent>>, parent_session_id: Option<&str>, emit_start: bool, ) -> Result<TaskResult>
Execute a task using a caller-supplied task id. Used by execute_background
so the synchronously-returned task id matches the one in lifecycle events.
When emit_start is false the caller is responsible for emitting
SubagentStart themselves (e.g. to avoid a race against a tracker query).
Sourcepub fn execute_background(
self: Arc<Self>,
params: TaskParams,
event_tx: Option<Sender<AgentEvent>>,
parent_session_id: Option<String>,
) -> String
pub fn execute_background( self: Arc<Self>, params: TaskParams, event_tx: Option<Sender<AgentEvent>>, parent_session_id: Option<String>, ) -> String
Execute a task in the background.
Returns immediately with the task ID; the same id is used in the emitted
SubagentStart/SubagentEnd events so callers can correlate. Pre-emits
SubagentStart synchronously when an event channel is available so a
caller that queries the subagent task tracker right after this call
observes the task in Running state without a race window.
Sourcepub async fn execute_parallel(
self: &Arc<Self>,
tasks: Vec<TaskParams>,
event_tx: Option<Sender<AgentEvent>>,
parent_session_id: Option<&str>,
) -> Vec<TaskResult>
pub async fn execute_parallel( self: &Arc<Self>, tasks: Vec<TaskParams>, event_tx: Option<Sender<AgentEvent>>, parent_session_id: Option<&str>, ) -> Vec<TaskResult>
Execute multiple tasks in parallel.
Spawns all tasks concurrently and waits for all to complete. Returns results in the same order as the input tasks.
Auto Trait Implementations§
impl Freeze for TaskExecutor
impl !RefUnwindSafe for TaskExecutor
impl Send for TaskExecutor
impl Sync for TaskExecutor
impl Unpin for TaskExecutor
impl UnsafeUnpin for TaskExecutor
impl !UnwindSafe for TaskExecutor
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more