Zero Labs
Industry News / AI

Dual-Model Review For The PRs

Source · Towards AI By Gayathri D

From the publisher’s feed, collected in the ZeroLabs newsroom.

A structured, deterministic workflow for running two coding agents in parallel, merging their verdicts, and automating the fixes both agree on.The Blind Spot ProblemMost engineers have settled into a workflow that looks something like this: before submitting a PR, paste the diff into an AI coding assistant, get a review back, fix the obvious things, and move on. It works well enough. But there’s a structural flaw in it that’s easy to miss.A single AI model has a single perspective — and consistent blind spots.After running parallel reviews across dozens of PRs, an obvious pattern emerges: OpenAI Codex skews toward syntactic and idiomatic issues — naming conventions, type annotations, redundant imports, API misuse. Claude reasons more deeply about design tradeoffs, security implications, and architectural consistency. Each catches things the other misses.And once the PR lands in GitHub, your team’s AI review bot — GitHub Copilot, or whatever you’re using — often surfaces a third, completely different set of findings.You’re doing multiple rounds of AI-assisted review in different tools, manually comparing responses in your head, and making judgment calls about what to fix without a clear audit trail.Definitely an opportunity to optimize here.The Idea: Dual-Model TriageThe core insight is simple: treat AI code review like a panel of independent reviewers, not a single oracle.The workflow:Feed both models the same input — the PR diff, inline comments, cited file contents, reviewer-specific notesGet a structured verdict from each — not prose, a tableMerge opinions deterministically — no third LLM call to adjudicate, just a truth tableApply only what both agree on — or use your judgment on the contested findingsThe output is a triage.md file. Every row is one PR comment, with two independent model verdicts and a computed action:The merge rule is a deterministic truth tableIf both models agree that something is a genuine issue, fix it. If they disagree, flag it for a human. If neither flags it, reject the finding. Clean. Auditable. Fast.The Time SavingsHere’s a before/after comparison for a typical medium-complexity PR:Manual dual-model review today (per PR)With automated dual-model triageThe primary gain is eliminating the cognitive overhead of processing PR feedback manually — the context switching, the mental tab-keeping between two model outputs, the micro-decisions about every comment.Architecture: How It Actually WorksThe workflow comprises three shell scripts that together take about 2–5 minutes to run end-to-end.dual-review.sh — The OrchestratorThis script runs both models in parallel against the same input. It accepts two modes:PR comment mode: pulls live comments from a GitHub PR via the GitHub CLI, runs both models against each comment plus the cited diff contextDiff mode: runs both models against a raw diff fileBoth models receive the same prompt template. The only thing that differs is which output column they fill../dual-review.sh --pr 123 --repo your-org/your-repo# or./dual-review.sh --diff changes.patchOutputs land in .reviews/pr-123/:codex-raw.md — Model A's structured tableclaude-raw.md — Model B's structured tablecomments.json — raw PR comment datadiff.patch — the diff used for contextAll of it is gitignored.The PromptsBoth models receive this structure:You are reviewing PR comments on a codebase.For each comment below, output a markdown table with exactly these columns:ID | Comment | Location | Verdict | Severity | ReasoningVerdict must be ✅ (valid issue) or ❌ (not a valid issue).Severity: C (critical), W (warning), S (style), or — (not applicable).Do not invent new findings. Your job is to validate existing comments, not generate a new review.Validate against the actual code diff provided. If you cannot verify a claim from the diff, say so in Reasoning.Two constraints matter most:“Do not invent new findings.” Without this, both models will free-form their own review on top of the existing comments. The triage table grows , and the workflow loses its focus.“Validate against the actual code.” The models are given the diff and instructed to check it. They independently verify whether the comment’s claim holds — not just agree with whatever the reviewer said.merge-triage.sh — Deterministic MergeThis script reads both raw outputs, joins rows by comment ID, and applies the truth table. Key behaviors:ID is the join key — rows match exactly even if the models output them in a different orderSeverity takes the higher value when the two models disagree (if Model A says W and Model B says C, the merged row gets C)Comment and location text is taken from whichever model produced the richer descriptionIf a model crashed or returned prose instead of a table, is_usable_review_output() detects this and skips rather than producing a half-empty mergeThe output triage.md is a durable, editable artifact. You can manually change any Action cell before the next step. The table is yours — the automation just built it.Implementation note: the merge logic is embedded Python 3 inside the shell script. This is intentional — macOS ships bash 3.x, which lacks associative arrays. Python handles the join portably across environments.apply-fixes.sh — Targeted Fix ApplicationThis script reads triage.md, collects every row where Action is Fix, builds a targeted prompt, and invokes your AI coding agent with file read/edit tools enabled:./apply-fixes.sh --triage .reviews/pr-123/triage.mdOptional flags:--dry-run — print the prompt without applying changes--ids 98123,98124 — apply only specific comment IDs--severity C — apply only critical findingsAfter apply, re-run the review on changed files to catch regressions before you push.Running It End-to-End# Prerequisites: both model CLIs + GitHub CLI on PATHwhich codex && which claude && which gh# Full run against a live PR./scripts/dual-review/dual-review.sh --pr 456 --repo your-org/your-repo# Review the triage tablecat .reviews/pr-456/triage.md# Apply agreed-upon fixes./scripts/dual-review/apply-fixes.sh --triage .reviews/pr-456/triage.md# Re-validate./scripts/dual-review/dual-review.sh --diff $(git diff HEAD~1)Known GotchasCodex doesn’t accept --base and a custom prompt together. Pipe the prompt on stdin: printf '%s' "$PROMPT" | codex exec -.--unattended mode must be opt-in. Hardcoding dangerously-skip-permissions as default is fine for CI, wrong for interactive developer use. Make it a flag.Branch names with special characters break output paths. feature/my-feature@v2 needs sanitization → feature_my-feature_v2. Build this into the path-handling early.macOS bash 3.x doesn’t support associative arrays. The merge script is embedded Python 3 for exactly this reason. It works on macOS and Linux without modification.ScopeThis workflow is a filter. Its job is to handle the unambiguous cases automatically and surface the contested ones for human judgment.It is not a replacement for human code review. It is not a guarantee that your code is correct after running it. It is not trying to catch everything.What it does do: if two independent AI models both flag a null dereference, you shouldn’t need a meeting to decide whether to fix it. Fix it. Free up your reviewers for the architectural questions, the domain-specific judgment calls, the things that actually require human expertise.There’s another benefit that’s easy to miss: auditability. The triage.md file shows exactly what each model said, why an action was taken, and what was deliberately skipped. This is meaningfully different from "I ran an AI review and it looked fine." When someone asks why a particular comment wasn't addressed, you have a record.What’s NextA few improvements worth building:--reply-on-pr — post back to GitHub when a comment thread is resolved, closing the loop automaticallyCI integration — trigger on PR label or workflow_dispatch, so the workflow runs without developer interventionPost-fix re-review — auto re-run on changed files after apply-fixes.sh to catch regressions before pushCost tracking — log token usage per run so you can measure model cost per PR over timeClosing ThoughtThe instinct to use AI for code review is right. The mistake is treating any single model as authoritative. Every model has a different training distribution, different attention to different problem types, different failure modes.Two models that disagree on a comment are telling you something: that comment is ambiguous enough that a human should look at it. Two models that agree are telling you something too: that finding is robust enough to act on automatically.The workflow above is just a structured way to listen to both signals at once.Principal AI Architect experienced in building distributed systems at scale. I write about what works in enterprise AI. Connect with me on LinkedIn.Dual-Model Review For The PRs was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.