Skip to content

Tool returns duplicate results when called via agent #34723

Closed

Description

@AiFu-o

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.8.1

Cloud or Self Hosted

Cloud

Steps to reproduce

When I publish a workflow as a tool and invoke it via the agent, the tool's output is returned twice.

Example:
请求
{"get_filtered_anomalous_transactions2": {"question": "时间范围: 2024年4月, 交易主体: 全部, 异常类型: 背靠背交易, 金额范围: 不限"}}
响应
{"get_filtered_anomalous_transactions2": "
{"reports": [{"支出二级单位简称": "1", "支出单位名称": "2", "支出本方账户": "3", "支出对方账户": "4"}]}
{"reports": [{"支出二级单位简称": "1", "支出单位名称": "2", "支出本方账户": "3", "支出对方账户": "4"}]}
"}

Steps to reproduce:

  1. Publish a workflow as a tool.
  2. Call the tool via the agent.
  3. Observe that the results are duplicated in the agent's response.

Expected behavior:
The tool should return the results only once.

Actual behavior:
The agent returns the same result twice.

Notes:

  • This occurs consistently for all workflows published as tools.
  • The duplication seems to happen on the agent side, not within the workflow itself.

✔️ Expected Behavior

请求
{"get_filtered_anomalous_transactions2": {"question": "时间范围: 2024年4月, 交易主体: 全部, 异常类型: 背靠背交易, 金额范围: 不限"}}
响应
{"get_filtered_anomalous_transactions2": "
{"reports": [{"支出二级单位简称": "1", "支出单位名称": "2", "支出本方账户": "3", "支出对方账户": "4"}]}“

❌ Actual Behavior

{"get_filtered_anomalous_transactions2": {"question": "时间范围: 2024年4月, 交易主体: 全部, 异常类型: 背靠背交易, 金额范围: 不限"}}
响应
{"get_filtered_anomalous_transactions2": "
{"reports": [{"支出二级单位简称": "1", "支出单位名称": "2", "支出本方账户": "3", "支出对方账户": "4"}]}
{"reports": [{"支出二级单位简称": "1", "支出单位名称": "2", "支出本方账户": "3", "支出对方账户": "4"}]}
"}

Activity

  1. added
    cloud
    🐞 bug
    on Apr 8, 2026
  2. dosubot commented on Apr 8, 2026

    @dosubot

    Hi @AiFu-o! I'm Dosu and I’m helping the dify team.

    This is a known bug that has been reported multiple times [1] [2] [3] [4]. The root cause is that WorkflowTool._invoke() yields both a TEXT message and a JSON message for the same output [5]:

    yield self.create_text_message(json.dumps(outputs, ensure_ascii=False))
    yield self.create_json_message(outputs, suppress_output=True)

    When the agent processes these, both representations end up in the final response, causing the duplication.

    Fixes were merged after v1.8.1 — specifically PR #27087 (added a suppress_output flag on JSON messages) and PR #27706 (set-based deduplication in the response converter). Since you're on v1.8.1, these fixes are not included.

    Upgrading to a newer version should resolve or significantly reduce this issue. That said, some users have reported edge cases where duplication still occurs in later versions [6] [4].

    As a workaround until you can upgrade, you could post-process the agent output to filter duplicates, or patch WorkflowTool._invoke() locally to yield only the JSON message [7].

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about dify with Dosu

  3. reopened this on Apr 9, 2026
  4. AiFu-o commented on Apr 9, 2026

    @AiFu-o
    Author

    After updating, I encountered another issue. The parameters are no longer in a valid JSON format, and the duplication problem still persists.

    Example:
    请求
    {"get_filtered_anomalous_transactions2": {"question": "时间范围: 2024年4月, 交易主体: 全部, 异常类型: 背靠背交易, 金额范围: 不限"}}
    响应
    {"get_filtered_anomalous_transactions_demo": "variable_name='reports' variable_value='
    [{"支出二级单位简称": "1", "支出单位名称": "2", "支出本方账户": "3", "支出对方账户": "4"}]}
    stream=False{"reports": "[{\"支出二级单位简称\": \"1\", \"支出单位名称\": \"2\", \"支出本方账户\": \"3\", \"支出对方账户\": \"4\"}]"}"}

  5. AiFu-o commented on Apr 9, 2026

    @AiFu-o
    Author

    version 1.13.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cloud🐞 bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions