Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

update parallel subflow to support conditional routing by the condition block & router

Type of Change

  • New feature

Testing

Tested manually.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

Screenshot 2025-09-24 at 1 26 20 PM Screenshot 2025-09-24 at 1 26 52 PM

@vercel
Copy link

vercel bot commented Sep 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Sep 26, 2025 1:39am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Sep 26, 2025 1:39am

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Summary

This PR updates the parallel execution system to support conditional routing by condition and router blocks. The key changes include:

  • Virtual Block ID Support: Updates condition handler and path tracker to use virtual block IDs (blockId_parallel_parallelId_iteration_N) for decision tracking in parallel iterations
  • Conditional Path Logic: Adds sophisticated logic to determine which blocks should execute in parallel iterations based on routing decisions from condition/router blocks
  • Enhanced Path Tracking: Extends the PathTracker class to handle virtual block IDs and properly track decisions across parallel executions

The implementation ensures that parallel executions can now handle branching logic where some blocks may not execute based on conditional routing, rather than assuming all blocks in a parallel should always execute. This enables more sophisticated workflow patterns with parallel processing and conditional logic combined.

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk
  • The changes are well-structured with proper fallback handling and error catching. The implementation maintains backward compatibility while adding sophisticated conditional routing support. The core logic is sound with appropriate defensive programming practices.
  • Pay close attention to apps/sim/executor/index.ts for the new parallel execution logic

Important Files Changed

File Analysis

Filename        Score        Overview
apps/sim/executor/handlers/condition/condition-handler.ts 5/5 Simple change to use virtual block ID for decision tracking in parallel execution - clean and safe
apps/sim/executor/index.ts 4/5 Complex logic for conditional parallel execution with proper fallback handling and error catching
apps/sim/executor/path/path.ts 4/5 Enhanced path tracking with virtual block ID extraction and proper state management for parallel execution

Sequence Diagram

sequenceDiagram
    participant E as Executor
    participant PT as PathTracker  
    participant CH as ConditionHandler
    participant C as Context

    Note over E,C: Parallel Iteration Processing

    E->>E: processParallelIteration()
    E->>E: getExpectedBlocksForIteration()
    
    loop For each block in parallel
        E->>E: shouldBlockExecuteInParallelIteration()
        alt Block has internal connections
            E->>C: Check decisions.condition/router
            C-->>E: Return routing decision
            alt Connection is active based on routing
                E-->>E: Include block in expected list
            else Connection not active
                E-->>E: Skip block (conditional routing)
            end
        else No internal connections
            E-->>E: Include block (start block)
        end
    end

    E->>E: Execute expected blocks only
    
    loop For each executed block
        E->>C: Set currentVirtualBlockId
        E->>CH: Handle block execution
        alt Block is condition/router
            CH->>C: Set decision using virtualBlockId as key
            CH->>PT: updateExecutionPaths()
            PT->>PT: extractOriginalBlockId()
            PT->>C: Update routing decisions
        end
        E->>C: Clear currentVirtualBlockId
    end

    E->>E: isParallelIterationComplete()
    E->>E: Check only expected blocks executed
Loading

3 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@vercel vercel bot temporarily deployed to Preview – docs September 25, 2025 22:21 Inactive
@vercel vercel bot temporarily deployed to Preview – docs September 26, 2025 00:39 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants