fix(react): stuck-loop detection returns FAILED, not COMPLETED (#740) - #820
Conversation
A repeated tool signature (3× identical) meant the agent was stuck, yet _react_loop returned AgentStatus.COMPLETED. Final verification then passed against the already-green repo, marking the task DONE and auto-closing the linked GitHub issue despite nothing being implemented. Loop detection now returns FAILED and records _early_termination_reason = 'loop_detected' so the run result distinguishes a stuck loop from plain max-iterations exhaustion; final verification no longer runs in that case.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 51 minutes Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Pre-PR third-party review (codex; opencode was down with a server error):
Reviewed control flow around the loop-detection return and reason propagation; no issues. |
ReviewSmall, well-scoped fix that does exactly what the title says. Verified downstream: Correctness
Test coverage
Minor observations (non-blocking)
No blocking issues found. The scope matches what's described in the PR body, and the fix doesn't touch anything beyond the single return site plus reason propagation as claimed. |
Closes #740
Problem
When the same tool signature repeats 3×,
_react_loopreturnedAgentStatus.COMPLETED. Final verification then passed against the already-green repo, so a stuck agent that implemented nothing → task DONE → (with auto-close) the linked GitHub issue closed. A stuck loop is a failure, not completion.Fix
AgentStatus.FAILED(codeframe/core/react_agent.py).self._early_termination_reason = "loop_detected"(reset perrun()) so the caller reportsloop_detectedinAGENT_FAILED, distinct frommax_iterations_reached/stall_detected. TheAGENT_EARLY_TERMINATIONevent already carried this reason.Acceptance criteria
test_loop_detected_returns_failed._early_termination_reason == "loop_detected"+AGENT_EARLY_TERMINATIONevent.Tests
test_loop_detected_returns_completedrenamed totest_loop_detected_returns_failed; now asserts FAILED, the early-termination reason, and thatgates.runis not called. No false-positive tests (different tools / different paths) unchanged and passing. Fullreact_agent+ escalation + engine-integration suites (108 tests) green; ruff clean.Review
Pre-PR third-party review: codex
LGTM, no correctness/logic regressions(opencode was unavailable — server error).Known limitations
None. Scope is the single
return AgentStatus.COMPLETED→FAILEDat the loop-detection site plus reason propagation.