Agents

Code Review Swarm

The code review swarm dispatches multiple specialized sub-agents to review a pull request in parallel. Each agent focuses on a single dimension — security, performance, style, or logic — then a root agent synthesizes the findings into a single structured report.

How it works

  1. Parallel sub-agents — When a review is triggered, the root agent spawns one sub-agent per enabled dimension. All sub-agents receive the diff and any relevant context (README, test files, dependency manifest) simultaneously and run in parallel
  2. Dimension analysis — Each sub-agent applies its specialized evaluation criteria to the diff and produces a list of findings with file, line, severity, and a plain-language explanation
  3. Synthesis — After all sub-agents complete, the root agent deduplicates overlapping findings, resolves conflicting assessments, assigns an overall risk score, and renders the final structured report

Invoking

bash
# Trigger a code review swarm on a pull request
POST /agents/code-review

{
  "repo": "owner/repository",
  "pr_number": 42,
  "dimensions": ["security", "performance", "style", "logic"]
}

# Retrieve the completed report
GET /agents/code-review/reports/:reportId

Review dimensions

DimensionFocus areaExample findings
SecurityVulnerabilities, injection risks, secrets in codeSQL injection, hardcoded API key, insecure deserialization
PerformanceAlgorithmic complexity, unnecessary allocations, N+1 queriesO(n²) loop, missing index, unbounded fetch
StyleNaming conventions, formatting, idiomatic patternsNon-standard casing, deep nesting, magic numbers
LogicCorrectness, edge cases, off-by-one errors, null handlingMissing null guard, incorrect boundary condition, unreachable branch
Test coverageUncovered paths, missing assertions, test qualityNew branch without test, assertion on mutable state, empty test body

Output format

The synthesized report is returned as JSON and rendered as a structured document. Each finding includes:

  • Severitycritical, high, medium, low, or info
  • Dimension — Which sub-agent raised the finding
  • Location — File path and line range within the diff
  • Description — Plain-language explanation of the issue
  • Suggestion — Concrete recommended fix or refactor

The report also includes a top-level riskScore (0–100) and a recommendation field with one of: approve, approve_with_suggestions, or request_changes.

Configuration

yaml
codeReview:
  enabled: true
  maxAgents: 5               # Maximum parallel sub-agents
  dimensions:
    - security
    - performance
    - style
    - logic
    - testCoverage
  severityThreshold: medium  # Only surface findings at this severity or above
  postComment: true          # Automatically post report as a PR comment
Set postComment: true together with a configured GitLab integration to have the swarm post its report directly as a pull request review comment, including inline annotations at the relevant diff lines.