dify - ✅(Solved) Fix Tool returns duplicate results when called via agent [1 pull requests, 3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langgenius/dify#34723Fetched 2026-04-09 08:18:11
View on GitHub
Comments
3
Participants
2
Timeline
9
Reactions
1
Author
Participants
Timeline (top)
commented ×3labeled ×2closed ×1mentioned ×1

PR fix notes

PR #34962: fix: fix tool output duplicate

Description (problem / solution / changelog)

[!IMPORTANT]

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

when tool message type is variable skip it, str(response.message) is no use for llm fix #34723

<!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. --> <!-- If this PR was created by an automated agent, add `From <Tool Name>` as the final line of the description. Example: `From Codex`. -->

Screenshots

BeforeAfter
......

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Changed files

  • api/core/tools/tool_engine.py (modified, +2/-0)
  • api/core/tools/utils/workflow_configuration_sync.py (modified, +0/-2)
  • api/services/tools/workflow_tools_manage_service.py (modified, +1/-0)
  • api/tests/unit_tests/core/tools/test_tool_engine.py (modified, +22/-0)
RAW_BUFFERClick to expand / collapse

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"}]} "}

extent analysis

TL;DR

The issue can be resolved by investigating and modifying the agent's response handling to prevent duplicate output.

Guidance

  • Verify that the workflow itself is not producing duplicate output by testing it independently of the agent.
  • Check the agent's configuration and code for any settings or logic that might be causing it to duplicate the response.
  • Inspect the network traffic or logs between the workflow and the agent to see if the duplication occurs during transmission or processing.
  • Consider adding logging or debugging statements in the agent's code to track the flow of data and identify where the duplication is happening.

Notes

The provided information suggests that the issue lies with the agent, but without access to the agent's code or configuration, it's difficult to provide a more specific solution.

Recommendation

Apply workaround: Modify the agent's response handling to remove duplicate output, as the root cause seems to be related to how the agent processes and returns the workflow's results.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING