direct response node only prints the value of the first variable. #5750

Closed
opened 2026-02-21 18:12:26 -05:00 by yindo · 3 comments
Owner

Originally created by @yuhp-zts on GitHub (Sep 23, 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.8.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When passing multiple variables to the direct response node, the frontend only prints the value of the first variable.

1727083630073

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @yuhp-zts on GitHub (Sep 23, 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.8.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce When passing multiple variables to the direct response node, the frontend only prints the value of the first variable. ![1727083630073](https://github.com/user-attachments/assets/ee5ea58a-4908-4a53-bd2a-1e05d229a8c7) ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo closed this issue 2026-02-21 18:12:26 -05:00
Author
Owner

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

I found a similar issue where the direct response node only prints the value of the first variable when passing multiple variables in Dify version 0.8.0. The root cause is that the getNodeOutputVars function is designed to handle only the first variable in the list. This function processes the variables based on the node type and adds them to the res array, but only the first variable is effectively utilized in subsequent operations, leading to the observed behavior [1].

Here is the relevant code snippet from the getNodeOutputVars function:

export const getNodeOutputVars = (node: Node, isChatMode: boolean): ValueSelector[] => {
  const { data, id } = node
  const { type } = data
  let res: ValueSelector[] = []

  switch (type) {
    case BlockEnum.Start: {
      const {
        variables,
      } = data as StartNodeType
      res = variables.map((v) => {
        return [id, v.variable]
      })

      if (isChatMode) {
        res.push([id, 'sys', 'query'])
        res.push([id, 'sys', 'files'])
      }
      break
    }

    case BlockEnum.LLM: {
      varsToValueSelectorList(LLM_OUTPUT_STRUCT, [id], res)
      break
    }

    case BlockEnum.KnowledgeRetrieval: {
      varsToValueSelectorList(KNOWLEDGE_RETRIEVAL_OUTPUT_STRUCT, [id], res)
      break
    }

    case BlockEnum.Code: {
      const {
        outputs,
      } = data as CodeNodeType
      Object.keys(outputs).forEach((key) => {
        res.push([id, key])
      })
      break
    }

    case BlockEnum.TemplateTransform: {
      varsToValueSelectorList(TEMPLATE_TRANSFORM_OUTPUT_STRUCT, [id], res)
      break
    }

    case BlockEnum.QuestionClassifier: {
      varsToValueSelectorList(QUESTION_CLASSIFIER_OUTPUT_STRUCT, [id], res)
      break
    }

    case BlockEnum.HttpRequest: {
      varsToValueSelectorList(HTTP_REQUEST_OUTPUT_STRUCT, [id], res)
      break
    }

    case BlockEnum.VariableAssigner: {
      res.push([id, 'output'])
      break
    }

    case BlockEnum.VariableAggregator: {
      res.push([id, 'output'])
      break
    }

    case BlockEnum.Tool: {
      varsToValueSelectorList(TOOL_OUTPUT_STRUCT, [id], res)
      break
    }
    case BlockEnum.ParameterExtractor: {
      const {
        parameters,
      } = data as ParameterExtractorNodeType
      if (parameters?.length > 0) {
        parameters.forEach((p) => {
          res.push([id, p.name])
        })
      }

      break
    }

    case BlockEnum.Iteration: {
      res.push([id, 'output'])
      break
    }
  }

  return res
}

This function needs to be updated to handle multiple variables correctly.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 23, 2024): <!-- Answer --> I found a similar issue where the direct response node only prints the value of the first variable when passing multiple variables in Dify version 0.8.0. The root cause is that the `getNodeOutputVars` function is designed to handle only the first variable in the list. This function processes the variables based on the node type and adds them to the `res` array, but only the first variable is effectively utilized in subsequent operations, leading to the observed behavior <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/app/components/workflow/nodes/_base/components/variable/utils.ts)</sup>. Here is the relevant code snippet from the `getNodeOutputVars` function: ```ts export const getNodeOutputVars = (node: Node, isChatMode: boolean): ValueSelector[] => { const { data, id } = node const { type } = data let res: ValueSelector[] = [] switch (type) { case BlockEnum.Start: { const { variables, } = data as StartNodeType res = variables.map((v) => { return [id, v.variable] }) if (isChatMode) { res.push([id, 'sys', 'query']) res.push([id, 'sys', 'files']) } break } case BlockEnum.LLM: { varsToValueSelectorList(LLM_OUTPUT_STRUCT, [id], res) break } case BlockEnum.KnowledgeRetrieval: { varsToValueSelectorList(KNOWLEDGE_RETRIEVAL_OUTPUT_STRUCT, [id], res) break } case BlockEnum.Code: { const { outputs, } = data as CodeNodeType Object.keys(outputs).forEach((key) => { res.push([id, key]) }) break } case BlockEnum.TemplateTransform: { varsToValueSelectorList(TEMPLATE_TRANSFORM_OUTPUT_STRUCT, [id], res) break } case BlockEnum.QuestionClassifier: { varsToValueSelectorList(QUESTION_CLASSIFIER_OUTPUT_STRUCT, [id], res) break } case BlockEnum.HttpRequest: { varsToValueSelectorList(HTTP_REQUEST_OUTPUT_STRUCT, [id], res) break } case BlockEnum.VariableAssigner: { res.push([id, 'output']) break } case BlockEnum.VariableAggregator: { res.push([id, 'output']) break } case BlockEnum.Tool: { varsToValueSelectorList(TOOL_OUTPUT_STRUCT, [id], res) break } case BlockEnum.ParameterExtractor: { const { parameters, } = data as ParameterExtractorNodeType if (parameters?.length > 0) { parameters.forEach((p) => { res.push([id, p.name]) }) } break } case BlockEnum.Iteration: { res.push([id, 'output']) break } } return res } ``` This function needs to be updated to handle multiple variables correctly. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

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

Duplicated https://github.com/langgenius/dify/issues/8420, this is an expected behavior if you append a Variable Aggregator.

@crazywoola commented on GitHub (Sep 23, 2024): Duplicated https://github.com/langgenius/dify/issues/8420, this is an expected behavior if you append a Variable Aggregator.
Author
Owner

@yuhp-zts commented on GitHub (Sep 23, 2024):

Duplicated #8420, this is an expected behavior if you append a Variable Aggregator.

可能我表述的不清楚,简单的场景就是,if else 下有四个链路,四个链路的结果我最后通过直接回复节点。直接回复节点中的顺序是执行器1,执行器2,执行器3,执行器4。当流程到执行器3时直接回复节点没有值。如果将执行器3放在第一位可以,但是后面的就不行了。针对这个场景,我每个执行器结果指定一个直接回复吗?可是我间介绍文档里面是可以将多个链路的结果都对接到一个直接回复节点呀
image

这是官方之前使用的一个例子,和我是一样的流程,但是我这边遇到直接回复时,位于直接回复内 后面位置的变量 没有输出
image

@yuhp-zts commented on GitHub (Sep 23, 2024): > Duplicated #8420, this is an expected behavior if you append a Variable Aggregator. 可能我表述的不清楚,简单的场景就是,if else 下有四个链路,四个链路的结果我最后通过直接回复节点。直接回复节点中的顺序是执行器1,执行器2,执行器3,执行器4。当流程到执行器3时直接回复节点没有值。如果将执行器3放在第一位可以,但是后面的就不行了。针对这个场景,我每个执行器结果指定一个直接回复吗?可是我间介绍文档里面是可以将多个链路的结果都对接到一个直接回复节点呀 ![image](https://github.com/user-attachments/assets/e1af6458-500b-42eb-9c4a-dc1b0c29f4d7) 这是官方之前使用的一个例子,和我是一样的流程,但是我这边遇到直接回复时,位于直接回复内 后面位置的变量 没有输出 ![image](https://github.com/user-attachments/assets/a7e42afb-cb89-4677-ae05-95e788e5444b)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5750