Skip to main content

04. Agentic Workflows

Workflow Patterns (Sequential, Parallel, Conditional, Iterative)

Most agentic workflows are built from four patterns: sequential pipelines, parallel fan-out/fan-in, conditional routing, and iterative loops. Master the shapes, then compose them.

What you will learn

  • Name and sketch the four core workflow patterns
  • Choose the right pattern for a given bottleneck
  • Compose patterns into a realistic agent graph
  • Apply bounds and joins so patterns stay safe
  • Answer interview questions with short, solid answers
Four workflow patterns: sequential, parallel, conditional, iterative
Interview staple: sequence, parallel join, branch, and bounded loop.

Definition

Workflow patterns are reusable control-flow shapes for agent runs. Sequential runs steps in order. Parallel runs independent steps then joins. Conditional picks a path from state or a router. Iterative repeats work until a verifier passes or a cap is hit.

Frameworks differ; the shapes do not. If you can draw the pattern, you can implement it in LangGraph, queues, or custom orchestrators.

Introduction

This lesson (#5 in Agentic Workflows) follows Task Planning and Scheduling. Scheduling picks ready tasks; patterns describe how those tasks connect in the graph.

Next: Human-in-the-Loop and Autonomous Execution — often implemented as gates on these patterns.

Why patterns matter

  • Shared vocabulary for design reviews
  • Predict latency/cost (parallel vs sequential)
  • Place safety gates on the right edges
  • Avoid inventing a new topology for every feature

Sequential

Steps run one after another. Output of A feeds B. Simplest to reason about and the default when later steps need earlier artifacts.

  • Use when - strict dependencies or shared mutable state
  • Examples - fetch → analyze → write → send
  • Watch for - long critical paths; unnecessary blocking
  • Tip - keep steps idempotent for safe resume

Parallel (fan-out / fan-in)

Start independent branches from a split node, then join before dependents continue. Speeds wall-clock time when work does not conflict.

Graph sketches for sequential, parallel, conditional, and iterative patterns
Draw the shape first — letters are enough for a design review.
  • Use when - independent retrievals, critiques, or specialist calls
  • Join policies - wait-all, wait-n, or first-success (pick explicitly)
  • Examples - search three sources then synthesize
  • Watch for - race writes, partial join bugs, cost multiplication

Conditional

A router (rules or LLM) selects the next path. Essential for multi-intent products and risk-based gates.

  • Use when - different tools/policies per case
  • Examples - billing vs tech vs spam; approve vs reject vs escalate
  • Watch for - unknown labels; always fail closed to a safe path
  • Tip - log router input features and chosen edge

Iterative

Loop a body until a done check passes — the home of ReAct micro-loops, refine-until-rubric, and retry-with-backoff.

  • Use when - quality needs revise cycles or tools reveal new info
  • Examples - draft → critique → revise; test → fix → retest
  • Hard requirement - max iterations / cost / time
  • Watch for - oscillation and retrying the same failing action

Composing patterns

Production flows mix shapes. Name each segment so on-call engineers can find the failure mode.

Composed research brief flow using conditional, parallel, iterative, and sequential patterns
Example: classify → parallel gather → iterative draft → sequential publish.
  • Conditional at the edge for intent/risk
  • Parallel for independent gathers
  • Iterative for quality refinement
  • Sequential for final side-effect chain
  • HITL gates often sit before irreversible sequential writes

Program / implementation notes

Represent patterns as graph edges and join nodes, not as buried prompt prose. Test each pattern with fixtures (especially joins and loop caps).

  • Give every edge a name in traces
  • Implement join timeouts separately from step timeouts
  • Store iteration counters in state
  • Next: Human-in-the-Loop and Autonomous Execution

Advantages and limitations

  • Advantage: reusable, reviewable designs
  • Advantage: performance knobs (parallelism) are explicit
  • Advantage: safer defaults via fail-closed conditionals and caps
  • Limitation: over-parallelism raises cost and complexity
  • Limitation: poorly named joins hide partial failures
  • Limitation: uncapped iteration becomes an infinite agent

Key points

  • Four cores: sequential, parallel, conditional, iterative.
  • Sequential for deps; parallel for independent work with a join.
  • Conditional routes by rules or model — fail closed on unknowns.
  • Iterative needs a verifier and hard caps.
  • Real products compose patterns; label each segment.
  • Encode patterns in the orchestrator graph, not only prompts.

FAQs

Is ReAct a workflow pattern?

ReAct is primarily an iterative micro-loop pattern (think/act/observe) often nested inside larger sequential or conditional graphs.

Parallel vs multi-agent?

Parallel is about concurrent branches. Those branches might be tools in one agent or separate agents — concurrency and agency are different axes.

What join policy should I use?

Default wait-all for synthesis tasks. Use first-success for racing redundant providers. Document the choice.

How do I stop iterative loops?

Combine a done verifier with max iterations, max cost, and escalate-on-stall rules in the orchestrator.

Interview questions

  1. What are the main agentic workflow patterns?

    Answer Sequential, parallel (fan-out/fan-in), conditional (routing), and iterative (bounded loops) — often composed together.

  2. When do you use parallel vs sequential?

    Answer Parallel when steps are independent and you need lower latency; sequential when later steps require earlier outputs or shared mutations.

  3. What is a conditional workflow?

    Answer A graph that branches to different paths based on rules or a router decision over current state.

  4. How do you keep iterative workflows safe?

    Answer Require a clear done check, cap iterations/cost/time, detect no-progress retries, and escalate when caps hit.

  5. What is fan-out / fan-in?

    Answer Fan-out starts parallel branches; fan-in joins their results before continuing — with an explicit join policy.

  6. Give a composed example.

    Answer Classify intent (conditional), gather sources in parallel, iteratively refine a draft, then sequentially format and send.

  7. Where do HITL gates fit in these patterns?

    Answer Usually as conditional exits or sequential barriers before high-risk side effects inside any of the four shapes.

Related topics

Practice task

Complete each numbered practice step in a notebook or doc before opening the next lesson.

  1. Sketch all four patterns from memory with 3–5 boxes each.
  2. For a support bot, mark where sequential, conditional, and iterative appear.
  3. Design a parallel gather with a wait-all join and a join timeout.
  4. Write loop caps for an iterative code-fix cycle.
  5. Answer interview questions 1, 2, and 4 in two sentences each.