﻿# Dify Agent Knowledge Retrieval can succeed with an empty result

Wire Dify Agent Knowledge Retrieval with explicit context and an empty-result branch, separating no matches from a failed selected knowledge base and from answer generation.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/guide-dify-agent-retrieval-result-branch/
Language: en

## Define success for the whole application

A workflow should answer a policy question only when approved evidence is found. A green retrieval node is insufficient for that requirement. Dify's beta [Agent Knowledge Retrieval reference](https://docs.dify.ai/en/cloud/use-dify/nodes/knowledge-retrieval-v2) explicitly permits successful execution with an empty `result`. Define application success in terms of the needed evidence, rather than borrowing the node's execution status as proof that the policy was found.

## Connect both evidence and question

The node supplies material for later nodes. In a downstream LLM on the same execution path, select `result` as Context and actually insert the Context variable into the prompt. Pass the original question into the User message and instruct the model to answer from retrieved material. A drawn connection does not itself prove that the text entered the answer prompt. Inspect the configured variables when a plausible response ignores the source.

## Route no matches deliberately

If the application must not answer without evidence, branch on an empty `result` before generation. The empty branch can report that the selected collection did not supply a supporting passage, preserving the user's question for review. Do not silently replace an internal procedure with general model knowledge. The [retrieval settings](https://docs.dify.ai/en/cloud/use-dify/knowledge-base/retrieval-settings) explain why depth and threshold changes can alter returned material, but relaxing them is a different decision from defining the no-evidence response.

## Separate failure from an empty evidence set

The node can search several knowledge bases, but a failure in any selected base returns no partial results and stops the run. The [connection guide](https://docs.dify.ai/en/cloud/use-dify/knowledge-base/use-knowledge-in-apps) documents Workflow access as another possible blocking condition. An empty successful result and failed retrieval therefore deserve different diagnostics. Increasing Top K will not restore disabled access, and an unavailable collection should not be described as proof that the underlying policy does not exist.

## Test the node contract and answer separately

Research depth in this node returns matching chunks rather than generating the answer shown by a retrieval test. Check a supported question, an unsupported question, and a deliberately unavailable test dependency in a controlled environment. The [tool-observation guide](/journal/learn-codex-tool-observation/) distinguishes execution from established evidence; [citation coverage](/journal/rag-citation-precision-completeness/) checks the later claims. Keep the node outcome and final answer decision visible as separate application states.
