Building a Multi-Agent Code Review System

AILangGraphFastAPISystem Design

Most code review tools give you a single pass — one model, one perspective, one set of suggestions. I wanted something that thinks the way a real engineering team does: multiple specialists looking at the same code from completely different angles, then synthesizing their findings into one coherent review.

The Problem

Code review is inherently multi-dimensional. A security engineer looks at the same function differently than a performance engineer, who looks at it differently than someone focused on maintainability. Collapsing all of that into a single prompt loses nuance.

The Architecture

The system runs three parallel LangGraph agent nodes:

  • Security Agent — scans for vulnerabilities, injection risks, auth issues
  • Performance Agent — identifies bottlenecks, unnecessary computations, memory concerns
  • Maintainability Agent — evaluates readability, naming, structural patterns

Each agent runs independently and concurrently. Their outputs feed into a Synthesis Layer powered by Claude Sonnet, which resolves conflicts, removes redundancies, and produces a unified review.

Why LangGraph Over Simple Chains

I initially prototyped this with sequential LangChain calls. The problem: it was slow (agents waited for each other) and the later agents were biased by earlier outputs. LangGraph let me define a proper DAG where agents run in parallel with no cross-contamination, then converge at the synthesis node.

What I Learned

The hardest part wasn't the AI — it was designing the synthesis prompt so it genuinely reconciled conflicting agent opinions instead of just concatenating them. A security agent might flag a piece of code as risky while the performance agent recommends keeping it for speed. The synthesis layer needs to weigh those tradeoffs, not just list both opinions.


This is a living post. I'll update it as the system evolves.