Skip to content
Blog

Parallel Code Review & Security Audit with ADK

Build an automated code review harness combining ParallelAgent auditors for security and performance with a SequentialAgent synthesizer in Google ADK.

Published on July 30, 2026

AI Assistant

Automated code review is an ideal candidate for parallel agent orchestration. Identifying security vulnerabilities, profiling algorithmic performance, and checking code style conventions are independent evaluation axes. Performing these reviews sequentially increases workflow latency unnecessarily.

By combining Google ADK’s ParallelAgent for concurrent domain audits with a SequentialAgent for lead synthesis, you can construct an enterprise-grade automated code review harness.

System Architecture

The code review harness executes in two primary stages:

  1. Stage 1 (Parallel Audit):
    • Security Auditor: Scans code specifically for OWASP vulnerabilities, SQL injection risks, and hardcoded credential leaks.
    • Performance Auditor: Analyzes memory efficiency, algorithmic complexity, and asynchronous bottlenecks.
  2. Stage 2 (Sequential Synthesis):
    • Lead Reviewer: Consolidates findings from both auditors into an actionable, prioritized pull request review summary.
import asyncio
from google.adk.agents import Agent, ParallelAgent, SequentialAgent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService

# Specialized Subagent 1: Security Auditor
security_agent = Agent(
    name="security_auditor",
    model="gemini-2.5-flash",
    instruction=(
        "Analyze the provided source code specifically for OWASP top vulnerabilities, "
        "SQL injection risks, unvalidated inputs, or leaked credentials."
    )
)

# Specialized Subagent 2: Performance Auditor
performance_agent = Agent(
    name="performance_auditor",
    model="gemini-2.5-flash",
    instruction=(
        "Analyze the provided source code specifically for algorithmic complexity ($O(N)$ issues), "
        "memory leaks, blocking I/O calls, and optimization opportunities."
    )
)

# Stage 1: Parallel Execution Group
parallel_audits = ParallelAgent(
    name="parallel_auditors",
    agents=[security_agent, performance_agent]
)

# Stage 2: Lead Synthesizer Agent
lead_reviewer = Agent(
    name="lead_reviewer",
    model="gemini-2.5-flash",
    instruction=(
        "Synthesize the security and performance audit reports into a single, structured, "
        "and prioritized code review document."
    )
)

# Full Hybrid Harness: Parallel Audits -> Lead Synthesis
full_audit_harness = SequentialAgent(
    name="complete_audit_harness",
    agents=[parallel_audits, lead_reviewer]
)

async def main():
    session_service = InMemorySessionService()
    runner = Runner(agent=full_audit_harness, session_service=session_service)

    # Sample snippet to audit
    sample_code = """
    def login_user(user_input, password_input):
        query = "SELECT * FROM users WHERE username = '" + user_input + "' AND pass = '" + password_input + "'"
        user = db.execute(query)
        if user:
            return {"status": "authenticated", "data": user}
        return {"status": "failed"}
    """

    res = await runner.run_async(
        session_id="audit-sess-1",
        message=f"Please audit this Python authentication function:\n```python\n{sample_code}\n```"
    )
    print("--- Consolidated Code Audit Report ---\n", res.text)

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

Why This Architecture Excels

  • Focused Prompt Contexts: The security agent’s system prompt focuses purely on vulnerability scanning, avoiding instruction confusion with PEP8 or memory optimization rules.
  • Biased-Free Parallel Analysis: Because auditors run in parallel without seeing each other’s intermediate outputs, the performance auditor doesn’t miss algorithmic issues by getting distracted by a glaring SQL injection.
  • Actionable Lead Synthesis: The lead synthesizer receives both structured sub-reports and merges them into a clean markdown review with clear priority levels (e.g., Critical Security Fix vs. Optional Performance Optimization).

Scaling the Audit Team

Adding new audit perspectives requires zero changes to the underlying synthesis pipeline. Simply instantiate a new agent and add it to the ParallelAgent list:

# Easily extend with specialized agents
style_agent = Agent(
    name="style_auditor",
    model="gemini-2.5-flash",
    instruction="Check Python code adherence to PEP8, docstring completeness, and variable naming clarity."
)

compliance_agent = Agent(
    name="compliance_auditor",
    model="gemini-2.5-flash",
    instruction="Check for open-source license headers and compliance with enterprise API guidelines."
)

expanded_parallel_auditing = ParallelAgent(
    name="expanded_auditors",
    agents=[security_agent, performance_agent, style_agent, compliance_agent]
)

Summary

Combining ParallelAgent and SequentialAgent primitives enables robust, multi-perspective automation workflows. By running domain audits concurrently and synthesizing their findings downstream, you achieve both minimum execution latency and maximum report quality.