improvement(subflows): support multiple blocks in parallel subflow, enhance logs to group by iteration for parallels/loop#1429
Merged
waleedlatif1 merged 7 commits intostagingfrom Sep 23, 2025
Merged
Conversation
…enhance logs to group by iteration for parallels/loops
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Greptile Overview
Summary
This PR enhances parallel subflow execution to support multiple blocks per iteration and improves log grouping for better debugging. The core executor logic was refactored to properly handle dependency ordering within parallel iterations using virtual block IDs. The loop handler was simplified to use 1-based iteration counting and improved forEach item access. Additionally, the changelog UI was updated to show contributor avatars inline with version numbers for a more compact display.
Key Changes:
- Parallel Execution: Added support for multiple blocks within parallel subflow iterations with proper dependency resolution
- Loop Iterations: Changed from 0-based to 1-based iteration counting for better user understanding
- Trace Spans: Enhanced log grouping to organize parallel and loop execution by iteration for clearer debugging
- UI Enhancement: Moved contributor avatars next to version numbers in changelog for improved layout density
Issues Found:
- Loop iteration counter update timing could cause inconsistency if child activation fails
- Early return in parallel processing might skip other blocks in the same iteration
- Array access in forEach loops needs adjustment for 1-based iteration counting
Confidence Score: 3/5
- This PR contains important execution logic changes that require careful testing before merge
- Score reflects complex executor refactoring with potential edge case issues around timing and iteration handling that could impact workflow execution reliability
- Pay close attention to
apps/sim/executor/index.tsandapps/sim/executor/handlers/loop/loop-handler.tsfor execution logic changes
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/executor/handlers/loop/loop-handler.ts | 4/5 | Changed loop iteration to start from 1 instead of 0, simplified logic for forEach items, and improved item access handling |
| apps/sim/executor/index.ts | 3/5 | Significant refactor to support parallel block execution with multiple blocks per iteration, added proper dependency handling and iteration completion tracking |
| apps/sim/lib/logs/execution/trace-spans/trace-spans.ts | 4/5 | Enhanced groupIterationBlocks function to better organize parallel and loop execution logs with proper iteration grouping |
| apps/sim/executor/index.test.ts | 4/5 | Added comprehensive tests for parallel execution ordering, iteration completion detection, and edge cases |
Sequence Diagram
sequenceDiagram
participant E as Executor
participant PM as ParallelManager
participant LH as LoopHandler
participant PB as ParallelBlock
participant WF as Workflow
Note over E,WF: Enhanced Parallel Subflow Execution
E->>E: getNextLayer()
E->>E: processParallelBlocks()
loop For each active parallel
E->>E: processParallelIteration(parallelId, iteration)
loop For each node in parallel.nodes
E->>E: Build dependency graph for iteration
Note right of E: Creates virtual block IDs:<br/>nodeId_parallel_parallelId_iteration_N
E->>E: Check internal dependencies
alt All dependencies met
E->>E: Add to pendingBlocks
E->>E: Store parallelBlockMapping
else Dependencies unmet
E->>E: Skip this block
end
end
end
E->>E: executeLayer(pendingBlocks)
loop For each pending block
alt Is virtual parallel block
E->>PM: Get original block from mapping
E->>LH: Execute with iteration context
LH->>LH: Set currentIteration (1-based)
LH->>LH: activateChildNodes()
LH->>LH: Update loopIterations counter
else Regular block
E->>PB: execute()
end
end
E->>E: isIterationComplete()
loop Check all nodes in parallel
E->>E: Verify virtual block execution
Note right of E: nodeId_parallel_parallelId_iteration_N
end
alt All iterations complete
E->>E: hasMoreParallelWork() = false
Note over E: Exit execution loop
else More work available
E->>E: Continue to next layer
end
10 files reviewed, 3 comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Type of Change
Testing
Tested manually, added tests
Checklist
Screenshots
New grouping for subflow logs:
