Comparing Sequential and Parallel Plan Execution
Decomposing tasks is only half the battle. In this lesson, we compare Sequential vs Parallel plan execution: applying the data dependency test, scheduling hybrid wave-based DAGs, and balancing token costs against latency.
1. Core Decision Framework
Select a strategy componentStrategy Benchmark Inspector
# 1. DEPENDENCY TEST EVALUATION
def is_independent(task_a: dict, task_b: dict) -> bool:
"""Returns True if task_b does not consume any outputs produced by task_a."""
return not any(dep in task_a["outputs"] for dep in task_b.get("depends_on", []))
# Independent Example:
# Task A: "Fetch Tesla Q3 deliveries"
# Task B: "Fetch BYD Q3 deliveries"
# -> Independent! Run parallel.
# Dependent Example:
# Task 1: "Find founder of DeepMind" -> output: 'Demis Hassabis'
# Task 2: "Find books written by <founder>" -> Depends on Task 1! Run sequential.2. Interactive Plan Execution Comparer
Sequential vs Parallel vs Hybrid SandboxUser Query
“Find AI products launched by the company that acquired DeepMind in 2024”
Why this strategy: Step 2 depends on Step 1's answer — you can't search 'products by X' until you know who X is.
Common Engineering Traps
Forcing Task B ("Find CEO's email") to run concurrently with Task A ("Who is the CEO of Acme?") results in Task B hallucinating an email address because Task A hasn't identified the person yet. Respect dataflow dependencies strictly.
In parallel execution, you pay token costs for ALL tasks even if the first subtask answers the question. If checking an in-memory cache could answer the query instantly, run that sequentially first before fanning out expensive web searches.
Key Architectural Takeaways
- 1.Dataflow Independence: Only tasks whose inputs do not depend on sibling outputs should run in parallel.
- 2.Wave-Based Architecture: Group subtasks into topological waves to achieve maximum parallelism without causality violations.
- 3.Latency vs Token Optimization: Use parallel execution for user-facing interactive queries, and sequential early-exit plans for cost-sensitive batch jobs.
Developing Error Handling and Recovery Pathways
When production agents hit rate limits or API downtime, crashes are unacceptable. Learn how to architect fallback routers, model downgrade chains, and self-healing recovery pathways.