This prompt is the final stage in a multi-hop RAG pipeline. After your system has decomposed a complex question, executed a sequence of dependent retrieval queries, and collected answers for each sub-question, this prompt merges those intermediate answers into a single coherent final response. Use it when you need a synthesized answer that traces every claim back to its specific retrieval hop, exposes contradictions between sub-answers, and flags any integration gaps where the assembled evidence still does not fully answer the original question. The ideal user is a RAG pipeline operator or agent developer who already has a working query decomposition and retrieval execution layer and now needs reliable answer fusion with provenance tracking.
Prompt
Sub-Question Answer Merging Prompt for Multi-Hop Synthesis

When to Use This Prompt
Understand the job-to-be-done, required context, and boundaries for the Sub-Question Answer Merging Prompt.
Do not use this prompt for single-hop retrieval answers, for generating the sub-questions themselves, or when the intermediate answers are already self-contained and require no cross-referencing. It is not a replacement for a query decomposition prompt, a retrieval execution engine, or a fact-verification step. If your pipeline produces only one retrieval result, or if the sub-answers are independent facts that can be listed without synthesis, this prompt adds unnecessary latency and token cost. The prompt assumes that each intermediate answer carries a hop identifier, source citations, and the retrieved evidence text. Without these inputs, the merging prompt cannot produce traceable provenance or detect contradictions reliably.
Before wiring this prompt into production, validate that your upstream decomposition and retrieval steps consistently produce structured intermediate answers with the fields this prompt expects: hop index, sub-question text, answer text, source citations, and confidence scores. Missing or malformed fields will cause the merge to fail silently or produce unsupported claims. For high-stakes domains such as healthcare, legal, or financial analysis, always route the merged output through a human review step and run an additional fact-verification pass that checks each claim against its cited source. The next section provides the copy-ready prompt template with all required placeholders.
Use Case Fit
Where the Sub-Question Answer Merging Prompt delivers value and where it introduces risk. Use these cards to decide if this prompt fits your pipeline stage before wiring it into production.
Good Fit: Final Synthesis Stage
Use when: you have already executed a multi-hop query plan and collected sub-answers from independent retrieval rounds. This prompt merges those answers into a single coherent response. Guardrail: always pass the original user question alongside sub-answers so the model can check that the synthesis addresses the original intent.
Bad Fit: Single-Hop RAG Pipelines
Avoid when: your pipeline performs only one retrieval round. This prompt expects multiple sub-answers with dependency context and will hallucinate integration steps if given a single flat context. Guardrail: gate execution behind a dependency detection check that confirms the question requires multi-hop synthesis before invoking this prompt.
Required Inputs
What you must provide: the original user question, an ordered list of sub-questions, the answer retrieved for each sub-question, and source citations with hop-level provenance. Guardrail: validate that every sub-answer has a non-empty evidence payload before merging. Missing evidence produces fabricated bridge facts.
Operational Risk: Contradiction Blindness
What to watch: the model may merge contradictory sub-answers into a fluent but logically inconsistent final answer without flagging the conflict. Guardrail: run a contradiction detection eval across sub-answer pairs before synthesis, and surface unresolved conflicts to a human reviewer when confidence is low.
Latency and Cost Sensitivity
What to watch: merging many sub-answers with full provenance chains can produce long prompts that increase token usage and latency. Guardrail: set a maximum sub-answer count and total token budget. If exceeded, prioritize sub-answers by relevance score and drop low-confidence hops before merging.
Provenance Traceability Requirement
What to watch: downstream consumers need to know which part of the final answer came from which retrieval hop. A merged answer without hop-level provenance is unverifiable. Guardrail: require the output schema to include a provenance array mapping each claim to its source sub-question and citation, and validate this structure in post-processing.
Copy-Ready Prompt Template
A copy-ready template for merging sub-question answers into a coherent final synthesis with traceable evidence chains.
This prompt is designed for the final stage of a multi-hop RAG pipeline. After your system has decomposed a complex question, executed a sequence of dependent retrieval queries, and collected answers for each sub-question, this prompt merges those intermediate findings into a single, coherent final answer. The template enforces hop-by-hop provenance, requires explicit contradiction flagging, and produces a structured output suitable for downstream display or further automated processing. Use this when your retrieval chain has produced a set of sub-question-answer pairs and you need to synthesize them without losing traceability back to the evidence.
codeYou are a synthesis engine for a multi-hop retrieval system. Your task is to merge answers from multiple sub-questions into a single, coherent final answer. You must preserve traceability to each hop and flag any contradictions. ## ORIGINAL USER QUESTION [ORIGINAL_QUESTION] ## SUB-QUESTION ANSWERS (in retrieval order) [SUB_QUESTION_ANSWER_PAIRS] ## OUTPUT SCHEMA Return a JSON object with the following structure: { "final_answer": "A coherent synthesis that answers the original question by integrating all sub-question findings. Use clear language and logical flow.", "hop_provenance": [ { "hop_number": 1, "sub_question": "The sub-question for this hop", "finding_used": "The specific finding from this hop that was incorporated into the final answer", "source_citation": "Citation or reference from the original sub-question answer" } ], "contradictions": [ { "hop_a": 1, "hop_b": 2, "description": "Description of the contradiction between the findings", "resolution_attempted": "How the contradiction was resolved, or 'unresolved' if it could not be reconciled" } ], "missing_information": ["List any information gaps that prevented a complete answer"], "confidence": "high|medium|low", "confidence_rationale": "Brief explanation of the confidence level based on evidence consistency and completeness" } ## CONSTRAINTS - Do not introduce facts not present in the sub-question answers. - If sub-question answers conflict, flag the contradiction rather than silently choosing one. - If critical information is missing, state it explicitly rather than fabricating. - Preserve all source citations from sub-question answers. - If the sub-question answers are insufficient to answer the original question, set confidence to "low" and explain why. - Order hop_provenance entries by retrieval sequence. - If fewer than [MIN_HOPS] hops are provided, note this as missing information.
To adapt this template, replace [ORIGINAL_QUESTION] with the user's initial complex question. Populate [SUB_QUESTION_ANSWER_PAIRS] with the structured output from each retrieval hop—typically a list of objects containing the sub-question text, the retrieved answer, and source citations. Set [MIN_HOPS] to the expected minimum number of hops for your pipeline, which helps the model detect incomplete retrieval chains. The output schema is designed for programmatic consumption: your application layer should parse the JSON, render final_answer to the user, and use hop_provenance to build clickable citations. The contradictions array should trigger a review workflow if unresolved conflicts are detected. Before deploying, run this prompt against a golden dataset of known multi-hop questions with expected answer spans and verify that provenance chains are complete and contradictions are correctly identified.
Prompt Variables
Required inputs for the Sub-Question Answer Merging Prompt. Each variable must be populated before the prompt is assembled and sent to the model. Missing or malformed inputs are the most common cause of merge failures in production.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[ORIGINAL_QUESTION] | The user's original multi-hop question that triggered the sub-question decomposition | What was the revenue impact of the security incident that affected our largest customer last quarter? | Must be non-empty string. Check that it matches the question used for sub-question generation. Mismatch between original question and sub-answers causes synthesis drift. |
[SUB_QUESTION_ANSWER_PAIRS] | Ordered list of sub-question and answer objects from prior retrieval hops, each with source citations | [{"sub_question": "Which customer is our largest?", "answer": "Acme Corp with $4.2M ARR", "sources": ["doc_12", "doc_45"]}, {"sub_question": "What security incident affected Acme Corp?", "answer": "Incident INC-2024-003 on 2024-09-15", "sources": ["doc_78"]}] | Must be valid JSON array with at least 2 objects. Each object requires non-null sub_question, answer, and sources fields. Empty answers must be flagged before merging. Missing sources on any hop should trigger a confidence downgrade. |
[DEPENDENCY_GRAPH] | Directed acyclic graph showing which sub-questions depend on which prior answers, used to validate merge ordering | {"nodes": ["SQ1", "SQ2", "SQ3"], "edges": [{"from": "SQ1", "to": "SQ2"}, {"from": "SQ2", "to": "SQ3"}]} | Must be valid JSON with nodes and edges arrays. Cycle detection required before merge. Orphan nodes are allowed but should be flagged. Graph must reference the same sub-question IDs present in SUB_QUESTION_ANSWER_PAIRS. |
[EVIDENCE_CHAIN_REQUIREMENT] | Boolean flag controlling whether the output must include hop-by-hop provenance trace | Must be true or false. When true, output schema must include an evidence_chain field. When false, provenance is optional. Set to true for regulated or audited workflows. False is acceptable for low-stakes summarization. | |
[CONTRADICTION_THRESHOLD] | Confidence score below which contradictory sub-answers trigger a merge abort and human escalation | 0.7 | Must be float between 0.0 and 1.0. Lower values allow more contradictions through. Production default is 0.7. Values below 0.5 effectively disable contradiction detection. Values above 0.9 cause excessive false-positive escalations. |
[MAX_ANSWER_LENGTH] | Token or word limit for the final synthesized answer to prevent runaway generation | 500 | Must be positive integer. Enforced post-generation with truncation or regeneration. Set based on downstream display constraints. Too-low limits cause incomplete synthesis. Too-high limits waste context window and latency budget. |
[CITATION_STYLE] | Format instruction for how sources should be cited in the final answer | inline_bracketed | Must be one of: inline_bracketed, footnote, endnote, or none. Inline_bracketed produces [1] [2] style. Footnote produces numbered footnotes. Endnote produces a sources section. None suppresses citations entirely. Mismatch with downstream renderer breaks display. |
[MISSING_HOP_POLICY] | Instruction for how to handle sub-questions that returned empty or low-confidence answers | flag_and_continue | Must be one of: abort, flag_and_continue, skip_silently, or synthesize_with_gap. Abort stops the pipeline. Flag_and_continue includes a missing_evidence section. Skip_silently omits the hop. Synthesize_with_gap attempts to fill from other hops. Production default is flag_and_continue. |
Implementation Harness Notes
How to wire the sub-question answer merging prompt into a production multi-hop RAG pipeline with validation, retries, and traceable provenance.
The sub-question answer merging prompt operates as the final synthesis stage in a multi-hop RAG pipeline. It receives a collection of sub-question/answer pairs produced by earlier retrieval and answering rounds, along with the original user question, and produces a single coherent answer with hop-by-hop provenance. In a production harness, this prompt is not called in isolation. It is invoked after all dependency-respecting sub-queries have been executed and their individual answers collected. The harness must assemble the input payload carefully: each sub-answer must be paired with its originating sub-question and source citations, because the merge prompt needs to trace which evidence came from which retrieval hop. If the upstream query planner produced a dependency graph, the harness should pass that graph as additional context so the merge prompt can validate that all required hops completed before synthesis begins.
A robust implementation wraps the merge prompt in a validation and retry loop. After the model returns a merged answer, the harness should run structural and semantic checks before surfacing the result to the user. Structural validation confirms that the output contains all required fields: the synthesized answer, a provenance array mapping each claim to its source sub-question and retrieval hop, and a contradictions array if the merge prompt detected conflicting sub-answers. Semantic validation checks for missing integration steps: if the original question required connecting entity A to entity C via bridge entity B, the harness should verify that the merged answer explicitly mentions the bridge step rather than jumping directly from A to C. For high-stakes domains such as clinical review or legal analysis, the harness should route merged outputs to a human review queue when the contradictions array is non-empty or when the merge prompt's confidence score falls below a configured threshold. Model choice matters here: models with strong instruction-following and long-context handling, such as Claude 3.5 Sonnet or GPT-4o, perform better at maintaining provenance fidelity across multiple sub-answers than smaller models that may drop citation links or flatten the reasoning chain.
Logging and observability are critical for debugging merge failures. The harness should log the full input payload (sub-questions, sub-answers, dependency graph, and original question), the raw model output, validation results, and any retry attempts. This trace data enables post-mortem analysis when users report answers that contradict source evidence or skip intermediate reasoning steps. Common failure modes to instrument for include: the merge prompt hallucinating a connection that none of the sub-answers support, omitting a sub-answer entirely from the synthesis, or producing a final answer that contradicts one of the input sub-answers without flagging it in the contradictions array. When these failures occur, the harness can trigger a repair path: re-invoke the merge prompt with explicit instructions to reconcile the specific contradiction, or escalate to a more capable model. Avoid the temptation to skip the merge step and concatenate sub-answers directly; users need a single coherent answer, not a list of partial results, and the merge prompt's provenance tracking is what makes the multi-hop pipeline auditable.
Expected Output Contract
Defines the required fields, types, and validation rules for the merged synthesis response. Use this contract to build a post-processing validator that rejects malformed or incomplete outputs before they reach the user.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
synthesized_answer | string | Must be non-empty and contain at least one complete sentence. Check for abrupt truncation by verifying the last character is sentence-ending punctuation. | |
hop_provenance | array of objects | Array length must equal the number of sub-questions in [SUB_QUESTION_LIST]. Each object must include a valid sub_question_id matching an input ID. | |
hop_provenance[].sub_question_id | string | Must match exactly one ID from the [SUB_QUESTION_LIST] input. No orphan or fabricated IDs allowed. | |
hop_provenance[].answer_fragment | string | Must be a non-empty string summarizing the evidence used from this hop. Cannot be identical to the raw sub-answer; must show synthesis. | |
hop_provenance[].source_spans | array of strings | Each span must be a direct, verbatim substring from the corresponding [SUB_ANSWER_LIST] entry. Validate via exact string match. | |
contradictions | array of objects or null | If no contradictions found, must be null. If present, each object requires both claim_a and claim_b fields with non-empty strings. | |
contradictions[].claim_a | string | Must be a direct quote or close paraphrase from one sub-answer. Validate presence in [SUB_ANSWER_LIST] via fuzzy match with threshold > 0.9. | |
contradictions[].claim_b | string | Must be a direct quote or close paraphrase from a different sub-answer. Validate presence in [SUB_ANSWER_LIST] via fuzzy match with threshold > 0.9. | |
contradictions[].resolution | string | Must be one of the enum values: resolved_in_final_answer, unresolved_preference_given, unresolved_flagged_for_review. No free-text allowed. | |
missing_integration_steps | array of strings or null | If all sub-answers are fully integrated, must be null. If present, each string must describe a specific gap in reasoning, not a generic statement. | |
confidence_score | number | Must be a float between 0.0 and 1.0 inclusive. Reject if score > 0.95 but contradictions array is not null; this indicates miscalibration. |
Common Failure Modes
What breaks first when merging sub-question answers into a final synthesis, and how to guard against it.
Contradictory Sub-Answers
What to watch: Two or more sub-answers provide conflicting facts, dates, or figures. The model may arbitrarily pick one, blend them into nonsense, or hallucinate a compromise. Guardrail: Add a pre-merge contradiction detection step. Prompt the model to list conflicts explicitly before synthesis, and flag unresolved contradictions for human review rather than silently resolving them.
Missing Integration Steps
What to watch: The model concatenates sub-answers without connecting them. The output reads like a list of facts rather than a coherent answer that explains how the pieces fit together. Guardrail: Require an explicit 'integration narrative' section in the output schema. Prompt the model to write bridging sentences that explain the relationship between each hop's findings before delivering the final answer.
Provenance Collapse
What to watch: The final answer mixes evidence from multiple retrieval rounds without tracking which claim came from which hop. Downstream users cannot verify sources or trace errors. Guardrail: Require hop-by-hop citation in the output. Each factual claim must carry a provenance tag linking it to the specific sub-question and source document it came from. Validate citation coverage before accepting the merge.
Early-Hop Dominance
What to watch: The model overweights evidence from the first retrieval hop and ignores or downplays later findings, especially when later evidence contradicts early results. Guardrail: Shuffle the order of sub-answer presentation in the merge prompt. Run multiple merge passes with different input orderings and check for consistency. Flag answers that change significantly based on input order.
Hallucinated Bridge Entities
What to watch: When a gap exists between sub-answers, the model invents a connecting fact, entity, or relationship to make the narrative coherent. This is especially dangerous in multi-hop chains where the model feels pressure to complete the chain. Guardrail: Require that every bridging claim be explicitly grounded in at least one retrieved sub-answer. Add a validator that checks each sentence in the synthesis against the input sub-answers and flags unsupported statements.
Confidence Dilution Across Hops
What to watch: The model presents a merged answer with uniform high confidence even when individual sub-answers had low retrieval quality or conflicting evidence. Users cannot distinguish well-supported claims from weak ones. Guardrail: Propagate per-hop confidence scores into the final synthesis. Require the output to include a confidence breakdown per claim, and suppress or qualify claims that depend on low-confidence intermediate hops.
Evaluation Rubric
Use this rubric to test the quality of merged multi-hop synthesis outputs before shipping. Each criterion targets a specific failure mode common in sub-question answer merging.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Hop Coverage | Every sub-question in the input set is addressed in the final answer | Final answer omits evidence or conclusions from one or more sub-questions | Parse the output for explicit references to each sub-question ID; flag any sub-question with zero mentions |
Contradiction Detection | No logical contradictions exist between merged sub-answers | Two sub-answer claims directly conflict without resolution or acknowledgment | Run a pairwise contradiction check across all extracted claims; flag unresolved conflicts |
Provenance Traceability | Every factual claim in the final answer cites the specific sub-question and source span it came from | Claims appear without a hop ID or source reference, or citations point to wrong sub-question | Extract all claims and verify each has a valid [SUB_QUESTION_ID] and [SOURCE_SPAN] pair; check for hallucinated citations |
Integration Completeness | Relationships between sub-answers are explicitly stated, not left implicit | Sub-answers are concatenated without connecting logic, transitions, or synthesis statements | Check for presence of bridge sentences between sub-answer segments; flag if output reads as a bullet list without connective tissue |
Temporal Consistency | Events and facts from different hops are ordered correctly in time | A fact from an earlier hop is presented as occurring after a fact from a later hop | Extract all temporal expressions and entity-event pairs; sort by timestamp and check for ordering violations |
Entity Resolution | The same real-world entity is referred to consistently across merged hops | Different names or pronouns are used for the same entity without establishing coreference | Run entity coreference check across the full merged output; flag unresolved aliases or ambiguous pronouns |
Confidence Calibration | Low-confidence sub-answers are flagged with uncertainty language in the final synthesis | A sub-answer with [CONFIDENCE] below 0.7 is presented as definitive fact without hedging | Parse [CONFIDENCE] scores from sub-answer inputs; verify hedging language appears in output for any sub-answer below threshold |
Hallucination Absence | No facts appear in the final answer that are not present in any sub-answer input | The merged output introduces a new entity, number, date, or claim not found in any sub-answer | Decompose final answer into atomic claims; verify each claim has a match in at least one sub-answer input; flag unmatched claims |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a single model call and minimal validation. Focus on getting a coherent merged answer from a small set of sub-answers (2-4). Skip strict schema enforcement; accept a markdown response with labeled sections for each hop.
codeMerge the following sub-answers into one final answer for the question: [ORIGINAL_QUESTION] Sub-answers: [HOP_1_ANSWER] [HOP_2_ANSWER]
Watch for
- The model fabricating bridge connections between sub-answers that don't logically link
- Contradictions between sub-answers being silently dropped instead of flagged
- Missing provenance: the merged answer may not trace claims back to specific hops

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us