AgentOrchestrator

Struct AgentOrchestrator 

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

Central orchestrator for agent lifecycle and workflows

The AgentOrchestrator manages the execution of agents, including:

  • Agent lifecycle (initialization, execution, cleanup)
  • Inter-agent communication and handoff
  • Sequential, parallel, and conditional workflows
  • Error handling and retry logic

§Examples

use ricecoder_agents::{AgentOrchestrator, AgentRegistry, AgentTask, TaskType, TaskTarget, TaskScope};
use std::sync::Arc;
use std::path::PathBuf;

#[tokio::main]
async fn main() {
    let registry = Arc::new(AgentRegistry::new());
    let orchestrator = AgentOrchestrator::new(registry);

    let task = AgentTask {
        id: "task-1".to_string(),
        task_type: TaskType::CodeReview,
        target: TaskTarget {
            files: vec![PathBuf::from("src/main.rs")],
            scope: TaskScope::File,
        },
        options: Default::default(),
    };

    let results = orchestrator.execute(vec![task]).await.unwrap();
}

Implementations§

Source§

impl AgentOrchestrator

Source

pub fn new(registry: Arc<AgentRegistry>) -> Self

Create a new agent orchestrator

§Arguments
  • registry - The agent registry containing registered agents
§Returns

A new AgentOrchestrator with default retry configuration

Source

pub fn with_retry_config( registry: Arc<AgentRegistry>, retry_config: RetryConfig, ) -> Self

Create a new agent orchestrator with custom retry configuration

§Arguments
  • registry - The agent registry containing registered agents
  • retry_config - Custom retry configuration
§Returns

A new AgentOrchestrator with the specified retry configuration

Source

pub fn set_retry_config(&mut self, retry_config: RetryConfig)

Set the retry configuration

Source

pub fn retry_config(&self) -> &RetryConfig

Get the retry configuration

Source

pub async fn execute_with_retry( &self, tasks: Vec<AgentTask>, ) -> Result<Vec<AgentOutput>>

Execute agents for the given tasks with retry logic

This method executes the given tasks with automatic retry on failure. If execution fails, it will retry up to max_retries times with exponential backoff.

§Arguments
  • tasks - Vector of tasks to execute
§Returns

A Result containing the agent outputs or an error

Source

pub async fn execute(&self, tasks: Vec<AgentTask>) -> Result<Vec<AgentOutput>>

Execute agents for the given tasks

This method executes the given tasks using the orchestrator’s scheduler to determine execution order and parallelism. Tasks are executed according to their dependencies, with independent tasks running in parallel.

§Arguments
  • tasks - Vector of tasks to execute
§Returns

A Result containing the agent outputs or an error

Source

pub async fn execute_and_aggregate( &self, tasks: Vec<AgentTask>, ) -> Result<AgentOutput>

Execute and aggregate results from multiple agents

This method executes the given tasks and then aggregates all results into a single AgentOutput, combining findings, suggestions, and generated content.

§Arguments
  • tasks - Vector of tasks to execute
§Returns

A Result containing the aggregated agent output or an error

Source

pub async fn execute_conditional<F>( &self, tasks: Vec<AgentTask>, condition: F, ) -> Result<Vec<AgentOutput>>
where F: Fn(&[AgentOutput]) -> bool,

Execute tasks conditionally based on a predicate

This method supports conditional workflows where later tasks only execute if earlier tasks meet certain conditions.

§Arguments
  • tasks - Vector of tasks to execute
  • condition - Closure that determines if execution should continue Takes the current outputs and returns true to continue, false to stop
Source

pub fn registry(&self) -> &AgentRegistry

Get the registry

Source

pub fn scheduler(&self) -> &AgentScheduler

Get the scheduler

Source

pub fn coordinator(&self) -> &AgentCoordinator

Get the coordinator

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more