Is your feature request related to a problem?
Yes.
When a Haystack RAG pipeline returns poor or empty results, there is currently no native way to determine where the retrieval process failed. While Haystack provides useful debugging primitives such as include_outputs_from, tracing, and breakpoints, developers still have to manually inspect intermediate outputs and infer the root cause themselves.
Some common scenarios are:
1. Empty retrieval
A query returns zero documents. The developer has no indication whether this is caused by embedding mismatch, metadata filters, indexing problems, or simply the absence of relevant content.
2. Metadata filter exclusion
A query with metadata filters unexpectedly returns no documents. Haystack exposes the empty result, but developers must manually inspect the underlying document store to understand whether filters excluded otherwise relevant documents.
3. Reranker context loss
A reranker is introduced to improve retrieval quality, but answer quality decreases.
Without manually inspecting intermediate component outputs, it is difficult to determine whether:
- the retriever never found relevant documents, or
- the retriever found them but the reranker removed or significantly demphasized them.
These represent different failure modes but currently require manual investigation.
Proposed solution
Introduce a framework-supported retrieval diagnostics API that interprets intermediate pipeline outputs and classifies common retrieval failures.
Rather than exposing only raw retriever and reranker outputs, Haystack could provide a higher-level diagnostic object.
Example:
from haystack.diagnostics import diagnose_retrieval
result = diagnose_retrieval(
pipeline=rag_pipeline,
query="What is the return policy?",
ranking_threshold=0.7,
)
print(result.failure_class)
print(result.explanation)
print(result.details)
One possible initial taxonomy could include:
| Failure class |
Description |
NO_RESULTS |
Retriever returned zero documents |
FILTER_EXCLUSION |
Metadata filters excluded candidate documents |
SCORE_BELOW_CUTOFF |
Retrieved documents scored below a configurable threshold |
CONTEXT_LOSS |
Documents retrieved upstream were removed or significantly reordered by downstream ranking |
EMPTY_CONTEXT |
Retrieved documents contain no usable textual content |
This API could internally build upon existing mechanisms such as include_outputs_from rather than introducing a separate execution path.
Why this belongs in Haystack
Haystack already provides the primitives required for debugging pipeline execution.
This proposal focuses on adding a framework-native interpretation layer that converts intermediate pipeline outputs into actionable diagnostics without requiring users to manually inspect component outputs or build custom debugging utilities.
It complements existing observability features rather than replacing them.
Prior prototype
I implemented an external prototype (haystack-diagnostics) to validate this idea.
GitHub repository: https://github.com/rautaditya2606/haystack-diagnostics
During development it successfully identified multiple real-world retrieval issues, including:
- retrieval failures caused by metadata filters
- reranker-induced context loss
- empty retrieved context caused by malformed documents
The prototype uses Haystack's existing APIs (include_outputs_from) to perform single-pass inspection without requiring additional pipeline executions.
The goal of this proposal is not to upstream that project directly, but to discuss whether a small, generic retrieval diagnostics API belongs in Haystack core.
Related discussion
This proposal is complementary to #11286 (Standardized Pipeline Run Artifacts).
That RFC focuses on recording pipeline execution.
This proposal focuses on interpreting retrieval behavior and classifying common retrieval failure modes.
Alternatives considered
- OpenTelemetry tracing provides excellent observability but requires additional infrastructure and still leaves interpretation to the developer.
include_outputs_from exposes intermediate outputs but requires manual inspection and does not provide structured diagnostics.
- External tooling works but fragments the debugging experience and requires additional installation and maintenance.
Scope
Initial MVP:
diagnose_retrieval()
- structured diagnostic result
- initial retrieval failure taxonomy
- implementation built on existing Haystack execution primitives
Out of scope:
- document store validation
- CLI
- debug bundle serialization
- async support
I'd be happy to prototype this if the maintainers think this direction aligns with Haystack's architecture. Given the new public API surface, I'm also happy to write a design proposal before opening a PR if that's preferred.
Is your feature request related to a problem?
Yes.
When a Haystack RAG pipeline returns poor or empty results, there is currently no native way to determine where the retrieval process failed. While Haystack provides useful debugging primitives such as
include_outputs_from, tracing, and breakpoints, developers still have to manually inspect intermediate outputs and infer the root cause themselves.Some common scenarios are:
1. Empty retrieval
A query returns zero documents. The developer has no indication whether this is caused by embedding mismatch, metadata filters, indexing problems, or simply the absence of relevant content.
2. Metadata filter exclusion
A query with metadata filters unexpectedly returns no documents. Haystack exposes the empty result, but developers must manually inspect the underlying document store to understand whether filters excluded otherwise relevant documents.
3. Reranker context loss
A reranker is introduced to improve retrieval quality, but answer quality decreases.
Without manually inspecting intermediate component outputs, it is difficult to determine whether:
These represent different failure modes but currently require manual investigation.
Proposed solution
Introduce a framework-supported retrieval diagnostics API that interprets intermediate pipeline outputs and classifies common retrieval failures.
Rather than exposing only raw retriever and reranker outputs, Haystack could provide a higher-level diagnostic object.
Example:
One possible initial taxonomy could include:
NO_RESULTSFILTER_EXCLUSIONSCORE_BELOW_CUTOFFCONTEXT_LOSSEMPTY_CONTEXTThis API could internally build upon existing mechanisms such as
include_outputs_fromrather than introducing a separate execution path.Why this belongs in Haystack
Haystack already provides the primitives required for debugging pipeline execution.
This proposal focuses on adding a framework-native interpretation layer that converts intermediate pipeline outputs into actionable diagnostics without requiring users to manually inspect component outputs or build custom debugging utilities.
It complements existing observability features rather than replacing them.
Prior prototype
I implemented an external prototype (haystack-diagnostics) to validate this idea.
GitHub repository: https://github.com/rautaditya2606/haystack-diagnostics
During development it successfully identified multiple real-world retrieval issues, including:
The prototype uses Haystack's existing APIs (
include_outputs_from) to perform single-pass inspection without requiring additional pipeline executions.The goal of this proposal is not to upstream that project directly, but to discuss whether a small, generic retrieval diagnostics API belongs in Haystack core.
Related discussion
This proposal is complementary to #11286 (Standardized Pipeline Run Artifacts).
That RFC focuses on recording pipeline execution.
This proposal focuses on interpreting retrieval behavior and classifying common retrieval failure modes.
Alternatives considered
include_outputs_fromexposes intermediate outputs but requires manual inspection and does not provide structured diagnostics.Scope
Initial MVP:
diagnose_retrieval()Out of scope:
I'd be happy to prototype this if the maintainers think this direction aligns with Haystack's architecture. Given the new public API surface, I'm also happy to write a design proposal before opening a PR if that's preferred.