This prompt is for architects and infrastructure engineers designing heterogeneous retrieval systems who need to map a user's query requirements to the most capable backend configuration. The job-to-be-done is not to rewrite a query, but to analyze the capabilities of available backends—dense vectors, sparse keyword indexes, graph traversals—and produce a reasoned plan for which backend or combination of backends should serve a given query. Use this when you have multiple live indexes with different strengths and you need an automated dispatch layer that understands each backend's schema, performance profile, and constraints before a single retrieval call is made.
Prompt
Retrieval Backend Capability Analysis Prompt for Query Planning

When to Use This Prompt
Define the job, reader, and constraints for the Retrieval Backend Capability Analysis Prompt.
The ideal user is a technical decision maker or platform engineer who already has a catalog of backend capabilities (e.g., 'dense index supports semantic similarity but not exact term matching', 'graph index supports 2-hop traversals on entity relationships', 'sparse index supports BM25 with field-level boosting'). You must supply this capability catalog as part of the [BACKEND_CAPABILITIES] input. The prompt is not a substitute for a vector database or a search engine; it is a reasoning layer that sits before retrieval to prevent wasted compute and bad results from sending queries to the wrong index. Do not use this prompt when you have a single backend, when you lack a formal capability specification, or when the query type is already statically routed by a rule-based classifier.
This prompt is high-risk in production because a capability mismatch can silently degrade retrieval quality. A query that requires exact entity matching sent to a dense embedding index will return semantically related but factually wrong documents. Always pair this prompt's output with validation checks: confirm that the recommended backend actually exists in your infrastructure, that its schema supports the required query shape, and that the capability claims in the plan match the backend's documented features. For regulated or high-stakes domains, require human review of the capability mapping before the plan is executed, and log every dispatch decision with the rationale for auditability.
Use Case Fit
This prompt analyzes backend capabilities and maps query requirements to the optimal configuration. It is a design-time tool for architects, not a runtime component.
Good Fit: Heterogeneous Index Design
Use when: You are designing a new retrieval system with multiple backend types (dense, sparse, graph) and need to map query patterns to the right index. Guardrail: Run this analysis before writing pipeline code to prevent architectural dead-ends where a critical query type cannot be served by any available backend.
Good Fit: Capability Gap Discovery
Use when: An existing retrieval pipeline fails for specific query categories and you need to identify which backend capability is missing. Guardrail: Pair the output with a concrete migration plan. The prompt identifies the gap; engineering must decide whether to add a new index, rewrite queries, or adjust user expectations.
Bad Fit: Runtime Query Dispatch
Avoid when: You need a low-latency classifier to route live user queries to backends. This prompt is analytical and verbose, not optimized for production dispatch. Guardrail: Use a dedicated classification router prompt or a lightweight model for runtime decisions. Reserve this analysis for offline architecture reviews.
Bad Fit: Single-Backend Systems
Avoid when: Your system uses only one retrieval backend (e.g., a single vector database). The capability mapping exercise adds overhead without actionable alternatives. Guardrail: If you only have one index, focus on query rewriting prompts specific to that backend type rather than multi-backend analysis.
Required Inputs: Backend Inventory and Query Taxonomy
What to watch: The prompt cannot analyze capabilities without a concrete description of available backends, their schemas, and the query types your system must handle. Guardrail: Provide a structured inventory of each backend's strengths, limitations, latency profile, and supported query operations. Include a taxonomy of expected user intents.
Operational Risk: Stale Capability Assumptions
What to watch: Backend capabilities evolve as you upgrade indexes, change embedding models, or add features. An analysis from six months ago may recommend configurations that no longer reflect reality. Guardrail: Version this analysis alongside your infrastructure-as-code. Re-run whenever a backend migration, model upgrade, or schema change occurs.
Copy-Ready Prompt Template
A reusable prompt for analyzing retrieval backend capabilities and mapping query requirements to the optimal backend configuration.
This prompt template is designed for architects and infrastructure engineers who need to systematically evaluate available retrieval backends—dense vectors, sparse keywords, graph traversals, and hybrid indexes—against the specific requirements of a user query. Rather than guessing which backend to use, this prompt forces the model to reason about each backend's strengths, limitations, and schema constraints before producing a concrete query plan. The output is a structured capability-to-requirement mapping that can be consumed by an orchestration layer or reviewed by a human before execution.
textYou are a retrieval architecture analyst. Your job is to evaluate available retrieval backends against a user query and produce a query plan that maps requirements to the most capable backend configuration. ## AVAILABLE BACKENDS [BACKEND_CATALOG] ## USER QUERY [USER_QUERY] ## QUERY CONTEXT - User role: [USER_ROLE] - Session history summary: [SESSION_CONTEXT] - Known constraints: [CONSTRAINTS] ## OUTPUT SCHEMA Return a JSON object with this structure: { "query_analysis": { "intent": "string", "required_capabilities": ["semantic_similarity", "exact_term_match", "graph_traversal", "temporal_range", "metadata_filtering"], "complexity": "simple | compound | multi_hop", "precision_recall_profile": "high_precision | high_recall | balanced" }, "backend_assessments": [ { "backend_id": "string", "backend_type": "dense_vector | sparse_keyword | graph | hybrid", "capability_match_score": 0.0-1.0, "matched_capabilities": ["string"], "missing_capabilities": ["string"], "schema_constraints": ["string"], "recommended": true | false, "rationale": "string" } ], "recommended_plan": { "primary_backend": "backend_id", "fallback_backends": ["backend_id"], "parallel_backends": ["backend_id"], "execution_order": ["backend_id"], "query_variants": { "backend_id": "reformulated query string" }, "fusion_strategy": "reciprocal_rank | weighted_score | round_robin | none", "confidence": 0.0-1.0, "risks": ["string"] } } ## ANALYSIS RULES 1. Evaluate every backend in the catalog against the query's required capabilities. 2. Do not recommend a backend that lacks a required capability unless no backend satisfies it. 3. Flag schema mismatches explicitly—if a backend requires metadata filters the query cannot provide, mark it as a constraint violation. 4. For multi-hop queries, specify execution order and dependency between backends. 5. If confidence is below 0.7, include a human_review_required flag and explain what information is missing. 6. Prefer parallel execution when backends are independent; prefer sequential when one backend's output feeds another. ## CONSTRAINTS [CONSTRAINTS] ## EXAMPLES [EXAMPLES]
To adapt this template, replace [BACKEND_CATALOG] with a structured description of each available backend, including its type, schema, supported query operations, and known limitations. The [USER_QUERY] placeholder accepts the raw user question, while [SESSION_CONTEXT] should contain a brief summary of prior turns if available. The [CONSTRAINTS] field is where you inject latency budgets, cost limits, or access-control rules. The [EXAMPLES] placeholder should contain one or two worked examples showing correct capability-to-backend mappings for your domain. After generating the plan, validate the output against your actual backend schemas before routing queries—the model may hallucinate capabilities that don't exist. For production use, add a post-generation validation step that checks every backend_id against a real registry and rejects plans referencing unavailable backends.
Prompt Variables
Required inputs for the Retrieval Backend Capability Analysis Prompt. Each placeholder must be populated before the prompt is sent. Validation notes describe how to confirm the input is well-formed before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[BACKEND_CATALOG] | Structured description of available retrieval backends, their capabilities, schemas, and performance characteristics | {"backends":[{"id":"dense_v1","type":"vector","embedding_model":"text-embedding-3-large","dimensions":3072,"supports_metadata_filter":true,"latency_p50_ms":45,"max_results":100}]} | Must be valid JSON with required fields: id, type, supports_metadata_filter. Type must be one of: vector, keyword, graph, hybrid. Reject if any backend lacks an id field. |
[USER_QUERY] | The raw natural language question or search request from the end user | Find me internal security audit reports from Q3 2024 that mention access control failures in the payment system | Non-empty string. Must be between 1 and 2000 characters. Reject if only whitespace or contains only stop words. Log a warning if query length exceeds 500 characters as it may indicate multi-part questions that need decomposition. |
[QUERY_INTENT] | Classified intent of the user query to guide backend capability matching | factual_retrieval_with_temporal_and_entity_constraints | Must be a non-empty string. Recommended enum values: factual_retrieval, summarization, comparison, procedural, temporal_retrieval, entity_lookup, multi_hop. If null, the prompt should infer intent from [USER_QUERY] but this increases failure risk. |
[RETRIEVAL_CONSTRAINTS] | Operational constraints that limit which backends can be used or how they must be configured | {"max_latency_ms":200,"required_freshness":"last_90_days","access_scope":"internal_audit","min_precision":0.85} | Must be valid JSON or null. If provided, validate that max_latency_ms is a positive integer, required_freshness is a recognized interval, and access_scope is a non-empty string. Null means no explicit constraints beyond backend defaults. |
[PREFERRED_STRATEGY] | Optional hint about the desired retrieval approach to bias capability matching | hybrid_dense_sparse_with_metadata_filter | String or null. If provided, must match one of: dense_only, sparse_only, graph_only, hybrid_dense_sparse, hybrid_all, auto. Null means the prompt should determine strategy from capabilities and constraints. Validate against known strategy labels. |
[OUTPUT_SCHEMA] | Expected structure for the capability analysis output including backend assignments and rationale | {"selected_backends":["string"],"query_plan":{"backend_id":{"query_formulation":"string","confidence":0.0}},"excluded_backends":["string"],"rationale":"string"} | Must be valid JSON schema definition. Required top-level fields: selected_backends, query_plan, excluded_backends, rationale. Reject if schema lacks required fields. The prompt will populate instances matching this schema. |
[CAPABILITY_MATCHING_RULES] | Explicit rules for how to match query requirements to backend capabilities, overriding model defaults | Prefer vector backends for semantic similarity. Require metadata filter support for temporal constraints. Exclude backends with p95 latency above max_latency_ms constraint. | String or null. If provided, must be non-empty and contain at least one explicit matching directive. Null means the model should infer matching logic from the catalog. Validate that rules reference actual backend capability fields from [BACKEND_CATALOG]. |
Implementation Harness Notes
How to wire the Retrieval Backend Capability Analysis prompt into a query planning application with validation, retries, and logging.
This prompt is designed to sit inside a query planning service that runs before retrieval execution. It should be called when the system needs to decide which backends (dense vector, sparse keyword, graph, hybrid) are capable of answering a given user query, given the available indexes and their documented capabilities. The prompt is not a real-time retrieval step—it is a planning step that produces a capability-to-requirement mapping used by downstream orchestrators to route queries and select backends. Expect to run this prompt once per query type or per new backend configuration, not per user request, unless backend capabilities change dynamically.
Integration pattern: Wrap the prompt in a service function that accepts a [BACKEND_CAPABILITY_MANIFEST] (a structured description of each available backend, its index type, supported operations, latency profile, and schema constraints) and a [QUERY_REQUIREMENTS] object (the user's question plus any extracted constraints like time ranges, entity types, or expected answer format). The function should call the LLM, parse the JSON output against a strict schema that includes backend_assignments, capability_gaps, and confidence_scores, and validate that every assigned backend actually exists in the input manifest. Model choice: Use a model with strong JSON-following behavior and reasoning capabilities—GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro are appropriate. Avoid smaller models for this task because capability reasoning requires holding the full manifest in context and making non-obvious trade-off decisions.
Validation and retry logic: After parsing the LLM output, run a validator that checks: (1) all backend_id values match an entry in the input manifest, (2) no backend is assigned a query requirement that its manifest explicitly marks as unsupported, (3) every required query capability has at least one backend assigned, and (4) capability_gaps entries are non-empty only when genuine gaps exist. If validation fails, construct a retry prompt that includes the original input, the invalid output, and a specific error message describing which validation rule failed. Retry once. If the second attempt also fails, log the failure, fall back to a default routing rule (e.g., send all queries to the most general-purpose backend), and alert the operations team. Logging: Log the full prompt input, output, validation result, and any retry attempts to your observability platform. Tag logs with prompt_id, backend_manifest_version, and query_fingerprint for traceability.
Human review gates: For production systems where backend misrouting causes user-visible failures, add a human review step when the prompt reports confidence_score below a threshold (e.g., < 0.7) or when capability_gaps contains entries that affect critical query types. The review interface should show the user query, the capability manifest, the model's assignment, and the gap explanation side by side. What to avoid: Do not call this prompt on every user query in a high-throughput system—cache capability assignments by query pattern or intent class. Do not use this prompt to generate actual retrieval queries; it produces backend assignments, not query strings. Downstream rewriters handle query formulation per backend. Finally, keep the backend capability manifest updated whenever indexes change, or the prompt will make decisions based on stale information.
Expected Output Contract
Defines the structure, types, and validation rules for the JSON object returned by the Retrieval Backend Capability Analysis prompt. Use this contract to parse the model's response and validate it before routing queries in a production pipeline.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
analysis_id | string (UUID v4) | Must match regex for UUID v4 format. Reject if missing or malformed. | |
query_intent | string | Must be one of the predefined enum values: 'factual_lookup', 'summarization', 'comparison', 'procedural', 'entity_resolution'. Reject unknown values. | |
required_capabilities | array of strings | Each element must be a non-empty string from the allowed capability list: 'dense_vector_search', 'sparse_keyword_search', 'graph_traversal', 'metadata_filtering', 'temporal_range_search'. Array must not be empty. | |
backend_recommendation | object | Must contain a 'primary' key with a valid backend name string. Optional 'fallback' key must be a valid backend name or null. Reject if 'primary' is missing or invalid. | |
query_plan | array of objects | Each object must have 'backend' (string), 'query_variant' (string, non-empty), and 'weight' (number, 0.0-1.0) fields. Sum of all weights must be 1.0. Array must contain at least one object. | |
constraint_analysis | object | Must contain 'identified_constraints' (array of strings) and 'unmet_constraints' (array of strings). Both arrays can be empty but must be present. Reject if either key is missing. | |
confidence_score | number | Must be a float between 0.0 and 1.0 inclusive. Reject if outside this range or not a number. | |
rationale_summary | string | Must be a non-empty string with a minimum length of 20 characters. Reject if too short, indicating a likely generation failure. |
Common Failure Modes
When a prompt analyzes backend capabilities and maps query requirements, these failures surface first. Each card identifies a specific breakage pattern and the guardrail that prevents it in production.
Capability Hallucination
What to watch: The model invents backend capabilities that don't exist—claiming a dense index supports exact-match filtering or a keyword index handles semantic similarity. This happens when the prompt lacks an explicit capability inventory. Guardrail: Provide a hardcoded capability matrix as part of [CONTEXT] and instruct the model to only select from listed capabilities. Add a post-generation validator that rejects any capability not present in the source inventory.
Constraint Blindness
What to watch: The model ignores latency budgets, index size limits, or freshness requirements when mapping queries to backends. It recommends a graph traversal for a 50ms SLA or a real-time vector index for a weekly batch report. Guardrail: Include explicit [CONSTRAINTS] with quantifiable limits (latency_ms, staleness_tolerance, cost_budget) and require the model to justify each backend assignment against every constraint. Flag outputs where any constraint is unaddressed.
Over-Fitting to One Backend Type
What to watch: The model defaults to recommending dense vector search for every query, ignoring cases where exact keyword matching, structured filtering, or graph traversal would be superior. This bias often comes from training data over-representation. Guardrail: Require the prompt to produce a comparative rationale for at least two backend types per query before selecting the primary recommendation. Add eval checks that measure backend-type diversity across a test suite.
Schema Mismatch Between Query and Backend
What to watch: The model generates a query shape that the target backend cannot execute—a dense embedding query sent to a BM25 index, or a graph pattern that references nonexistent relationship types. Guardrail: Supply each backend's [INDEX_SCHEMA] including field names, types, and supported operations. Add a structural validator that checks generated queries against the target schema before execution. Reject and retry on mismatch.
Missing Fallback Path When No Backend Fits
What to watch: The model forces a backend assignment even when no available backend adequately serves the query requirements, producing a low-confidence recommendation that silently degrades retrieval quality. Guardrail: Include an explicit 'no-suitable-backend' output option with required justification. When confidence scores fall below a threshold, route to a human reviewer or a degraded-mode response rather than executing a poor match.
Capability Drift Across Model Versions
What to watch: A prompt that reliably maps queries to backends on one model version produces different capability assessments after a model upgrade, breaking downstream routing logic. Guardrail: Pin capability definitions in the prompt rather than relying on model knowledge. Maintain a regression test suite of query-to-backend mappings and run it against every model version change. Flag any output divergence above a tolerance threshold for review.
Evaluation Rubric
Use this rubric to test the Retrieval Backend Capability Analysis Prompt before shipping. Each criterion targets a specific failure mode in capability mapping, constraint awareness, or output structure. Run these checks against a golden dataset of heterogeneous backend configurations and query requirements.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Capability-to-Backend Mapping Accuracy | Every required capability in [QUERY_REQUIREMENTS] maps to at least one backend in [BACKEND_CATALOG] that actually supports it | Output assigns a capability to a backend that lacks it in the catalog, or omits a required capability entirely | Parse output JSON. For each capability in the input requirements, verify the assigned backend's capabilities list in the catalog includes it. Flag missing or unsupported assignments. |
Constraint Satisfaction | All explicit constraints in [CONSTRAINTS] are respected in the final backend configuration | Output violates a stated constraint such as latency budget, cost limit, or required index type | Extract constraints from input. For each constraint, check the output configuration against it. Latency: sum backend p99 latencies. Cost: sum estimated query costs. Index type: verify backend type matches requirement. |
Schema Compliance | Output matches [OUTPUT_SCHEMA] exactly with all required fields present and correctly typed | Missing required fields, wrong types, or extra fields not in schema | Validate output against the JSON schema. Check field presence, types, enums, and nested object structure. Reject on schema violation. |
Backend Selection Justification | Each selected backend includes a non-empty justification field that references specific capabilities from the catalog | Justification is missing, generic, or hallucinates capabilities not present in the backend catalog | For each backend in output, extract justification text. Verify it references at least one capability name that exists in that backend's catalog entry. Flag empty or hallucinated justifications. |
Fallback and Degradation Handling | When no single backend satisfies all requirements, output proposes a valid multi-backend composition or explicitly states the gap | Output selects an incapable backend without noting the gap, or fails to propose a composition when needed | Check if any single backend satisfies all requirements. If not, verify output either proposes a multi-backend plan with coverage justification or includes a gap_statement field explaining what is missing. |
Query Type to Backend Type Alignment | Dense vector requirements map to dense-capable backends, keyword requirements to sparse-capable backends, graph requirements to graph-capable backends | Output assigns a semantic similarity requirement to a BM25-only backend, or a graph traversal requirement to a vector-only backend | Classify each requirement by type. Cross-reference assigned backends against their index types in the catalog. Flag type mismatches. |
Output Determinism Under Identical Inputs | Same [BACKEND_CATALOG] and [QUERY_REQUIREMENTS] produce identical backend selection and configuration across 3 runs with temperature=0 | Backend selections, ordering, or capability assignments change between runs | Run the prompt 3 times with identical inputs and temperature=0. Compare output JSONs. Flag any difference in backend IDs, capability assignments, or configuration parameters. |
Edge Case: Empty or Minimal Backend Catalog | When [BACKEND_CATALOG] contains zero or one backend, output either selects the available backend with noted gaps or returns an empty plan with explanation | Output hallucinates backends not in catalog, crashes, or produces invalid JSON | Test with catalog containing 0 backends and 1 backend. Verify output is valid JSON, contains only catalog backends, and includes gap_statement when requirements cannot be met. |
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 backend description and a simplified capability schema. Drop the constraint-awareness scoring and focus on getting a readable capability map. Replace the full [BACKEND_CATALOG] with a short list of 2-3 backends described in plain text. Remove the [CONSTRAINT_BUDGET] placeholder and ask for a simple ranked recommendation instead.
Watch for
- The model inventing capabilities that aren't in your backend descriptions
- Overly confident recommendations without noting gaps
- Missing the distinction between what a backend can do and what it does well

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