| name | google-adk-workflow-agents |
| description | Create ADK workflow agents: LoopAgent, ParallelAgent, SequentialAgent. Use when orchestrating deterministic multi-step workflows — sequential pipelines, parallel fan-out, or iterative loops with exit conditions. |
Google ADK — Workflow Agents
Workflow agents are non-LLM orchestrators that control execution flow deterministically (no model calls for routing).
Imports
from google.adk.agents import LoopAgent, ParallelAgent, SequentialAgent
from google.adk.tools import exit_loop
SequentialAgent
Executes sub_agents one after another in order.
from google.adk.agents import Agent, SequentialAgent
research_agent = Agent(
name="researcher",
model="gemini-2.5-flash",
instruction="Research the topic and output findings.",
output_key="research_output",
)
writer_agent = Agent(
name="writer",
model="gemini-2.5-flash",
instruction="Write a report based on the research output.",
include_contents="none",
)
pipeline = SequentialAgent(
name="research_pipeline",
sub_agents=[research_agent, writer_agent],
)
SequentialAgent Parameters
| Parameter | Type | Description |
|---|
name | str | Unique identifier |
sub_agents | list | Agents to execute in order |
description | str | For parent agent delegation |
before_agent_callback | Callable | Pre-execution hook |
after_agent_callback | Callable | Post-execution hook |
ParallelAgent
Executes all sub_agents concurrently. Results stored via output_key.
from google.adk.agents import Agent, ParallelAgent
sentiment_agent = Agent(
name="sentiment_analyzer",
model="gemini-2.5-flash",
instruction="Analyze the sentiment of the text.",
output_key="sentiment_result",
)
keyword_agent = Agent(
name="keyword_extractor",
model="gemini-2.5-flash",
instruction="Extract key topics from the text.",
output_key="keywords_result",
)
parallel_analysis = ParallelAgent(
name="parallel_analysis",
sub_agents=[sentiment_agent, keyword_agent],
)
ParallelAgent Parameters
| Parameter | Type | Description |
|---|
name | str | Unique identifier |
sub_agents | list | Agents to execute concurrently |
description | str | For parent agent delegation |
LoopAgent
Repeats sub_agents until exit_loop is called or max_iterations reached.
from google.adk.agents import Agent, LoopAgent
from google.adk.tools import exit_loop
refine_agent = Agent(
name="refiner",
model="gemini-2.5-flash",
instruction="""Refine the draft. If the quality is satisfactory, call exit_loop.
Otherwise, continue improving.""",
tools=[exit_loop],
output_key="draft",
)
review_loop = LoopAgent(
name="review_loop",
sub_agents=[refine_agent],
max_iterations=5,
)
LoopAgent Parameters
| Parameter | Type | Description |
|---|
name | str | Unique identifier |
sub_agents | list | Agents to repeat each iteration |
max_iterations | int | Safety limit (default: no limit) |
description | str | For parent agent delegation |
Composing Workflow Agents
Workflow agents can be nested for complex pipelines:
full_pipeline = SequentialAgent(
name="full_pipeline",
sub_agents=[
research_agent,
parallel_analysis,
review_loop,
final_output_agent,
],
)
Data Flow Between Agents
Use output_key and state to pass data between agents in a sequence:
from google.adk.agents.readonly_context import ReadonlyContext
def writer_instruction(ctx: ReadonlyContext) -> str:
research = ctx.state.get("research_output", "")
return f"Write a report based on this research:\n{research}"
writer_agent = Agent(
name="writer",
model="gemini-2.5-flash",
instruction=writer_instruction,
include_contents="none",
)
Key Patterns
- SequentialAgent: ETL pipelines, multi-step processing, draft→review→publish
- ParallelAgent: Fan-out analysis, multi-perspective evaluation, concurrent API calls
- LoopAgent: Iterative refinement, retry patterns, convergence loops
exit_loop tool must be given to an agent inside a LoopAgent to break the loop
output_key stores the agent's text output in state[key] for downstream agents
include_contents="none" prevents downstream agents from seeing upstream conversation
Related Skills
google-adk-llm-agent — Agent parameters and configuration
google-adk-multi-agent — LLM-routed (non-deterministic) multi-agent
google-adk-function-tool — Creating tools for sub-agents