Skip to main content

SubAgentManager

Struct SubAgentManager 

Source
pub struct SubAgentManager { /* private fields */ }
Expand description

Manages named sub-agent configurations and spawns them.

Generic over nothing — the provider and context are passed at spawn time because Provider and ContextStrategy use RPITIT and are not dyn-compatible.

Implementations§

Source§

impl SubAgentManager

Source

pub fn new() -> Self

Create a new empty manager.

Source

pub fn register(&mut self, name: impl Into<String>, config: SubAgentConfig)

Register a named sub-agent configuration.

Source

pub fn get(&self, name: &str) -> Option<&SubAgentConfig>

Get a registered sub-agent configuration by name.

Source

pub async fn spawn<P: Provider, C: ContextStrategy>( &self, name: &str, provider: P, context: C, parent_tools: &ToolRegistry, user_message: Message, tool_ctx: &ToolContext, current_depth: usize, ) -> Result<AgentResult, SubAgentError>

Spawn a sub-agent by name, running it to completion.

Filters the parent’s tool registry to only include tools listed in the sub-agent’s configuration. Takes the provider and context strategy as generics because they use RPITIT.

§Errors

Returns SubAgentError::NotFound if the name is not registered. Returns SubAgentError::MaxDepthExceeded if current_depth >= config.max_depth. Returns SubAgentError::Loop if the sub-agent’s loop fails.

Source

pub async fn spawn_parallel<P, C>( &self, tasks: Vec<(String, P, C, Message)>, parent_tools: &ToolRegistry, tool_ctx: &ToolContext, current_depth: usize, ) -> Vec<Result<AgentResult, SubAgentError>>

Spawn multiple sub-agents concurrently with the same parent tools and context.

Each entry is (name, provider, context, user_message). All share the same parent tools and tool context. Results are returned in the same order as the input.

Sub-agents run concurrently on the current task via futures::future::join_all, which interleaves their execution without requiring 'static bounds. This avoids the tokio::spawn limitation where Provider and ContextStrategy RPITIT types are not 'static.

§Errors

Each element of the returned Vec is an independent Result. All sub-agents are executed regardless of earlier failures.

Trait Implementations§

Source§

impl Default for SubAgentManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,