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 more