Configuration-Driven Workflow Design
This document describes the configuration-driven workflow design pattern implemented in Curriculum Curator.
Overview
The Curriculum Curator system uses a configuration-driven approach to defining workflows. In this pattern, the workflow logic and execution engine are separated from the workflow definitions, which are stored in external configuration files. This approach has several advantages:
- Flexibility: Workflows can be modified without changing code
- Reusability: Common steps can be reused across different workflows
- Shareability: Workflow definitions can be easily shared between users
- Version Control: Workflows can be versioned independently of the core code
- Extensibility: New step types can be added without breaking existing workflows
Workflow Configuration Structure
Workflows are defined in YAML files that specify the sequence of steps to be executed:
name: minimal_educational_module
description: "Generates a complete educational module with basic components"
steps:
- name: course_overview
type: prompt
prompt: course/overview.txt
llm_model_alias: default_smart
output_format: raw
output_variable: course_overview
# Additional steps...
- name: generate_outputs
type: output
output_mapping:
course_overview: overview.md
remediated_lecture: lecture.md
worksheet: worksheet.md
assessment: assessment.md
instructor_materials: instructor_guide.md
output_dir: output/{course_slug}/{module_id}
Each workflow configuration includes: - name: Unique identifier for the workflow - description: Human-readable description of the workflow's purpose - steps: Array of step configurations, each with: - name: Unique identifier for the step - type: Step type (prompt, validation, remediation, output, etc.) - step-specific parameters: Parameters specific to the step type
Workflow Discovery
Workflows are discovered dynamically at runtime:
- The system looks for workflow configurations in predefined directories:
examples/workflows/
-
workflows/
-
All YAML files in these directories are loaded and indexed by name
-
When a user requests a workflow by name, the system:
- Searches for a matching workflow in the loaded configurations
- If found, loads the configuration and executes the workflow
- If not found, returns an error
This approach allows users to add new workflows simply by adding new YAML files to the appropriate directory.
Execution Engine
The workflow execution engine is responsible for:
- Loading the workflow configuration
- Creating step instances based on the step type
- Executing each step in sequence
- Managing the context shared between steps
- Handling errors and recovering from failures
- Persisting the state of the workflow for potential resumption
The execution engine provides a uniform interface for all workflows, regardless of their specific steps or configurations.
Context Sharing
Steps in a workflow share a common context dictionary that allows them to pass data to subsequent steps:
- The initial context contains variables provided by the user
- Each step can read values from the context and add new values to it
- Output variables from one step can be used as input for subsequent steps
- The final context contains all intermediate results and the final outputs
This pattern allows complex workflows to be built from simple steps that each perform a specific task.
Benefits of Configuration-Driven Workflows
The configuration-driven approach provides several benefits:
- Separation of Concerns: Core logic remains stable while workflows can evolve
- Reduced Code Duplication: Common patterns are encapsulated in the engine
- Lower Barrier to Entry: Users can create workflows without coding
- Flexibility: Workflows can be adapted to different use cases without code changes
- Testing Simplicity: Workflows can be tested independently of the core code
Implementation
The workflow system is implemented in the following components:
- WorkflowStep: Base class for all step types
- Workflow: Class that manages the execution of a sequence of steps
- Step Type Implementations: Specialized classes for each step type (PromptStep, ValidationStep, etc.)
- Workflow Configuration Loader: Utilities for loading workflow configurations from files
This implementation allows for easy extension with new step types and workflow patterns.
Future Enhancements
The configuration-driven workflow system can be extended in several ways:
- Conditional Steps: Steps that execute based on conditions
- Loop Steps: Steps that repeat a sequence for each item in a collection
- Parallel Steps: Steps that execute in parallel for improved performance
- Custom Step Types: Support for user-defined step types
- Visual Workflow Editor: A graphical interface for building workflows