pub struct AgentOrchestrator { /* private fields */ }Expand description
Manages a set of named agents with parent/child hierarchies and supervision.
§Usage
let mut orchestrator = AgentOrchestrator::new();
orchestrator.add_agent("planner", || planner_options());
orchestrator.add_child("researcher", "planner", || researcher_options());
let handle = orchestrator.spawn("planner")?;
let result = handle.send_message("Plan a trip to Paris").await?;Implementations§
Source§impl AgentOrchestrator
impl AgentOrchestrator
Sourcepub fn with_supervisor(self, policy: impl SupervisorPolicy + 'static) -> Self
pub fn with_supervisor(self, policy: impl SupervisorPolicy + 'static) -> Self
Set a supervisor policy for error recovery.
Sourcepub const fn with_channel_buffer(self, size: usize) -> Self
pub const fn with_channel_buffer(self, size: usize) -> Self
Set the request channel buffer size (default: 32).
Sourcepub const fn with_max_restarts(self, max: u32) -> Self
pub const fn with_max_restarts(self, max: u32) -> Self
Set the default max restarts for supervised agents (default: 3).
Sourcepub fn add_agent(
&mut self,
name: impl Into<String>,
options_factory: impl Fn() -> AgentOptions + Send + Sync + 'static,
)
pub fn add_agent( &mut self, name: impl Into<String>, options_factory: impl Fn() -> AgentOptions + Send + Sync + 'static, )
Register an agent by name with a factory that produces its options.
The factory is called each time the agent is spawned or restarted.
§Panics
Panics if an agent with the same name has already been registered.
Sourcepub fn add_child(
&mut self,
name: impl Into<String>,
parent: impl Into<String>,
options_factory: impl Fn() -> AgentOptions + Send + Sync + 'static,
)
pub fn add_child( &mut self, name: impl Into<String>, parent: impl Into<String>, options_factory: impl Fn() -> AgentOptions + Send + Sync + 'static, )
Register a child agent under the given parent.
§Panics
Panics if the parent agent has not been registered or if the child name is already registered.
Sourcepub fn parent_of(&self, name: &str) -> Option<&str>
pub fn parent_of(&self, name: &str) -> Option<&str>
Get the parent name for a registered agent.
Sourcepub fn children_of(&self, name: &str) -> Option<&[String]>
pub fn children_of(&self, name: &str) -> Option<&[String]>
Get the child names for a registered agent.
Sourcepub fn spawn(&self, name: &str) -> Result<OrchestratedHandle, AgentError>
pub fn spawn(&self, name: &str) -> Result<OrchestratedHandle, AgentError>
Spawn a registered agent, returning a handle for interaction.
The agent runs in a background tokio task listening for requests. Each
request triggers prompt_async and the result is sent via a one-shot
reply channel.
If a SupervisorPolicy is set, the agent is automatically restarted
when the supervisor returns SupervisorAction::Restart.
§Errors
Returns AgentError::Plugin if the agent name is not registered.