-
Notifications
You must be signed in to change notification settings - Fork 3.2k
improvement(subflows): support multiple blocks in parallel subflow, enhance logs to group by iteration for parallels/loop #1429
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
…enhance logs to group by iteration for parallels/loops
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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 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
Summary
Type of Change
Testing
Tested manually, added tests
Checklist
Screenshots
New grouping for subflow logs:
