Section 2: Agentic Architecture - Task Decomposition & Planning
Summary
Key Ideas
L1: Break complex goals into actionable subtasks
- Definition of Key Concepts:
- Task decomposition: Breaking a high-level goal into smaller subtasks β assign to agents, tools, workflow steps
- Handoff point: Boundary between subtasks where one stepβs output becomes the next stepβs input β requires an explicit schema
- Orchestrator: Controlling agent that decomposes goal β assigns subtasks β manages execution order β synthesizes result
- Importance of Decomposition: Agents struggle with vague goals, leading to inefficiencies and potential failures. Decomposing tasks into subtasks makes them independently retryable and testable, enhancing overall reliability β clear boundaries let multiple agents work together
- Caution Against Fragility (the decomposability spectrum): Avoid monolithic tasks (fragile, hard to debug) and over-decomposed tasks (excessive management overhead) β goal: subtask is meaningful and executable
- Monolithic vs decomposed task:
- Monolithic: one agent handles everything β simple to assign initially β hard to debug β fails completely on any error β hard to parallelize or retry
- Decomposed: split into well-defined subtasks β independently retryable, delegatable, testable β upfront design cost
- Analyzing Goal Structures: Three critical questions to identify natural boundaries:
- Can any part run independently of the rest?
- Does one stepβs output feed directly into another?
- Are there distinct capability domains that need different agents?
- Characteristics of Well-Defined Subtasks: Single responsibility, defined inputs, bounded scope, clean structured outputs
- Handoff Points: Critical junctions where output of one subtask becomes input of another. Potential failure points β pass only necessary information, use structured schemas, document what is NOT passed to prevent false assumptions
- Cost of Decomposition:
- More subtasks β more orchestration logic and latency
- Handoff is a potential failure point
- Deeply decomposed systems are harder to trace and debug
- Trade-off: Balance between reliability and complexity β thoughtful decomposition maintains reliability without high management costs
- Next lesson preview: Decomposition patterns β hierarchical, sequential, and parallel approaches
L2: Decomposition patterns β hierarchical, sequential, and parallel
- Hierarchical Decomposition:
- Recursively breaking down goals into sub-goals, creating a tree structure
- Each level manages only its tier of complexity β similar to how organizations delegate from executives to departments
- Sequential Decomposition:
- Tasks executed in a defined order, each taskβs output serving as input for the next
- Straightforward but inefficient if tasks donβt inherently depend on one another
- Appropriate whenever genuine data dependencies exist between steps
- Parallel Decomposition:
- Build a goal tree β break goal into subgoals β each level handles its tier β results flow back up through the hierarchy to be synthesized
- Independent tasks run simultaneously to reduce overall execution time
- Parallel branches must be truly independent β no shared state
- Requires synchronization when converging back to main workflow β fan-in sync step and explicit handling for partial failure
- Powerful but introduces failure scenarios that sequential patterns avoid
- Go Deep vs. Flatten:
- Hierarchy depth is a design choice β trade-off between specialization and coordination overhead
- Deeper when subtasks require fundamentally different capabilities
- Flatten when subtasks are similar enough to share one agent
- Each added level increases error propagation surface
- Flatten wherever possible
- Real Systems Mix Patterns:
- Most systems combine these decomposition patterns in practice
- Recognizing which pattern applies to which part of the workflow is essential
- Example: pipeline stages run sequentially but parallel within each stage
- Common Anti-Patterns:
- Over-decomposition: too many steps β coordination costs > execution costs
- Under-decomposition: tasks too large to retry and delegate reliably
- False parallelism: treating dependent steps as independent β data hazard
L3: Sequential Pipelines - Design & Tradeoff
This lecture on task decomposition covers several foundational concepts and techniques essential for efficiently managing complex goals within agentic systems. Here are the main points and key takeaways:
- 3 pipeline concepts
- Sequential Execution β easy to debug / harder to speed up β execution order is fixed and deterministic β no branching
- Prompt chaining β each step has a single/narrow job
- Dependency graph β show dependency β reveals ordering and steps could run in parallel
- When to use sequential:
- Data dependency
- State accumulation β each step builds on context that earlier steps procedures
- Order transforms β operation run in a strict order / one stage at a time
- Simplicity goal β debugging and audibility matter mα»e than raw speed
- Task Decomposition: This is the process of breaking down high-level goals into smaller, manageable subtasks that can be executed by agents. This clarification promotes better understanding and execution among agents.
- Sequential: Simplicity vs Latency Accumulation
- Strengths: Easy to debug, Clear data flow, failure are isolated/easy to trace, No sync logic, Correct when steps have true data dependencies
- Costs: TOtal latency accumulation, independent step (which can run concurrently) are forces wait, wasted wall-clock (when data dependencies donβt actual exist)
- Error cascades in sequential pipelines β failure step block downstream β cascade risk grows with depth - more steps, more failure surface β early validation @ step entry reduce bad data travel β design to error handing at each step boundary not the end of pipeline
- True vs Artificial dependency
- True dependencies β downstream need output of upstream
- Artificial dip β steps are sequence only by convention (not data necessity) β remove this let independent steps run at the same time
- Key Vocabulary:
- Handoff Point: The transition between two subtasks, where the output from one serves as the input for the next. Clear definition and structure are crucial here (loose handoff cause silent data loss and hard-to-diagnose downstream errors)
- Orchestrator: The controlling agent responsible for overseeing the workflow, assigning subtasks, managing their execution order, and aggregating the results.
- Importance of Decomposition: When goals arenβt well-defined and broken down, agents may struggle to infer meaning and tasks. Without clear boundaries, agents are likely to misinterpret their priorities, leading to failed attempts at accomplishing complex tasks.
- Analyzing Goals: Itβs vital to analyze complex goals for natural boundaries to avoid vague specifications that can lead to confusion and errors among agents.
- Real Costs of Over-Decomposition: While breaking down tasks is beneficial, over-decomposition can lead to excessive management overhead and complexity, making tasks cumbersome rather than streamlined.
Key Takeaway: Proper task decomposition is a fundamental skill for anyone building agentic systems, as it helps clarify workflows, improves execution efficiency, and reduces the likelihood of errors stemming from undefined tasks.
L4: Parallel Execution - Fan-out, Fan-in and Synchronization
This lecture focuses on task decomposition, which is the essential skill of breaking complex goals into smaller, manageable subtasks. Here are the main points covered:
- Definition and Importance:
- Parallel executions run independent tasks at the same time, cutting overall runtime. However, synchronization points are needed to collect results and manage any partial failures.
- Fan-out: This is the process where a single task splits into multiple concurrent subtasks. Each of these branches must operate independently. Key criteria to test this independence include (Independence test):
- Can a branch start without waiting for another?
- Do branches write to shared states that could cause race conditions?
- Does the order of execution affect the final result? If dependencies exist, fan-out is not suitable and adjustments are necessary.
- Fan-in: This refers to the synchronization step that gathers outputs from successful branches. It also involves managing failures, reordering results if needed, and merging outputs for subsequent pipeline steps. Explicitly addressing partial failures is crucial to prevent silent failures that can lead to incorrect outcomes.
- 4 fan-in responsibility
- Collect result
- Handle failure
- Order result
- Merge & Continue
- 4 fan-in responsibility
- Trade-offs (Parallel vs Sequential): While parallel execution can save time, it comes at the cost of increased complexity in failure management. Strategies for handling failures in parallel branches include (partial failure handling):
- Failing the entire pipeline.
- Proceeding with partial results
- Retrying only the failed branches.
- Note that: silently dropping failed branches introduces silent failure β always handle explicitly
- Merging Strategies:
- Fan-in combines results using methods like
- voting (majority result wins)
- concatenation (join result into one list)
- structured aggregation (contribute field into a shared object)
- Choosing a merging strategy in advance is necessary for effective branch design.
- Fan-in combines results using methods like
- Cost vs Latency in Parallel exec
- Cut latency but increase token spend for the same period (do many job in parallel)
- Token cost are sum
- Rate limits and quotas may constraint the parallel
Key Takeaway: Although parallel execution can improve performance, it introduces complexities and higher costs, especially in managing synchronization and failures. Careful planning is essential to ensure successful implementation.
Quotes
My Take
Links
- task-decomposition
- sequential-pipeline
- dependency-graph
- error-cascade
- true-vs-artificial-dependency
- handoff-point
- orchestrator-agentic
- over-decomposition
- parallel-execution
- fan-out
- fan-in
- partial-failure-handling
- merging-strategies-agentic
L5: Adaptive Planning - Update the plan mid-execution
This lecture focuses on adaptive planning within agentic systems, covering the differences between static and dynamic planning, as well as the mechanisms for updating plans mid-execution. Here are the main points:
- 3 planning concepts
- Static planning
- Dynamic planning
- Replanning β revising the current plan in response to a failed step (Or unexpected tool output or changed environment state)
- Static vs. Dynamic Planning (most systems combine elements of both approach)
- Static Planning: All steps are defined before execution starts. Itβs predictable and auditable since every action is pre-written, allowing for precise failure localization. (Every action in known at design time)
- Dynamic Planning: The agent adapts its plan during execution based on real-time observations. While this allows for greater adaptability, it introduces unpredictability, requiring stronger monitoring and fallback mechanisms, the plans are generated or revised at inference time by model
- Trade-offs:
- Predictable auditable cost-efficient vs adaptable and powerful for open-end goals
- Replanning Triggers: Events that necessitate replanning include:
- Failed tool calls (errors or timeouts).
- Unexpected results that are technically valid but do not align with the intended goals.
- Changed state (environment is changed in mid-execution)
- Constraint violations β a proposed next action would violate a goal constraint or safety boundary
- Replan vs Continue: The decision
- Not every surprise warrants a full replanning cycle
- Replan when a core assumption has been invalidated
- Continue when the deviation is minor and recoverable
- Check whether the original goal is still archivable
- Unnecessary replanning waste tokens and add latency
- Bounding replanning cycles
- Maximum iterations: hard cap of number of replanning (that agent is allowed) β prevent infinite loops
- Goal Constraint Check: validation step confirm revised plan still satisfies the original req before cont exec
- Loop Termination: The condition that halt replanning
- Goal Drift: A significant risk in adaptive planning where the agent revises its plan to overcome obstacles but strays from its original goals. Mechanisms to prevent this include:
- Explicit validation of each revised plan against the original goal.
- Creating an audit trail by logging original goals alongside revised plans. (Log the original goal and check every revised plan)
- Preserving plan state across cycles keeps the agent anchored
- Guardrails for Replanning: To improve reliability in dynamic planning, it is essential to employ bounded planning cycles, iteration limits, and continuous checks against the original goals to ensure that adaptations do not lead to drift.
Key Takeaway: Adaptive planning allows agents to navigate unpredictable environments effectively, but it requires careful management of the replanning process to maintain alignment with original goals and prevent drift. Implementing structured monitoring and validation mechanisms is crucial to ensure successful outcomes.
L6: Handling Ambiguity and Incomplete Specifications
This lecture discusses how agentic systems manage ambiguity and incomplete specifications in goals. Here are the main points:
- Understanding Ambiguity:
- An ambiguous goal lacks a clear definition, leaving multiple valid interpretations. The agent has to choose one to continue, which can lead to unexpected outcomes if the assumption it makes is misaligned with human intentions.
- Concepts
- Ambiguous goal: do not define the expected outcome
- Clarify first strategy: pause exec to request more info form human before proceeding (use when the cost of wrong assumption is high)
- Assume and Process: making a reasonable inference and cont without human input (use when the action is low-stakes, reversible or time-sensitive)
- Strategies for Handling Ambiguity:
- Clarify First (irreversible actions, high-cost operations, scope uncertainty): The agent pauses execution to seek further information from a human. This adds latency but prevents costly mistakes, particularly for high-stakes tasks where assumptions could lead to significant issues, like data deletion or irreversible actions. β a brief clarification prevents large downstream error
- Assume and Proceed (low-stakes or easily reversible actions, time-sensitive tasks, well-constrained context): The agent makes a reasonable inference and moves forward without waiting for clarification. This approach is suitable for low-risk situations where the cost of a wrong assumption is minimal. β goal is appropriate judgment, not maximum caution
- Clarify or Assume: Decision:
- Reversibility
- Stake level
- Scope clarity
- Iterative Refinement Loops (evaluator-optimizer loop):
- Generate-evaluate-refine cycles close the quality gaps
- Generator produces an initial candidate output
- An evaluator scores it against a rubric or constraint set (return structured critique, not pass/fail signal)
- Feedback is passed back to the generator for revision
- A convergence criteria: a threshold or condition to stop the loop: quality bar is met or an iteration cap hit
- Judgment in Execution: The ability to determine which approach suits a situation is crucial. Understanding when to clarify and when to assume can prevent unnecessary errors and keep workflows efficient.
- Costs of Ambiguity: Ambiguous prompts can lead to unpredictable outputs, complicate quality evaluations, and increase debugging expenses. Each vague instruction can introduce variability in results, requiring more effort to reexamine and refine prompts through iterations.
- Specificity in Instruction: Providing concrete, specific instructions closes ambiguities and helps improve predictability in outputs. The more constraints and precise details included in the prompt, the narrower the interpretation space, leading to more reliable outcomes.
- Document assumptions: assumption should be visible (state in agent output or logs) β enable human review β well-documented assumption reduce the audit burden
Key Takeaway: Managing ambiguity effectively is essential for optimizing agentic system performance. By strategically choosing when to clarify versus assume and emphasizing specificity in instructions, the likelihood of errors can be significantly reduced, enhancing overall reliability.