Work / Case study 2 of 4 · developer tooling · multi-agent

Code Review Agent

A pull-request reviewer that only reports a defect once it has found evidence for it in the repository at the exact reviewed commit. On a 30-PR synthetic test set it found all 20 planted bugs with 0 false findings, and that result taught me the test set is too easy.

  • LangGraph
  • Multi-agent
  • FastAPI
  • React + TypeScript
  • Docker sandbox
  • Caddy
  • LangSmith
Code Review Agent
The review UI: PR input, the review flow, and an evidence-backed finding with GitHub links pinned to the PR's commit.
The review UI: PR input, the review flow, and an evidence-backed finding with GitHub links pinned to the PR's commit.

Engineering in 30 seconds

  • Supervisor routes each change to correctness, security and performance specialists, which run in parallel as separate subgraphs
  • Each specialist forms up to 5 hypotheses, investigates them with tools, and passes them to one shared evidence judge
  • Bounded: 3 model turns and 6 tool calls per hypothesis, 30 tool calls per review
  • Optional network-less Docker sandbox runs pytest and Ruff to confirm a hypothesis
  • Eval: 20 buggy + 10 clean synthetic PRs, 3 architectures. Verification: 20/20 bugs, 0 false findings, $0.00085/review, p50 21 s
  • LangSmith tracing (optional)

Delivery in 30 seconds

  • Intended user: a small Python team whose PR queue is slowed by noisy automated review comments
  • Integrates the GitHub REST API; every link is pinned to the PR's exact commit SHA
  • Deploy config: Caddy gateway (HTTPS + auth) in front of FastAPI, which is never exposed directly
  • Secrets only via environment variables; the API requires a bearer token injected server-side
  • Sandbox worker runs on a separate Linux host under systemd
  • Troubleshooting table and API docs ready for a handover

The short version: every architecture, including the cheap diff-only baseline, scored 95–100% on my test set. The benchmark is saturated, so it can’t yet show whether the multi-agent design is worth its 8x cost. Building a harder test set is the next job.

The problem

Reviewers that only read the diff flag code that looks wrong in isolation but is fine in context: a caller that already guards the input, a config value, an existing test. Every false alarm costs reviewer attention, and teams soon learn to ignore the bot.

Constraints

  • Precision matters more than coverage. A reviewer that cries wolf gets switched off.
  • Claims must be checkable. A finding is useful only if a developer can follow its evidence in seconds.
  • Bounded cost. Agent loops must not run up unbounded tool calls or tokens on a large PR.
  • Running untrusted code is dangerous. Any test execution needs isolation, with no network access.

What I built

  1. fetch_pr
  2. analyse_diff
  3. load_repo_tree
  4. retrieve_context
  5. supervisor
  6. specialists ×3 (parallel)
  7. evidence_judge
  8. merge_findings
  9. generate_review
Calls an LLMDeterministic codeExternal system / data
Each specialist loops over its hypotheses using read_file, search_code, find_references, and optionally run_test / run_static_analysis. Only findings the judge confirms with valid citations reach the report.

1. Hypothesis → evidence → verdict. Specialists don’t write findings directly. They propose hypotheses, gather evidence with tools, and a single shared judge confirms or discards each one. That gives every specialist the same standard of proof.

2. Revision pinning. All inspection and every link uses the PR’s exact commit SHA, so the evidence a reviewer clicks on is the code that was reviewed.

3. Hard budgets. 3 model turns and 6 tool calls per hypothesis, a maximum of 5 hypotheses per specialist, and 30 tool calls per review, shared across specialists.

4. Execution as optional evidence. pytest and Ruff run in locked-down, network-less Docker containers, on a separate worker so the API host never executes PR code.

Result

Live run on 23 Nov 2026, model gpt-6-luna, one run per mode at default temperature. The test set has 30 synthetic Python PRs: 20 with one planted bug each (concrete trigger and consequence), and 10 clean. Two of the buggy cases need caller or config context to judge.

ModeWhat it doesBug recallFalse findings (10 clean PRs)Tool calls / reviewp50 / p95 latencyCost / review
diff_onlyStructured review of the diff alone (baseline)95% (19/20)003.7 s / 4.8 s$0.00011
contextContext retrieval, then a structured review100% (20/20)01.77.6 s / 9.1 s$0.00021
verificationFull multi-agent hypothesis and evidence graph100% (20/20)03.220.8 s / 27.0 s$0.00085

All 90 reviews completed. The whole run cost about $0.035. Each finding was matched to the planted bug by meaning (same trigger and consequence), not by line number. Every finding matched its bug, and no PR got a duplicate or extra finding.

What this does and doesn’t show

  • The only case that separated the architectures was caller-contract. A lookup now returns None, and the crash only happens in a caller in another file. Diff-only missed it; both context-aware modes caught it.
  • The other context case, shared-constant, was caught even by diff-only, because the variable names gave the units away.
  • The full verification graph costs about 8x diff-only and 4x context, and is about 3x slower than context. On this test set it bought nothing extra. That is not evidence that verification is useless. It is evidence that these single-function bugs are too easy to need it.
  • Zero false findings across 30 clean-PR reviews is the encouraging part: none of the modes cried wolf on renames, docstrings, equivalent rewrites or formatting.

Known limitations

  • The test set is small, synthetic, Python-only and saturated: 59 of 60 possible bug detections were made. It cannot rank the architectures.
  • One run per mode at default temperature, so run-to-run variance is not measured yet.
  • The eval measures inspection-based verification. Sandbox execution is excluded from it.
  • Before drawing production conclusions, the test set needs pinned, independently adjudicated real PRs, more languages and larger repositories.

What I’d do next

  1. Build a harder test set where the diff alone is misleading: cross-file contracts, config-dependent behaviour, and plausible-looking changes that are actually fine. Then re-run all 3 modes, 3 times each.
  2. Add 10 real, already-merged open-source PRs with known follow-up fixes.
  3. Publish one public LangSmith trace of a full verification review.
  4. Write a 2-week pilot plan for one team’s repos: success means comments that get accepted, not more comments.

How it was built

Built with heavy use of Claude Code as a pair programmer. State what you designed and verified yourself (e.g. the hypothesis/judge architecture, budgets, eval design and adjudication rules) and make sure you can whiteboard the graph and debug any node live.

TODO: the multi-agent version lives on branch feat/multi-agent-specialists. Merge it into the default branch before linking the repo publicly, so reviewers see the version described here.


← All case studies