Sequential Workflow Example
ASequentialWorkflow executes tasks in a strict order, forming a pipeline where each agent builds upon the work of the previous one. This architecture is ideal for processes that have clear, ordered steps and ensures that tasks with dependencies are handled correctly.
How Sequential Workflow Works
In a sequential workflow:- Linear Execution: Agents execute tasks one after another in a defined order
- Output Chaining: The output of one agent becomes the input for the next agent
- Dependency Management: Ensures tasks with dependencies are handled correctly
- Sequential Processing: Each agent must complete before the next one starts
Basic Example: Researcher to Writer Pipeline
This example demonstrates a two-agent workflow for researching and writing a blog post:How This Example Works
- Task Assignment: The initial task “The history and future of artificial intelligence” is sent to the first agent (Researcher)
- Research Phase: The Researcher agent processes the task and produces a detailed summary
- Handoff: The Researcher’s output automatically becomes the input for the Writer agent
- Writing Phase: The Writer agent takes the research summary and creates an engaging blog post
- Final Output: The workflow returns the final blog post from the Writer agent
Common Use Cases
SequentialWorkflow is ideal for:- Content Creation Pipelines: Research → Writing → Editing → Publishing
- Data Processing: Collection → Cleaning → Analysis → Reporting
- Software Development: Design → Implementation → Testing → Deployment
- Document Processing: Extraction → Transformation → Validation → Storage
- Report Generation: Data gathering → Analysis → Visualization → Summary
Variations
Three-Stage Content Pipeline
Add an editor to review and polish the content:Multi-Step Data Processing
Process data through multiple transformation stages:Code Development Pipeline
Build a complete software development workflow:Best Practices
- Clear Agent Roles: Define specific, focused responsibilities for each agent
- Appropriate Ordering: Arrange agents in logical sequence based on task dependencies
- Detailed System Prompts: Provide clear instructions about input expectations and output format
- Error Handling: Consider what happens if an intermediate agent fails
- Pipeline Length: Keep workflows manageable; very long pipelines may benefit from breaking into sub-workflows
Key Benefits
- Maintainability: Easy to understand and modify the workflow sequence
- Reliability: Deterministic execution order ensures consistent results
- Debugging: Simple to identify and fix issues at specific stages
- Reusability: Individual agents can be reused in different workflows
- Scalability: Easy to add or remove stages from the pipeline
Related Architectures
- ConcurrentWorkflow: Run agents in parallel instead of sequence
- HierarchicalSwarm: Use a director to coordinate multiple workers
- AgentRearrange: Define complex agent relationships