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
impl AgentOrchestrator
Sourcepub fn new(registry: Arc<AgentRegistry>) -> Self
pub fn new(registry: Arc<AgentRegistry>) -> Self
Sourcepub fn with_retry_config(
registry: Arc<AgentRegistry>,
retry_config: RetryConfig,
) -> Self
pub fn with_retry_config( registry: Arc<AgentRegistry>, retry_config: RetryConfig, ) -> Self
Sourcepub fn set_retry_config(&mut self, retry_config: RetryConfig)
pub fn set_retry_config(&mut self, retry_config: RetryConfig)
Set the retry configuration
Sourcepub fn retry_config(&self) -> &RetryConfig
pub fn retry_config(&self) -> &RetryConfig
Get the retry configuration
Sourcepub async fn execute_with_retry(
&self,
tasks: Vec<AgentTask>,
) -> Result<Vec<AgentOutput>>
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
Sourcepub async fn execute(&self, tasks: Vec<AgentTask>) -> Result<Vec<AgentOutput>>
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
Sourcepub async fn execute_and_aggregate(
&self,
tasks: Vec<AgentTask>,
) -> Result<AgentOutput>
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
Sourcepub async fn execute_conditional<F>(
&self,
tasks: Vec<AgentTask>,
condition: F,
) -> Result<Vec<AgentOutput>>
pub async fn execute_conditional<F>( &self, tasks: Vec<AgentTask>, condition: F, ) -> Result<Vec<AgentOutput>>
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 executecondition- Closure that determines if execution should continue Takes the current outputs and returns true to continue, false to stop
Sourcepub fn registry(&self) -> &AgentRegistry
pub fn registry(&self) -> &AgentRegistry
Get the registry
Sourcepub fn scheduler(&self) -> &AgentScheduler
pub fn scheduler(&self) -> &AgentScheduler
Get the scheduler
Sourcepub fn coordinator(&self) -> &AgentCoordinator
pub fn coordinator(&self) -> &AgentCoordinator
Get the coordinator