Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor(tool-engine): Optimize tool engine response handling (#14216)

Zhang Xudongce545274a621
diff --git a/api/core/tools/tool_engine.py b/api/core/tools/tool_engine.py
index 2ad52a46c92..37b4582381e 100644
--- a/api/core/tools/tool_engine.py
+++ b/api/core/tools/tool_engine.py
@@ -246,10 +246,11 @@ class ToolEngine:
+ "you do not need to create it, just tell the user to check it now."
)
elif response.type == ToolInvokeMessage.MessageType.JSON:
- text = json.dumps(cast(ToolInvokeMessage.JsonMessage, response.message).json_object, ensure_ascii=False)
- result += f"tool response: {text}."
+ result = json.dumps(
+ cast(ToolInvokeMessage.JsonMessage, response.message).json_object, ensure_ascii=False
+ )
else:
- result += f"tool response: {response.message!r}."
+ result += str(response.message)
return result