Workflows

Build complex multi-step agent workflows

Workflows chain agents, conditions, and loops into powerful automation pipelines.

Diagram

Workflow

Pass

Fail

📥 Input

🤖 Agent 1

Check

🤖 Agent 2

📤 Output

Quick Start

  1. Linear Workflow
    rust
    use praisonai::{Agent, workflow};
    
    let writer = Agent::new().name("Writer").build()?;
    let editor = Agent::new().name("Editor").build()?;
    
    let flow = workflow()
        .then(writer)
        .then(editor);
    
    flow.run("Write about AI").await?;
  2. With Conditions
    rust
    use praisonai::{workflow, when};
    
    let flow = workflow()
        .then(researcher)
        .when(|result| result.len() > 100)
            .then(summarizer)
        .then(publisher);

Workflow Patterns

Research → Write → Edit

rust
use praisonai::workflow;

let content_pipeline = workflow()
    .then(researcher)    // Research the topic
    .then(writer)        // Write the content
    .then(editor)        // Edit and polish
    .then(reviewer);     // Final review

With Validation Loop

rust
use praisonai::{workflow, r#loop};

let validated_pipeline = workflow()
    .then(generator)
    .then(r#loop(validator)
        .until(|r| r.contains("approved"))
        .max_iterations(3));

Best Practices

Start simple

Build linear workflows first, add branching later.

Give each step a clear purpose

Name agents by their role in the workflow.


Related