Skip to content
Blog

ParallelAgent Fan-Out: Concurrent Sub-Agent Processing with Aggregation

Learn how to use Google ADK's ParallelAgent to execute multiple specialist agents concurrently, minimize total turnaround latency, and aggregate outputs.

Published on • November 29, 2026

AI Assistant

When an AI system needs to evaluate an inquiry from multiple perspectives—such as running legal, financial, and technical feasibility reviews on a vendor proposal—running those steps sequentially compounds total latency. If each agent review takes 3 seconds, a sequential review takes 9 seconds.

Google Agent Development Kit (ADK) introduces ParallelAgent to solve this bottleneck. By executing independent sub-agents concurrently using Python’s async event loop, total wall-clock latency drops to the slowest single sub-agent turn (~3 seconds).

In this tutorial, we will explore the internal execution mechanics of ParallelAgent, how to prevent state collisions across concurrent sub-agents, and how to combine ParallelAgent with SequentialAgent for fan-out / fan-in workflows.


1. Concurrency Model: Fan-Out and Fan-In

A standard fan-out pattern consists of three phases:

  1. Dispatcher / Input Stage: Prepares the shared problem statement.
  2. Parallel Fan-Out (ParallelAgent): Triggers multiple specialist agents simultaneously.
  3. Reducer / Synthesis Stage: Ingests all concurrent outputs and generates the unified verdict.
                    [User Query]
                         │
                         ▼
┌──────────────────────────────────────────────────┐
│ ParallelAgent: "due_diligence_reviewers"         │
│                                                  │
│   ┌──────────────────────────────────────────┐   │
│   │ Legal Agent -> state["legal_review"]     │   │
│   └──────────────────────────────────────────┘   │
│                        ││                        │
│   ┌────────────────────┴┴────────────────────┐   │
│   │ Security Agent -> state["sec_review"]    │   │
│   └──────────────────────────────────────────┘   │
│                        ││                        │
│   ┌────────────────────┴┴────────────────────┐   │
│   │ Financial Agent -> state["fin_review"]   │   │
│   └──────────────────────────────────────────┘   │
└──────────────────────────────────────────────────┘
                         │
                         ▼ (Fan-In Aggregator)
┌──────────────────────────────────────────────────┐
│ Synthesis Agent                                  │
│ - Reads {legal_review}, {sec_review}, {fin_review}│
│ - Emits final comprehensive recommendation       │
└──────────────────────────────────────────────────┘

2. Preventing State Race Conditions

Because all sub-agents share the same underlying Session, never assign identical output_key values to parallel sub-agents.

If both legal_agent and security_agent write to output_key="review_result", the faster agent’s output will be overwritten by the slower agent. Always ensure disjoint, clearly named keys:

# GOOD: Disjoint keys
legal_agent = Agent(name="legal", ..., output_key="legal_output")
security_agent = Agent(name="security", ..., output_key="security_output")

# BAD: Race condition!
legal_agent = Agent(name="legal", ..., output_key="output")
security_agent = Agent(name="security", ..., output_key="output")

3. Implementing the Vendor Review Workflow

Let’s build a complete workflow that reviews a prospective third-party SaaS vendor across three dimensions in parallel:

import asyncio
from google.adk.agents import Agent, ParallelAgent, SequentialAgent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService

# 1. Parallel Sub-Agent: Legal & Compliance
legal_agent = Agent(
    name="legal_auditor",
    model="gemini-3.8-flash",
    instruction="""
    You are a corporate compliance attorney.
    Evaluate the vendor proposal for GDPR, CCPA, and data processing liabilities.
    Highlight any red flags or indemnification risks.
    """,
    output_key="legal_analysis",
)

# 2. Parallel Sub-Agent: Cybersecurity
security_agent = Agent(
    name="security_auditor",
    model="gemini-3.8-flash",
    instruction="""
    You are an enterprise CISO.
    Evaluate the vendor proposal for SOC 2 compliance, encryption standards,
    zero-trust support, and vulnerability remediation SLAs.
    """,
    output_key="security_analysis",
)

# 3. Parallel Sub-Agent: Financial Feasibility
financial_agent = Agent(
    name="financial_analyst",
    model="gemini-3.8-flash",
    instruction="""
    You are a corporate financial analyst.
    Evaluate the vendor's pricing model, implementation cost, and ROI.
    Identify hidden costs or rigid long-term contract lock-ins.
    """,
    output_key="financial_analysis",
)

# 4. Wrap parallel agents in ParallelAgent container
parallel_reviewers = ParallelAgent(
    name="vendor_review_panel",
    sub_agents=[legal_agent, security_agent, financial_agent],
    description="Simultaneously assesses vendor proposals from legal, security, and financial perspectives.",
)

# 5. Reducer / Aggregator Agent
executive_summarizer = Agent(
    name="procurement_director",
    model="gemini-3.8-flash",
    instruction="""
    You are the VP of Procurement.
    Synthesize the independent specialist reviews into a final decision matrix:

    --- Legal Review ---
    {legal_analysis}

    --- Security Review ---
    {security_analysis}

    --- Financial Review ---
    {financial_analysis}

    Provide a final recommendation (Approve, Reject, or Require Remediation)
    with clear justifications.
    """,
    output_key="final_procurement_verdict",
)

# 6. Compose into end-to-end pipeline: Parallel Review -> Synthesis
complete_procurement_workflow = SequentialAgent(
    name="procurement_orchestrator",
    sub_agents=[
        parallel_reviewers,
        executive_summarizer,
    ],
)

4. Running the Workflow and Measuring Latency

Let’s execute the workflow and observe concurrent execution:

async def main():
    session_service = InMemorySessionService()
    runner = Runner(agent=complete_procurement_workflow, session_service=session_service)
    session = await session_service.get_or_create("vendor_rfp_session")

    vendor_proposal = """
    Vendor RFP: CloudData Analytics Inc.
    - Cloud: Multi-tenant AWS hosting, TLS 1.2 in transit, AES-256 at rest.
    - Certifications: SOC 2 Type I achieved, ISO 27001 in progress.
    - Data Rights: Vendor retains anonymized aggregate data rights for AI model training.
    - Pricing: $120,000/year minimum 3-year upfront commitment.
    - Uptime SLA: 99.5% with service credit remedy.
    """

    print("Submitting RFP to parallel review panel...\n")
    import time
    start = time.perf_counter()

    async for event in runner.run_async(session=session, message=vendor_proposal):
        if event.author:
            print(f"[Completed Turn: {event.author}]")

    elapsed = time.perf_counter() - start
    print(f"\nAll reviews finished in {elapsed:.2f} seconds!")

    print("\n================ FINAL VERDICT ================")
    print(session.state.get("final_procurement_verdict"))

if __name__ == "__main__":
    asyncio.run(main())

5. Architectural Considerations

  1. Model Concurrency Quotas: When executing 5 or more sub-agents simultaneously with ParallelAgent, you make multiple concurrent API calls to the Google GenAI backend. Ensure your Vertex AI / Gemini API project has sufficient TPM (tokens per minute) and RPM (requests per minute) quotas.
  2. Handling Individual Agent Failures: If one sub-agent in a ParallelAgent throws an unhandled exception, by default the gather group will propagate it. Wrap individual tool calls in try/except blocks so partial reviews still succeed.
  3. Context Truncation in the Reducer: If each parallel agent generates 2,000 tokens of review, the reducer receives 6,000 tokens of input context. Gemini 3.8 Flash’s massive context window handles this effortlessly, but enforce conciseness in specialist instructions to keep cost and latency low.

Takeaway: ParallelAgent drastically reduces end-to-end execution latency for multi-perspective assessments, enabling fast, multi-faceted AI decision making.

Sources