Task Decomposition
Intent
Break a complex goal into smaller, manageable subtasks that can be tackled independently.
Problem
Large, open-ended tasks overwhelm LLMs. 'Build me a website' is too vague and complex for a single prompt. The agent needs to understand what 'done' looks like and break the work into chunks small enough to execute reliably.
Solution
The agent (or a dedicated decomposition step) takes a high-level goal and produces a list of atomic subtasks. Each subtask should be self-contained enough that it can be executed and verified independently. The decomposition can be hierarchical: high-level goals β sub-goals β individual tasks. Good decomposition is the single most important factor in agent success. Poorly decomposed tasks lead to confusion, duplication, and missed requirements.
Diagram
"Build a todo app"
β [Decompose]
βββ Set up project structure
βββ Design data model
βββ Implement CRUD API
β βββ Create endpoint
β βββ Read endpoint
β βββ Update endpoint
β βββ Delete endpoint
βββ Build UI components
βββ Add testsWhen to Use
- Any complex task that can't be done in a single LLM call
- When you need to track progress on a large project
- When subtasks can be delegated to different agents or workers
- When you need human review of the work breakdown before execution
When NOT to Use
- Simple, atomic tasks that are already small enough
- Tasks where decomposition adds overhead without benefit
Pros & Cons
Pros
- Makes large tasks tractable
- Enables parallel execution of independent subtasks
- Progress is trackable and measurable
- Subtasks can be delegated to specialized agents
Cons
- Decomposition quality varies β bad splits waste effort
- May miss cross-cutting concerns that span subtasks
- Overhead for simple tasks
- Subtask dependencies can be hard to identify
Implementation Steps
- 1Provide the agent with the high-level goal and relevant context
- 2Prompt it to produce a structured list of subtasks
- 3Validate: are subtasks atomic, independent, and verifiable?
- 4Identify dependencies between subtasks
- 5Execute subtasks in dependency order (or parallel where independent)
- 6Verify each subtask's completion before marking done
Real-World Example
Feature Implementation
Goal: 'Add dark mode to the app.' Decomposed into: 1) Define color palette for dark theme, 2) Create theme context/provider, 3) Update base components to use theme tokens, 4) Add toggle component, 5) Persist user preference, 6) Test in both themes.
Break down this goal into atomic, executable subtasks.
Goal: {user_goal}
For each subtask, provide:
- id: unique identifier (task_1, task_2, ...)
- description: clear, actionable description
- dependencies: list of task IDs that must complete first
- complexity: low | medium | high
Rules:
- Each subtask must be independently verifiable
- Dependencies must form a DAG (no cycles)
- Order subtasks by logical execution sequence
Output as JSON:
{
"subtasks": [
{"id": "task_1", "description": "...", "dependencies": [], "complexity": "low"},
{"id": "task_2", "description": "...", "dependencies": ["task_1"], "complexity": "medium"}
]
}