Process

Execution strategies for multi-agent workflows in PraisonAI Rust SDK

Process types define how agents execute tasks in a team – sequentially, in parallel, or hierarchically.

Diagram

Hierarchical

👔 Manager

🛠️ Worker 1

🛠️ Worker 2

Parallel

🤖 Agent 1

🤖 Agent 2

🤖 Agent 3

Sequential

🤖 Agent 1

🤖 Agent 2

🤖 Agent 3

Process Types

📋 Sequential

⚡ Parallel

👔 Hierarchical

Quick Start

  1. Sequential Pipeline
    rust
    use praisonai::{Agent, AgentTeam, Process};
    
    // Create specialized agents
    let researcher = Agent::new()
        .name("Researcher")
        .instructions("Research the given topic thoroughly")
        .build()?;
    
    let writer = Agent::new()
        .name("Writer")
        .instructions("Write a clear article based on the research")
        .build()?;
    
    // Build team with sequential process
    let team = AgentTeam::new()
        .agent(researcher)
        .agent(writer)
        .process(Process::Sequential)
        .build();
    
    // Run the pipeline
    let result = team.start("Write about quantum computing").await?;
    println!("{}", result);
  2. Parallel Execution
    rust
    use praisonai::{Agent, AgentTeam, Process};
    
    // Agents work simultaneously on the same task
    let analyzer1 = Agent::new()
        .name("Analyzer1")
        .instructions("Analyze from perspective A")
        .build()?;
    
    let analyzer2 = Agent::new()
        .name("Analyzer2")
        .instructions("Analyze from perspective B")
        .build()?;
    
    let team = AgentTeam::new()
        .agent(analyzer1)
        .agent(analyzer2)
        .process(Process::Parallel)
        .build();
    
    // Both agents run concurrently
    let combined = team.start("Analyze this dataset").await?;

User Interaction Flow

Diagram
WriterResearcherAgentTeamUserWriterResearcherAgentTeamUseralt[Sequential Process]start(“Research topic”)chat(task)Research resultschat(task + prev_output)Final articleCombined result

Process Enum

rust
pub enum Process {
    Sequential,   // default
    Parallel,
    Hierarchical,
}

Process Types

TypeDescriptionUse Case
SequentialAgents run one after another, each receiving previous outputPipelines, step-by-step workflows
ParallelAgents run concurrently on the same taskMulti-perspective analysis, speed
HierarchicalManager delegates to workersComplex coordination, validation

AgentTeam

rust
pub struct AgentTeam {
    agents: Vec<Arc<Agent>>,
    process: Process,
    verbose: bool,
}

Builder Methods

MethodSignatureDescription
new()fn new() -> AgentTeamBuilderCreate builder
agent(a)fn agent(self, Agent) -> SelfAdd agent
process(p)fn process(self, Process) -> SelfSet process type
verbose(b)fn verbose(self, bool) -> SelfEnable logging
build()fn build(self) -> AgentTeamBuild team

Runtime Methods

MethodSignatureDescription
start(task)`async fn start(&self, &str) -> Result

| Run team on task | | run(task) | async fn run(&self, &str) -> Result

| Alias for start | | len() | fn len(&self) -> usize` | Number of agents |


Sequential Process

Each agent runs in order, receiving the previous agent’s output as context:

rust
use praisonai::{Agent, AgentTeam, Process};

let step1 = Agent::new()
    .name("Step1")
    .instructions("First processing step")
    .build()?;

let step2 = Agent::new()
    .name("Step2")
    .instructions("Use previous output for next step")
    .build()?;

let pipeline = AgentTeam::new()
    .agent(step1)
    .agent(step2)
    .process(Process::Sequential)
    .verbose(true)
    .build();

let result = pipeline.start("Initial input").await?;

Parallel Process

All agents work simultaneously on the same input, results are combined:

rust
use praisonai::{Agent, AgentTeam, Process};

let fast_analyzer = Agent::new().name("Fast").build()?;
let deep_analyzer = Agent::new().name("Deep").build()?;

let team = AgentTeam::new()
    .agent(fast_analyzer)
    .agent(deep_analyzer)
    .process(Process::Parallel)
    .build();

// Both agents run concurrently
let combined = team.start("Analyze this").await?;

Best Practices

Use Sequential for dependent steps

When each agent needs the previous agent’s output – research → write → edit.

Use Parallel for independent analysis

When agents can work simultaneously – multiple perspectives, speed optimization.

Enable verbose for debugging

Use .verbose(true) to see workflow execution details.

Keep teams focused

3-5 agents typically works well. Split larger workflows into multiple teams.


Related