Workflows
Workflows allow you to orchestrate multiple agents into coordinated pipelines. Agents can work sequentially, in parallel, or with conditional logic.Workflow Engine
The workflow engine (openfang-kernel/src/workflow.rs) supports:
- Sequential execution - Run agents one after another
- Parallel execution - Run multiple agents concurrently
- Conditional branching - Route based on agent outputs
- Error handling - Retry logic and fallback paths
- State passing - Share data between workflow steps
Creating a Workflow
Workflow Patterns
Sequential Pipeline
Parallel Execution
depends_on run in parallel.
Conditional Branching
Variable Substitution
Workflows support template variables:| Variable | Description |
|---|---|
{{workflow.input}} | Input provided when running the workflow |
{{steps.step_id.output}} | Output from a previous step |
{{steps.step_id.status}} | Status of a previous step (success/failure) |
{{env.VAR_NAME}} | Environment variable |
Error Handling
Triggers
Automate workflow execution with triggers:API Usage
Create Workflow
Run Workflow
Get Status
Best Practices
Start simple
Start simple
Begin with 2-3 step workflows before building complex pipelines.
Use descriptive step IDs
Use descriptive step IDs
IDs like
research-web are clearer than step1.Handle failures gracefully
Handle failures gracefully
Always configure retry logic and fallback steps for critical operations.
Monitor workflow execution
Monitor workflow execution
Use
openfang workflow list to track active workflows.Test steps individually first
Test steps individually first
Ensure each agent works correctly before chaining them.
Next Steps
Triggers
Automate workflow execution
API Reference
Complete workflow API documentation
