【advice】Variables Cannot Be Initialized Independently
- Dominant language
- TypeScript
- Stars
- 156k
- Forks
- 24.6k
- Avg merge
- 22h 9m
- Merged PRs (30d)
- 610
Description
### 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.
# Description
Currently, when defining a variable in Dify, the variable can only be initialized using the output of a previous step. There does not appear to be an option to initialize a variable with a constant, default value, or user-defined value independently.
This limitation makes it difficult to define variables that need an initial state before the workflow begins or before any previous node produces an output.
# Expected Behavior
It would be helpful to allow variables to be initialized independently, for example with:
A constant value, such as 0, "", false, or a custom string
A user-defined default value
An optional initial value that can later be updated by subsequent nodes
For example:
count = 0
status = "pending"
result = ""
These variables could then be updated during the workflow execution.
# Current Behavior
At present, the variable initialization requires selecting the output of a previous step as its initial value. This creates an unnecessary dependency on upstream nodes and prevents variables from being initialized independently.
# Use Case
A common use case is maintaining state across multiple workflow steps. For example, a counter or status variable may need to start with a predefined value and then be modified by subsequent nodes.
Supporting independent variable initialization would make workflow design more flexible and reduce unnecessary intermediate nodes that exist solely to provide an initial value.
# Suggestion
Consider allowing variables to be initialized with either:
The output of a previous node, or
A manually specified initial/default value.
This would provide greater flexibility when designing complex workflows.
Thank you for considering this feature.
### 2. Additional context or comments
### 3. Can you help us with this feature?
- [x] I am interested in contributing to this feature.
Contributor guide
Assessment
This issue has not been assessed yet.