Planning & Control Flow

Query-Decomposition Agent

An agent whose explicit job is to split an incoming user query into smaller independent sub-queries that can be answered sequentially or in parallel, then merge results.

Problem

Monolithic prompts on multi-part questions collapse into vague aggregates. The model has no scaffold for fanning out and re-joining. Plan-and-Execute helps when the answer requires ordered tool actions, but multi-part questions usually need equivalent leaf sub-queries that are independent and can run in parallel. Without a decomposition-then-aggregate stage, deep-research and complex-QA pipelines produce shallow output proportional to the question's compositional complexity.

Solution

Front the workflow with a decomposer agent whose system prompt asks it to enumerate independent sub-queries that, together, would answer the user's question. Run each sub-query (in parallel or sequence) through the answering agent, RAG retriever, or tool. Pass the leaf answers to an aggregator that composes the final response. Distinct from Plan-and-Execute (ordered actions): decomposition produces equivalent leaves, not a plan.

When to use

  • Questions are compositional (entity × dimension matrices, multi-source comparisons).
  • Sub-queries are usefully independent.
  • Latency budget allows parallel leaf execution.

Open the full interactive page

Diagram, neighbourhood map, code examples, related patterns and full provenance.

Related