Fan-Out and Fan-In Topologies: Executing Parallel Graph Branches
Build parallel ADK graph workflows with multiple START edges and JoinNode barriers, and learn the rules that keep fan-in from deadlocking in production.
Published on • November 30, 2026
AI Assistant

Most real pipelines are not lines. Research three topics at once, check a price in two systems, run validation and enrichment in parallel — then stop and wait for all of them before the report can be written. Serializing that work wastes wall-clock time, but naively splitting it creates a worse problem: nothing tells the final step when it is allowed to run.
ADK graph workflows model this with two primitives that come as a pair: fan-out, which is just more than one edge row leaving the same source, and fan-in, a JoinNode that acts as a barrier and hands the aggregated results downstream. In this tutorial you will build both halves, learn the exact shape of a join’s output, and see the validation rules that prevent a join from hanging forever.
1. Why a barrier, not a poll
Consider a competitive-analysis workflow: three research agents scrape different sources, and a synthesis node needs all three summaries. Without a barrier, the synthesis node either runs too early (missing data) or you end up writing polling code that checks session state until some flag flips.
┌──▶ research_A ──┐
START ───────────────┼──▶ research_B ──┼──▶ gather ──▶ format ──▶ synthesis
└──▶ research_C ──┘ (JoinNode)
The JoinNode is the barrier. It waits for every predecessor to finish, then passes its successor a record of their outputs. No polling, no counters in state, no “did C finish yet?” logic.
2. Fan-out is just repeated START rows
A row that starts with 'START' runs each listed node once, in order. Listing 'START' in more than one row creates parallel paths instead:
from google.adk import Workflow
from google.adk.workflow import JoinNode
my_join_node = JoinNode(name="my_join_node")
edges = [
("START", parallel_task_A, my_join_node),
("START", parallel_task_B, my_join_node),
("START", parallel_task_C, my_join_node),
(my_join_node, final_task_D),
]
Each branch gets the original node input, independently. The number of rows is the width of the fan-out — there is no separate “parallel” keyword to reach for, because parallelism is a property of the topology, not of a node type.
3. What the join receives
A JoinNode waits for all predecessors, then emits a dict keyed by predecessor node name, where each value is that predecessor’s latest output:
def final_task_D(node_input: dict) -> str:
return (
f"Uppercase: {node_input['parallel_task_A']}\n"
f"Length: {node_input['parallel_task_B']}\n"
f"Reversed: {node_input['parallel_task_C']}\n"
)
The keys are node names — which is why node naming is part of your data contract. Rename parallel_task_A and you break the consumer, exactly like renaming a dict key. In tests, assert on the key set the join produces.
There is an alternative edge spelling for the same shape: a group of predecessors in a tuple, ((a, b), join, c), which reads as “a and b both feed join, which feeds c.” Both forms describe the same barrier; use whichever makes the graph clearest to a reviewer.
4. A complete fan-out / fan-in workflow
from google.adk import Agent, Workflow
from google.adk.workflow import JoinNode
research_a = Agent(
name="research_A",
model="gemini-flash-latest",
instruction="Summarize facts about renewable energy in 3 bullets.",
mode="single_turn",
)
def research_b(node_input: str):
return "Fact about electric vehicles."
def research_c(node_input: str):
return "Fact about carbon capture."
gather = JoinNode(name="gather")
def format_node(node_input: dict) -> str:
return (
f"A: {node_input['research_A']}\n"
f"B: {node_input['research_B']}\n"
f"C: {node_input['research_C']}"
)
synthesis = Agent(
name="synthesis",
model="gemini-flash-latest",
instruction="Write a short report combining these findings.",
mode="single_turn",
)
root_agent = Workflow(
name="fan_out_workflow",
edges=[
("START", research_a, gather),
("START", research_b, gather),
("START", research_c, gather),
(gather, format_node, synthesis),
],
)
Notice what is not in this code: locks, futures, shared mutable state, an ordering assumption between the branches. The branches may finish in any order; the join normalizes the timing for everyone downstream.
5. The rules that keep fan-in from deadlocking
The docs are blunt about the failure mode, and it is worth repeating as three rules:
Rule 1: every node feeding a join must produce output. A JoinNode releases only after all predecessors finish — and a predecessor that finishes without an output leaves its branch with no value, pushing the failure downstream, away from the node that caused it. Function nodes should return a value (or Event(output=...)), and any branch that can fail needs a retry configuration so it re-runs rather than poisoning the barrier.
Rule 2: the workflow must end in exactly one output-producing terminal node. If two parallel branches each terminate in an output — which is precisely what fan-out invites — the workflow fails with a ValueError. The fix is the same primitive: merge the branches with a JoinNode so the graph ends in a single terminal output.
Rule 3: joins inside loops are scoped to the loop. Each firing of a join waits for the predecessors it can reach by following edges from inside the loop — including routes the run never took. A predecessor the join cannot reach (a setup step that runs once before the loop starts) keeps counting in later iterations. Get this wrong and an iteration waits on a node that will never run again.
6. When the fan-out width isn’t known at build time
A static graph’s topology must be drawn before the input arrives. Three research branches are three edge rows; fifty accounts requiring compliance verification are not. For runtime-sized fan-out, ADK offers two escalation paths:
-
Dynamic workflows. In an orchestrator node, schedule children yourself and collect them in parallel:
@node(rerun_on_resume=True) async def parallel_supervisor(ctx: Context, node_input: list[Any]): tasks = [ ctx.run_node(worker_node, item, use_sub_branch=True) for item in node_input ] return await asyncio.gather(*tasks)use_sub_branch=Trueisolates each run’s events so the replay log stays readable, and on resume only failed or interrupted workers re-execute. -
The built-in parallel worker. For the common “run one node over each item” case,
node(worker, parallel_worker=True, max_parallel_workers=4)performs the fan-out and bounds concurrency for you.
Use the static JoinNode graph when the branches are known and stable; use dynamic scheduling when the number of branches is data.
7. Choosing the topology
| Topology | Shape | Use when |
|---|---|---|
| Sequence | A → B → C | Steps genuinely depend on the previous output |
| Fan-out / fan-in | START → A,B,C → join → D | Independent branches, one consumer |
| Branch + join | router selects subset → join | Which branches run is data-dependent |
| Dynamic fan-out | run_node per item | Width known only at runtime |
A useful discipline: draw the graph first. If you cannot name each branch’s output and the join’s key set on paper, the code will not either — and the failure will surface as a node waiting on a value that never arrives.
8. Checklist
- Each parallel branch emits exactly one
output, and the emitting node has aretry_configif it can fail. - Join keys (node names) are asserted in a test, since they are a data contract.
- The workflow has a single output-producing terminal node after the merge.
- Joins inside loops only wait on predecessors that re-run each iteration.
- Branch width is static → edge rows; runtime width → dynamic
run_nodeorparallel_worker. - Large per-branch payloads go to artifacts or a database, not session state.
Fan-out is cheap to declare and expensive to get wrong, which is exactly why the barrier is a first-class node: the topology carries the synchronization, and your code only carries the logic.