Skip to content

Implement control flow routing: on_false and on_success #333

Description

@jeremymanning

Problem

Issue #307 specifies advanced control flow routing that is missing from YAML pipeline specification:

steps:
  - id: check_input
    condition: "len(topic) > 10"
    on_false: short_topic_handler
    on_failure: error_recovery  
    on_success: main_processing

Solution Required

Implement complete control flow routing system:

1. Conditional Execution

  • condition field with Python expression evaluation
  • Runtime condition evaluation with pipeline variables
  • Skip step execution when condition is False

2. Control Flow Routing

  • on_false - next step when condition is False
  • on_failure - next step when step execution fails
  • on_success - next step when step completes successfully
  • Default behavior when routing not specified

3. StateGraph Integration

  • Modify LangGraph StateGraph to support conditional edges
  • Dynamic routing based on execution results
  • State management for complex control flows

Implementation Details

  • Extend YAML compiler to parse routing attributes
  • Modify StateGraph construction for conditional edges
  • Add condition evaluation engine with variable access
  • Implement routing decision logic in execution engine
  • Compile-time validation of routing targets

Acceptance Criteria

  • All 4 routing attributes supported in YAML
  • Python condition expressions work with pipeline variables
  • StateGraph properly routes based on execution results
  • Compilation validation prevents invalid routing
  • Tests cover complex control flow scenarios

Files to Modify

  • src/orchestrator/compiler/yaml_compiler.py - YAML parsing
  • src/orchestrator/execution/engine.py - Routing logic
  • src/orchestrator/core/pipeline.py - StateGraph construction

Priority: High - Core specification requirement from #307

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions