Skip to content

docs: clarify loop variable setup and scope in loop node guide - #946

Open
Th1rtynine wants to merge 1 commit into
langgenius:mainfrom
Th1rtynine:fix/loop-variable-guide
Open

docs: clarify loop variable setup and scope in loop node guide#946
Th1rtynine wants to merge 1 commit into
langgenius:mainfrom
Th1rtynine:fix/loop-variable-guide

Conversation

@Th1rtynine

Copy link
Copy Markdown

Fixes #886

The loop node guide explained what loop variables are but not how to declare them, initialize them, or update them, and users hit the "variable is undefined / please select an existing variable" prompt when configuring them.

This change expands the Loop Variables section in all three languages (en source, zh and ja in the same pass):

  • Loop variables are declared on the Loop node, with a type and an initial value that is either a constant or a reference to an existing workflow variable
  • When the initial value references a variable, the picker only lists variables that already exist in the current scope; typing a new name or referencing an out-of-scope variable triggers the undefined-variable prompt
  • Loop variables are updated inside the loop body with a Variable Assigner node and remain readable after the loop ends
  • Variables created inside the loop body are scoped to that iteration and are not visible outside the loop

Behavior was verified against the graphon v0.7.0 source pinned by dify (LoopNodeData, LoopVariableData, loop_node.py, variable_assigner v2), not just the existing docs. Also added a missing description to the zh frontmatter and a sentence on combining multiple termination conditions with AND/OR.

@Th1rtynine
Th1rtynine requested a review from RiskeyL as a code owner August 18, 2026 07:05
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. documentation Improvements or additions to documentation labels Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A very poor document. In the loop, setting a loop variable keeps prompting that the variable is undefined. Please select an existing variable!

1 participant