Skip to content

Feature/new workflow loop node - #13058

Closed
Woo0ood wants to merge 17 commits into
langgenius:plugins/betafrom
AICT-Team:feature/new-workflow-loop-node
Closed

Feature/new workflow loop node#13058
Woo0ood wants to merge 17 commits into
langgenius:plugins/betafrom
AICT-Team:feature/new-workflow-loop-node

Conversation

@Woo0ood

@Woo0ood Woo0ood commented Jan 26, 2025

Copy link
Copy Markdown
Contributor

Summary

This PR introduces the Loop Node, a feature designed to enable workflows or processes to execute repeatedly until specific conditions or formats are met. The node allows users to define internal variables and outputs that determine whether to exit the loop. A maximum iteration limit can also be set to prevent infinite loops.

The addition of the Loop Node addresses the community’s and team’s demand for executing repeated HTTP interface calls or invoking LLMs multiple times in a workflow. The implementation aligns with the feedback and requirements outlined in Issue #12354.

Resolves #12354
Close #12289

Author

This PR is submitted by the AICT Team from NetDragon Websoft Inc., aiming to contribute to the open-source community. The AICT Team is dedicated to promoting the continuous optimization and functional expansion of Dify and other open-source products. By introducing practical features such as the Loop Node, the team hopes to help community users build more efficient and intelligent workflow solutions, working together to create a stronger Dify ecosystem.

Screenshots

Loop node

Some Details

This section was automatically generated by GitHub Copilot actions.

This pull request introduces a new feature for handling single loop runs in workflows and advanced chat applications. The changes include adding new API endpoints, updating the app generator and runner classes, and modifying the task pipeline to support loop events.

New API endpoints:

  • Added Advanc /edChatDraftRunLoopNodeApi and WorkflowDraftRunLoopNodeApi classes to handle POST requests for running draft workflow loop nodes. (api/controllers/console/app/workflow.py)

App generator updates:

  • Introduced single_loop_generate method in AdvancedChatAppGenerator and WorkflowAppGenerator to generate app responses for single loop runs. (api/core/app/apps/advanced_chat/app_generator.py) [1] (api/core/app/apps/workflow/app_generator.py) [2]

App runner updates:

  • Updated AdvancedChatAppRunner and WorkflowAppRunner to handle single loop runs by adding logic to fetch and process graph and variable pool for loops. (api/core/app/apps/advanced_chat/app_runner.py) [1] (api/core/app/apps/workflow/app_runner.py) [2]

Task pipeline modifications:

  • Added new events (QueueLoopStartEvent, QueueLoopNextEvent, QueueLoopCompletedEvent, QueueNodeInLoopFailedEvent) and updated the _process_stream_response method to handle these events. (api/core/app/apps/advanced_chat/generate_task_pipeline.py) [1] [2] [3] (api/core/app/apps/workflow/generate_task_pipeline.py) [4] [5] [6]

These changes collectively enhance the system's ability to manage and execute single loop runs within workflows and advanced chat applications.

Checklist

Important

Please review the checklist below before submitting your pull request.

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. 🌊 feat:workflow Workflow related stuff. labels Jan 26, 2025
@laipz8200
laipz8200 self-requested a review February 5, 2025 07:51
@Yeuoly
Yeuoly deleted the branch langgenius:plugins/beta February 17, 2025 09:05
@Yeuoly Yeuoly closed this Feb 17, 2025
@ykrsama

ykrsama commented Feb 20, 2025

Copy link
Copy Markdown

I'm also looking forward to this feature. What's the status?

clubanderson added a commit to kubestellar/console-kb that referenced this pull request Apr 3, 2026
The original fix PR langgenius/dify#13058 was closed without merging.
Replace with langgenius/dify#14863 which was merged and implements
the loop node feature.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
clubanderson added a commit to kubestellar/console-kb that referenced this pull request Apr 3, 2026
…cution and (#1886)

* 🌱 Add dify: Enhancing Workflow with Loop and Sleep Nodes for Repeated mission

* 🌱 Add dify: Enhancing Workflow with Loop and Sleep Nodes for Repeated mission

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: replace closed dify PR #13058 with merged PR #14863

The original fix PR langgenius/dify#13058 was closed without merging.
Replace with langgenius/dify#14863 which was merged and implements
the loop node feature.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>

---------

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌊 feat:workflow Workflow related stuff. size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants