Sub-Agent Types: Sequential, Parallel & Loop AgentsOpen in Colab
Agentic project loop
Task definition·Context & tools·Orchestration loop·Evaluation·Guardrails·Operations feedback

Sub-Agent Types: Sequential, Parallel & Loop Agents

The cooperation-patterns lesson covers who the agents are (voters, roles, debaters). This page covers how control flows between them. Multi-agent frameworks (Google's ADK, LangGraph, OpenAI's Agents SDK, and others) converge on the same small algebra: a sub-agent is any agent invoked as a child of another, and there are exactly two ways to decide which sub-agent runs next — a deterministic workflow you wrote, or an LLM deciding at runtime. The deterministic side reduces to three primitives.

Workflow agents vs. LLM-driven delegation

  • Workflow agents are orchestrators whose control flow is code: the order of sub-agents is fixed before the request arrives. Predictable, testable, cheap — no LLM call is spent deciding what to do next.
  • LLM-driven delegation (orchestrator/router agents, A2A handoffs) asks a model to choose the next sub-agent from the descriptions it can see. Flexible, but every routing decision is a paid, fallible inference.

Same rule as the deployment lesson

Reach for a workflow before an agent: if the decomposition is known in advance, encode it as a sequential/parallel/loop structure and spend LLM calls only inside the sub-agents. Reserve LLM-driven routing for the part of the task that genuinely can't be predetermined.

Sequential agents

Structure. Sub-agents A1→A2→⋯→AKA_1 \to A_2 \to \cdots \to A_K run in a fixed order; each reads the shared state the previous one wrote (outline → draft → edit; extract → transform → validate).

  • Latency and cost add up: T=∑kTkT = \sum_k T_k, C=∑kCkC = \sum_k C_k.
  • Use when steps genuinely depend on each other's output, or each step needs a different prompt/model/toolset (the role-based pipeline from the lesson is a sequential agent).
  • Failure mode: cascading errors. A wrong A1A_1 output silently poisons every later stage. Mitigate with validation between stages — a schema check or critic gate after each step, failing fast instead of forwarding garbage.
Text
state: {topic} ─▶ [Researcher] ─▶ {notes} ─▶ [Writer] ─▶ {draft} ─▶ [Editor] ─▶ {final}

Parallel agents

Structure. Sub-agents A1,…,ANA_1, \dots, A_N run concurrently on independent sub-tasks (fan-out); an aggregation step merges their outputs (fan-in) — search three sources at once, generate NN candidates for voting, review code for security/style/performance simultaneously.

  • Latency is the max, not the sum: T=max⁡nTn+TmergeT = \max_n T_n + T_{\text{merge}} — the whole point. Cost still adds up: C=∑nCnC = \sum_n C_n.
  • Use when sub-tasks share no dependencies and you want wall-clock speed (or independent samples for a voting pattern).
  • Failure modes: a straggler sets the latency (add per-branch timeouts); branches writing the same state key clobber each other (give each branch its own output slot and merge explicitly); and "parallel" branches that secretly depend on each other, which deadlock or silently read stale state.
Text
                 ┌─▶ [Security reviewer] ─▶ {sec}  ─┐
{diff} ─ fan-out ─┼─▶ [Style reviewer]    ─▶ {style} ─┼─ fan-in ─▶ [Merger] ─▶ {review}
                 └─▶ [Perf reviewer]     ─▶ {perf} ─┘

Loop agents

Structure. A body of sub-agents runs repeatedly (generate → critique → revise) until a termination condition fires: a critic approves, a test passes, the output stops changing, or a hard iteration cap kmax⁡k_{\max} is hit.

  • Cost and latency are unbounded by design: T=∑i=1kTbodyT = \sum_{i=1}^{k} T_{\text{body}} where kk is unknown in advance. The cap converts "unknown" into "bounded".
  • Use when quality comes from iteration and you have a checkable stopping signal — the reflection pattern run under a workflow harness.
  • Failure modes: never converging (oscillating between two drafts), a rubber-stamp critic that exits on iteration 1, and the classic — no cap at all.

Every loop gets a cap — in the runtime, not the prompt

A loop agent whose exit relies on a model's judgment will eventually meet an input where that judgment never fires. Enforce kmax⁡k_{\max} (and a token/dollar budget) in the orchestration code. On cap-out, return the best iterate so far with a "did not converge" flag rather than failing the whole task.

Composition: it's an algebra

The primitives nest — each workflow agent is itself a sub-agent to its parent. A realistic research pipeline:

Text
Sequential(
  Planner,
  Parallel(WebResearcher, PaperResearcher, DataAnalyst),   # independent gathering
  Loop(Writer → Critic, until approved, k_max = 3),        # iterative drafting
  Formatter
)

An LLM-driven orchestrator can sit at any node too — e.g. a router that picks which sequential pipeline to run, with everything below it deterministic. Hierarchy bounds each decision: the router chooses among 3 pipelines, not among 12 raw agents.

PrimitiveLatencyCostTerminationPrimary failure mode
Sequential∑kTk\sum_k T_k∑kCk\sum_k C_kafter step KKcascading upstream error
Parallelmax⁡nTn\max_n T_n∑nCn\sum_n C_nafter fan-instragglers; state clobbering
Loopk⋅Tbodyk \cdot T_{\text{body}}k⋅Cbodyk \cdot C_{\text{body}}condition or kmax⁡k_{\max}non-convergence, rubber-stamp critic
LLM router+ one LLM call per hop+ routing tokensmodel decidesmis-routing, unpredictable paths

Common mistakes

  1. Using an LLM router for a fixed pipeline: paying inference (and accepting mis-routes) to rediscover an order you already knew.
  2. Parallel branches sharing a mutable state key: last-writer-wins clobbering that only surfaces under race timing.
  3. Loops without a runtime cap: the prompt is a suggestion; the cap is a guarantee.
  4. Sequential chains with no inter-stage validation: every stage runs at full cost on garbage input after an early failure.
  5. Deep nesting without tracing: a hierarchy of workflow agents is undebuggable unless each sub-agent invocation is a span in one trace.

Related concepts

Concept neighbourhood

How this concept connects — click any node to jump there, or explore the whole concept map.

RelatedReferenced by
Sub-Agent Types: Sequential, Para…Observability for AgentsLangGraph: Agents as Stat…Agent Protocols: MCP & A2AThe Agentic Project LoopAgents & Tool UseMulti-Agent Cooperation P…Deploying Agents in Produ…Reflection Patterns