Overview
This comprehensive example demonstrates MoFA’s graph-based workflow orchestration system. It includes:- Linear, conditional, and parallel workflow patterns
- ETL data pipelines
- LLM agent workflow integration (Dify-style)
- Event listening and monitoring
- ReAct agent workflow integration
- Multi-agent parallel analysis
- Intelligent data pipelines
What You’ll Learn
- Using
WorkflowBuilderfor fluent workflow construction - Implementing conditional branching
- Parallel execution and result aggregation
- State management and data passing
- LLM integration in workflows
- Event monitoring and checkpoints
Prerequisites
- Rust 1.75 or higher
- OpenAI API key (for LLM examples)
- Understanding of async/await and graph concepts
Architecture
Source Code Overview
The example contains 1061 lines with 10 different workflow scenarios:Running the Example
Workflow Examples
- 1. Linear
- 2. Conditional
- 3. Parallel
- 4. Data Pipeline
- 5. Event Monitoring
- 6. ReAct Agent
- 7. Multi-Agent
- 8. Conditional LLM
- 9. Intelligent Pipeline
- 10. Tool Chain
Pattern: Start → Fetch → Process → Save → EndSimple sequential processing pipeline.Use Case: ETL, data transformation
Key Concepts
WorkflowBuilder API
Node Types
Start Node
Start Node
Entry point of the workflow:
Task Node
Task Node
Executes custom logic:
Condition Node
Condition Node
Routes based on predicate:
LLM Agent Node
LLM Agent Node
Integrates LLM agent:
End Node
End Node
Workflow termination:
Context and State
Event Monitoring
Expected Output
Advanced Features
Checkpoints and Recovery
Timeout and Retries
Custom Aggregation
Common Use Cases
ETL Pipelines
Extract, transform, load data workflows
ML Pipelines
Training, validation, deployment flows
CI/CD
Build, test, deploy automation
Business Process
Multi-stage approval workflows
Troubleshooting
Node Execution Failure
Node Execution Failure
Problem: Node returns errorSolution: Add error handling:
Workflow Deadlock
Workflow Deadlock
Problem: Workflow hangsSolution: Check for circular dependencies and add timeout:
Memory Issues
Memory Issues
Problem: Large workflows consume too much memorySolution: Use streaming or chunking:
Next Steps
ReAct Agent
Integrate reasoning agents
Multi-Agent
Multi-agent workflows
Workflow Guide
Advanced workflow patterns
Workflow API
Complete API reference