Task 1.5
Task Decomposition
Prompt chaining vs dynamic adaptive decomposition
📘What You Need to Know
Why Task Decomposition Matters
Complex agent tasks rarely succeed as a single monolithic prompt. Decomposition breaks work into manageable steps, each with focused context and clear success criteria. The exam tests whether you choose the right decomposition strategy for the task type.
Two strategies dominate: prompt chaining for predictable linear workflows, and dynamic adaptive decomposition for tasks where the path cannot be predetermined.
Prompt Chaining: Static Sequences
Prompt chaining defines a fixed sequence of steps executed in order. Each step's output becomes the next step's input. The agent does not decide what to do next — the developer predefines the pipeline.
Best for: data extraction pipelines (extract → validate → store), document processing workflows, ETL operations, and any task where the steps are known in advance and do not change based on intermediate results.
# Prompt chaining example — document processing pipeline
step1 = extract_data(document) # always first
step2 = validate_schema(step1.output) # always second
step3 = store_to_database(step2.output) # always third
# Path is fixed regardless of what step1 findsDynamic Adaptive Decomposition
Dynamic adaptive decomposition lets the agent decide next steps based on intermediate results. After each action, the agent evaluates what it learned and chooses the most appropriate next action. The path emerges from the work itself.
Best for: debugging production issues, research tasks, exploratory analysis, customer support with unpredictable requests, and any task where intermediate results might completely change the approach.
Use dynamic adaptive when complexity is unknown or intermediate results change the approach. Use prompt chaining when the path is predictable.
Choosing the Right Strategy
Ask: "Can I write the full sequence of steps before starting?" If yes → prompt chaining. If no → dynamic adaptive.
A common exam trap: using prompt chaining for debugging or research tasks. When the root cause is unknown, a fixed 5-step sequence will miss the actual problem because step 3's result might reveal you need a completely different step 4 than planned.
- •Prompt chaining: extract → validate → store, invoice processing, report generation
- •Dynamic adaptive: production debugging, research, ambiguous customer requests, code exploration
Real-World Example
Invoice processing: always extract fields, validate against schema, store to database. The steps never change — prompt chaining is correct.
Production outage investigation: check logs → might lead to database, network, or code issue → each finding changes the next diagnostic step. Dynamic adaptive is correct — the agent must reason about what to investigate next based on what it finds.
⚠️Exam Traps
Trap: Using prompt chaining for tasks with unknown complexity
Why it's wrong: Static sequences fail when intermediate results require different next steps.
Trap: Using dynamic adaptive for a well-defined ETL pipeline
Why it's wrong: Unnecessary agent reasoning adds latency and inconsistency to predictable workflows.
Trap: Hard-coding a fixed if/else decision tree instead of using agent reasoning
Why it's wrong: Rigid code trees cannot adapt to unexpected situations the developer did not anticipate.
✓Concept Check
An agent must debug a production issue where the root cause is unknown. Which decomposition approach fits?
🔨Build Exercise
Intermediate40 minutesCompare Chaining vs Adaptive Decomposition
What you'll learn
- •Choose the right decomposition strategy for different task types
- •Implement both patterns and compare behavior