Google ADKgoogle-adk 2.8 · Python 3.10+
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
28 small wins to finish your pathNext lesson

Two things at once

When two steps do not need each other's answers, running them one after the other is just slower.

python
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.

python
checks = ParallelAgent(name="checks", sub_agents=[account, payments])
Example
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.

python
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.

One key each
Two agents writing to the same state key in parallel is a race, and the result depends on which finished last. Give every parallel agent its own key.
Try it yourself
  • Give both agents the same output_key and see which one wins.
  • Wrap the parallel group in a sequence with a summarising step.

Slow is fine. Stopping is the only problem.