In the same conversation, modifying variables in inputs does not take effect. #5427

Closed
opened 2026-02-21 18:10:55 -05:00 by yindo · 5 comments
Owner

Originally created by @dc-vin on GitHub (Sep 6, 2024).

Self Checks

  • 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 (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.7.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I created a knowledge base workflow and defined a variable called "type." Each time the user asks a question, they can choose a different "type," but I found that modifying the "type" on subsequent questions does not work.

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @dc-vin on GitHub (Sep 6, 2024). ### Self Checks - [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 (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.7.3 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce I created a knowledge base workflow and defined a variable called "type." Each time the user asks a question, they can choose a different "type," but I found that modifying the "type" on subsequent questions does not work. ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug🌚 invalid labels 2026-02-21 18:10:55 -05:00
yindo closed this issue 2026-02-21 18:10:55 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 6, 2024):

I found a similar open issue and discussion that might be relevant to your problem:

  1. Issue: seems that some variables are lost after the Parameter Extraction node (closed) [1]
  2. Discussion: Knowledge retrieval with variable (unsolved) [2]

The suggested solution for the issue was to set up two direct reply nodes to ensure the content in the Parameter Extraction node is output correctly.

Additionally, the problem you're experiencing with modifying the "type" variable in a knowledge base workflow not taking effect in subsequent questions is due to the updateNodeVars function not handling the KnowledgeRetrievalNodeType correctly. Specifically, the query_variable_selector is not updated to reflect the new variable selector. Here is the relevant code snippet:

case BlockEnum.KnowledgeRetrieval: {
    const payload = data as KnowledgeRetrievalNodeType
    if (payload.query_variable_selector.join('.') === oldVarSelector.join('.'))
        payload.query_variable_selector = newVarSelector
    break
}

This code checks if the query_variable_selector matches the old variable selector and updates it to the new variable selector. If this logic is not executed correctly or if there are other dependencies not updated, the changes will not propagate as expected [3].

To ensure variable modifications take effect in a self-hosted Docker environment, you need to edit the .env file with the desired environment variable values and restart the Docker containers:

  1. Edit the .env file.
  2. Restart the Docker containers:
docker compose down
docker compose up -d

Make sure to sync your local .env file with any updates from the .env.example file and check if all containers are running successfully:

docker compose ps

This will ensure that the modifications to the environment variables take effect [4][5][6][7].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 6, 2024): <!-- Answer --> I found a similar open issue and discussion that might be relevant to your problem: 1. **Issue**: [seems that some variables are lost after the Parameter Extraction node](https://github.com/langgenius/dify/issues/5393) (closed) <sup>[[1]](https://github.com/langgenius/dify/issues/5393)</sup> 2. **Discussion**: [Knowledge retrieval with variable](https://github.com/langgenius/dify/discussions/7106) (unsolved) <sup>[[2]](https://github.com/langgenius/dify/discussions/7106)</sup> The suggested solution for the issue was to set up two direct reply nodes to ensure the content in the Parameter Extraction node is output correctly. Additionally, the problem you're experiencing with modifying the "type" variable in a knowledge base workflow not taking effect in subsequent questions is due to the `updateNodeVars` function not handling the `KnowledgeRetrievalNodeType` correctly. Specifically, the `query_variable_selector` is not updated to reflect the new variable selector. Here is the relevant code snippet: ```ts case BlockEnum.KnowledgeRetrieval: { const payload = data as KnowledgeRetrievalNodeType if (payload.query_variable_selector.join('.') === oldVarSelector.join('.')) payload.query_variable_selector = newVarSelector break } ``` This code checks if the `query_variable_selector` matches the old variable selector and updates it to the new variable selector. If this logic is not executed correctly or if there are other dependencies not updated, the changes will not propagate as expected <sup>[[3]](https://github.com/langgenius/dify/blob/main/web/app/components/workflow/nodes/_base/components/variable/utils.ts)</sup>. To ensure variable modifications take effect in a self-hosted Docker environment, you need to edit the `.env` file with the desired environment variable values and restart the Docker containers: 1. Edit the `.env` file. 2. Restart the Docker containers: ```bash docker compose down docker compose up -d ``` Make sure to sync your local `.env` file with any updates from the `.env.example` file and check if all containers are running successfully: ```bash docker compose ps ``` This will ensure that the modifications to the environment variables take effect <sup>[[4]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/getting-started/install-self-hosted/docker-compose.md)</sup><sup>[[5]](https://github.com/langgenius/dify-docs/blob/main/en/getting-started/install-self-hosted/docker-compose.md)</sup><sup>[[6]](https://github.com/langgenius/dify-docs/blob/main/jp/getting-started/install-self-hosted/docker-compose.md)</sup><sup>[[7]](https://github.com/langgenius/dify/blob/main/docker/README.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@dc-vin commented on GitHub (Sep 6, 2024):

The inputs variable for each conversation only takes effect the first time it is passed in. Continuous questioning and updating the variable value does not take effect.

@dc-vin commented on GitHub (Sep 6, 2024): The inputs variable for each conversation only takes effect the first time it is passed in. Continuous questioning and updating the variable value does not take effect.
Author
Owner

@crazywoola commented on GitHub (Sep 6, 2024):

Please use the conversational variables instead. If you need to modify something, you need the conversational variables.

https://docs.dify.ai/guides/workflow/node/variable-assignment

@crazywoola commented on GitHub (Sep 6, 2024): Please use the conversational variables instead. If you need to modify something, you need the conversational variables. https://docs.dify.ai/guides/workflow/node/variable-assignment
Author
Owner

@dc-vin commented on GitHub (Sep 6, 2024):

Please use the conversational variables instead. If you need to modify something, you need the conversational variables.

https://docs.dify.ai/guides/workflow/node/variable-assignment
@crazywoola

I used variable assignment and passed the response_type field through the API. However, when switching options via the dropdown menu, I found that it did not take effect and still followed the old branch, resulting in the same response.

image
image

@dc-vin commented on GitHub (Sep 6, 2024): > Please use the conversational variables instead. If you need to modify something, you need the conversational variables. > > https://docs.dify.ai/guides/workflow/node/variable-assignment @crazywoola I used variable assignment and passed the response_type field through the API. However, when switching options via the dropdown menu, I found that it did not take effect and still followed the old branch, resulting in the same response. ![image](https://github.com/user-attachments/assets/8d113248-9e54-4d43-af6b-76ea3e6d6014) ![image](https://github.com/user-attachments/assets/e6aeeb71-0e7e-487a-9ed9-8a1069651233)
Author
Owner

@dc-vin commented on GitHub (Sep 6, 2024):

image

@dc-vin commented on GitHub (Sep 6, 2024): ![image](https://github.com/user-attachments/assets/1a25baf9-27f7-417b-a0ab-3b4fc1718a90)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5427