Skip to main content
One agent knowledge base can serve many apps at once. Connect it to workflows, Agents, or programs that should answer from it, or let a coding agent on your machine read its documents through the Dify CLI.
Chatbot, legacy Agent, and Text Generator apps can’t search an agent knowledge base. To answer from one, rebuild the app as a Chatflow or an Agent.

From Workflow and Chatflow Apps

Add an Agent Knowledge Retrieval node and pick the knowledge bases it searches. A knowledge base you don’t have permission to view doesn’t appear in the picker. To limit searches to certain documents, filter by metadata in the node. To stop every workflow from searching the knowledge base, test runs included, turn off Workflow access in the knowledge base’s Settings. Workflows that already use it fail at that node until you turn it back on.

From the New Agent

In an Agent’s Configure editor, add the knowledge base under Agent Knowledge Base. The Agent decides on its own when to search the knowledge base by its name and description, always at the Fast retrieval depth. To stop published Agents from searching the knowledge base, turn off API access in the knowledge base’s Settings. Agents that use it keep running but can no longer search it. The same switch cuts off the Service API.

From Your Own Code

Through the Service API, your code can ask the knowledge base questions, run longer Research searches in the background, and maintain its documents. To shut API callers out, turn off API access in the knowledge base’s Settings; Agents lose access too.

From Your Coding Agent

A coding agent on your own machine, such as Claude Code or Codex, can use the knowledge base as reference while it works. Through the Dify CLI, it browses the documents like files in folders, reads them, and searches them for exact words. It can’t change anything in the knowledge base. To search by meaning, as your apps do, use the Service API. To set it up, follow Get Started in the CLI docs: install difyctl, sign in with your Dify account, and give your agent the difyctl skill. Then ask your agent for what you need, and include two things:
  • difyctl knowledge_fs, the commands to use. The difyctl skill doesn’t cover them.
  • The knowledge base’s ID. With the knowledge base open in Dify, copy it from the browser’s address: it’s the part between /datasets/new/ and the next /.
For example:
Your agent can open any agent knowledge base you can view in Dify. It looks in the workspace you had open in Dify when you signed in. For a knowledge base in another workspace, switch difyctl to that workspace first.

After Your Apps Go Live

Sync or re-upload a document, and your apps, Agents, API callers, and external coding agents see the new version as soon as it finishes indexing. On the Overview page, watch for sources that stopped syncing and questions that came back empty. See Maintain an Agent Knowledge Base for what to do about each.
Last modified on October 28, 2026