This prompt serves as a routing decision point for RAG architects and agent developers who operate systems with both fast single-hop and slower multi-hop retrieval paths. Its job is to analyze a user question and determine whether the information needed to answer it can be gathered in one retrieval call or if the question contains implicit dependencies that require a sequence of queries where each subsequent step depends on results from prior steps. The output is a structured verdict—single-hop or multi-hop—along with a confidence score and a human-readable rationale. Your application can use this verdict to branch execution: send single-hop questions directly to a standard RAG pipeline for low-latency answers, and route multi-hop questions to a decomposition and chain-execution engine that will plan and execute dependent retrieval steps.
Prompt
Multi-Hop Query Dependency Detection Prompt

When to Use This Prompt
A pre-retrieval gate that classifies whether a user question can be answered from a single retrieval round or requires a chained sequence of dependent queries.
The ideal user is a retrieval pipeline engineer who has observed that some complex questions produce poor answers from a flat RAG setup and needs to avoid wasting latency budget on unnecessary chain execution for simple questions. Required context includes the full user question text and, optionally, conversation history if the question is a follow-up turn. Do not use this prompt when your system architecture mandates a fixed pipeline for all queries regardless of complexity, or when your retrieval backend cannot execute dependent query sequences—in those cases, the classification adds latency without actionable routing value. Also avoid this prompt for questions that are purely conversational, chitchat, or meta-instructions about the system itself; those should be caught by an upstream intent classifier before reaching this gate.
Before deploying, calibrate the dependency detection threshold against a labeled dataset of known single-hop and multi-hop questions from your domain. The most common production failure mode is false-positive chain triggers—questions that the model classifies as multi-hop but could have been answered correctly from a single well-constructed retrieval call. Each unnecessary chain execution adds latency and token cost. Start by setting a high confidence threshold for the multi-hop verdict and monitor the ratio of chain triggers to actual multi-hop questions in production traces. If you observe chains being executed for questions that a single retrieval round would have handled, raise the threshold or add a lightweight pre-check that tests whether a single retrieval call returns sufficient evidence before committing to the full chain.
Use Case Fit
Where the Multi-Hop Query Dependency Detection Prompt delivers value and where it introduces unnecessary risk or latency.
Strong Fit: Complex Analytical Questions
Use when: User questions require synthesizing information from multiple documents or data sources that cannot be retrieved in a single round. Guardrail: Calibrate the confidence threshold to avoid triggering multi-hop chains for simple comparative questions that a single well-constructed hybrid search could resolve.
Poor Fit: Simple Factoid Lookups
Avoid when: The question is a straightforward factoid request (e.g., 'What is the capital of France?'). Guardrail: Implement a pre-check classifier or keyword heuristic to short-circuit dependency detection for queries with low semantic complexity, saving latency and compute.
Required Inputs: A Well-Defined User Query
What to watch: Ambiguous or severely underspecified user questions will produce unreliable dependency verdicts. Guardrail: Pair this prompt with an ambiguity detection step. If the query is flagged as ambiguous, request clarification from the user before running dependency detection to prevent a cascade of bad retrieval plans.
Operational Risk: False-Positive Chain Triggers
What to watch: The model incorrectly classifies a single-hop question as multi-hop, triggering an unnecessary and costly chain of retrieval calls. Guardrail: Log all verdicts and monitor the ratio of multi-hop to single-hop detections. Implement an A/B testing framework to measure if multi-hop chains actually improve answer accuracy or just increase latency.
Operational Risk: Latency Budget Blowout
What to watch: Even correctly identified multi-hop questions can cause timeouts if the generated chain is too long. Guardrail: Set a hard limit on the maximum number of hops (e.g., 3). If the prompt detects a dependency chain longer than the limit, it should return a needs_decomposition flag and escalate to a more powerful planning agent or a human operator.
Poor Fit: Real-Time Conversational Agents
Avoid when: The user expects a sub-second response. Guardrail: For latency-sensitive applications, use this prompt only as an offline evaluation tool to build a routing heuristic, or run it in parallel with a fast single-hop attempt and cancel the chain if the first result is sufficient.
Copy-Ready Prompt Template
A copy-paste ready system prompt that classifies whether a user question requires a single retrieval round or a multi-hop chain of dependent queries.
This template is designed to be placed directly into your system prompt or a dedicated classification step before your retrieval pipeline executes. It forces the model to make a binary decision—single-hop or multi-hop—and provide a structured rationale. The strict JSON output contract with an enum-constrained dependency_verdict field makes the result trivially parsable by downstream orchestration logic, eliminating the need for fragile regex or intent-parsing on free-text responses.
textYou are a query dependency classifier for a Retrieval-Augmented Generation (RAG) system. Your only job is to analyze a user's question and determine if it can be answered with a single round of retrieval or if it requires a chain of dependent queries where later queries need information from earlier results. ## Input User Question: [USER_QUESTION] Conversation History (last 3 turns): [CONVERSATION_HISTORY] Available Data Sources: [AVAILABLE_DATA_SOURCES] ## Classification Rules - Classify as "multi_hop" if answering the question requires finding one piece of information and then using that result to find another, distinct piece of information. - Classify as "single_hop" if the question can be answered by retrieving documents matching the question's core entities and concepts in one retrieval call. - Multi-hop indicators include: comparisons requiring separate lookups, questions with implicit intermediate entities, temporal sequences where one event depends on another, and questions using superlatives that require finding a set and then filtering. - Do not classify a question as multi-hop simply because it is long or contains multiple clauses. Only classify as multi-hop if there is a genuine dependency chain. ## Output Contract Respond with a single JSON object. No other text. { "dependency_verdict": "single_hop" | "multi_hop", "confidence": 0.0-1.0, "rationale": "A concise explanation of why this verdict was chosen, citing specific phrases from the user question.", "suggested_hop_count": null | integer, "intermediate_entities": null | ["entity1", "entity2"] } ## Constraints - If confidence is below [CONFIDENCE_THRESHOLD], set dependency_verdict to "single_hop" and note the ambiguity in the rationale. - Never invent entities not present or directly implied by the user question. - If the conversation history resolves an ambiguity, reference it in the rationale.
To adapt this template, replace the square-bracket placeholders with your application's runtime values. [USER_QUESTION] is the raw user input. [CONVERSATION_HISTORY] should be a serialized summary of recent turns to resolve anaphora. [AVAILABLE_DATA_SOURCES] is a brief description of your indexes so the model can reason about whether a single retrieval target can satisfy the question. [CONFIDENCE_THRESHOLD] is a critical calibration parameter: start at 0.7 and adjust based on your tolerance for false-positive multi-hop classifications, which add latency and cost. After receiving the JSON response, validate the dependency_verdict enum strictly before routing to your single-hop or multi-hop retrieval pipeline. Log any parse failures and the raw model output for offline threshold tuning.
Prompt Variables
Required and optional inputs for the Multi-Hop Query Dependency Detection Prompt. Validate these before sending the prompt to avoid misclassification and wasted retrieval latency.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[USER_QUESTION] | The raw user question to classify for multi-hop dependency | What was the revenue of the company that acquired our main competitor last year? | Required. Must be a non-empty string. Strip leading/trailing whitespace. Reject inputs under 10 characters or over 2000 tokens as likely malformed. |
[CONVERSATION_HISTORY] | Prior turns in the current session to resolve anaphora and implicit references | User: Who are our top competitors? Assistant: Your top three competitors are Acme Corp, Beta Inc, and Gamma LLC. | Optional. Pass as empty string or null if no history exists. If provided, must be a valid JSON array of message objects with role and content fields. Validate JSON parse before prompt assembly. |
[DOMAIN_CONTEXT] | Brief description of the knowledge domain to calibrate dependency detection | Enterprise B2B SaaS market intelligence database covering acquisitions, revenue, and product lines from 2018-2025. | Optional but recommended. Improves accuracy by grounding the classifier in domain-specific relationship types. Keep under 200 words. Null allowed. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score required to return a definitive SINGLE_HOP or MULTI_HOP verdict | 0.85 | Required. Must be a float between 0.0 and 1.0. Default to 0.80 if not specified. Values below 0.70 produce excessive UNCLEAR verdicts. Values above 0.95 may force false SINGLE_HOP classifications on genuinely ambiguous questions. |
[MAX_HOPS_ESTIMATE] | Upper bound on the number of expected retrieval hops to constrain the dependency analysis | 5 | Optional. Integer between 1 and 10. Defaults to 5 if null. Prevents the model from over-decomposing simple questions. If the question genuinely requires more hops, the model should flag it as EXCEEDS_BOUND rather than truncating. |
[OUTPUT_SCHEMA] | Expected JSON structure for the dependency verdict | {"verdict": "SINGLE_HOP|MULTI_HOP|UNCLEAR", "confidence": 0.92, "rationale": "...", "estimated_hops": 3, "dependency_chain": ["Q1", "Q2", "Q3"]} | Required. Embed the exact schema in the prompt. Validate output against this schema post-generation. Reject responses missing required fields or with verdict values outside the enum. |
[FEW_SHOT_EXAMPLES] | Calibrated examples showing correct SINGLE_HOP, MULTI_HOP, and UNCLEAR classifications | [{"question": "What is Acme's revenue?", "verdict": "SINGLE_HOP", "confidence": 0.97, "rationale": "Direct fact lookup with no intermediate entity required."}] | Optional. Provide 2-4 examples covering each verdict type. Must be valid JSON array. Examples should match the domain context. Stale or off-domain examples degrade accuracy. |
Implementation Harness Notes
How to wire the Multi-Hop Query Dependency Detection Prompt into a production RAG or agent application with validation, routing, and cost controls.
Integrating the dependency detection prompt into an application requires treating it as a pre-retrieval classifier, not a standalone utility. The prompt should be called immediately after user input is received and before any retrieval I/O is initiated. Its output—a binary verdict with a confidence score—acts as a traffic cop: a single-hop verdict routes the original query directly to your standard retrieval pipeline, while a multi-hop verdict triggers a more expensive, latency-sensitive chain-of-queries workflow. The implementation harness must enforce a strict timeout and cost ceiling at this stage because a false-positive multi-hop classification on a simple factual query wastes significant compute and degrades user experience. Wire the prompt into an asynchronous pre-processing step in your query intake service, and ensure the verdict is logged as a structured metadata field on every trace for later analysis.
The core of the harness is a validation and retry layer wrapped around the model call. The expected output is a JSON object with a dependency_verdict enum (single_hop or multi_hop), a confidence float between 0.0 and 1.0, and a rationale string. Implement a post-processing validator that rejects any response where the JSON schema is violated, the confidence score is outside bounds, or the rationale is empty. On validation failure, implement a single retry with a stricter prompt that includes the raw model output and the specific validation error. If the retry also fails, the system should default to the safest behavior for your application's risk profile—typically routing to the more thorough multi-hop path to avoid a false negative that could produce an incomplete answer. Crucially, you must calibrate a CONFIDENCE_THRESHOLD for your domain. Start with a conservative threshold like 0.8 for triggering multi-hop, and monitor the ratio of multi-hop verdicts that result in a single useful retrieval versus those that execute unnecessary chains. Adjust this threshold based on observed latency and cost data, not intuition.
Model choice and tool integration are critical harness decisions. This classification task benefits from fast, cost-effective models. Start with a capable small model like claude-3-haiku or gpt-4o-mini rather than a large frontier model, as the classification logic rarely requires deep reasoning. The prompt should be deployed without access to retrieval tools or external APIs; it relies solely on the user's question text. Log the raw user query, the model's verdict, confidence, and rationale, and the final routed path in a structured format for observability. Connect these logs to your evaluation framework to run regression tests weekly, checking for drift in the classifier's behavior. The next step after implementing this harness is to build a dashboard that tracks the multi-hop activation rate, average latency added by the classification step, and the downstream success rate of multi-hop chains versus single-hop retrievals. Avoid deploying this as a black box; its value is proven only when you can measure and tune the trade-off between answer completeness and system cost.
Expected Output Contract
Fields, types, and validation rules for the Multi-Hop Query Dependency Detection prompt output. Use this contract to parse, validate, and route the model's verdict before executing a retrieval plan.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
dependency_verdict | enum: single_hop | multi_hop | Must be exactly one of the two allowed string values. Reject any other string or null. | |
confidence_score | float (0.0 to 1.0) | Must be a number between 0.0 and 1.0 inclusive. Reject if non-numeric, negative, or >1.0. If missing, treat as 0.0 and flag for review. | |
rationale | string | Must be a non-empty string with at least 20 characters. Reject empty, whitespace-only, or placeholder strings like 'N/A' or 'none'. | |
required_hops | integer | Required when dependency_verdict is multi_hop. Must be an integer >= 2. Reject if present but <2. Ignore or set to null for single_hop verdicts. | |
dependency_type | enum: explicit_entity | implicit_bridge | temporal_chain | comparative | none | Required when dependency_verdict is multi_hop. Must be one of the allowed enum values. Reject unknown types. Set to 'none' for single_hop verdicts. | |
bridge_entity_hint | string or null | If dependency_type is implicit_bridge, must be a non-empty string describing the likely bridge entity. Null allowed for other dependency types. Reject if present but empty for implicit_bridge. | |
suggested_initial_query | string or null | If multi_hop, should contain a suggested first-hop query string. Null allowed. If present, must be non-empty. Reject empty string. | |
processing_notes | array of strings | If present, must be a valid JSON array of strings. Each string must be non-empty. Reject if not an array or if any element is empty. Null allowed. |
Common Failure Modes
Multi-hop dependency detection fails in predictable ways. These are the most common production failure patterns and how to catch them before they waste retrieval rounds.
False-Positive Chain Triggers
What to watch: The prompt classifies a simple, single-hop question as requiring a multi-hop chain. This adds unnecessary latency and cost for questions that could be answered in one retrieval round. Common with questions containing multiple entities that don't actually depend on each other. Guardrail: Calibrate a confidence threshold below which the system defaults to single-hop. Log all chain triggers with their rationale and audit a sample weekly to tune the threshold. Add a 'complexity score' field that gates whether chaining is even considered.
Missed Implicit Dependencies
What to watch: The prompt fails to detect that a question requires chained retrieval because the dependency is implicit rather than explicit. For example, 'What was the revenue impact of the policy change announced by the CEO last quarter?' requires first identifying the CEO, then the policy, then the revenue data—but the dependency chain isn't spelled out. Guardrail: Include few-shot examples that demonstrate implicit dependency detection. Add a pre-check step that asks: 'Does answering this question require knowing something not stated in the question itself?' Log false negatives from user feedback to expand the example set.
Confidence Miscalibration
What to watch: The model outputs high confidence for incorrect dependency verdicts or low confidence for correct ones. This makes threshold-based gating unreliable. Overconfident false positives waste resources; underconfident true positives cause the system to fall back to inadequate single-hop retrieval. Guardrail: Run the prompt against a golden dataset with known dependency labels and plot confidence against accuracy. Adjust the system prompt to anchor confidence language to specific evidence patterns. Use a separate calibration prompt or logit-based scoring if available.
Over-Decomposition of Atomic Questions
What to watch: The prompt decomposes a question that is already atomic into multiple unnecessary sub-queries. This happens when the model interprets any multi-faceted question as multi-hop, even when all facets can be retrieved in parallel from the same index. Guardrail: Add an explicit instruction to distinguish between parallel-retrievable facets and sequentially-dependent hops. Include a 'parallelizable' flag in the output schema. Validate that questions marked as multi-hop actually contain a dependency chain, not just multiple independent retrieval targets.
Entity Resolution Blindness
What to watch: The prompt correctly identifies a dependency chain but fails to recognize that intermediate entities are ambiguous or unresolvable. The chain proceeds with a vague entity reference that produces irrelevant retrieval results downstream. Guardrail: Require the prompt to output specific entity identifiers or canonical names for each hop, not just descriptive phrases. Add a validation step that checks whether each hop's target entity exists in the knowledge base before executing the chain. Flag hops with unresolvable entities for human review.
Context Window Contamination in Session
What to watch: In conversational settings, the prompt misinterprets prior turn context as creating a dependency where none exists. A follow-up question about a different aspect of the same topic gets incorrectly chained to prior retrieval results. Guardrail: Include explicit session-context handling rules in the prompt. Distinguish between 'same topic, new question' and 'dependent follow-up.' Add a turn-boundary marker in the input and instruct the model to evaluate each question's dependency structure independently before considering prior context.
Evaluation Rubric
Use this rubric to evaluate the quality of the Multi-Hop Query Dependency Detection Prompt's output before integrating it into a production RAG pipeline. Each criterion targets a specific failure mode that can cause wasted latency or incorrect retrieval paths.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Dependency Verdict Accuracy | Correctly classifies single-hop vs. multi-hop for 95% of a golden test set of 50 manually labeled queries. | A clearly multi-hop question is classified as single-hop, or a simple lookup is flagged as multi-hop. | Run prompt against a pre-labeled golden dataset. Measure precision, recall, and F1 score for the multi-hop class. |
Confidence Score Calibration | Confidence score correlates with actual correctness. High-confidence predictions are correct >90% of the time. | The model outputs | Plot a calibration curve using the golden dataset. Calculate Expected Calibration Error (ECE). |
Rationale Grounding | The rationale references specific entities or logical operators from [USER_QUESTION] that imply dependency. | The rationale is generic ('it seems complex') or hallucinates a dependency not present in the question. | Human review of 20 random rationales. Check for direct quotes or logical references to the input text. |
False-Positive Chain Trigger Rate | Fewer than 10% of single-hop questions are incorrectly flagged as multi-hop. | Simple questions like 'What is the capital of France?' trigger a multi-hop verdict. | Measure the false-positive rate on a dataset of 100 simple, single-hop questions. |
False-Negative Chain Trigger Rate | Fewer than 5% of true multi-hop questions are missed and classified as single-hop. | A question like 'What is the population of the city where the CEO of the company that made [PRODUCT] was born?' is classified as single-hop. | Measure the false-negative rate on a dataset of 50 complex, manually verified multi-hop questions. |
Output Schema Compliance | The output is valid JSON matching the [OUTPUT_SCHEMA] with all required fields present and correctly typed. | The output is missing the | Automated JSON Schema validation in a test harness. Check field types, required fields, and enum values. |
Latency Budget Adherence | The prompt's classification time is under 500ms for a 200-token question on the target model. | Classification takes over 2 seconds, adding unacceptable latency before retrieval even begins. | Benchmark the prompt's end-to-end response time with 50 varied queries. Calculate p50, p95, and p99 latency. |
Adversarial Robustness | The prompt correctly identifies a single-hop question even when it is phrased to sound complex. | A question like 'After the event that occurred in 1945, what was the resulting geopolitical state?' is misclassified as multi-hop. | Run a set of 10 adversarially phrased single-hop questions. Verify the verdict remains single-hop. |
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 frontier model and relaxed validation. Focus on getting the dependency verdict and rationale correct before adding strict schema enforcement.
code[SYSTEM] You are a query dependency classifier. Analyze the user question and determine if it requires a single retrieval round or a chained sequence of dependent queries. [USER QUESTION] [QUESTION] [OUTPUT] Return JSON with: - dependency_verdict: "single_hop" or "multi_hop" - confidence: 0.0-1.0 - rationale: string
Watch for
- Over-classifying simple comparison questions as multi-hop
- Missing implicit dependencies where one answer requires another
- Confidence scores that don't match rationale quality

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