Can AI Agents Review Their Own Code? A Layered Pre-Ship Gate

Share

FuturPulse analysis

PostgreSQL 19 is now expected around 19 November after a late review uncovered architectural defects and a long tail of smaller issues. Sphinx and Tracely show two different ways to move that scrutiny before software ships.

At a glance

What changed in the PostgreSQL 19 release?

PostgreSQL 19 is a useful case study in what happens when review finds more defects than a release process can absorb. The revised expectation is around 19 November, after the project moved away from an earlier late-September or early-October window.

Eisentraut’s account separates the findings into two groups. Some reverted features had architectural defects that would have been difficult to fix during the beta period. Others had relatively harmless edge cases that earlier review methods might have found only after release.

That distinction matters for teams adopting agent gates. A gate should not treat every model warning as a merge blocker. It should separate an uncertain suggestion from a failure that can be reproduced, explained and assigned to an owner.

The practical lesson: more review capacity can reveal more work than a release window can absorb. A good gate raises confidence before merge. It does not merely create a longer queue of unranked alerts.

Why did the release schedule move?

The PostgreSQL story is a timeline of changing expectations, not proof that one AI reviewer delayed the release. Eisentraut described several contributing factors, including late review, security work, feature complexity and the decision to keep working toward the existing schedule.

Feature freeze began during a period when senior developers were also dealing with security fixes. Eisentraut said the usual additional review and testing during the beta period was reduced, then picked up again later.

That timing helps explain why so many issues appeared late. The project was examining mature features at the same time that improved LLM-assisted review made more edge cases visible.

During feature freeze
Review capacity was diverted

Senior PostgreSQL developers were busy with security fixes. The normal level of beta-period review and testing fell during that work.

During the beta period
A feature was removed

SQL Property Graph Queries were pulled from PostgreSQL 19 over unresolved issues. The feature is now expected to return in a later release.

Late in the beta period
More defects surfaced

Eisentraut described roughly 40 defect reports from LLM-assisted review. Even a small fix creates review, testing and coordination work.

The revised release expectation
Features were held back

The project kept the release moving while postponing features that could not be fixed with enough confidence. That is a release-management decision, not an automatic verdict on every reported defect.

This is the operational risk that pre-ship gates address. Review must happen while a patch is still cheap to change, rather than after a beta branch has accumulated dependencies, release notes and expectations.

Does Sphinx stop code before it ships?

Sphinx stops a matching Git push until a person passes an understanding check, pauses or skips. It is not primarily an automated code auditor. It asks the developer to predict behaviour, failure modes and invariants, which are conditions the system must preserve.

Sphinx’s documentation says its reviewer reads the committed change through read-only Git tools and does not see the conversation that produced the code. The questions cover behaviour, failure modes and invariants rather than file names or function names.

The separation is important when an agent wrote the patch but a human still owns the outcome. The person must explain a retry path, an ordering rule or a data-loss edge case. The check is open-book, so the developer can read the code or ask the agent to show it.

A wrong answer produces an explanation and another scenario about the same concept. A dispute does not count as a pass. That design tests understanding, but it does not prove that the patch is secure or correct.

The push can pause, continue after a successful answer or be skipped. A skip is useful during an incident, but it should create an explicit record of who bypassed the check and why.

Sphinx also has important limits. Anyone with local access can bypass a Git hook or obtain outside help. The examiner is an LLM and can be wrong, so the product describes the check as practice rather than a security gate.

For a small team, the trade-off is clear. Use a question gate for changes involving permissions, migrations, payment flows or destructive operations. Do not present a passed understanding check as evidence that ordinary tests and security review are unnecessary.

Can Tracely stop an agent from repeating a failure?

Tracely takes a different route. It turns a production failure trace into a pull-request regression test. A trace is the recorded chain of prompts, tool calls and outputs from an agent run.

Tracely says it freezes a failing trace into a hermetic replay case and blocks a pull request that would reproduce the failure. Hermetic means that the replay uses recorded inputs and outputs instead of calling a live model or external tool again.

The approach starts with an incident that already happened. The recorded input, tool results and model outputs become fixtures. The resulting case can then be replayed in CI, the automated checks that run before a merge.

Tracely describes a fail-to-pass contract for promoted cases. The old code must fail, and the fixed code must pass. That requirement gives a team a reason to distrust a regression test that was created from an incomplete or misunderstood incident.

The system also groups failures into issues. Instead of asking a developer to read every broken run separately, it can cluster related failures and attach a count to the resulting issue.

That is useful operationally, but it is not broad proof of safety. A replay covers the behaviour captured in its fixtures. It does not test every possible input, tool response or model decision.

Tracely also supports model judges and structural checks. Structural checks do not need a model. Model judges can assess a trace at conversation, run or span level, but their verdicts need calibration against human labels.

Calibration is the safeguard that matters most. A model judge can over-flag harmless behaviour or miss a serious failure. A team should compare its verdicts with human review before allowing the judge to block a release.

Replay also changes the cost profile. Once the fixtures exist, the CI replay uses no live model call. Teams still pay for the original production calls, storage and any online judges used to assess new traces.

How much does an AI review gate cost?

Model review costs depend on tokens, the chunks of text a model reads and bills by. The table compares one large agent step across the routes listed by OpenRouter. It assumes 30,000 input tokens and 2,000 output tokens for each step.

Reviewer route Input / output price Cost per 1,000 large review steps What changes for a team
ByteDance Seed-2.0-Code $0.50 / $3.00 per million tokens $21.00 Baseline paid route for large diffs.
Google Gemini 2.5 Pro Preview $1.25 / $10.00 per million tokens $57.50 Highest listed cost in this comparison.
Google Gemini 3 Flash Preview $0.50 / $3.00 per million tokens $21.00 Same calculated large-step cost as Seed.
Google Gemini 3 Flash Preview, batch $0.25 / $1.50 per million tokens $10.50 Cheaper when the workflow can wait for batch processing.

Our calculation uses OpenRouter’s published list prices and assumes 30,000 input tokens plus 2,000 output tokens per agent step. This is arithmetic on list prices, not a benchmark or a measured workload.

Batch review can cut the model bill for large code checks: Seed-2.0-Code, Gemini 2.5 Pro, Gemini 3 Flash, Gemini 3 Flash batch
Batch review can cut the model bill for large code checks · Source: openrouter.ai

The table measures model calls, not the full cost of a review process. A large diff can require repeated context, and a questionnaire can make several requests before the check finishes.

Sphinx therefore has a variable cost rather than a simple per-seat price. Its reviewer can use a coding-agent plan, an OpenRouter route or another OpenAI-compatible endpoint. A team must also account for the time a developer spends answering questions.

Tracely shifts part of the cost away from CI. Recorded fixtures allow a regression case to run without a live model call. The original production run, trace storage and any online evaluation still consume resources.

The practical comparison is not “free versus paid”. It is the cost of preventing a known failure, the cost of asking a person to explain a risky change and the cost of repairing a defect after release.

What should a layered gate do?

A practical gate uses different controls for different kinds of failure. The goal is not to make an AI agent approve itself. The goal is to make the agent’s output pass independent checks before a human or a production user depends on it.

  1. Run deterministic checks first. Use unit tests, type checks, linters and security scanners. These checks are cheap when they have precise expected results.
  2. Ask for human understanding on risky code. Use a Sphinx-style question gate for permissions, migrations, payment flows and destructive operations.
  3. Replay known agent failures. Use a Tracely-style fixture gate when an agent has already produced a bad production outcome.
  4. Keep model judges advisory at first. Allow a judge to block releases only after comparing its verdicts with human decisions.
  5. Keep an emergency bypass. Record who skipped the gate, why they did so and which follow-up test is required.

The order matters. Deterministic checks should reject failures that a machine can explain. Replay should cover incidents that the team has already observed. A human understanding check should focus on risks that require reasoning about behaviour.

These controls should produce separate results rather than one undifferentiated approval badge. A passed unit test says something different from a successful replay. A correct answer to a Sphinx question says something different from either.

Teams should also define ownership. Every blocking result needs a person who can decide whether to fix, defer or dispute it. Without that ownership, the gate becomes an alert queue that delays delivery without improving the code.

Does PostgreSQL prove that AI review works?

No. PostgreSQL shows that LLM-assisted review can change release economics by making edge cases visible sooner. Eisentraut also described architectural defects, reduced beta-period review and a heavy security workload.

The episode does not support the claim that AI wrote the problematic code. Eisentraut said most affected work predated “vibe coding”. The quality bar rose after the features had already been committed.

The narrower conclusion is more useful. Teams should run agent-assisted review and fuzzing before feature freeze, then turn confirmed failures into ordinary regression tests.

Finding a defect late is better than shipping it. Finding it before a beta branch is usually easier because fewer release decisions depend on the patch.

That does not make an agent reviewer authoritative. It makes the reviewer one instrument in a process that still needs tests, human ownership and a release decision.

What could teams measure next?

A gate should be judged by more than the number of warnings it produces. Teams can track how many findings reproduce, how often developers override them and how many confirmed defects become regression tests.

They can also compare the time spent answering questions with the time saved by catching a failure before merge. For replay systems, the useful measure is whether a known production failure would have been blocked by the fixture.

Those measurements should be separated by change type. A permission change, a documentation edit and a database migration carry different risks. One average pass rate would hide those differences.

The most useful result is a feedback loop. A confirmed incident becomes a test. A recurring question becomes a review rule. A noisy judge remains advisory until its errors are understood.

What we could not verify?

PostgreSQL has not published a complete, feature-by-feature account of which LLM reviewer or fuzzing system found each defect. The specific tools, prompts, model versions, false-positive rate and developer hours behind the reverts remain unpublished.

The public material also does not establish that AI review alone caused the release change. The project’s own account describes several factors, including security work, feature complexity, late review and the decision to keep the schedule.

Sphinx and Tracely do not provide independent, real-repository studies showing how many production defects their gates prevent. Their documented workflows describe mechanisms, not comparative effectiveness.

That evidence would require disclosed evaluations and incident data. Until then, the defensible claim is limited: these tools provide different checks, and neither replaces ordinary testing or accountable release ownership.

Sources


Maya Chen
Maya Chen
Maya Chen covers AI agents, orchestration frameworks, tool-use, and evaluation. She focuses on what actually works in production—failure modes, safety boundaries, and measurable performance—without the hype.

Read more

Local News