Workflow DSL
The Workflow DSL (Domain Specific Language) allows you to define workflows declaratively using YAML or TOML configuration files. This provides a more accessible way to build workflows without writing Rust code.Overview
The Workflow DSL supports:- Declarative configuration in YAML or TOML
- Agent registry for reusable LLM agents
- Environment variable substitution
- Multiple node types (start, end, task, agent, condition, parallel, join, loop, transform, sub-workflow, wait)
- Conditional and parallel edges
- Retry policies and timeouts
- Validation before execution
Basic Structure
WorkflowDefinition Schema
Metadata
Configuration
Agents
Registry of reusable LLM agents
Model identifier (e.g., “gpt-4”, “gpt-3.5-turbo”)
System prompt for the agent
Temperature parameter (0.0 - 2.0)
Maximum tokens to generate
Number of conversation rounds to keep in context
User ID for persistence
Tenant ID for multi-tenancy
Node Definitions
Start Node
End Node
Workflow exit point
Task Node
Custom task execution
Node identifier
Human-readable name
Executor type:
none: No-op (pass-through)function: Function executor (code-defined)http: HTTP request executorscript: Rhai script executor
Node configuration (see Node Configuration)
LLM Agent Node
Invokes an LLM agentAgent reference (registry):Agent reference (inline):
Optional prompt template with
{{ input }} placeholderCondition Node
Parallel Node
Fan-out marker for parallel executionUse with parallel edges to define branches.
Join Node
Aggregates results from parallel branches
List of node IDs to wait for completion
Loop Node
Executes body repeatedly while condition is trueLoop condition types:
while: Continue while expression is trueuntil: Continue until expression is truecount: Fixed number of iterations
Transform Node
SubWorkflow Node
Wait Node
Edge Definitions
Simple Edges
Conditional Edges
Parallel Edges
Node Configuration
WorkflowDslParser API
Parsing Methods
Parse workflow from YAML string
Parse workflow from TOML string
Parse workflow from file (auto-detects format by extension)Supports
.yaml, .yml, and .toml files.build_with_agents
async fn(definition: WorkflowDefinition, agent_registry: &HashMap<String, Arc<LLMAgent>>) -> DslResult<WorkflowGraph>
Build executable workflow from definitionRequires a registry of pre-built LLMAgent instances.
Environment Variables
The DSL parser supports environment variable substitution using${VAR_NAME} syntax.
Complete Examples
Customer Support Workflow
Parallel Analysis Workflow
Usage Example (Rust)
Error Handling
Errors that can occur during DSL parsing
IO error reading file
YAML parsing error
TOML parsing error
Workflow validation error (missing start/end, invalid references, etc.)
Referenced agent not found in registry
Invalid node type specified
Invalid edge reference
Error building workflow from definition
See Also
- StateGraph API - Graph building and execution
- Workflow Nodes - Node types and implementations
- LLMAgent - LLM agent configuration