智能体
dev.to ·
@Wonil Cho
会记住发现的 AI 代码审查器仍需要停止条件
文章描述自动代码审查可能陷入看似有产出的循环:发现三个问题,Agent 修复两个并改动邻近代码,下一轮又出现一个旧问题和两个新问题,直到有人放弃。作者认为问题在于循环缺少显式终止状态,并在 frontier-simplify 中实现了一个可选的本地审查运行器:跨审查轮次保留具体发现,用这些发现校验后续修复,并在自动预算耗尽时向人类提供证据。该工具定位为本地维护者工具,不是托管服务,也不是合并门禁。
AI推荐理由 指出自动代码审查循环缺少显式终止条件这一具体工程问题,并描述在 frontier-simplify 中实现的本地审查运行器如何跨轮次保留发现、校验修复、在预算耗尽时向人提供证据;属于开发者工具实践分享,但为个人项目、无独立验证。
68
正文
An automated code reviewer can get stuck in a loop that looks productive:
It finds three problems.
An agent fixes two and changes something nearby.
The next review finds one old problem again, plus two new ones.
Repeat until somebody gives up.
The failure is not just that the model is imperfect. It is that the loop has no explicit end state.
I built an optional review runner in frontier-simplify to make that failure visible and bounded. It is a local maintainer tool, not a hosted service and not a merge gate. The runner keeps concrete findings across review rounds, checks later repairs against those findings, and gives a human the evidence when the automatic budget is exhausted.
Remembering findings is the first requirement
A second review should not behave as though the first review never happened.
The runner stores the original findings and carries them into the next attempt. If the target branch changes, history is rewritten, or the supplied context changes, it performs a fresh scope review without resetting the PR's overall attempt budget. Identical inputs reuse the most recent attempt rather than spending another model call on the same failure.
That produces a more useful question on the second pass: was this particular concern repaired? It is not just another open-ended request to inspect the whole pull request.
Three is a backstop, not a magic number
I chose three attempts as a practical safety mechanism, not because I have evidence that three reviews is the correct amount for every pull request.
A cap prevents an unattended agent from turning a small review into an unbounded process. But reaching the cap does not mean the code is unsafe, and staying below it does not mean the code is safe. It means automated review has reached the point where it should stop spending more model calls and preserve what it knows for a person.
The runner returns a distinct human-handoff result when the budget ends. The handoff includes the original findings, the latest review, and the evidence needed to see what changed. It does not approve, merge, push, or post on anyone's behalf.
The hard part is still scope
A useful comment on the project pointed out a limitation: attempt limits cannot decide whether a finding belongs in the current task. A reviewer needs some definition of what the PR is meant to change.
I do not want to answer that by creating another permanent process document or requiring a human approval step for every PR. My current direction is narrower:
derive a provisional scope from the PR description, linked issue, diff, and tests;
require each finding to point to the evidence that makes it relevant;
mark the review as under-specified when that evidence is missing, instead of silently expanding the task;
keep the attempt limit as a backstop for ambiguous or badly specified work.
That is deliberately not presented as solved. If a model writes the scope and then judges its own work against it, it can rationalize the very expansion the guard is supposed to prevent. The design question is how much independent evidence is enough before a finding stays in the loop.
Running it
The review runner is a separate optional skill. It runs from a trusted local maintainer host outside the repository being reviewed:
export REVIEW_CODEX_MODEL=gpt-6-astra
skills/frontier-simplify-review/scripts/review-pr.sh "$CONSUMER_REPO" "$PR_NUMBER" auto codex
skills/frontier-simplify-review/scripts/review-pr.sh "$CONSUMER_REPO" "$PR_NUMBER" status codex
Enter fullscreen mode
Exit fullscreen mode
It has a default 1,800-second executor timeout. A timeout, interrupt, or termination signal preserves the failed attempt instead of quietly losing it. A status check reads evidence without starting a model run.
The main point is not the number three. It is making the loop accountable: every repeated review should either resolve an earlier finding, produce new evidence, or stop and say why it cannot decide.
The source, install instructions, local self-tests, and raw benchmark limits are in MongLong0214/frontier-simplify.