tools return double output result #14803

Closed
opened 2026-02-21 19:18:49 -05:00 by yindo · 7 comments
Owner

Originally created by @winqihe on GitHub (Jun 22, 2025).

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

1.3.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

in agent mode, tools return double output result

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @winqihe on GitHub (Jun 22, 2025). ### 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 1.3.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce in agent mode, tools return double output result ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🔨 feat:tools label 2026-02-21 19:18:49 -05:00
yindo closed this issue 2026-02-21 19:18:49 -05:00
Author
Owner

@winqihe commented on GitHub (Jun 22, 2025):

Image Image
@winqihe commented on GitHub (Jun 22, 2025): <img width="460" alt="Image" src="https://github.com/user-attachments/assets/1e22b2e6-fbfe-46c2-9350-fe182a6990a1" /> <img width="442" alt="Image" src="https://github.com/user-attachments/assets/a6732d12-3519-409c-be16-f37630cd2974" />
Author
Owner

@winqihe commented on GitHub (Jun 22, 2025):

in agent mode, tools return double repeatly output result, and llm obsersation also repeat

@winqihe commented on GitHub (Jun 22, 2025): in agent mode, tools return double repeatly output result, and llm obsersation also repeat
Author
Owner

@dosubot[bot] commented on GitHub (Jun 22, 2025):

This double output and repeated observation in agent mode is likely caused by how Dify handles agent tool results and LLM observations: the system streams outputs live (via LLMResultChunk) and also reconstructs the full conversation history for context or display, but there’s no deduplication between these two flows. As a result, tool results and observations can appear twice—once in the live stream and again when the frontend or another consumer processes the reconstructed history. This is a known architectural issue and not a configuration problem. You may be able to work around it by filtering duplicates on the frontend or by monitoring for upstream fixes that address output deduplication in agent mode.
For more technical details, see the relevant code in CotAgentRunner and AppRunner classes, which manage this output flow (source).

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Jun 22, 2025): <!-- Answer --> This double output and repeated observation in agent mode is likely caused by how Dify handles agent tool results and LLM observations: the system streams outputs live (via LLMResultChunk) and also reconstructs the full conversation history for context or display, but there’s no deduplication between these two flows. As a result, tool results and observations can appear twice—once in the live stream and again when the frontend or another consumer processes the reconstructed history. This is a known architectural issue and not a configuration problem. You may be able to work around it by filtering duplicates on the frontend or by monitoring for upstream fixes that address output deduplication in agent mode. For more technical details, see the relevant code in CotAgentRunner and AppRunner classes, which manage this output flow ([source](https://github.com/langgenius/dify/blob/f2f6e958805aaf90f2a1b70cc6eac4c4628c4383/api/core/agent/cot_agent_runner.py)). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/df8b1d57-0512-4664-ac68-9a9094e8a89a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/df8b1d57-0512-4664-ac68-9a9094e8a89a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/df8b1d57-0512-4664-ac68-9a9094e8a89a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/df8b1d57-0512-4664-ac68-9a9094e8a89a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/df8b1d57-0512-4664-ac68-9a9094e8a89a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/df8b1d57-0512-4664-ac68-9a9094e8a89a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/df8b1d57-0512-4664-ac68-9a9094e8a89a?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/21350)
Author
Owner

@chiehw commented on GitHub (Jul 10, 2025):

I got the same problem

@chiehw commented on GitHub (Jul 10, 2025): I got the same problem
Author
Owner

@chiehw commented on GitHub (Jul 10, 2025):

I located the problem here

Image

The workflow will return both text and json, and the Agent will use both text and json as the output structure of the tool

@chiehw commented on GitHub (Jul 10, 2025): I located the problem here <img width="922" height="439" alt="Image" src="https://github.com/user-attachments/assets/99acc520-6ba6-481d-ab81-d5a222c37149" /> The workflow will return both text and json, and the Agent will use both text and json as the output structure of the tool
Author
Owner

@chiehw commented on GitHub (Jul 10, 2025):

Image 复现版本为 cloud 中的 1.5.1 Image
@chiehw commented on GitHub (Jul 10, 2025): <img width="1920" height="911" alt="Image" src="https://github.com/user-attachments/assets/d9178fb7-a8e7-4225-9b91-385c25d8bc6a" /> 复现版本为 cloud 中的 1.5.1 <img width="1920" height="808" alt="Image" src="https://github.com/user-attachments/assets/923040d5-2b43-4780-9303-c0ab6521f01f" />
Author
Owner

@dosubot[bot] commented on GitHub (Aug 30, 2025):

Hi, @winqihe. I'm Dosu, and I'm helping the Dify team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported duplicate output results and repeated LLM observations in agent mode on Dify v1.3.1 self-hosted via Docker.
  • The duplication stems from the architecture streaming outputs live and reconstructing them from conversation history without deduplication.
  • A suggested workaround is to filter duplicates on the frontend.
  • Another user, chiehw, confirmed the issue and noted that workflows returning both text and JSON outputs cause duplication.
  • The problem persists in cloud version 1.5.1 as demonstrated by shared screenshots.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of Dify by commenting here to keep the discussion open.
  • Otherwise, this issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Aug 30, 2025): Hi, @winqihe. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported duplicate output results and repeated LLM observations in agent mode on Dify v1.3.1 self-hosted via Docker. - The duplication stems from the architecture streaming outputs live and reconstructing them from conversation history without deduplication. - A suggested workaround is to filter duplicates on the frontend. - Another user, chiehw, confirmed the issue and noted that workflows returning both text and JSON outputs cause duplication. - The problem persists in cloud version 1.5.1 as demonstrated by shared screenshots. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of Dify by commenting here to keep the discussion open. - Otherwise, this issue will be automatically closed in 15 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#14803