-
Notifications
You must be signed in to change notification settings - Fork 3.2k
improvement(parallel): update parallel subflow to support conditional routing #1444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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.tsfor 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
3 files reviewed, no comments
cddd83a to
31e9029
Compare
* feat(manual-trigger): add manual trigger * consolidate input format extraction * exclude triggers from console logs + deployed chat error surfacing * works * centralize error messages + logging for deployed chat
* fix(css-config): use correct version * fix lint
…nto improvement/parallel
Summary
update parallel subflow to support conditional routing by the condition block & router
Type of Change
Testing
Tested manually.
Checklist
Screenshots/Videos