Pipeline errors
Common error signatures
Failures in the RAG pipeline fall into three broad categories: misconfigured pipeline components, retrieval producing no results, and LLM generation errors. They typically appear as exceptions raised from RagPipeline.run() or RagPipeline.run_and_generate() and are visible in the returned RagResult fields — particularly fallback_used: bool and confidence: float.
Watch for these specific conditions:
corpusisNoneor unset —RagPipelineacceptscorpus=Nonein__init__, but callingrun()without a validCorpusProtocolwill fail when the pipeline attempts retrieval. Checkpipeline.corpusbefore callingrun().- No grounding context found — When retrieval returns no hits, the pipeline falls back to
FALLBACK_PROMPT_TEMPLATE. The returnedRagResultwill havefallback_used=True. This is expected behavior, not an exception, but it signals that the query did not match corpus content. - Invalid
prompt_variant—run()andrun_and_generate()accept aprompt_variantargument. Passing a value not present inPROMPT_VARIANTSwill raise aKeyErrororValueErrorduring prompt assembly. providerresolution failure inrun_and_generate()— Theproviderargument accepts either anLLMProviderinstance or a string name. An unrecognised string will raise an error before any LLM call is made.ktoo large — Ifkexceeds the number of documents in the corpus, retrieval may return fewer results than expected. This silently reduces context rather than raising an exception, which can lowerconfidencein the result.
Where errors originate
Trace the failure to the specific method before walking the call stack further.
RagPipeline.run(query, k, prompt_variant)— Orchestrates corpus retrieval, optional query expansion and reranking, and prompt assembly. Errors here are most often caused by a missing or misconfiguredcorpus,retriever, orexpander.RagPipeline.run_and_generate(query, provider, ...)— Extendsrun()with LLM generation. Errors here can originate in either the retrieval/prompt layer or the LLM provider call. CheckRagResultfields from the returned tuple to distinguish the two.RagPipeline.corpusproperty — Accessing this property whencorpuswas not supplied to__init__will raise anAttributeErroror similar. Validate the corpus is set before use.
How to diagnose
-
Inspect
RagResultfields first. Before examining the traceback, checkfallback_used,confidence, andcontexton the returnedRagResult. Afallback_used=Trueresult with an emptycontextconfirms retrieval found nothing — the problem is in the corpus or query, not the pipeline code itself. -
Check that
corpusandretrieverare notNone. Both are optional constructor parameters, butrun()requires them at call time. Printpipeline.corpusbefore callingrun()to confirm the pipeline is fully initialised. -
Validate
prompt_variantagainstPROMPT_VARIANTS. If the traceback points to prompt assembly, confirm the variant string you're passing is a key inPROMPT_VARIANTS. Log or print the value immediately before therun()call. -
Trace
run_and_generate()failures to their layer. This method returnstuple[str, RagResult]. If the exception occurs before the LLM call, theRagResultwill not be available. If it occurs after, inspect the returned result forelapsed_msandconfidenceto understand what the retrieval stage produced. -
Check
claim_citationsandused_native_citationsfor generation-side issues. Whenuse_native_citations=Trueis passed torun_and_generate(), the pipeline delegates citation extraction to the LLM. Ifused_native_citationsisFalseon the result despite being requested, the provider did not support it — confirm your provider and model support native citations.
Source files
src/attune_rag/pipeline.pysrc/attune_rag/__init__.py
Tags: pipeline, orchestration, rag, result