Agent in Dify access Knowledge Base directly

Hi everyone,

I’m experimenting with Dify and noticed that the Agent node is designed to call tools only, but it cannot directly access the Knowledge Base / vector DB.

I want the AI to be able to self-reason (self-ask) in order to:

  1. Break down a user question into smaller sub-questions.

  2. Query the Knowledge Base to retrieve accurate information.

  3. Aggregate the results and provide a final answer to the user.

Does anyone have experience implementing this kind of workflow in Dify when the KB is not a tool?

Thanks!

@nam
Hi, the simplest way I know is:

  1. Create a workflow that performs only knowledge retrieval and returns the result.
  2. Publish it as a “Workflow as Tool”.
  3. Add the published tool to the agent node.

This way, agents can use the knowledge retrieval feature as a tool.

Hope this helps :slight_smile:

2 Likes

Hi, kurokobo, Thank your help in github. I defined below a workflow and publish it as a tool. Then I use it in a chat workflow

The detail configuration in chat workflow like below.

but while the agent execute for some times, the agent only return below content:

<tool_call>
{“name”: “Query_KB”, “arguments”: {“query”: “SLM32F1XM606 WWDG 窗口看门狗 模块 详细功能 说明 文档”}}
</tool_call>

The agent and chat configuration like this:

I don’t know how to avid this error. this cause the agent output the query parameters instead of expected output.

I’m not very familiar with Qwen, so I’m not too confident in my answer, but I think this format is specific to Qwen’s Tool Call request.

I’m not sure if the Agent node can properly interpret this kind of Tool Call request from the LLM. If possible, maybe you could try it with a model other than Qwen to see how it behaves.