Two things at once
When two steps do not need each other's answers, running them one after the other is just slower.
account = LlmAgent(
name="account",
model=PretendModel(replies=[say("active")]),
instruction="Report the account status.",
output_key="account",
)
payments = LlmAgent(
name="payments",
model=PretendModel(replies=[say("two charges on 3 March")]),
instruction="Report recent payments.",
output_key="payments",
)Two independent lookups. Neither reads the other's key, which is the condition for running them together.
checks = ParallelAgent(name="checks", sub_agents=[account, payments])session = await run(checks, "Look up this customer")
print("state:", dict(session.state))Both ran and both left their result in state under their own key. Nothing was shared between them while they worked.
Running this prints a deprecation warning: as of ADK 2.x the three template workflow agents are deprecated in favour of a newer Workflow API. They still work, they are still what most existing code uses, and there is one thing only they can do. Lesson 20 covers the newer way and when each is right.
The rule for using it
Every agent in a parallel group must be able to do its job without the others' output. If one needs what another produces, they belong in a sequence.
Mixing the two is normal: a parallel group inside a sequence, so the slow independent work happens at once and a final step reads both results.
gather = ParallelAgent(name="gather", sub_agents=[account, payments])
summarise = LlmAgent(
name="summarise",
model="gemini-flash-latest",
instruction="Summarise for an agent: account {account}, payments {payments}.",
)
desk = SequentialAgent(name="desk", sub_agents=[gather, summarise])That shape is the common one in real projects: fan out for the lookups, then one agent to write the answer. It reads exactly as it runs.
- Give both agents the same
output_keyand see which one wins. - Wrap the parallel group in a sequence with a summarising step.
Slow is fine. Stopping is the only problem.