Autonomous Code-Review Agents in CI/CD: How to stop infinite fix-lint-retest loops without disabling auto-commits?
We wired up an autonomous PR review-and-fix agent in GitHub Actions that inspects failing checks, edits the branch, and pushes a fix commit.
Most of the time it saves engineers 20 minutes of boilerplate cleanup. However, twice this week it got stuck in an expensive loop:
- Agent fixes a type error -> breaks a
ruffimport-sort rule. - CI re-runs -> Agent runs
ruff --fix, which accidentally removes an unused import needed by a dynamicmock.patchtest. - Unit test fails -> Agent restores the import ->
rufffails again.
Before we knew it, the PR had 14 auto-commits and burned through 400k reasoning tokens.
We still want the agent to push fixes automatically for genuine 1-2 step issues. What deterministic guardrails are teams using to detect and halt these CI agent cycles early?