Sequential Workflow
Chain agents one after another like an assembly line
Pass work from one agent to the next when each step depends on the previous output.
from praisonaiagents import Agent, AgentFlow
researcher = Agent(name="Researcher", instructions="Research topics")
analyst = Agent(name="Analyst", instructions="Analyze research findings")
writer = Agent(name="Writer", instructions="Write based on analysis")
flow = AgentFlow(steps=[researcher, analyst, writer])
flow.start("AI trends in 2024")The user chains agents in order; each step receives the prior output until the final result is ready.
graph LR
U[Input] --> A[Agent]
A --> O[Output]
classDef agent fill:#8B0000,color:#fff
classDef tool fill:#189AB4,color:#fff
class A agent
class U,O toolSequential Workflow
Pass work from one agent to the next, like an assembly line.
graph LR
Input([📝 Request]) --> A1[🔍 Researcher]
A1 --> A2[📊 Analyst]
A2 --> A3[✍️ Writer]
A3 --> A4[📋 Editor]
A4 --> Output([✅ Result])
classDef io fill:#8B0000,stroke:#7C90A0,color:#fff
classDef agent fill:#189AB4,stroke:#7C90A0,color:#fff
class Input,Output io
class A1,A2,A3,A4 agent
classDef agent fill:#8B0000,color:#fff
classDef tool fill:#189AB4,color:#fffHow Context Flows
sequenceDiagram
participant You
participant Researcher
participant Analyst
participant Writer
You->>Researcher: "Write about AI trends"
Researcher->>Analyst: Research findings
Analyst->>Writer: Key insights
Writer->>You: Final articleEach agent receives the previous output automatically.
When to Use
graph LR
subgraph "✅ Use Sequential"
A[Step depends on previous]
B[Order matters]
C[Quality review chain]
end
subgraph "❌ Use Parallel"
D[Independent tasks]
E[Speed critical]
end
classDef good fill:#10B981,stroke:#7C90A0,color:#fff
classDef bad fill:#EF4444,stroke:#7C90A0,color:#fff
class A,B,C good
class D,E badCode
from praisonaiagents import Agent, AgentFlow
researcher = Agent(name="Researcher", instructions="Research topics")
analyst = Agent(name="Analyst", instructions="Analyze research findings")
writer = Agent(name="Writer", instructions="Write based on analysis")
# Sequential: researcher → analyst → writer
flow = AgentFlow(steps=[researcher, analyst, writer])
result = flow.start("AI trends in 2024")Example: Blog Post Pipeline
graph LR
Topic([📝 Topic]) --> R[🔍 Research]
R --> A[📊 Analyze]
A --> W[✍️ Write]
W --> E[📋 Edit]
E --> Post([✅ Published])
classDef io fill:#8B0000,stroke:#7C90A0,color:#fff
classDef step fill:#189AB4,stroke:#7C90A0,color:#fff
class Topic,Post io
class R,A,W,E step| Step | Agent | Receives | Outputs |
|---|---|---|---|
| 1 | Researcher | Topic | Facts, data |
| 2 | Analyst | Facts | Key insights |
| 3 | Writer | Insights | Draft article |
| 4 | Editor | Draft | Polished post |
With Callbacks
from praisonaiagents import AgentFlow, WorkflowHooksConfig
flow = AgentFlow(
steps=[researcher, analyst, writer],
hooks=WorkflowHooksConfig(
on_step_complete=lambda name, r: print(f"✅ {name} done")
)
)