pub struct Supervisor { /* private fields */ }Expand description
Supervisor dynamic-routing orchestrator (N1).
Each round it asks supervisor_llm (a String -> String Orchestrator,
typically an LLM with a routing prompt) where to send the current sub-task,
parses the decision, and either returns the final answer or invokes the chosen
worker as a sub-agent. Worker outputs accumulate in the scratchpad and are
re-presented to the model on the next round. Delegation is bounded by
max_rounds, which is the one-level recursion guard: the run errors rather
than looping forever if the model never reaches SUPERVISOR_FINISH.
Implementations§
Source§impl Supervisor
impl Supervisor
Sourcepub fn new(
supervisor_llm: Arc<dyn Orchestrator<Input = String, Output = String>>,
workers: Vec<(String, Arc<dyn Orchestrator<Input = AgentTask, Output = String>>)>,
max_rounds: usize,
) -> Self
pub fn new( supervisor_llm: Arc<dyn Orchestrator<Input = String, Output = String>>, workers: Vec<(String, Arc<dyn Orchestrator<Input = AgentTask, Output = String>>)>, max_rounds: usize, ) -> Self
Build a supervisor.
§Arguments
supervisor_llm— the router (takessupervisor_envelope, returns a decision parseable byparse_supervisor_decision).workers—(name, sub-agent)pairs in delegation/listing order; names must be unique and must not beSUPERVISOR_FINISH.max_rounds— maximum delegation rounds (at least 1).
Sourcepub fn with_max_rounds(self, max_rounds: usize) -> Self
pub fn with_max_rounds(self, max_rounds: usize) -> Self
Adjust the maximum delegation rounds (at least 1).
Sourcepub fn max_rounds(&self) -> usize
pub fn max_rounds(&self) -> usize
The maximum delegation rounds.
Sourcepub fn worker_names(&self) -> Vec<&str>
pub fn worker_names(&self) -> Vec<&str>
Registered worker names in registration order.
Trait Implementations§
Source§impl Orchestrator for Supervisor
impl Orchestrator for Supervisor
Source§fn run_with_context<'life0, 'life1, 'async_trait>(
&'life0 self,
input: Self::Input,
ctx: &'life1 RunContext,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run_with_context<'life0, 'life1, 'async_trait>(
&'life0 self,
input: Self::Input,
ctx: &'life1 RunContext,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execution entry point carrying the run context.
Auto Trait Implementations§
impl !RefUnwindSafe for Supervisor
impl !UnwindSafe for Supervisor
impl Freeze for Supervisor
impl Send for Supervisor
impl Sync for Supervisor
impl Unpin for Supervisor
impl UnsafeUnpin for Supervisor
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
Mutably borrows from an owned value. Read more