Sub-Task Decomposition Patterns
The Challenge of Complex Tasks
When a user says "build me a REST API for user management," that's not one task — it's dozens. Database design, authentication, input validation, error handling, testing, documentation. A single LLM call can't do this well.
Decomposition Pipeline
BuddyMe's task planner breaks complex requests into a structured pipeline:
- SEARCH — Gather context: examine existing code, check dependencies, understand conventions
- CREATE — Generate the initial implementation based on gathered context
- EDIT — Refine and fix issues found during review
- VERIFY — Run tests, lint, type-check to validate the output
Example: Building an API Endpoint
User: "Add a password reset endpoint"
Planner分解:
1. SEARCH — Find auth module, check existing patterns
2. CREATE — Write the endpoint following project conventions
3. EDIT — Add error handling, validate edge cases
4. VERIFY — Run tests, check types, verify imports
Why This Works
Each stage has a focused objective and clear success criteria. The agent isn't trying to do everything at once — it's executing a well-defined plan. This approach:
- Reduces hallucination (each step is grounded in real context)
- Improves consistency (follows the same pipeline every time)
- Enables recovery (if one stage fails, you can retry just that stage)
- Provides visibility (you can see exactly what the agent is doing)