Support Human Input Nodes Inside Loop Nodes #22260

Open
opened 2026-02-21 20:16:20 -05:00 by yindo · 0 comments
Owner

Originally created by @amirreza-noori on GitHub (Feb 21, 2026).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Summary

Enable Human Input nodes to be placed inside Loop nodes and properly pause workflow execution, allowing for interactive multi-iteration workflows.

Current Behavior

UI Restriction

Human Input nodes are currently filtered out from the node palette when adding nodes inside Loop containers. The filtering happens in:

  • File: web/app/components/workflow/hooks/use-available-blocks.ts
  • Lines 8-16 in the availableBlocksFilter function
  • BlockEnum.HumanInput is explicitly blocked when inContainer=true

Backend Limitation

Even if you manually edit the workflow YAML to add a Human Input node inside a Loop, it doesn't work as expected because:

  • File: api/core/workflow/graph_engine/event_management/event_handlers.py
  • Lines 96-99 in the dispatch method
  • All events from nodes inside loops (marked with in_loop_id) are collected but not propagated
  • NodeRunPauseRequestedEvent events are silently consumed instead of pausing the workflow

Impact

This limitation forces developers to implement manual "unrolled loops" by duplicating nodes, which:

  • Increases workflow complexity
  • Makes workflows harder to maintain
  • Limits the number of iterations to what can be manually created
  • Reduces workflow reusability

Desired Behavior

Use Case

Allow workflows to perform multi-iteration loops where each iteration can pause for human input. Example scenarios:

  1. Iterative Data Analysis: An AI agent analyzes data, proposes insights, asks for user confirmation, then refines based on feedback (repeat N times)
  2. Multi-Step Approval Workflows: Each iteration requires human review/approval before proceeding
  3. Interactive Form Filling: Loop through a list of items, asking user for input on each one
  4. Incremental Content Generation: Generate content in stages, getting user feedback after each iteration

Technical Considerations

State Persistence

  • Loop iteration index must be saved when pausing
  • Loop variables must be preserved across pause/resume
  • Form token mapping must handle loop context

Resume Mechanism

  • When resuming, loop should continue from the paused iteration (not restart)
  • Loop variables should maintain correct state
  • Nested loops should be supported (save/restore multiple loop contexts)

Edge Cases to Handle

  1. Multiple Human Input nodes in one iteration: Queue them or handle sequentially?
  2. Timeout during pause: Should loop continue or exit?
  3. Cancel during pause: Should loop exit gracefully?
  4. Nested loops with pauses: Track parent/child loop states correctly

Benefits of Implementation

  1. Cleaner Workflows: Reduce node duplication and visual clutter
  2. Dynamic Iteration Counts: Use loop variables to determine iteration count
  3. Better Maintainability: Changes to loop logic only need to be made once
  4. More Powerful Workflows: Enable complex interactive workflows that weren't possible before
  5. Consistent with User Expectations: Users expect loops to support all node types

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @amirreza-noori on GitHub (Feb 21, 2026). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. ## Summary Enable Human Input nodes to be placed inside Loop nodes and properly pause workflow execution, allowing for interactive multi-iteration workflows. ## Current Behavior ### UI Restriction Human Input nodes are currently filtered out from the node palette when adding nodes inside Loop containers. The filtering happens in: - File: `web/app/components/workflow/hooks/use-available-blocks.ts` - Lines 8-16 in the `availableBlocksFilter` function - `BlockEnum.HumanInput` is explicitly blocked when `inContainer=true` ### Backend Limitation Even if you manually edit the workflow YAML to add a Human Input node inside a Loop, it doesn't work as expected because: - File: `api/core/workflow/graph_engine/event_management/event_handlers.py` - Lines 96-99 in the `dispatch` method - All events from nodes inside loops (marked with `in_loop_id`) are collected but not propagated - `NodeRunPauseRequestedEvent` events are silently consumed instead of pausing the workflow ### Impact This limitation forces developers to implement manual "unrolled loops" by duplicating nodes, which: - Increases workflow complexity - Makes workflows harder to maintain - Limits the number of iterations to what can be manually created - Reduces workflow reusability ## Desired Behavior ### Use Case Allow workflows to perform multi-iteration loops where each iteration can pause for human input. Example scenarios: 1. **Iterative Data Analysis**: An AI agent analyzes data, proposes insights, asks for user confirmation, then refines based on feedback (repeat N times) 2. **Multi-Step Approval Workflows**: Each iteration requires human review/approval before proceeding 3. **Interactive Form Filling**: Loop through a list of items, asking user for input on each one 4. **Incremental Content Generation**: Generate content in stages, getting user feedback after each iteration ## Technical Considerations ### State Persistence - Loop iteration index must be saved when pausing - Loop variables must be preserved across pause/resume - Form token mapping must handle loop context ### Resume Mechanism - When resuming, loop should continue from the paused iteration (not restart) - Loop variables should maintain correct state - Nested loops should be supported (save/restore multiple loop contexts) ### Edge Cases to Handle 1. **Multiple Human Input nodes in one iteration**: Queue them or handle sequentially? 2. **Timeout during pause**: Should loop continue or exit? 3. **Cancel during pause**: Should loop exit gracefully? 4. **Nested loops with pauses**: Track parent/child loop states correctly ## Benefits of Implementation 1. **Cleaner Workflows**: Reduce node duplication and visual clutter 2. **Dynamic Iteration Counts**: Use loop variables to determine iteration count 3. **Better Maintainability**: Changes to loop logic only need to be made once 4. **More Powerful Workflows**: Enable complex interactive workflows that weren't possible before 5. **Consistent with User Expectations**: Users expect loops to support all node types ### 2. Additional context or comments _No response_ ### 3. Can you help us with this feature? - [x] I am interested in contributing to this feature.
yindo added the 💪 enhancement label 2026-02-21 20:16:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#22260