Task decomposition and subtask generation
What it is
Task decomposition is splitting a goal into smaller pieces called subtasks. A good subtask is:
- small enough to finish in a few steps;
- checkable: there is a clear way to tell it is done;
- self-contained: it states what it needs and what it produces;
- necessary: removing it would leave the goal unmet.
Why it matters
Large goals overwhelm a model the way they overwhelm a person.
- 'Plan a three-city trip under ₹60,000' is too big to act on. 'Find flights from Pune to Delhi on 4 March under ₹6,000' is not.
- Small subtasks have a higher success rate each, and a failed one can be retried alone.
- A list of subtasks is also something a person can read and correct before any money is spent.
In the real world: A research agent asked to 'assess a competitor' produced a rambling report until its goal was decomposed into five named questions, each with a 'done when' line.
from pydantic import BaseModel
class Subtask(BaseModel):
id: str
description: str # what to do, in one sentence
depends_on: list[str] = [] # ids that must finish first
done_when: str # how to tell it is finished
class Plan(BaseModel):
goal: str
subtasks: list[Subtask]
PLANNER_PROMPT = """Break the goal into the fewest subtasks that fully achieve it.
Each subtask must be doable with the tools listed, checkable, and no larger than
about five tool calls. Give each a 'done_when'. List dependencies by id.
Do not add subtasks the goal did not ask for.
Tools available: {tools}
Goal: {goal}"""Decomposing too finely. Twenty one-line subtasks cost twenty rounds of overhead and lose the thread between them. Split until each piece is doable, then stop.
Practise it: Design a Multi-Agent AI System