• 3 min read

Second Look

AI code review that writes a test for each bug it suspects and runs it in a sandbox before it comments.

PythonFastAPIGitHub AppsDockerPostgresEvals

A Second Look comment with the failing test, the passing run on main and a checked fix

What it is

Most AI review comments are guesses, so teams learn to skip them. Second Look treats each suspicion as a hypothesis and tries to prove it by running code before anyone sees it.

For every suspected bug it writes a focused test and runs it in an isolated sandbox, once against the pull request and once against main. If the test passes, the suspicion is dropped. If it fails on the pull request and passes on main, the comment goes up with the test, its output and a suggested fix. With min_tier: confirmed it posts nothing it hasn’t proven.

It runs as a GitHub Action with no server, or as a GitHub App on my own server. It reviews Python, JavaScript and TypeScript, Go and Java.

How it works

  1. Suspect. First come checks that need no model: the repo’s own tests near the change, run on both branches, and files the change leaves unparseable. Then the model reads each changed function before and after, its callers, related tests and the repo’s conventions. A suspicion only counts if it names exact inputs, the wrong result and the right one.
  2. Prove. The test runs offline in a locked-down container. A passing test only refutes a suspicion if it actually executed the suspected lines, and a second strict check rejects tests that assert the wrong expectation.
  3. Speak. Refuted suspicions, style nits and duplicates are dropped. The rest are ranked, capped per pull request and posted inline. A suggested fix is applied and the test rerun first, so a fix marked “checked” makes the failing test pass.

Other details I cared about:

  • Comments update in place on new pushes and resolve themselves when the flagged lines change.
  • A force-push cancels the review of the old commit mid-flight, so nothing is posted about code that’s gone.
  • The sandbox has no network and no capabilities. Tokens never enter the checkout, and symlinks in a pull request are never followed.
  • Tests that need Postgres or Redis get those containers next to them, still with no internet.
  • Webhooks are verified and deduplicated, and work goes through a Postgres queue with leases and retries. Each installation has its own rate limits and a monthly budget.
  • Replying @second-look add test to a confirmed comment commits the test that proved the bug to the branch.

Second Look dashboard with accept rates, latency and cost per review

Results

I measured it on bugs that real open-source projects shipped and later fixed, each mixed with unrelated real changes, plus clean pull requests to count false alarms. A comment counts as right only if it lands within three lines of the fix the project shipped.

Version 0.6.0 on 39 real pull requests:

ReviewerComments that point at the real bugComments per clean pull requestBugs found
Second Look 0.6.070%0.1354%
Second Look 0.5.060%0.2754%
Baseline: always comment on the biggest change23%1.0038%

When a failing test proved the bug, it was right 85% of the time (11 of 13). Model cost was $0.0023 per pull request with GLM-5.3-Flash through OpenRouter.

Version 0.5.0 was also measured on all 275 pull requests in the benchmark: 59% of comments pointed at the real bug, with 0.31 comments per clean pull request, and it found 53% of bugs.

Limits

  • The 0.6.0 numbers come from 39 pull requests, and only 13 bugs were proven by a test, so the 85% is a small sample.
  • About half of the real bugs still go unfound.

Stack

Python 3.11, FastAPI, Postgres, Docker sandboxes, GitHub Apps and Actions, OpenRouter (GLM-5.3-Flash by default) or the Anthropic API, Fly.io.

Website · Benchmarks

Back to top