BUG: The agent uses a tool, and if the tool returns a link, the final link replied by the agent is incorrect
Self Checks
- [X] 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
0.7.3
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
正确的链接http://m801.music.126.net/20240906113456/af23cec22bbd6df43053095b60b83af7/jdymusic/obj/wo3DlMOGwrbDjj7DisKw/18708866715/5eb8/dad6/61f5/42c7fc29510cc3e521bb285c54489852.flac
✔️ Expected Behavior
No response
❌ Actual Behavior
No response
回复的错误链接http://m801.music.126.net/20240906113456/af23cec22bbd6df43053095b60b83af7/jdymusic/obj/wo3DlMOGwrbDjj7DisKw/18708866715/5eb8/dad6/61f5/42c7fc29510cc3e521bb285c54454489852.flac
左边日志追踪输出的链接是正常的,右边回复的链接不对
The issue with the agent replying with an incorrect link is due to the tool_icon not being set correctly when the tool_provider_type is "dataset-retrieval". In the code, tool_icon is set to an empty string in this case, which results in the agent not having the correct link to reply with.
Here's the relevant code snippet:
if tool_config.get("tool_provider_type", "") != "dataset-retrieval":
tool_icon = ToolManager.get_tool_icon(
tenant_id=app_model.tenant_id,
provider_type=tool_config.get("tool_provider_type", ""),
provider_id=tool_config.get("tool_provider", ""),
)
if not tool_icon:
tool_entity = find_agent_tool(tool_name)
if tool_entity:
tool_icon = ToolManager.get_tool_icon(
tenant_id=app_model.tenant_id,
provider_type=tool_entity.provider_type,
provider_id=tool_entity.provider_id,
)
else:
tool_icon = ""
To address this, you can use the create_link_message method from the Tool class to ensure the correct link is returned. Here is an example of how you can use this method:
def create_link_message(self, link: str, save_as: str = '') -> ToolInvokeMessage:
"""
create a link message
:param link: the url of the link
:return: the link message
"""
By using this method, you can ensure that the correct link is generated and returned by the agent, thus resolving the issue of the agent replying with an incorrect link [1][2][3].
To continue talking to Dosu, mention @dosu.
Can you provide the tool's configuration?
Please attach the original output of the answer as well.
Can you provide the tool's configuration?您能提供该工具的配置吗?
Please attach the original output of the answer as well.请附上答案的原始输出。
Can you provide the tool's configuration?您能提供该工具的配置吗?
Please attach the original output of the answer as well.请附上答案的原始输出。
原始输出和日志详情的歌曲链接不一样,日志详情是正常的,原始对话输出错误
Can you provide the tool's configuration?您能提供该工具的配置吗?
Please attach the original output of the answer as well.请附上答案的原始输出。
# 日志详情输出:
🎵 遇见一曲,叙述着命运和相遇的美丽篇章。\n\n你可以通过点击 [这里](http://m801.music.126.net/20240906140436/744e04c5a5d7f462531841884bb68677/jdymusic/obj/wo3DlMOGwrbDjj7DisKw/18708866715/5eb8/dad6/61f5/42c7fc29510cc3e521bb285c54489852.flac) 聆听这首歌曲。享受音乐带来的温暖,仿佛在悠长的岁月中,邂逅了一段尘封已久的缘分。
# 原始输出:
🎵 遇见一曲,叙述着命运和相遇的美丽篇章。
你可以通过点击 [这里](http://m801.music.126.net/20240906140436/744e04c5a5d7f462531841884bb68677/jdymusic/obj/wo3DlMOGwrbDjj7DisKw/18708866766715/5eb8/dad6/61f5/42c7fc29510cc3e521bb285c54489852.flac) 聆听这首歌曲。享受音乐带来的温暖,仿佛在悠长的岁月中,邂逅了一段尘封已久的缘分。
你可以看这个两个输出结果的链接不一样
18708866715
18708866766715
看起来是这里解析出错了,我不太确是哪儿的问题,可能是 markdown 那边?
1870886671518708866766715看起来是这里解析出错了,我不太确是哪儿的问题,可能是 markdown 那边?
这个不太清楚是哪里错误,其他的工具如果是链接返回,有概率会出现这个情况,这个问题不是必现的
1870886671518708866766715看起来是这里解析出错了,我不太确是哪儿的问题,可能是 markdown 那边?
是前端的问题,我看到后台的API消息,回复的消息是正确的,前端显示有问题