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.
Quick Start
- 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); - 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
Process Enum
pub enum Process {
Sequential, // default
Parallel,
Hierarchical,
}Process Types
| Type | Description | Use Case |
|---|---|---|
Sequential | Agents run one after another, each receiving previous output | Pipelines, step-by-step workflows |
Parallel | Agents run concurrently on the same task | Multi-perspective analysis, speed |
Hierarchical | Manager delegates to workers | Complex coordination, validation |
AgentTeam
pub struct AgentTeam {
agents: Vec<Arc<Agent>>,
process: Process,
verbose: bool,
}Builder Methods
| Method | Signature | Description |
|---|---|---|
new() | fn new() -> AgentTeamBuilder | Create builder |
agent(a) | fn agent(self, Agent) -> Self | Add agent |
process(p) | fn process(self, Process) -> Self | Set process type |
verbose(b) | fn verbose(self, bool) -> Self | Enable logging |
build() | fn build(self) -> AgentTeam | Build team |
Runtime Methods
| Method | Signature | Description |
|---|---|---|
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:
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:
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.