In parallel mode, the assignment of session variables by the iteration node through the assignment node may fail. #21203

Closed
opened 2026-02-21 20:11:26 -05:00 by yindo · 1 comment
Owner

Originally created by @liqigang63 on GitHub (Dec 22, 2025).

Originally assigned to: @fatelei on GitHub.

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • 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.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.9.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

In parallel mode, the assignment of session variables by the iteration node through the assignment node may fail.
Image
After the assignment is set to 0, the iteration ends, but the value of the session variable printed out is still 1.
Image

✔️ Expected Behavior

Is this the way DIFY is designed, or is it a bug in the process?

Actual Behavior

No response

Originally created by @liqigang63 on GitHub (Dec 22, 2025). Originally assigned to: @fatelei on GitHub. ### 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] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [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] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.9.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce In parallel mode, the assignment of session variables by the iteration node through the assignment node may fail. <img width="1247" height="390" alt="Image" src="https://github.com/user-attachments/assets/ac8fc351-f7bc-4218-b122-71b1c065aae1" /> After the assignment is set to 0, the iteration ends, but the value of the session variable printed out is still 1. <img width="1154" height="281" alt="Image" src="https://github.com/user-attachments/assets/e5ba9b7d-5763-4e01-9d91-0f1b8cf10b2b" /> ### ✔️ Expected Behavior Is this the way DIFY is designed, or is it a bug in the process? ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 20:11:26 -05:00
yindo closed this issue 2026-02-21 20:11:26 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 22, 2025):

This is a known limitation in Dify 1.9.1: session variable assignments inside parallel iteration nodes may not update as expected due to how variable state is merged after each parallel run. Each iteration runs in its own isolated context, and when iterations finish, their session variable snapshots overwrite the parent state without any locking or merge logic. This means whichever parallel iteration finishes last can overwrite changes made by others, causing assignments to appear lost or out of sync—especially if multiple iterations update the same variable at once. This is not fully by design and has been acknowledged as a bug, with improvements and fixes merged in later versions (details, iteration node code).

Workarounds for 1.9.1 include switching the iteration node to serial mode, using output selectors to aggregate results outside the loop, or restructuring your workflow to avoid relying on session variable mutation inside parallel iterations. Upgrading to a newer Dify version is recommended for better parallel workflow support (see PR #26036). If you need help restructuring your workflow, let me know!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 22, 2025): <!-- Answer --> This is a known limitation in Dify 1.9.1: session variable assignments inside parallel iteration nodes may not update as expected due to how variable state is merged after each parallel run. Each iteration runs in its own isolated context, and when iterations finish, their session variable snapshots overwrite the parent state without any locking or merge logic. This means whichever parallel iteration finishes last can overwrite changes made by others, causing assignments to appear lost or out of sync—especially if multiple iterations update the same variable at once. This is not fully by design and has been acknowledged as a bug, with improvements and fixes merged in later versions ([details](https://github.com/langgenius/dify/issues/26233), [iteration node code](https://github.com/langgenius/dify/blob/eabdc5f0ebd806ede0c8f8695d54efb24e61748b/api/core/workflow/nodes/iteration/iteration_node.py)). Workarounds for 1.9.1 include switching the iteration node to serial mode, using output selectors to aggregate results outside the loop, or restructuring your workflow to avoid relying on session variable mutation inside parallel iterations. Upgrading to a newer Dify version is recommended for better parallel workflow support ([see PR #26036](https://github.com/langgenius/dify/pull/26036)). If you need help restructuring your workflow, let me know! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/3f6a6f29-224d-4900-b0ec-ccbccb902916?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/3f6a6f29-224d-4900-b0ec-ccbccb902916?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/3f6a6f29-224d-4900-b0ec-ccbccb902916?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/3f6a6f29-224d-4900-b0ec-ccbccb902916?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3f6a6f29-224d-4900-b0ec-ccbccb902916?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/3f6a6f29-224d-4900-b0ec-ccbccb902916?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/3f6a6f29-224d-4900-b0ec-ccbccb902916?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20a%20known%20limitation%20in%20Dify%201.9.1%3A%20session%20variable%20assignments%20inside%20parallel%20iteration%20nodes%20may%20not%20update%20as%20expected%20due%20to%20how%20variable%20state%20is%20merged%20after%20each%20parallel%20run.%20Each%20iteration%20runs%20in%20its%20own%20isolated%20context%2C%20and%20when%20iterations%20finish%2C%20their%20session%20variable%20snapshots%20overwrite%20the%20parent%20state%20without%20any%20locking%20or%20merge%20logic.%20This%20means%20whichever%20parallel%20iteration%20finishes%20last%20can%20overwrite%20changes%20made%20by%20others%2C%20causing%20assignments%20to%20appear%20lost%20or%20out%20of%20sync%E2%80%94especially%20if%20multiple%20iterations%20update%20the%20same%20variable%20at%20once.%20This%20is%20not%20fully%20by%20design%20and%20has%20been%20acknowledged%20as%20a%20bug%2C%20with%20improvements%20and%20fixes%20merged%20in%20later%20versions%20%28%5Bdetails%5D%28https%3A//github.com/langgenius/dify/issues/26233%29%2C%20%5Biteration%20node%20code%5D%28https%3A//github.com/langgenius/dify/blob/eabdc5f0ebd806ede0c8f8695d54efb24e61748b/api/core/workflow/nodes/iteration/iteration_node.py%29%29.%0A%0AWorkarounds%20for%201.9.1%20include%20switching%20the%20iteration%20node%20to%20serial%20mode%2C%20using%20output%20selectors%20to%20aggregate%20results%20outside%20the%20loop%2C%20or%20restructuring%20your%20workflow%20to%20avoid%20relying%20on%20session%20variable%20mutation%20inside%20parallel%20iterations.%20Upgrading%20to%20a%20newer%20Dify%20version%20is%20recommended%20for%20better%20parallel%20workflow%20support%20%28%5Bsee%20PR%20%2326036%5D%28https%3A//github.com/langgenius/dify/pull/26036%29%29.%20If%20you%20need%20help%20restructuring%20your%20workflow%2C%20let%20me%20know%21)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/29989)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21203