A lawyer, a paralegal or a member of the public rarely types only "deposit protection requirements". They describe when they moved in, what they paid, what the landlord did and what happened next. The actual question comes at the end. Sometimes there are two or three questions.

Sending that whole story to a retriever as one query can produce passages about the right topic without covering the issues the person needs answered. A more capable retriever helps, but it does not explicitly separate those issues.

This article explains RAG query planning, also called query decomposition when the task is split into sub-questions. A model first identifies the evidence needs inside the message. Retrieval runs for each need, and a coverage check records what the sources do and do not support before an answer is drafted.

The tenancy story and retrieval outcomes below are illustrative, not a measured benchmark or client case study. Public legal sources are linked for checking. This is an article about retrieval design, not legal advice.

What is query planning in retrieval-augmented generation?

In retrieval-augmented generation (RAG), query planning is a step between understanding a request and searching the knowledge base. Instead of treating a long message as a single search, the planner identifies its separate questions, relevant dates and required evidence. It then prepares a bounded set of retrieval queries.

Query rewriting makes a query clearer. Query expansion adds useful formulations or vocabulary. Query decomposition separates distinct information needs. A narrative legal question may benefit from all three, but they should preserve the user's meaning rather than introduce new assumptions.

Our article on hybrid search and reciprocal rank fusion for legal RAG covers the retrieval layer: keyword search and semantic search run together, their results are fused, and a reranker can refine the shortlist. Planning sits in front of that layer. It is not a replacement for it.

Why can narrative questions weaken embedding retrieval?

A common dense retriever encodes the query into one vector. That representation must capture the useful meaning of the input, including several topics when the input is a story. Its nearest passages may match the general situation without supplying evidence for every sub-question.

An embedding is not necessarily an arithmetic average of topics, and token counts do not translate into proportional influence on its vector. Narrative questions do not always fail either. The outcome depends on the embedding model, corpus, query processing and retrieval settings. The practical risk is incomplete evidence coverage, not a universal mathematical rule.

Conversation history can add further ambiguity. Concatenating every previous turn into a new search query may retain obsolete facts or an earlier topic. A planner should carry forward relevant context while resolving corrections and follow-up references, rather than blindly searching the whole transcript.

The symptom is a fluent answer that cites real passages but addresses only one of the user's questions. A citation-presence check will not catch that omission. The system must also check whether it answered the request.

A legal RAG example: a tenancy deposit story

The following fictional scenario concerns a private tenancy in England beginning in 2024. The applicable tenancy rules and their versions must be checked for the relevant dates; this example does not determine the tenant's legal entitlement.

I moved into a flat in January 2024 and paid a £1,200 deposit. The landlord never sent me anything about where the deposit was held. In June 2024 he said he would keep £400 for a damaged sofa, but the sofa was already damaged when I moved in and I have photos from the first day. I moved out in September 2024 and he has stopped replying to messages. Can I get my deposit back, and can I claim anything on top because he never protected it?

There are two main requested outcomes: recovering the deposit and investigating an additional remedy. The story also contains evidence about a disputed deduction, missing information and an unresponsive landlord. Importantly, not receiving scheme information does not by itself prove that the deposit was unprotected. A safe plan searches for how to check protection rather than turning the user's suspicion into a finding.

Single-query retrieval: a possible failure pattern

Suppose the baseline embeds the full message, runs hybrid search and selects five passages. An illustrative result set might include a deposit overview, a passage about deposit amounts, tenancy-ending guidance and a dispute summary. These are related to the story, but may omit the evidence needed to address a protection breach.

The draft could then discuss deductions without answering the additional-remedy question. This is a failure mode to test, not an observed result claimed for a particular model or knowledge base. A strong single-query baseline may perform well, so it must be included in any evaluation.

Query decomposition: four focused evidence needs

A planner could produce the following searches. The third column describes evidence to seek, not passages that we claim to have retrieved in a test.

Illustrative search plan for the fictional tenancy deposit story
Planned searchUser statement it servesEvidence to seek
Tenancy deposit protection, checking an authorised scheme, prescribed information and the 30-day requirements"Never sent me anything about where the deposit was held"Protection and information duties, plus how to check registration. See GOV.UK on required information and Reading Borough Council's scheme guidance.
Possible court remedies if a landlord failed to comply with deposit protection rules"Can I claim anything on top?"Conditions for a claim and possible remedies, not an assumed award. GOV.UK describes court applications and compensation of up to three times the deposit.
Disputed deposit deductions, pre-existing damage, check-in inventories and dated photographs"The sofa was already damaged ... and I have photos"Applicable deduction rules and evidence requirements. GOV.UK explains scheme dispute resolution and the need for evidence; detailed evidence guidance must also be retrieved if needed.
Deposit recovery after a tenancy ends when the landlord cannot be contacted"I moved out ... and he has stopped replying"The route depends on whether the deposit is protected. GOV.UK distinguishes scheme disputes from possible court recovery.

Each query has a traceable purpose. Keyword retrieval can now search for source vocabulary such as "prescribed information", while semantic retrieval searches for related explanations. Hybrid fusion and reranking operate on each evidence need, and duplicate passages can be removed before drafting.

If the corpus supports deposit recovery but not the additional remedy, the output should say so. It should not silently drop the second question or treat missing retrieval results as proof that no remedy exists.

When should a RAG system plan before searching?

Planning adds work, latency and another opportunity for model error. A focused lookup such as "What information must a landlord give about a deposit?" may go straight to retrieval. A message describing several events and asking for several outcomes is a better candidate for decomposition.

Useful routing signals include multiple requested outcomes, several events or dates, unresolved references to earlier turns, and explicit requests to compare sources. Length alone is not enough: a short question can need several documents, and a long quotation may need only one lookup.

A classifier or rule-based gate can make the routing decision. Measure its overhead too: even a gate that skips planning may still add latency. If the gate sends a complex question straight to retrieval, the subsequent coverage check may detect the omission, but that check can fail as well.

Two constraints keep the planner focused:

A bounded search-planning and evidence-coverage workflow

The supplied implementation diagram names the planning and drafting component Luna and the retrieval component Masih. Its database label records a snapshot of 85,807 shared chunks. That implementation-specific count is not a benchmark result, a quality score or a claim that every chunk is accessible to every user.

RAG query planning workflow: route a question and conversation history to direct retrieval or focused searches, retrieve with keyword and semantic search, check evidence coverage, allow one recovery round, select up to eight sources, draft a cited answer, check citations with one repair pass, then return a complete or partial answer or explain insufficient sources.
Search planning, hybrid retrieval, per-question coverage and bounded recovery. The component names, source cap and corpus snapshot belong to this implementation. Open the full-size diagram.

The steps matter more than the component names. This is the proposed control flow, not evidence that a model will follow every instruction correctly.

  1. Check evidence coverage per question. Assess each evidence need as supported, partial or missing. "Supported" must refer to the requested fact and its conditions, not merely to a passage on the same topic. Keep the relevant source references for review.
  2. Allow one recovery round, then stop. Refine missing or partial searches using what the first retrieval revealed. In the illustrated design, recovery is bounded to one round. If support remains inadequate, preserve that gap in the answer.
  3. Select passages for coverage. Deduplicate results and choose evidence across the planned questions, not only the highest similarity scores. The diagram caps selected sources at eight; a separate context-token budget is still required because source lengths differ.
  4. Draft with citations, or quote when appropriate. Instruct the drafting model to use the selected evidence, attach source references and distinguish facts from assumptions. If the user requests exact statutory wording, use the verified source text and version rather than presenting a paraphrase as a quotation. Access and reuse restrictions still apply.
  5. Check citations and allow one repair pass. Check that cited passages support the associated claims, that source identifiers actually came from retrieval and that the answer is internally consistent. Independent model checks can still be wrong. Remove or qualify unsupported material that remains after repair; human review is needed for consequential use.

The output may be complete, partial with explicit gaps, or a statement that the available sources are insufficient. An inability to answer safely is useful information, especially in legal document processing and cited search.

Retry caps alone do not impose a fixed cost or latency ceiling. A bounded implementation also needs limits on query count, input and output tokens, retrieval candidates, concurrency and total execution time. If a timeout is reached, return a clear status instead of silently extending the loop.

What query planning does not solve

Retrieval quality for each sub-question

A clear plan can still feed a weak retriever. Chunk boundaries, hybrid search, fusion and reranking must be evaluated on the actual documents. Planning may simply produce several misses instead of one. The legal hybrid-search article explains these complementary controls.

Temporal validity and changing law

The right topic in the wrong version can still produce the wrong answer. Retain source versions, effective dates and jurisdiction metadata, and apply the relevant filters to each search. A date in the user's story is a fact to interpret, not automatically the effective date of every legal rule. Ask for clarification where that distinction changes the answer.

Planner drift and prompt injection

A planner can introduce an issue the user never raised, overinterpret a missing detail or mistake quoted material for instructions. Keep user and retrieved text separate from system instructions, restrict tool access, and treat retrieved passages as evidence rather than authority to change the workflow. Showing concise planned searches can make drift visible without exposing hidden model reasoning.

Permissions and source boundaries

Multiple queries create multiple chances to cross an access boundary. Enforce permissions within every retrieval and recovery call, before unauthorised content enters the candidate pool. Source-completion or neighbouring-passage expansion must preserve those same controls. Planning must not bypass the security and governance rules used by direct search.

How to evaluate RAG query decomposition fairly

Build a reviewed set of identifier lookups, conceptual questions and narrative questions. For each narrative, have a suitably qualified reviewer mark the separate information needs, acceptable evidence and important conditions. Around 50 varied stories can be a practical starting set, not a statistically justified minimum or a sufficient release criterion on its own.

Compare a credible single-query baseline with the planned version using the same corpus snapshot, permission rules and source versions. Report the embedding and generation models, retrieval settings and test date. A study of question decomposition for RAG by Ammann, Golde and Akbik examines decomposition and reranking on multi-hop benchmarks. Its results motivate testing the approach; they are not validation of this tenancy example or this implementation.

Re-run the evaluation when prompts, models, embeddings, chunking or the corpus change. Keep difficult and failed examples, and avoid publishing a single improvement percentage without its baseline, sample size and budget. This article reports a design and an evaluation method; it does not report measured performance gains.

What buyers should ask in a legal RAG demonstration

Do not test only tidy questions. Supply a realistic, anonymised story containing several facts and at least two requested outcomes. Then ask:

A narrative query is not an unusual edge case. It is how many people describe document problems. RAG development should therefore evaluate how the system turns that description into evidence needs, not only how well it answers a prepared search phrase.

Related reading

Sources and example notes

Sources checked on 5 November 2026. The story, search plan and possible retrieval outcomes are illustrative and contain no client data. The supplied workflow diagram documents an implementation design, not a comparative test. Legal applicability depends on facts, dates and jurisdiction; obtain qualified advice before acting on a legal conclusion.