Overview
TheGraphExecutor extends the base Executor to execute workflows as directed acyclic graphs (DAGs), enabling parallel execution of independent members and optimized workflow scheduling.
Constructor
Graph executor configuration (extends ExecutorOptions)
Cloudflare Workers environment bindings
Parsed ensemble definition
Initial input data
Maximum concurrent member executions
Scheduling algorithm:
topological, priority, resource-awareEnable graph optimization
Methods
execute()
Execute the workflow as a DAG with parallelization.Promise<ExecutionResult>
The graph executor automatically:
- Builds dependency graph from ensemble
- Identifies independent members
- Schedules parallel execution
- Manages resource allocation
- Handles errors and retries
buildGraph()
Build execution graph from ensemble.ExecutionGraph
getExecutionPlan()
Get optimized execution plan.ExecutionPlan
getCriticalPath()
Find critical path through the graph.string[] - Member names on critical path
The critical path is the longest sequence of dependent members that determines minimum execution time.
Example:
visualize()
Generate graph visualization (DOT format).string - Graph visualization
Example:
analyzeDependencies()
Analyze member dependencies.Member name to analyze
DependencyAnalysis
optimizeGraph()
Optimize execution graph.OptimizationResult
- Removing unreachable nodes
- Merging small sequential members
- Reordering for better parallelization
- Resource-aware scheduling
Graph Scheduling
Topological Scheduler
Default scheduler that executes members in topological order:- Dependencies executed before dependents
- Maximum parallelization
- Deterministic ordering
Priority Scheduler
Prioritizes critical path and high-priority members:- Critical path membership
- Number of dependents
- Estimated duration
- Explicit priority annotations
Resource-Aware Scheduler
Optimizes based on resource availability:- CPU limits
- Memory constraints
- API rate limits
- Worker concurrency
Parallel Execution
Automatic Parallelization
The graph executor automatically identifies and executes independent members in parallel:Controlling Parallelism
Explicit Parallel Groups
Performance Metrics
The graph executor tracks detailed performance metrics:Error Handling
Partial Failures
When a member fails, the graph executor:- Marks member as failed
- Skips all dependent members
- Continues executing independent members
- Returns partial results
Retry Strategies
Configure per-member retry with graph awareness:Advanced Features
Dynamic Graph Modification
Modify the graph during execution:Subgraph Execution
Execute a portion of the graph:Graph Comparison
Compare two ensemble graphs:Graph Metrics
Analyze graph properties:Testing
Best Practices
- Minimize dependencies - Enable more parallelization
- Use priority hints - For critical members
- Set realistic timeouts - Per member and total
- Monitor concurrency - Adjust maxParallelism
- Analyze critical path - Optimize slowest sequence
- Handle partial failures - Expect some members to fail
- Test with various graphs - Different topologies
- Profile execution - Identify bottlenecks
- Visualize graphs - Understand dependencies
- Document dependencies - Make implicit explicit

