← Systems Manual/Code Quality & Autonomous Loops
Code Quality & Autonomous Loops11 min read

The Closed-Loop Code Review & Auto-Fix Engine: Independent Second-LLM Verification

How /v1/review inspects diffs with an independent reviewer LLM (temperature 0.1), detects bugs, and feeds fix prompts back into the coder.

Standard AI code generators suffer from 'self-confirmation bias'—when an LLM creates buggy code, asking the same LLM if the code is correct almost always yields a false 'looks good'. Unchained Code breaks this flaw by deploying a closed-loop architecture: every generated diff is piped to an independent reviewer LLM with temperature 0.1. If issues are found, the engine synthesizes a targeted fix prompt and reinjects it into the primary coder model until /v1/review issues a clean verdict.

Direct AnswerDirect Answer / AI Executive Summary

Unchained Code's review engine operates via POST /v1/review. A dedicated paid reviewer (Gemini 3.7 Flash or Pro for Fast-Lane) parses the diff up to 200,000 characters. If verdict === 'issues', it extracts structured findings and builds a deterministic fix prompt. The workbench applies the correction automatically without human intervention, ensuring bug-free code before execution.

Step-by-Step Walkthrough & User Guide

1

Diff Generation by Primary Coder

The primary model (DeepSeek-V4 Pro or Qwen 3.8 Max) produces the code modifications.

2

Independent Reviewer Dispatch

The diff is automatically transmitted to /v1/review with strict AST inspection rules and 0.1 temperature.

3

Automated Finding Extraction

The reviewer isolates syntax bugs, missing imports, unhandled exceptions, and security vulnerabilities into structured findings.

4

Closed-Loop Auto-Fix Reinjection

If issues are found, the workbench reinjects the fix prompt into the coding agent to apply corrections immediately.

💡Pro Tips & Engineering Best Practices

  • •Review findings are capped at 240 characters per item to ensure ultra-precise, actionable fix instructions.
  • •Fast-Lane users receive the high-context Pro reviewer supporting up to 200k diff tokens.
  • •Review never claims 'looks good' if upstream fails; it explicitly reports 'review unavailable' for absolute safety.

Code & Technical Integration

Terminal & Integration Code
typescript
// Closed-Loop Review & Fix Prompt Construction in src/server.ts
export function buildFixPrompt(findings: string[]): string {
  return `Please fix the following issues detected during code review:\n` +
    findings.map((f, i) => `${i + 1}. ${f}`).join('\n');
}

Related Engineering Walkthroughs