pub struct SubagentCoordinator { /* private fields */ }Expand description
Subagent coordinator.
Wraps an AgentSupervisor to add lifecycle tracking, cancellation,
and depth guarding. Owns the SubagentTracker registry.
Implementations§
Source§impl SubagentCoordinator
impl SubagentCoordinator
Sourcepub fn new(supervisor: AgentSupervisor) -> Self
pub fn new(supervisor: AgentSupervisor) -> Self
Create a new coordinator with the default max depth
(DEFAULT_MAX_SUBAGENT_DEPTH).
Sourcepub fn with_max_depth(supervisor: AgentSupervisor, max_depth: u32) -> Self
pub fn with_max_depth(supervisor: AgentSupervisor, max_depth: u32) -> Self
Create with an explicit max subagent nesting depth.
Sourcepub fn supervisor(&self) -> &AgentSupervisor
pub fn supervisor(&self) -> &AgentSupervisor
Borrow the wrapped supervisor (for direct spawns that bypass coordinator tracking).
Sourcepub fn tracked_count(&self) -> usize
pub fn tracked_count(&self) -> usize
Number of currently-tracked subagents (any state).
Sourcepub fn tracker(&self, agent_id: &str) -> Option<Arc<SubagentTracker>>
pub fn tracker(&self, agent_id: &str) -> Option<Arc<SubagentTracker>>
Look up a tracker by agent ID.
Sourcepub fn state(&self, agent_id: &str) -> Option<SubagentState>
pub fn state(&self, agent_id: &str) -> Option<SubagentState>
Current state of an agent, or None if unknown.
Sourcepub fn snapshot(&self) -> HashMap<String, SubagentState>
pub fn snapshot(&self) -> HashMap<String, SubagentState>
Snapshot of every tracked agent ID → state.
Sourcepub fn spawn(
&self,
req: SubagentSpawnRequest,
) -> Result<String, SubagentCoordinatorError>
pub fn spawn( &self, req: SubagentSpawnRequest, ) -> Result<String, SubagentCoordinatorError>
Spawn a subagent. Returns immediately with the agent ID on success — the run proceeds in a background task.
Errors:
SubagentCoordinatorError::MaxDepthExceeded—req.depthexceedsSelf::max_depth.SubagentCoordinatorError::DuplicateId—req.agent_idis already tracked.SubagentCoordinatorError::SpawnFailed— supervisor rejected the spawn (bad model/provider).SubagentCoordinatorError::ResumeFromNotFound—req.resume_fromnames an unknown agent.
Sourcepub fn cancel(&self, agent_id: &str) -> bool
pub fn cancel(&self, agent_id: &str) -> bool
Trigger cancellation for an agent. Returns true if the agent
was tracked (and is now scheduled to transition to
SubagentState::Cancelled).
Sourcepub async fn block_wait_slot(
&self,
agent_id: &str,
timeout: Duration,
) -> Option<SubagentState>
pub async fn block_wait_slot( &self, agent_id: &str, timeout: Duration, ) -> Option<SubagentState>
Block until the named agent reaches a terminal state, or
timeout elapses. Returns the terminal state on completion,
None on timeout (the underlying run continues), or None
if the agent is unknown.
This is the “block_wait_slot” operation from the design doc: on timeout the caller can either treat the agent as backgrounded (move on) or re-poll.
Trait Implementations§
Source§impl Clone for SubagentCoordinator
impl Clone for SubagentCoordinator
Source§fn clone(&self) -> SubagentCoordinator
fn clone(&self) -> SubagentCoordinator
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for SubagentCoordinator
impl !UnwindSafe for SubagentCoordinator
impl Freeze for SubagentCoordinator
impl Send for SubagentCoordinator
impl Sync for SubagentCoordinator
impl Unpin for SubagentCoordinator
impl UnsafeUnpin for SubagentCoordinator
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.