SequentialWorkflow orchestrates multiple agents in a linear chain, where each agent processes the output from the previous agent. This creates a pipeline where tasks flow through a series of specialized agents.
When to Use
- Step-by-step processes: Tasks with clear sequential dependencies
- Data transformation pipelines: Progressive refinement of outputs
- Multi-stage analysis: Research → Analysis → Writing → Review
- Quality improvement: Multiple rounds of refinement
Key Features
- Automatic flow construction from agent list
- Support for multiple execution loops
- Shared memory between agents (optional)
- Team awareness capabilities
- Conversation history tracking
- Autosave functionality
Basic Example
Advanced Configuration
With Team Awareness
With Shared Memory
Key Parameters
str
default:"SequentialWorkflow"
Identifier for the workflow instance
List[Agent]
required
List of agents to execute sequentially
int
default:"1"
Number of times to execute the complete workflow
OutputType
default:"dict"
Format for workflow output (dict, str, list, etc.)
bool
default:"False"
Enable agents to know about team structure and flow
bool
default:"False"
Add collaboration instructions to agent prompts
bool
default:"True"
Automatically save conversation history
Methods
run()
Execute the workflow with a task.run_batched()
Process multiple tasks sequentially.run_async()
Execute workflow asynchronously.run_concurrent()
Run multiple tasks concurrently.run_stream() / arun_stream()
Stream tokens from each agent in pipeline order, in real time. Each agent’s tokens are yielded the moment the LLM produces them; once an agent finishes, its full output is handed off to the next agent — same hand-off asrun(), just streamed.
Structured events: with_events=True
By default both methods yield plain token strings. Pass with_events=True to receive structured event dicts instead — useful when you want to render per-agent panels, attribute tokens to their emitting agent, or know exactly when each agent starts and finishes.
max_loops > 1 and drift_detection are not applied in streaming mode. Use run() if you need those.Use Cases
Content Creation Pipeline
Data Analysis Pipeline
Code Review Pipeline
Best Practices
Tip: Keep each agent focused on a single responsibility for cleaner workflows
- Clear Agent Roles: Each agent should have a distinct, well-defined purpose
- Appropriate Ordering: Place agents in logical sequence (research before writing)
- Output Formatting: Ensure each agent’s output format matches the next agent’s expected input
- Error Handling: Monitor for failures in early stages to prevent cascade issues
- Performance: Consider workflow length - too many agents can slow execution
Advanced Features
Custom Flow Generation
The workflow automatically generates a flow string:Conversation Tracking
Access complete conversation history:Related Architectures
- Concurrent Workflow - For parallel execution
- Agent Rearrange - For custom flows
- Hierarchical Swarm - For complex orchestration