Decomposed Prompting (DecomP)
Break complex tasks into specialized sub-procedures, routing each sub-problem to its ideal solver.
Decomposed Prompting was introduced by Tushar Khot et al. at Carnegie Mellon and the Allen Institute for AI. The paper demonstrated that complex tasks benefit from decomposition into sub-tasks, each handled by a purpose-built sub-procedure—whether that’s an LLM prompt, a retrieval function, or a code executor. This insight became a foundational pattern in modern agentic AI systems like LangChain, AutoGen, and CrewAI.
Not All Sub-Problems Are Created Equal
Think of a hospital emergency room. A patient arrives with multiple symptoms—the triage nurse doesn’t try to treat everything herself. She routes the broken arm to orthopedics, the allergic reaction to immunology, and the paperwork to administration. Each specialist uses different tools and expertise.
Decomposed Prompting works the same way. Instead of forcing a single LLM prompt to handle an entire complex task, DecomP breaks it into sub-tasks and assigns each one to the most appropriate handler. Some sub-tasks need factual retrieval, others need mathematical calculation, others need multi-step reasoning, and others need code execution.
Least-to-Most decomposes a problem and solves sub-tasks sequentially, always using the same LLM approach for every step.
DecomP goes further: each sub-task is routed to a specialized handler—one might use retrieval, another might use code execution, another might use a different prompt template entirely.
Why It Works
Specialization
Each sub-prompt handles one specific task using the most appropriate tool or strategy. A retrieval handler fetches facts, a calculator crunches numbers, and a reasoning prompt draws conclusions — each operating in its zone of strength.
Modularity
Sub-procedures are self-contained components that can be mixed, matched, and reused across different tasks. Swap out a retrieval handler for a code executor without changing the rest of the pipeline — each module has a clean interface.
Error Isolation
Failures in one sub-task do not cascade to others. If the data lookup returns an error, the biographical facts remain intact. Each sub-procedure succeeds or fails independently, making debugging straightforward and results more reliable.
How DecomP Works
Follow a running example: “Who invented the telephone, and what was the GDP of their birth country in the year they died?”
Analyze the Task
Examine the question to identify its composite nature. This question requires biographical facts, geographic knowledge, historical economic data, and temporal reasoning—no single prompt can handle all of these reliably.
Identify Sub-Tasks
Break the question into discrete sub-problems: (a) Who invented the telephone? (b) Where were they born? (c) When did they die? (d) What was the GDP of their birth country in that year?
Assign Specialized Handlers
Route each sub-task to its ideal solver: (a) and (b) go to a retrieval sub-procedure for factual lookup. (c) goes to retrieval as well. (d) requires a data lookup sub-procedure that can query economic databases or structured datasets.
Execute Sub-Procedures
Run each handler: (a) Alexander Graham Bell. (b) Edinburgh, Scotland—part of the United Kingdom. (c) Died in 1922. (d) UK GDP in 1922 was approximately £5.5 billion (nominal).
Integrate Results
A final integration step combines all sub-answers into a coherent response: “Alexander Graham Bell invented the telephone. He was born in Edinburgh, Scotland (UK) and died in 1922. The GDP of the United Kingdom in 1922 was approximately £5.5 billion.”
See the Difference
Monolithic Prompt
“Tell me who invented the telephone, where they were born, when they died, and what the GDP of their birth country was in their death year.”
Model may hallucinate GDP figures. No verification of individual facts. Failure in one part corrupts the whole answer.
DecomP Approach
Break into 4 sub-tasks, each with a specialized handler for retrieval, lookup, or reasoning.
Each sub-task uses the right tool. GDP retrieved from reliable data source. Each fact independently verifiable. Failure is isolated to one sub-task.
DecomP in Action
“Who invented the telephone, and what was the GDP of their birth country in the year they died?”
Sub-task 1 (Retrieval): Who invented the telephone? → Alexander Graham Bell
Sub-task 2 (Retrieval): Where was Bell born? → Edinburgh, Scotland (UK)
Sub-task 3 (Retrieval): When did Bell die? → 1922
Sub-task 4 (Data Lookup): UK GDP in 1922? → Approximately £5.5 billion
Integration: “Alexander Graham Bell invented the telephone. Born in Edinburgh, Scotland (UK), he died in 1922. The UK’s GDP that year was approximately £5.5 billion.”
“Compare our Q3 sales performance across all regions, identify the top-performing product category, and project Q4 targets based on historical trends.”
Sub-task 1 (Data Retrieval): Pull Q3 sales data by region → Returns structured dataset
Sub-task 2 (Calculation): Compute regional comparisons, growth rates → North America +12%, EMEA +8%, APAC +15%
Sub-task 3 (Aggregation): Identify top product category → Cloud Services at 34% of revenue
Sub-task 4 (Code Execution): Run time-series projection model → Q4 projected targets by region
Integration: Synthesize findings into executive summary with regional breakdown, category winner, and Q4 projections.
“Our API is returning 500 errors intermittently. Diagnose the issue and recommend a fix.”
Sub-task 1 (Log Analysis): Parse error logs → Errors correlate with high-traffic windows, stack traces point to connection pool exhaustion
Sub-task 2 (Code Review): Examine connection management code → Pool max set to 10, no timeout configured
Sub-task 3 (Reasoning): Correlate findings—pool too small, leaked connections not reclaimed → Root cause: pool exhaustion under load
Sub-task 4 (Retrieval): Look up best practices for pool configuration → Recommended pool size formula, timeout settings
Integration: “Root cause: connection pool exhaustion. Increase pool to 50, add 30s idle timeout, implement health checks, add monitoring.”
When to Use DecomP
Perfect For
- Multi-Tool Workflows — Tasks requiring different capabilities: retrieval, calculation, code execution, and reasoning working together.
- Multi-Hop Reasoning — Questions where the answer to one sub-question feeds into the next, and each hop may need a different solving strategy.
- Agent Architecture Design — Building AI systems where specialized modules handle different responsibilities, following the DecomP pattern at a systems level.
- Accuracy-Critical Tasks — Scenarios where you cannot afford hallucinated facts—decomposition lets you verify each sub-answer independently.
Skip It When
- Simple, Single-Step Tasks — If the question can be answered directly without decomposition, DecomP adds unnecessary overhead.
- Latency-Sensitive Applications — Each sub-procedure adds a round-trip. If speed matters more than accuracy, a single well-crafted prompt may be preferable.
- No Specialized Tools Available — DecomP’s power comes from routing to different handlers. If every sub-task would use the same generic LLM call, Least-to-Most may be simpler.
Real-World Use Cases
Research Automation
Decompose literature reviews into search, filtering, extraction, and synthesis sub-tasks. Each phase uses the right tool—search APIs for discovery, NLP for extraction, LLMs for synthesis.
Software Engineering
Break feature requests into requirements analysis, architecture design, code generation, testing, and review—each handled by a specialized agent or tool.
Financial Analysis
Route market data retrieval to APIs, numerical analysis to code execution, regulatory checks to document search, and narrative generation to LLMs.
Medical Diagnostics
Decompose diagnostic reasoning into symptom extraction, differential diagnosis generation, evidence retrieval from medical literature, and treatment recommendation—each with appropriate safeguards.
Legal Due Diligence
Split contract review into clause extraction, risk identification, precedent search, and compliance checking—with document retrieval handling the knowledge-intensive parts.
Customer Support Agents
Decompose support tickets into intent classification, account lookup, knowledge base search, and response generation—each sub-task optimized for speed and accuracy.
Where DecomP Fits
Decomposed Prompting builds on earlier decomposition methods and directly inspired the agentic AI architectures that followed.
DecomP's core idea — breaking tasks into sub-procedures with specialized handlers — is exactly the architecture used by modern AI agent frameworks. When LangChain chains together tools, when AutoGen coordinates specialist agents, or when CrewAI assigns roles to team members, they are implementing the DecomP pattern at scale.
Related Techniques
Explore complementary decomposition techniques
Design Smarter Workflows
Use the Prompt Builder to create decomposed prompts that route sub-tasks to specialized handlers, or explore all frameworks in the AI History hub.