langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
36.05k stars 4.87k forks source link

Got unknown type role=<PromptMessageRole.TOOL:'tool'> #5353

Open drfenixlinghu opened 2 weeks ago

drfenixlinghu commented 2 weeks ago

Self Checks

Dify version

0.6.11

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

every time i use a tool in the agent mode, after the tool perform its job, the agent no longer accept any further prompts. seems the agent feels that it has used the tool and the tool has done the job, therefore no more action is required or accepted. This happens with all tools available to dify. d1ed109e672c393659c6f3c2e928385 0efff3d09b4986e4a6f215f96423143

anyone has the same issue?

✔️ Expected Behavior

to be able to continue with the conversation

❌ Actual Behavior

cannot go on with the conversation.

dosubot[bot] commented 2 weeks ago

Hello @drfenixlinghu! I'm here to assist you with bug fixes, answer questions, and guide you on becoming a contributor. Let's tackle this issue together!

Yes, the issue you described with Dify version 0.6.11, where the agent no longer accepts further prompts after a tool has completed its task and throws an error indicating an unknown type role with role=<PromptMessageRole.TOOL: 'tool'>, has been experienced by others. The provided code defines the PromptMessageRole enum, which includes the TOOL role, and the ToolPromptMessage class, which uses this role. The error might be due to improper handling or validation of the TOOL role in the system.

From the api/core/agent/base_agent_runner.py file, it appears that the BaseAgentRunner class initializes and manages tools through methods like _init_prompt_tools and _convert_tool_to_prompt_message_tool. These methods ensure that tools are properly converted to PromptMessageTool instances and their parameters are correctly set. However, if there is an issue with how the TOOL role is being processed or validated, it could lead to the error you are encountering. It might be worth checking the implementation of these methods and ensuring that the TOOL role is being handled correctly throughout the agent's lifecycle [1][2].

To continue talking to Dosu, mention @dosu.

crazywoola commented 2 weeks ago

I think this should be fixed in latest main branch.

cjdxhjj commented 2 weeks ago

the error exist a long time since 0.6.10 and can't resolved at 0.6.11

crazywoola commented 2 weeks ago

Link https://github.com/langgenius/dify/issues/5304

crazywoola commented 2 weeks ago

Yes we just fixed yesterday. https://github.com/langgenius/dify/pull/5245

drfenixlinghu commented 2 weeks ago

Yes we just fixed yesterday. #5245

updated today the problem is still there

mmm8955405 commented 1 week ago

最新mast版本, sd遇到同样错误

Yeuoly commented 1 week ago

which model are you using for this?

fandych commented 1 week ago

@Yeuoly I'm using GLM-4 with the same problem.