mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-21 17:45:23 -04:00
[PR #2154] Fix duplicate JSON response output when agent invokes tools #2290
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/langgenius/dify-official-plugins/pull/2154
Author: @paul0728
Created: 11/30/2025
Status: 🔄 Open
Base:
main← Head:fix/agent-tool-response-duplicate📝 Commits (5)
787e641修复 agent 调用工具时 JSON 响应重复输出的问题51116dd修复 agent 调用工具时 JSON 响应重复输出的问题5679d61refactor: 改進工具響應去重邏輯a7912b9重構:簡化工具響應處理邏輯,直接跳過 TEXT 類型921b9c1Merge branch 'fix/agent-tool-response-duplicate' of https://github.com/paul0728/dify-official-plugins into fix/agent-tool-response-duplicate📊 Changes
4 files changed (+141 additions, -84 deletions)
View changed files
📝
.gitignore(+3 -0)📝
agent-strategies/cot_agent/manifest.yaml(+1 -1)📝
agent-strategies/cot_agent/strategies/ReAct.py(+76 -46)📝
agent-strategies/cot_agent/strategies/function_calling.py(+61 -37)📄 Description
Related Issues or Context
This PR fixes an issue where duplicate JSON content appears in tool responses when an agent invokes a workflow tool.
Problem Background:
When an agent calls a workflow tool, the tool returns responses in both TEXT and JSON formats simultaneously. The TEXT type serializes the JSON structure into a string, while the JSON type preserves the original JSON structure. This results in the final
tool_responsecontaining duplicate content, for example:Solution:
Implement smart deduplication logic in
function_calling.pyandReAct.py. When a JSON-type response is detected, the TEXT-type response is skipped, and only the JSON response is retained.Key Changed Files:
agent-strategies/cot_agent/strategies/function_calling.py: Added response deduplication logicagent-strategies/cot_agent/strategies/ReAct.py: Added response deduplication logicagent-strategies/cot_agent/manifest.yaml: Bumped version to 0.0.26.gitignore: Added.claudeanddify-plugin.exeImpact Scope:
This PR contains Changes to Non-Plugin
This PR contains Changes to Non-LLM Models Plugin
This PR contains Changes to LLM Models Plugin
My Changes Affect Message Flow Handling (System Messages and User→Assistant Turn-Taking)
My Changes Affect Tool Interaction Flow (Multi-Round Usage and Output Handling, for both Agent App and Agent Node)
My Changes Affect Multimodal Input Handling (Images, PDFs, Audio, Video, etc.)
My Changes Affect Multimodal Output Generation (Images, Audio, Video, etc.)
My Changes Affect Structured Output Format (JSON, XML, etc.)
My Changes Affect Token Consumption Metrics
My Changes Affect Other LLM Functionalities (Reasoning Process, Grounding, Prompt Caching, etc.)
Other Changes (Add New Models, Fix Model Parameters etc.)
Version Control (Any Changes to the Plugin Will Require Bumping the Version)
Dify Plugin SDK Version
dify_plugin>=0.3.0,<0.6.0is in requirements.txt (Current:dify_plugin>=0.5.0,<0.6.0)Environment Verification (If Any Code Changes)
Local Deployment Environment
SaaS Environment
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.