Skip to content

Conversation

@rohitpalod
Copy link
Contributor

@rohitpalod rohitpalod commented Jan 18, 2026

Summary

  • Fixes infinite loop bug when all kanban features are completed
  • Agent now exits gracefully when 100% of features are passing
  • Single-feature mode now exits after one session

Problem

When all features were marked as passing, the agent would run forever because:

  1. The main loop in agent.py had no completion detection
  2. The coding prompt instructs Claude to run regression tests BEFORE checking for new features via feature_get_for_regression
  3. feature_get_next() returns "All features passing!" but nothing acted on it

This caused Claude to infinitely run regression tests on random passing features.

Solution

Added three completion checks to agent.py:

Check Location Purpose
Pre-loop Before first session Exits immediately if project already 100% complete
Post-session After each session Exits when all features become passing
Single-feature After session Exits after one session (orchestrator manages agents)

Test Plan

  • Tested with project having 240/240 features passing
  • Agent now exits immediately with "ALL FEATURES ALREADY COMPLETE!" message
  • Verified normal operation still works (agent continues when features remain)

Changes

+ from progress import count_passing_tests, ...

  while True:
+     # Pre-loop: Exit if already complete
+     if not is_first_run and iteration == 1:
+         if total > 0 and passing == total:
+             print("ALL FEATURES ALREADY COMPLETE!")
+             break

      # ... session runs ...

+     # Post-session: Exit if now complete
+     if total > 0 and passing == total:
+         print("ALL FEATURES COMPLETE!")
+         break
+
+     # Single-feature mode: Exit after one session
+     if feature_id is not None:
+         break

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Agent now automatically detects when all features are passing and displays a completion banner before exiting gracefully.
    • Single-feature mode automatically terminates after the current feature's session completes without waiting for subsequent sessions to run.
    • Enhanced early-exit checks have been added across the session workflow to ensure proper termination behavior in all scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

…res done

The agent was running in an infinite loop when all kanban features were
completed. This happened because:

1. The main loop in agent.py had no completion detection
2. The coding prompt instructs Claude to run regression tests BEFORE
   checking for new features
3. feature_get_next() returns "All features passing!" but nothing acted on it

This fix adds three completion checks:

1. Pre-loop check: Exits immediately if project is already 100% complete
   when the agent starts (avoids running unnecessary sessions)

2. Post-session check: After each session, checks if all features are now
   passing and exits gracefully with a success message

3. Single-feature mode: Exits after one session since the parallel
   orchestrator manages spawning new agents for other features

Tested with a project that had 240/240 features passing - agent now exits
immediately with "ALL FEATURES ALREADY COMPLETE!" message.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Jan 18, 2026

📝 Walkthrough

Walkthrough

The agent now detects when all features are complete by checking test pass counts using count_passing_tests(). Early-exit conditions were added at multiple codepaths to gracefully terminate the main loop and prevent unnecessary iterations when all features pass or in single-feature mode.

Changes

Cohort / File(s) Summary
Early-exit Logic Addition
agent.py
Added count_passing_tests, has_features, print_progress_summary, and print_session_header imports from progress module. Integrated completion checks after sessions and in multiple control flow paths (session finish, limit reached scenarios). Added single-feature mode early-exit condition. Prints completion banner and exits loop when all features pass (total > 0 and passing == total).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Poem

🐰 A loop that ran without an end,
Now finds completion—agents' friend!
When all tests pass, we hop away,
No more infinite loops to stay! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding completion detection to prevent infinite loops when all features are complete.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@leonvanzyl leonvanzyl merged commit 0391df8 into leonvanzyl:master Jan 19, 2026
1 check passed
@leonvanzyl
Copy link
Owner

Thank you.

leonvanzyl added a commit that referenced this pull request Jan 19, 2026
The PR #77 introduced a bug where `is_first_run` was used in the
completion detection check, but this variable is only defined when
`agent_type is None`. When the orchestrator runs agents with explicit
`--agent-type` or `--feature-id`, the variable is undefined causing
a NameError crash.

Changed to use `is_initializer` which is always defined and has the
correct semantic meaning for this check.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants